From 2f73986b44a4ec10c7ebe7188e23863c3879d54e Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 4 Jun 2018 14:02:51 -0700 Subject: [PATCH] Update LKG --- lib/cs/diagnosticMessages.generated.json | 10 + lib/de/diagnosticMessages.generated.json | 7 + lib/enu/diagnosticMessages.generated.json.lcg | 48 + lib/es/diagnosticMessages.generated.json | 13 +- lib/fr/diagnosticMessages.generated.json | 11 +- lib/it/diagnosticMessages.generated.json | 10 + lib/ja/diagnosticMessages.generated.json | 7 + lib/ko/diagnosticMessages.generated.json | 10 + lib/lib.es2015.core.d.ts | 16 +- lib/lib.esnext.array.d.ts | 38 +- lib/lib.esnext.d.ts | 1 + lib/lib.esnext.full.d.ts | 1 + lib/lib.esnext.symbol.d.ts | 26 + lib/pl/diagnosticMessages.generated.json | 10 + lib/protocol.d.ts | 18 +- lib/pt-br/diagnosticMessages.generated.json | 11 +- lib/ru/diagnosticMessages.generated.json | 10 + lib/tr/diagnosticMessages.generated.json | 7 + lib/tsc.js | 11136 +++++----- lib/tsserver.js | 16069 +++++++------- lib/tsserverlibrary.d.ts | 881 +- lib/tsserverlibrary.js | 17962 ++++++++-------- lib/typescript.d.ts | 821 +- lib/typescript.js | 17723 +++++++-------- lib/typescriptServices.d.ts | 821 +- lib/typescriptServices.js | 17723 +++++++-------- lib/typingsInstaller.js | 2830 +-- lib/zh-cn/diagnosticMessages.generated.json | 10 + lib/zh-tw/diagnosticMessages.generated.json | 10 + 29 files changed, 45342 insertions(+), 40898 deletions(-) create mode 100644 lib/lib.esnext.symbol.d.ts diff --git a/lib/cs/diagnosticMessages.generated.json b/lib/cs/diagnosticMessages.generated.json index 7271e1a2328..bd5bf11f505 100644 --- a/lib/cs/diagnosticMessages.generated.json +++ b/lib/cs/diagnosticMessages.generated.json @@ -106,6 +106,7 @@ "Add_initializer_to_property_0_95019": "Přidat inicializační výraz k vlastnosti {0}", "Add_initializers_to_all_uninitialized_properties_95027": "Přidat inicializátory do všech neinicializovaných vlastností", "Add_missing_super_call_90001": "Přidat chybějící volání metody super()", + "Add_missing_typeof_95052": "Přidat chybějící typeof", "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "Přidat kvalifikátor do všech nerozpoznaných proměnných odpovídajících názvu členu", "Add_to_all_uncalled_decorators_95044": "Přidat () do všech nevolaných dekorátorů", "Add_ts_ignore_to_all_error_messages_95042": "Přidat @ts-ignore do všech chybových zpráv", @@ -119,6 +120,7 @@ "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Všechny deklarace abstraktní metody musí jít po sobě.", "All_destructured_elements_are_unused_6198": "Žádný z destrukturovaných elementů se nepoužívá.", "All_imports_in_import_declaration_are_unused_6192": "Žádné importy z deklarace importu se nepoužívají.", + "All_variables_are_unused_6199": "Žádná z proměnných se nepoužívá.", "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011": "Povolte výchozí importy z modulů bez výchozího exportu. Nebude to mít vliv na generování kódu, jenom na kontrolu typů.", "Allow_javascript_files_to_be_compiled_6102": "Povolí kompilaci souborů javascript.", "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "Když se zadá příznak --isolatedModules, nepovolují se ambientní výčty.", @@ -255,6 +257,7 @@ "Class_0_used_before_its_declaration_2449": "Třída {0} se používá dříve, než se deklaruje.", "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "Deklarace tříd nemůžou mít více než jednu značku @augments nebo @extends.", "Class_name_cannot_be_0_2414": "Třída nemůže mít název {0}.", + "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725": "Když se cílí na ES5 s modulem {0}, název třídy nemůže být Object.", "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417": "Statická strana třídy {0} nesprávně rozšiřuje statickou stranu základní třídy {1}.", "Classes_can_only_extend_a_single_class_1174": "Třídy můžou rozšířit jenom jednu třídu.", "Classes_containing_abstract_methods_must_be_marked_abstract_2514": "Třídy obsahující abstraktní metody musí být označené jako abstraktní.", @@ -273,11 +276,14 @@ "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674": "Konstruktor třídy {0} je chráněný a dostupný jenom v rámci deklarace třídy.", "Constructors_for_derived_classes_must_contain_a_super_call_2377": "Konstruktory odvozených tříd musí obsahovat volání příkazu super.", "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126": "Není zadaný obsažený soubor a nedá se určit kořenový adresář – přeskakuje se vyhledávání ve složce node_modules.", + "Convert_0_to_mapped_object_type_95055": "Převést {0} na typ mapovaného objektu", "Convert_all_constructor_functions_to_classes_95045": "Převést všechny funkce konstruktoru na třídy", "Convert_all_require_to_import_95048": "Převést všechna volání require na import", "Convert_all_to_default_imports_95035": "Převést vše na výchozí importy", "Convert_function_0_to_class_95002": "Převést funkci {0} na třídu", "Convert_function_to_an_ES2015_class_95001": "Převést funkci na třídu ES2015", + "Convert_named_imports_to_namespace_import_95057": "Převést pojmenované importy na import oboru názvů", + "Convert_namespace_import_to_named_imports_95056": "Převést import oboru názvů na pojmenované importy", "Convert_require_to_import_95047": "Převést require na import", "Convert_to_ES6_module_95017": "Převést na modul ES6", "Convert_to_default_import_95013": "Převést na výchozí import", @@ -580,6 +586,7 @@ "Not_all_code_paths_return_a_value_7030": "Ne všechny cesty kódu vracejí hodnotu.", "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413": "Typ číselného indexu {0} se nedá přiřadit k typu indexu řetězce {1}.", "Numeric_separators_are_not_allowed_here_6188": "Číselné oddělovače tady nejsou povolené.", + "Object_is_of_type_unknown_2571": "Objekt je typu Neznámý.", "Object_is_possibly_null_2531": "Objekt je pravděpodobně null.", "Object_is_possibly_null_or_undefined_2533": "Objekt je pravděpodobně null nebo undefined.", "Object_is_possibly_undefined_2532": "Objekt je pravděpodobně undefined.", @@ -708,10 +715,13 @@ "Redirect_output_structure_to_the_directory_6006": "Přesměrování výstupní struktury do adresáře", "Referenced_project_0_must_have_setting_composite_Colon_true_6306": "Odkazovaný projekt {0} musí mít nastavení \"composite\": true.", "Remove_all_unreachable_code_95051": "Odebrat veškerý nedosažitelný kód", + "Remove_all_unused_labels_95054": "Odebrat všechny nepoužívané popisky", "Remove_declaration_for_Colon_0_90004": "Odebrat deklaraci pro {0}", "Remove_destructuring_90009": "Odebrat destrukci", "Remove_import_from_0_90005": "Odebrat import z {0}", "Remove_unreachable_code_95050": "Odebrat nedosažitelný kód", + "Remove_unused_label_95053": "Odebrat nepoužitý popisek", + "Remove_variable_statement_90010": "Odebrat příkaz proměnné", "Replace_import_with_0_95015": "Nahradí import použitím: {0}.", "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Oznámí se chyba, když některé cesty kódu ve funkci nevracejí hodnotu.", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "Oznámí se chyby v případech fallthrough v příkazu switch.", diff --git a/lib/de/diagnosticMessages.generated.json b/lib/de/diagnosticMessages.generated.json index 61c5a4bc241..01dc8cbf466 100644 --- a/lib/de/diagnosticMessages.generated.json +++ b/lib/de/diagnosticMessages.generated.json @@ -106,6 +106,7 @@ "Add_initializer_to_property_0_95019": "Initialisierer zu Eigenschaft \"{0}\" hinzufügen", "Add_initializers_to_all_uninitialized_properties_95027": "Allen nicht initialisierten Eigenschaften Initialisierer hinzufügen", "Add_missing_super_call_90001": "Fehlenden super()-Aufruf hinzufügen", + "Add_missing_typeof_95052": "Fehlenden \"typeof\" hinzufügen", "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "Allen nicht aufgelösten Variablen, die einem Membernamen entsprechen, Qualifizierer hinzufügen", "Add_to_all_uncalled_decorators_95044": "Allen nicht aufgerufenen Decorators \"()\" hinzufügen", "Add_ts_ignore_to_all_error_messages_95042": "Allen Fehlermeldungen \"@ts-ignore\" hinzufügen", @@ -119,6 +120,7 @@ "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Alle Deklarationen einer abstrakten Methode müssen aufeinanderfolgend sein.", "All_destructured_elements_are_unused_6198": "Alle destrukturierten Elemente werden nicht verwendet.", "All_imports_in_import_declaration_are_unused_6192": "Keiner der Importe in der Importdeklaration wird verwendet.", + "All_variables_are_unused_6199": "Alle Variablen werden nicht verwendet.", "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011": "Standardimporte von Modulen ohne Standardexport zulassen. Dies wirkt sich nicht auf die Codeausgabe aus, lediglich auf die Typprüfung.", "Allow_javascript_files_to_be_compiled_6102": "Kompilierung von JavaScript-Dateien zulassen.", "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "const-Umgebungsenumerationen sind unzulässig, wenn das Flag \"-isolatedModules\" angegeben wird.", @@ -255,6 +257,7 @@ "Class_0_used_before_its_declaration_2449": "Klasse \"{0}\", die vor der Deklaration verwendet wurde.", "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "Klassendeklarationen dürfen maximal ein \"@augments\"- oder \"@extends\"-Tag aufweisen.", "Class_name_cannot_be_0_2414": "Der Klassenname darf nicht \"{0}\" sein.", + "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725": "Der Klassenname darf nicht \"Object\" lauten, wenn ES5 mit Modul \"{0}\" als Ziel verwendet wird.", "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417": "Die statische Seite der Klasse \"{0}\" erweitert fälschlicherweise die statische Seite der Basisklasse \"{1}\".", "Classes_can_only_extend_a_single_class_1174": "Klassen dürfen nur eine einzelne Klasse erweitern.", "Classes_containing_abstract_methods_must_be_marked_abstract_2514": "Klassen, die abstrakte Methoden enthalten, müssen als abstrakt markiert werden.", @@ -273,6 +276,7 @@ "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674": "Der Konstruktor der Klasse \"{0}\" ist geschützt. Auf ihn kann nur innerhalb der Klassendeklaration zugegriffen werden.", "Constructors_for_derived_classes_must_contain_a_super_call_2377": "Konstruktoren für abgeleitete Klassen müssen einen Aufruf \"super\" enthalten.", "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126": "Die enthaltene Datei wird nicht angegeben, und das Stammverzeichnis kann nicht ermittelt werden. Die Suche im Ordner \"node_modules\" wird übersprungen.", + "Convert_0_to_mapped_object_type_95055": "\"{0}\" in zugeordneten Objekttyp konvertieren", "Convert_all_constructor_functions_to_classes_95045": "Alle Konstruktorfunktionen in Klassen konvertieren", "Convert_all_require_to_import_95048": "Alle Aufrufe von \"require\" in \"import\" konvertieren", "Convert_all_to_default_imports_95035": "Alle in Standardimporte konvertieren", @@ -708,10 +712,13 @@ "Redirect_output_structure_to_the_directory_6006": "Die Ausgabestruktur in das Verzeichnis umleiten.", "Referenced_project_0_must_have_setting_composite_Colon_true_6306": "Das referenzierte Projekt \"{0}\" muss für die Einstellung \"composite\" den Wert TRUE aufweisen.", "Remove_all_unreachable_code_95051": "Gesamten nicht erreichbaren Code entfernen", + "Remove_all_unused_labels_95054": "Alle nicht verwendeten Bezeichnungen entfernen", "Remove_declaration_for_Colon_0_90004": "Deklaration entfernen für: {0}", "Remove_destructuring_90009": "Destrukturierung entfernen", "Remove_import_from_0_90005": "Import aus \"{0}\" entfernen", "Remove_unreachable_code_95050": "Nicht erreichbaren Code entfernen", + "Remove_unused_label_95053": "Nicht verwendete Bezeichnung entfernen", + "Remove_variable_statement_90010": "Variablenanweisung entfernen", "Replace_import_with_0_95015": "Ersetzen Sie den Import durch \"{0}\".", "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Fehler melden, wenn nicht alle Codepfade in der Funktion einen Wert zurückgeben.", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "Für FallTrough-Fälle in switch-Anweisung Fehler melden.", diff --git a/lib/enu/diagnosticMessages.generated.json.lcg b/lib/enu/diagnosticMessages.generated.json.lcg index 3ea2129b89b..dfa254800c9 100644 --- a/lib/enu/diagnosticMessages.generated.json.lcg +++ b/lib/enu/diagnosticMessages.generated.json.lcg @@ -735,6 +735,12 @@ + + + + + + @@ -1551,6 +1557,12 @@ + + + + + + @@ -1659,6 +1671,12 @@ + + + + + + @@ -1689,6 +1707,18 @@ + + + + + + + + + + + + @@ -3501,6 +3531,12 @@ + + + + + + @@ -4305,6 +4341,12 @@ + + + + + + @@ -5619,6 +5661,12 @@ + + + + + + diff --git a/lib/es/diagnosticMessages.generated.json b/lib/es/diagnosticMessages.generated.json index 9d6ee4cc1f9..debe11fef02 100644 --- a/lib/es/diagnosticMessages.generated.json +++ b/lib/es/diagnosticMessages.generated.json @@ -106,7 +106,7 @@ "Add_initializer_to_property_0_95019": "Agregar inicializador a la propiedad \"{0}\"", "Add_initializers_to_all_uninitialized_properties_95027": "Agregar inicializadores a todas las propiedades sin inicializar", "Add_missing_super_call_90001": "Agregar la llamada a \"super()\" que falta", - "Add_missing_typeof_95052": "Agregar el objeto typeof que falta", + "Add_missing_typeof_95052": "Agregar el elemento \"typeof\" que falta", "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "Agregar un calificador a todas las variables no resueltas que coincidan con un nombre de miembro", "Add_to_all_uncalled_decorators_95044": "Agregar \"()\" a todos los elementos Decorator a los que no se llama", "Add_ts_ignore_to_all_error_messages_95042": "Agregar \"@ts-ignore\" a todos los mensajes de error", @@ -120,6 +120,7 @@ "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Todas las declaraciones de un método abstracto deben ser consecutivas.", "All_destructured_elements_are_unused_6198": "Todos los elementos desestructurados están sin utilizar.", "All_imports_in_import_declaration_are_unused_6192": "Todas las importaciones de la declaración de importación están sin utilizar.", + "All_variables_are_unused_6199": "Todas las variables son no utilizadas.", "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011": "Permitir las importaciones predeterminadas de los módulos sin exportación predeterminada. Esto no afecta a la emisión de código, solo a la comprobación de tipos.", "Allow_javascript_files_to_be_compiled_6102": "Permitir que se compilen los archivos de JavaScript.", "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "No se permiten enumeraciones const de ambiente cuando se proporciona la marca \"--isolatedModules\".", @@ -256,6 +257,7 @@ "Class_0_used_before_its_declaration_2449": "Se ha usado la clase \"{0}\" antes de declararla.", "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "Las declaraciones de clase no pueden tener más de una etiqueta \"@augments\" o \"@extends\".", "Class_name_cannot_be_0_2414": "El nombre de la clase no puede ser \"{0}\".", + "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725": "El nombre de clase no puede ser \"Object\" cuando el destino es ES5 con un módulo {0}.", "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417": "El lado estático de la clase '{0}' extiende el lado estático de la clase base '{1}' de forma incorrecta.", "Classes_can_only_extend_a_single_class_1174": "Las clases solo pueden extender una clase única.", "Classes_containing_abstract_methods_must_be_marked_abstract_2514": "Las clases con métodos abstractos deben marcarse como abstractas.", @@ -274,11 +276,14 @@ "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674": "El constructor de la clase '{0}' está protegido y solo es accesible desde la declaración de la clase.", "Constructors_for_derived_classes_must_contain_a_super_call_2377": "Los constructores de las clases derivadas deben contener una llamada a \"super\".", "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126": "El archivo contenedor no se ha especificado y no se puede determinar el directorio raíz. Se omitirá la búsqueda en la carpeta 'node_modules'.", + "Convert_0_to_mapped_object_type_95055": "Convertir \"{0}\" en el tipo de objeto asignado", "Convert_all_constructor_functions_to_classes_95045": "Convertir todas las funciones de constructor en clases", "Convert_all_require_to_import_95048": "Convertir todas las repeticiones de \"require\" en \"import\"", "Convert_all_to_default_imports_95035": "Convertir todo en importaciones predeterminadas", "Convert_function_0_to_class_95002": "Convertir la función \"{0}\" en una clase", "Convert_function_to_an_ES2015_class_95001": "Convertir la función en una clase ES2015", + "Convert_named_imports_to_namespace_import_95057": "Convertir importaciones con nombre en una importación de espacio de nombres", + "Convert_namespace_import_to_named_imports_95056": "Convertir una importación de espacio de nombres en importaciones con nombre", "Convert_require_to_import_95047": "Convertir \"require\" en \"import\"", "Convert_to_ES6_module_95017": "Convertir en módulo ES6", "Convert_to_default_import_95013": "Convertir en importación predeterminada", @@ -581,6 +586,7 @@ "Not_all_code_paths_return_a_value_7030": "No todas las rutas de acceso de código devuelven un valor.", "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413": "El tipo de índice numérico '{0}' no se puede asignar a un tipo de índice de cadena '{1}'.", "Numeric_separators_are_not_allowed_here_6188": "Aquí no se permiten separadores numéricos.", + "Object_is_of_type_unknown_2571": "El objeto es de tipo \"desconocido\".", "Object_is_possibly_null_2531": "El objeto es posiblemente \"null\".", "Object_is_possibly_null_or_undefined_2533": "El objeto es posiblemente \"null\" o \"undefined\".", "Object_is_possibly_undefined_2532": "El objeto es posiblemente \"undefined\".", @@ -709,12 +715,13 @@ "Redirect_output_structure_to_the_directory_6006": "Redirija la estructura de salida al directorio.", "Referenced_project_0_must_have_setting_composite_Colon_true_6306": "El proyecto \"{0}\" al que se hace referencia debe tener el valor \"composite\": true.", "Remove_all_unreachable_code_95051": "Quitar todo el código inaccesible", - "Remove_all_unused_labels_95054": "Remove all unused labels", + "Remove_all_unused_labels_95054": "Quitar todas las etiquetas no utilizadas", "Remove_declaration_for_Colon_0_90004": "Quitar declaración de: \"{0}\"", "Remove_destructuring_90009": "Quitar la desestructuración", "Remove_import_from_0_90005": "Quitar importación de \"{0}\"", "Remove_unreachable_code_95050": "Quitar el código inaccesible", - "Remove_unused_label_95053": "Remove unused label", + "Remove_unused_label_95053": "Quitar etiqueta no utilizada", + "Remove_variable_statement_90010": "Quitar la declaración de variable", "Replace_import_with_0_95015": "Reemplazar importación por \"{0}\".", "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Notificar un error cuando no todas las rutas de acceso de código en funcionamiento devuelven un valor.", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "Notificar errores de los casos de fallthrough en la instrucción switch.", diff --git a/lib/fr/diagnosticMessages.generated.json b/lib/fr/diagnosticMessages.generated.json index 23f0d175862..55ad54ddf55 100644 --- a/lib/fr/diagnosticMessages.generated.json +++ b/lib/fr/diagnosticMessages.generated.json @@ -106,7 +106,7 @@ "Add_initializer_to_property_0_95019": "Ajouter un initialiseur à la propriété '{0}'", "Add_initializers_to_all_uninitialized_properties_95027": "Ajouter des initialiseurs à toutes les propriétés non initialisées", "Add_missing_super_call_90001": "Ajouter l'appel manquant à 'super()'", - "Add_missing_typeof_95052": "Ajouter un typeof manquant", + "Add_missing_typeof_95052": "Ajouter un 'typeof' manquant", "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "Ajouter un qualificateur à toutes les variables non résolues correspondant à un nom de membre", "Add_to_all_uncalled_decorators_95044": "Ajouter '()' à tous les décorateurs non appelés", "Add_ts_ignore_to_all_error_messages_95042": "Ajouter '@ts-ignore' à tous les messages d'erreur", @@ -120,6 +120,7 @@ "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Toutes les déclarations d'une méthode abstraite doivent être consécutives.", "All_destructured_elements_are_unused_6198": "Tous les éléments déstructurés sont inutilisés.", "All_imports_in_import_declaration_are_unused_6192": "Les importations de la déclaration d'importation ne sont pas toutes utilisées.", + "All_variables_are_unused_6199": "Toutes les variables sont inutilisées.", "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011": "Autorisez les importations par défaut à partir des modules sans exportation par défaut. Cela n'affecte pas l'émission du code, juste le contrôle de type.", "Allow_javascript_files_to_be_compiled_6102": "Autorisez la compilation des fichiers JavaScript.", "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "Les enums const ambiants ne sont pas autorisés quand l'indicateur '--isolatedModules' est fourni.", @@ -256,6 +257,7 @@ "Class_0_used_before_its_declaration_2449": "Classe '{0}' utilisée avant sa déclaration.", "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "Les déclarations de classes ne peuvent pas avoir plusieurs balises '@augments' ou '@extends'.", "Class_name_cannot_be_0_2414": "Le nom de la classe ne peut pas être '{0}'.", + "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725": "Le nom de la classe ne peut pas être 'Object' quand ES5 est ciblé avec le module {0}.", "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417": "Le côté statique de la classe '{0}' étend de manière incorrecte le côté statique de la classe de base '{1}'.", "Classes_can_only_extend_a_single_class_1174": "Les classes ne peuvent étendre qu'une seule classe.", "Classes_containing_abstract_methods_must_be_marked_abstract_2514": "Les classes contenant des méthodes abstraites doivent être marquées comme étant abstraites.", @@ -274,11 +276,14 @@ "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674": "Le constructeur de la classe '{0}' est protégé et uniquement accessible dans la déclaration de classe.", "Constructors_for_derived_classes_must_contain_a_super_call_2377": "Les constructeurs pour les classes dérivées doivent contenir un appel de 'super'.", "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126": "Fichier conteneur non spécifié et répertoire racine impossible à déterminer. Recherche ignorée dans le dossier 'node_modules'.", + "Convert_0_to_mapped_object_type_95055": "Convertir '{0}' en type d'objet mappé", "Convert_all_constructor_functions_to_classes_95045": "Convertir toutes les fonctions de constructeur en classes", "Convert_all_require_to_import_95048": "Convertir tous les 'require' en 'import'", "Convert_all_to_default_imports_95035": "Convertir tout en importations par défaut", "Convert_function_0_to_class_95002": "Convertir la fonction '{0}' en classe", "Convert_function_to_an_ES2015_class_95001": "Convertir la fonction en classe ES2015", + "Convert_named_imports_to_namespace_import_95057": "Convertir les importations nommées en importation d'espace de noms", + "Convert_namespace_import_to_named_imports_95056": "Convertir l'importation d'espace de noms en importations nommées", "Convert_require_to_import_95047": "Convertir 'require' en 'import'", "Convert_to_ES6_module_95017": "Convertir en module ES6", "Convert_to_default_import_95013": "Convertir en importation par défaut", @@ -581,6 +586,7 @@ "Not_all_code_paths_return_a_value_7030": "Les chemins de code ne retournent pas tous une valeur.", "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413": "Impossible d'assigner le type d'index numérique '{0}' au type d'index de chaîne '{1}'.", "Numeric_separators_are_not_allowed_here_6188": "Les séparateurs numériques ne sont pas autorisés ici.", + "Object_is_of_type_unknown_2571": "L'objet est de type 'unknown'.", "Object_is_possibly_null_2531": "L'objet a peut-être la valeur 'null'.", "Object_is_possibly_null_or_undefined_2533": "L'objet a peut-être la valeur 'null' ou 'undefined'.", "Object_is_possibly_undefined_2532": "L'objet a peut-être la valeur 'undefined'.", @@ -709,10 +715,13 @@ "Redirect_output_structure_to_the_directory_6006": "Rediriger la structure de sortie vers le répertoire.", "Referenced_project_0_must_have_setting_composite_Colon_true_6306": "Le projet référencé '{0}' doit avoir le paramètre \"composite\" avec la valeur true.", "Remove_all_unreachable_code_95051": "Supprimer tout le code inaccessible", + "Remove_all_unused_labels_95054": "Supprimer toutes les étiquettes inutilisées", "Remove_declaration_for_Colon_0_90004": "Supprimer la déclaration pour : '{0}'", "Remove_destructuring_90009": "Supprimer la déstructuration", "Remove_import_from_0_90005": "Supprimer l'importation de '{0}'", "Remove_unreachable_code_95050": "Supprimer le code inaccessible", + "Remove_unused_label_95053": "Supprimer l'étiquette inutilisée", + "Remove_variable_statement_90010": "Supprimer l'instruction de variable", "Replace_import_with_0_95015": "Remplacez l'importation par '{0}'.", "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Signalez une erreur quand les chemins de code de la fonction ne retournent pas tous une valeur.", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "Signalez les erreurs pour les case avec fallthrough dans une instruction switch.", diff --git a/lib/it/diagnosticMessages.generated.json b/lib/it/diagnosticMessages.generated.json index b7463e378ef..d69031f584a 100644 --- a/lib/it/diagnosticMessages.generated.json +++ b/lib/it/diagnosticMessages.generated.json @@ -106,6 +106,7 @@ "Add_initializer_to_property_0_95019": "Aggiungere l'inizializzatore alla proprietà '{0}'", "Add_initializers_to_all_uninitialized_properties_95027": "Aggiungere gli inizializzatori a tutte le proprietà non inizializzate", "Add_missing_super_call_90001": "Aggiungere la chiamata mancante a 'super()'", + "Add_missing_typeof_95052": "Aggiungere l'elemento 'typeof' mancante", "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "Aggiungere il qualificatore a tutte le variabili non risolte corrispondenti a un nome di membro", "Add_to_all_uncalled_decorators_95044": "Aggiungere '()' a tutti gli elementi Decorator non chiamati", "Add_ts_ignore_to_all_error_messages_95042": "Aggiungere '@ts-ignore' a tutti i messaggi di errore", @@ -119,6 +120,7 @@ "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Tutte le dichiarazioni di un metodo astratto devono essere consecutive.", "All_destructured_elements_are_unused_6198": "Tutti gli elementi destrutturati sono inutilizzati.", "All_imports_in_import_declaration_are_unused_6192": "Tutte le importazioni nella dichiarazione di importazione sono inutilizzate.", + "All_variables_are_unused_6199": "Tutte le variabili sono inutilizzate.", "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011": "Consente di eseguire importazioni predefinite da moduli senza esportazione predefinita. Non influisce sulla creazione del codice ma solo sul controllo dei tipi.", "Allow_javascript_files_to_be_compiled_6102": "Consente la compilazione di file JavaScript.", "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "Le enumerazioni const di ambiente non sono consentite quando viene specificato il flag '--isolatedModules'.", @@ -255,6 +257,7 @@ "Class_0_used_before_its_declaration_2449": "La classe '{0}' è stata usata prima di essere stata dichiarata.", "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "Le dichiarazioni di classe non possono contenere più di un tag `@augments` o `@extends`.", "Class_name_cannot_be_0_2414": "Il nome della classe non può essere '{0}'.", + "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725": "Il nome della classe non può essere 'Object' quando la destinazione è ES5 con il modulo {0}.", "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417": "Il lato statico '{0}' della classe estende in modo errato il lato statico '{1}' della classe di base.", "Classes_can_only_extend_a_single_class_1174": "Le classi possono estendere solo un'unica classe.", "Classes_containing_abstract_methods_must_be_marked_abstract_2514": "Le classi che contengono metodi astratti devono essere contrassegnate come astratte.", @@ -273,11 +276,14 @@ "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674": "Il costruttore della classe '{0}' è protetto e accessibile solo all'interno della dichiarazione di classe.", "Constructors_for_derived_classes_must_contain_a_super_call_2377": "I costruttori di classi derivate devono contenere una chiamata 'super'.", "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126": "Il file contenitore non è specificato e non è possibile determinare la directory radice. La ricerca nella cartella 'node_modules' verrà ignorata.", + "Convert_0_to_mapped_object_type_95055": "Convertire '{0}' nel tipo di oggetto con mapping", "Convert_all_constructor_functions_to_classes_95045": "Convertire tutte le funzioni di costruttore in classi", "Convert_all_require_to_import_95048": "Convertire tutte le occorrenze di 'require' in 'import'", "Convert_all_to_default_imports_95035": "Convertire tutte le impostazioni predefinite", "Convert_function_0_to_class_95002": "Converti la funzione '{0}' in classe", "Convert_function_to_an_ES2015_class_95001": "Converti la funzione in una classe ES2015", + "Convert_named_imports_to_namespace_import_95057": "Convertire le importazioni denominate in importazione spazi dei nomi", + "Convert_namespace_import_to_named_imports_95056": "Convertire l'importazione spazi dei nomi in importazioni denominate", "Convert_require_to_import_95047": "Convertire 'require' in 'import'", "Convert_to_ES6_module_95017": "Converti in modulo ES6", "Convert_to_default_import_95013": "Converti nell'importazione predefinita", @@ -580,6 +586,7 @@ "Not_all_code_paths_return_a_value_7030": "Non tutti i percorsi del codice restituiscono un valore.", "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413": "Il tipo di indice numerico '{0}' non è assegnabile al tipo di indice stringa '{1}'.", "Numeric_separators_are_not_allowed_here_6188": "I separatori numerici non sono consentiti in questa posizione.", + "Object_is_of_type_unknown_2571": "L'oggetto è di tipo 'unknown'.", "Object_is_possibly_null_2531": "L'oggetto è probabilmente 'null'.", "Object_is_possibly_null_or_undefined_2533": "L'oggetto è probabilmente 'null' o 'undefined'.", "Object_is_possibly_undefined_2532": "L'oggetto è probabilmente 'undefined'.", @@ -708,10 +715,13 @@ "Redirect_output_structure_to_the_directory_6006": "Reindirizza la struttura di output alla directory.", "Referenced_project_0_must_have_setting_composite_Colon_true_6306": "Il progetto di riferimento '{0}' deve includere l'impostazione \"composite\": true.", "Remove_all_unreachable_code_95051": "Rimuovere tutto il codice non eseguibile", + "Remove_all_unused_labels_95054": "Rimuovere tutte le etichette inutilizzate", "Remove_declaration_for_Colon_0_90004": "Rimuovere la dichiarazione per '{0}'", "Remove_destructuring_90009": "Rimuovere la destrutturazione", "Remove_import_from_0_90005": "Rimuovere l'importazione da '{0}'", "Remove_unreachable_code_95050": "Rimuovere il codice non eseguibile", + "Remove_unused_label_95053": "Rimuovere l'etichetta inutilizzata", + "Remove_variable_statement_90010": "Rimuovere l'istruzione di variabile", "Replace_import_with_0_95015": "Sostituire l'importazione con '{0}'.", "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Segnala l'errore quando non tutti i percorsi del codice nella funzione restituiscono un valore.", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "Segnala errori per i casi di fallthrough nell'istruzione switch.", diff --git a/lib/ja/diagnosticMessages.generated.json b/lib/ja/diagnosticMessages.generated.json index 6189d07adce..21721d5f147 100644 --- a/lib/ja/diagnosticMessages.generated.json +++ b/lib/ja/diagnosticMessages.generated.json @@ -106,6 +106,7 @@ "Add_initializer_to_property_0_95019": "プロパティ '{0}' に初期化子を追加します", "Add_initializers_to_all_uninitialized_properties_95027": "初期化されていないすべてのプロパティに初期化子を追加します", "Add_missing_super_call_90001": "欠落している 'super()' 呼び出しを追加する", + "Add_missing_typeof_95052": "不足している 'typeof' を追加します", "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "メンバー名と一致するすべての未解決の変数に修飾子を追加します", "Add_to_all_uncalled_decorators_95044": "呼び出されていないすべてのデコレーターに '()' を追加します", "Add_ts_ignore_to_all_error_messages_95042": "すべてのエラー メッセージに '@ts-ignore' を追加します", @@ -119,6 +120,7 @@ "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "抽象メソッドの宣言はすべて連続している必要があります。", "All_destructured_elements_are_unused_6198": "非構造化要素はいずれも使用されていません。", "All_imports_in_import_declaration_are_unused_6192": "インポート宣言内のインポートはすべて未使用です。", + "All_variables_are_unused_6199": "すべての変数は未使用です。", "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011": "既定のエクスポートがないモジュールからの既定のインポートを許可します。これは、型チェックのみのため、コード生成には影響を与えません。", "Allow_javascript_files_to_be_compiled_6102": "javascript ファイルのコンパイルを許可します。", "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "'--isolatedModules' フラグが指定されている場合、アンビエント const 列挙型は使用できません。", @@ -255,6 +257,7 @@ "Class_0_used_before_its_declaration_2449": "クラス '{0}' は宣言の前に使用されました。", "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "クラス宣言で複数の '@augments' または `@extends` タグを使用することはできません。", "Class_name_cannot_be_0_2414": "クラス名を '{0}' にすることはできません。", + "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725": "モジュール {0} を使用して ES5 をターゲットとするときに、クラス名を 'オブジェクト' にすることはできません。", "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417": "クラス側の静的な '{0}' が基底クラス側の静的な '{1}' を正しく拡張していません。", "Classes_can_only_extend_a_single_class_1174": "クラスで拡張できるクラスは 1 つのみです。", "Classes_containing_abstract_methods_must_be_marked_abstract_2514": "抽象メソッドを含むクラスは abstract に指定する必要があります。", @@ -273,6 +276,7 @@ "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674": "クラス '{0}' のコンストラクターは保護されており、クラス宣言内でのみアクセス可能です。", "Constructors_for_derived_classes_must_contain_a_super_call_2377": "派生クラスのコンストラクターには 'super' の呼び出しを含める必要があります。", "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126": "包含するファイルが指定されていないため、ルート ディレクトリを決定できません。'node_modules' フォルダーのルックアップをスキップします。", + "Convert_0_to_mapped_object_type_95055": "'{0}' をマップされたオブジェクト型に変換する", "Convert_all_constructor_functions_to_classes_95045": "すべてのコンストラクター関数をクラスに変換します", "Convert_all_require_to_import_95048": "'require' をすべて 'import' に変換", "Convert_all_to_default_imports_95035": "すべてを既定のインポートに変換します", @@ -708,10 +712,13 @@ "Redirect_output_structure_to_the_directory_6006": "ディレクトリへ出力構造をリダイレクトします。", "Referenced_project_0_must_have_setting_composite_Colon_true_6306": "参照されているプロジェクト '{0}' には、設定 \"composite\": true が必要です。", "Remove_all_unreachable_code_95051": "到達できないコードをすべて削除します", + "Remove_all_unused_labels_95054": "すべての未使用のラベルを削除します", "Remove_declaration_for_Colon_0_90004": "次に対する宣言を削除する: '{0}'", "Remove_destructuring_90009": "非構造化を削除します", "Remove_import_from_0_90005": "'{0}' からのインポートを削除", "Remove_unreachable_code_95050": "到達できないコードを削除します", + "Remove_unused_label_95053": "未使用のラベルを削除します", + "Remove_variable_statement_90010": "変数のステートメントを削除します", "Replace_import_with_0_95015": "インポートを '{0}' に置換します。", "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "関数の一部のコード パスが値を返さない場合にエラーを報告します。", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "switch ステートメントに case のフォールスルーがある場合にエラーを報告します。", diff --git a/lib/ko/diagnosticMessages.generated.json b/lib/ko/diagnosticMessages.generated.json index 9ab72b1379f..a75f68d2b77 100644 --- a/lib/ko/diagnosticMessages.generated.json +++ b/lib/ko/diagnosticMessages.generated.json @@ -106,6 +106,7 @@ "Add_initializer_to_property_0_95019": "'{0}' 속성에 이니셜라이저 추가", "Add_initializers_to_all_uninitialized_properties_95027": "초기화되지 않은 모든 속성에 이니셜라이저 추가", "Add_missing_super_call_90001": "누락된 'super()' 호출 추가", + "Add_missing_typeof_95052": "누락된 'typeof' 추가", "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "멤버 이름과 일치하는 모든 확인되지 않은 변수에 한정자 추가", "Add_to_all_uncalled_decorators_95044": "호출되지 않는 모든 데코레이터에 '()' 추가", "Add_ts_ignore_to_all_error_messages_95042": "모든 오류 메시지에 '@ts-ignore' 추가", @@ -119,6 +120,7 @@ "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "추상 메서드의 모든 선언은 연속적이어야 합니다.", "All_destructured_elements_are_unused_6198": "구조 파괴된 요소가 모두 사용되지 않습니다.", "All_imports_in_import_declaration_are_unused_6192": "가져오기 선언의 모든 가져오기가 사용되지 않습니다.", + "All_variables_are_unused_6199": "모든 변수가 사용되지 않습니다.", "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011": "기본 내보내기가 없는 모듈에서 기본 가져오기를 허용합니다. 여기서는 코드 내보내기에는 영향을 주지 않고 형식 검사만 합니다.", "Allow_javascript_files_to_be_compiled_6102": "Javascript 파일을 컴파일하도록 허용합니다.", "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "'--isolatedModules' 플래그가 제공된 경우 앰비언트 const 열거형이 허용되지 않습니다.", @@ -255,6 +257,7 @@ "Class_0_used_before_its_declaration_2449": "선언 전에 사용된 '{0}' 클래스입니다.", "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "클래스 선언은 '@augments' 또는 `@extends` 태그를 둘 이상 가질 수 없습니다.", "Class_name_cannot_be_0_2414": "클래스 이름은 '{0}'일 수 없습니다.", + "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725": "{0} 모듈을 사용하는 ES5를 대상으로 하는 경우 클래스 이름은 'Object'일 수 없습니다.", "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417": "클래스 정적 측면 '{0}'이(가) 기본 클래스 정적 측면 '{1}'을(를) 잘못 확장합니다.", "Classes_can_only_extend_a_single_class_1174": "클래스는 단일 클래스만 확장할 수 있습니다.", "Classes_containing_abstract_methods_must_be_marked_abstract_2514": "추상 메서드를 포함하는 클래스는 abstract로 표시되어 있어야 합니다.", @@ -273,11 +276,14 @@ "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674": "'{0}' 클래스의 생성자는 protected이며 클래스 선언 내에서만 액세스할 수 있습니다.", "Constructors_for_derived_classes_must_contain_a_super_call_2377": "파생 클래스의 생성자는 'super' 호출을 포함해야 합니다.", "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126": "포함 파일이 지정되지 않았고 루트 디렉터리를 확인할 수 없어 'node_modules' 폴더 조회를 건너뜁니다.", + "Convert_0_to_mapped_object_type_95055": "'{0}'을(를) 매핑된 개체 형식으로 변환", "Convert_all_constructor_functions_to_classes_95045": "모든 생성자 함수를 클래스로 변환", "Convert_all_require_to_import_95048": "모든 'require'를 'import'로 변환", "Convert_all_to_default_imports_95035": "모든 항목을 기본 가져오기로 변환", "Convert_function_0_to_class_95002": "'{0}' 함수를 클래스로 변환", "Convert_function_to_an_ES2015_class_95001": "함수를 ES2015 클래스로 변환", + "Convert_named_imports_to_namespace_import_95057": "명명된 가져오기를 네임스페이스 가져오기로 변환", + "Convert_namespace_import_to_named_imports_95056": "네임스페이스 가져오기를 명명된 가져오기로 변환", "Convert_require_to_import_95047": "'require'를 'import'로 변환", "Convert_to_ES6_module_95017": "ES6 모듈로 변환", "Convert_to_default_import_95013": "기본 가져오기로 변환", @@ -580,6 +586,7 @@ "Not_all_code_paths_return_a_value_7030": "일부 코드 경로가 값을 반환하지 않습니다.", "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413": "숫자 인덱스 형식 '{0}'을(를) 문자열 인덱스 형식 '{1}'에 할당할 수 없습니다.", "Numeric_separators_are_not_allowed_here_6188": "숫자 구분 기호는 여기에서 허용되지 않습니다.", + "Object_is_of_type_unknown_2571": "개체가 '알 수 없는' 형식입니다.", "Object_is_possibly_null_2531": "개체가 'null'인 것 같습니다.", "Object_is_possibly_null_or_undefined_2533": "개체가 'null' 또는 'undefined'인 것 같습니다.", "Object_is_possibly_undefined_2532": "개체가 'undefined'인 것 같습니다.", @@ -708,10 +715,13 @@ "Redirect_output_structure_to_the_directory_6006": "출력 구조를 디렉터리로 리디렉션합니다.", "Referenced_project_0_must_have_setting_composite_Colon_true_6306": "참조되는 프로젝트 '{0}'에는 \"composite\": true 설정이 있어야 합니다.", "Remove_all_unreachable_code_95051": "접근할 수 없는 코드 모두 제거", + "Remove_all_unused_labels_95054": "사용되지 않는 레이블 모두 제거", "Remove_declaration_for_Colon_0_90004": "'{0}'에 대한 선언 제거", "Remove_destructuring_90009": "구조 파괴 제거", "Remove_import_from_0_90005": "'{0}'에서 가져오기 제거", "Remove_unreachable_code_95050": "접근할 수 없는 코드 제거", + "Remove_unused_label_95053": "사용되지 않는 레이블 제거", + "Remove_variable_statement_90010": "변수 문 제거", "Replace_import_with_0_95015": "가져오기를 '{0}'(으)로 바꿉니다.", "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "함수의 일부 코드 경로가 값을 반환하지 않는 경우 오류를 보고합니다.", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "switch 문의 fallthrough case에 대한 오류를 보고합니다.", diff --git a/lib/lib.es2015.core.d.ts b/lib/lib.es2015.core.d.ts index 16105331f1f..7c43b36c424 100644 --- a/lib/lib.es2015.core.d.ts +++ b/lib/lib.es2015.core.d.ts @@ -222,29 +222,29 @@ interface NumberConstructor { * Returns true if passed value is finite. * Unlike the global isFinite, Number.isFinite doesn't forcibly convert the parameter to a * number. Only finite values of the type number, result in true. - * @param value The value you want to test. + * @param number A numeric value. */ - isFinite(value: any): boolean; + isFinite(number: number): boolean; /** * Returns true if the value passed is an integer, false otherwise. - * @param value The value you want to test. + * @param number A numeric value. */ - isInteger(value: any): boolean; + isInteger(number: number): boolean; /** * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a * number). Unlike the global isNaN(), Number.isNaN() doesn't forcefully convert the parameter * to a number. Only values of the type number, that are also NaN, result in true. - * @param value The value you want to test. + * @param number A numeric value. */ - isNaN(number: any): boolean; + isNaN(number: number): boolean; /** * Returns true if the value passed is a safe integer. - * @param value The value you want to test + * @param number A numeric value. */ - isSafeInteger(value: any): boolean; + isSafeInteger(number: number): boolean; /** * The value of the largest integer n such that n and n + 1 are both exactly representable as diff --git a/lib/lib.esnext.array.d.ts b/lib/lib.esnext.array.d.ts index ce26358d3d6..3da8562d2ea 100644 --- a/lib/lib.esnext.array.d.ts +++ b/lib/lib.esnext.array.d.ts @@ -23,7 +23,7 @@ interface ReadonlyArray { /** * Calls a defined callback function on each element of an array. Then, flattens the result into * a new array. - * This is identical to a map followed by a flatten of depth 1. + * This is identical to a map followed by flat with depth 1. * * @param callback A function that accepts up to three arguments. The flatMap method calls the * callback function one time for each element in the array. @@ -42,7 +42,7 @@ interface ReadonlyArray { * * @param depth The maximum recursion depth */ - flatten(this: + flat(this: ReadonlyArray | ReadonlyArray> | @@ -71,7 +71,7 @@ interface ReadonlyArray { * * @param depth The maximum recursion depth */ - flatten(this: + flat(this: ReadonlyArray | ReadonlyArray[][]> | @@ -91,7 +91,7 @@ interface ReadonlyArray { * * @param depth The maximum recursion depth */ - flatten(this: + flat(this: ReadonlyArray | ReadonlyArray> | @@ -106,7 +106,7 @@ interface ReadonlyArray { * * @param depth The maximum recursion depth */ - flatten(this: + flat(this: ReadonlyArray | ReadonlyArray>, depth?: 1 @@ -118,18 +118,18 @@ interface ReadonlyArray { * * @param depth The maximum recursion depth */ - flatten(this: + flat(this: ReadonlyArray, depth: 0 ): U[]; /** * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. If no depth is provided, flatten method defaults to the depth of 1. + * specified depth. If no depth is provided, flat method defaults to the depth of 1. * * @param depth The maximum recursion depth */ - flatten(depth?: number): any[]; + flat(depth?: number): any[]; } interface Array { @@ -137,7 +137,7 @@ interface Array { /** * Calls a defined callback function on each element of an array. Then, flattens the result into * a new array. - * This is identical to a map followed by a flatten of depth 1. + * This is identical to a map followed by flat with depth 1. * * @param callback A function that accepts up to three arguments. The flatMap method calls the * callback function one time for each element in the array. @@ -155,7 +155,7 @@ interface Array { * * @param depth The maximum recursion depth */ - flatten(this: U[][][][][][][][], depth: 7): U[]; + flat(this: U[][][][][][][][], depth: 7): U[]; /** * Returns a new array with all sub-array elements concatenated into it recursively up to the @@ -163,7 +163,7 @@ interface Array { * * @param depth The maximum recursion depth */ - flatten(this: U[][][][][][][], depth: 6): U[]; + flat(this: U[][][][][][][], depth: 6): U[]; /** * Returns a new array with all sub-array elements concatenated into it recursively up to the @@ -171,7 +171,7 @@ interface Array { * * @param depth The maximum recursion depth */ - flatten(this: U[][][][][][], depth: 5): U[]; + flat(this: U[][][][][][], depth: 5): U[]; /** * Returns a new array with all sub-array elements concatenated into it recursively up to the @@ -179,7 +179,7 @@ interface Array { * * @param depth The maximum recursion depth */ - flatten(this: U[][][][][], depth: 4): U[]; + flat(this: U[][][][][], depth: 4): U[]; /** * Returns a new array with all sub-array elements concatenated into it recursively up to the @@ -187,7 +187,7 @@ interface Array { * * @param depth The maximum recursion depth */ - flatten(this: U[][][][], depth: 3): U[]; + flat(this: U[][][][], depth: 3): U[]; /** * Returns a new array with all sub-array elements concatenated into it recursively up to the @@ -195,7 +195,7 @@ interface Array { * * @param depth The maximum recursion depth */ - flatten(this: U[][][], depth: 2): U[]; + flat(this: U[][][], depth: 2): U[]; /** * Returns a new array with all sub-array elements concatenated into it recursively up to the @@ -203,7 +203,7 @@ interface Array { * * @param depth The maximum recursion depth */ - flatten(this: U[][], depth?: 1): U[]; + flat(this: U[][], depth?: 1): U[]; /** * Returns a new array with all sub-array elements concatenated into it recursively up to the @@ -211,13 +211,13 @@ interface Array { * * @param depth The maximum recursion depth */ - flatten(this: U[], depth: 0): U[]; + flat(this: U[], depth: 0): U[]; /** * Returns a new array with all sub-array elements concatenated into it recursively up to the - * specified depth. If no depth is provided, flatten method defaults to the depth of 1. + * specified depth. If no depth is provided, flat method defaults to the depth of 1. * * @param depth The maximum recursion depth */ - flatten(depth?: number): any[]; + flat(depth?: number): any[]; } diff --git a/lib/lib.esnext.d.ts b/lib/lib.esnext.d.ts index 095e46de36f..c81534fc03b 100644 --- a/lib/lib.esnext.d.ts +++ b/lib/lib.esnext.d.ts @@ -21,3 +21,4 @@ and limitations under the License. /// /// /// +/// diff --git a/lib/lib.esnext.full.d.ts b/lib/lib.esnext.full.d.ts index 76d3c72b283..bc9e7060f9e 100644 --- a/lib/lib.esnext.full.d.ts +++ b/lib/lib.esnext.full.d.ts @@ -21,6 +21,7 @@ and limitations under the License. /// /// /// +/// ///////////////////////////// diff --git a/lib/lib.esnext.symbol.d.ts b/lib/lib.esnext.symbol.d.ts new file mode 100644 index 00000000000..98293eaf572 --- /dev/null +++ b/lib/lib.esnext.symbol.d.ts @@ -0,0 +1,26 @@ +/*! ***************************************************************************** +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 Symbol { + /** + * expose the [[Description]] internal slot of a symbol directly + */ + readonly description: string; +} diff --git a/lib/pl/diagnosticMessages.generated.json b/lib/pl/diagnosticMessages.generated.json index 7a5316e7673..f2891354fe4 100644 --- a/lib/pl/diagnosticMessages.generated.json +++ b/lib/pl/diagnosticMessages.generated.json @@ -106,6 +106,7 @@ "Add_initializer_to_property_0_95019": "Dodaj inicjator do właściwości „{0}”", "Add_initializers_to_all_uninitialized_properties_95027": "Dodaj inicjatory do wszystkich niezainicjowanych właściwości", "Add_missing_super_call_90001": "Dodaj brakujące wywołanie „super()”", + "Add_missing_typeof_95052": "Dodaj brakujący element „typeof”", "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "Dodaj kwalifikator do wszystkich nierozpoznanych zmiennych pasujących do nazwy składowej", "Add_to_all_uncalled_decorators_95044": "Dodaj element „()” do wszystkich niewywoływanych dekoratorów", "Add_ts_ignore_to_all_error_messages_95042": "Dodaj element „@ts-ignore” do wszystkich komunikatów o błędach", @@ -119,6 +120,7 @@ "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Wszystkie deklaracje metody abstrakcyjnej muszą występować obok siebie.", "All_destructured_elements_are_unused_6198": "Wszystkie elementy, których strukturę usunięto, są nieużywane.", "All_imports_in_import_declaration_are_unused_6192": "Wszystkie importy w deklaracji importu są nieużywane.", + "All_variables_are_unused_6199": "Wszystkie zmienne są nieużywane.", "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011": "Zezwalaj na domyślne importy z modułów bez domyślnego eksportu. To nie wpływa na emitowanie kodu, a tylko na sprawdzanie typów.", "Allow_javascript_files_to_be_compiled_6102": "Zezwalaj na kompilowanie plików JavaScript.", "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "Otaczające wyliczenia ze specyfikacją const nie są dozwolone w przypadku podania flagi „--isolatedModules”.", @@ -255,6 +257,7 @@ "Class_0_used_before_its_declaration_2449": "Klasa „{0}” została użyta przed zadeklarowaniem.", "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "Deklaracje klas nie mogą mieć więcej niż jeden tag „@augments” lub „@extends”.", "Class_name_cannot_be_0_2414": "Klasa nie może mieć nazwy „{0}”.", + "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725": "Nazwą klasy nie może być słowo „Object”, gdy docelowym językiem jest ES5 z modułem {0}.", "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417": "Strona statyczna klasy „{0}” niepoprawnie rozszerza stronę statyczną klasy bazowej „{1}”.", "Classes_can_only_extend_a_single_class_1174": "Klasy mogą rozszerzać tylko pojedynczą klasę.", "Classes_containing_abstract_methods_must_be_marked_abstract_2514": "Klasy zawierające metody abstrakcyjne muszą być oznaczone jako abstrakcyjne.", @@ -273,11 +276,14 @@ "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674": "Konstruktor klasy „{0}” jest chroniony i dostępny tylko w ramach deklaracji klasy.", "Constructors_for_derived_classes_must_contain_a_super_call_2377": "Konstruktory klas pochodnych muszą zawierać wywołanie „super”.", "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126": "Nie podano pliku zawierającego i nie można określić katalogu głównego. Pomijanie wyszukiwania w folderze „node_modules”.", + "Convert_0_to_mapped_object_type_95055": "Konwertuj element „{0}” na zamapowany typ obiektu", "Convert_all_constructor_functions_to_classes_95045": "Przekonwertuj wszystkie funkcje konstruktora na klasy", "Convert_all_require_to_import_95048": "Konwertuj wszystkie wywołania „require” na wywołania „import”", "Convert_all_to_default_imports_95035": "Przekonwertuj wszystko na domyślne importowanie", "Convert_function_0_to_class_95002": "Konwertuj funkcję „{0}” na klasę", "Convert_function_to_an_ES2015_class_95001": "Konwertuj funkcję na klasę ES2015", + "Convert_named_imports_to_namespace_import_95057": "Konwertuj importy nazwane na import przestrzeni nazw", + "Convert_namespace_import_to_named_imports_95056": "Konwertuj import przestrzeni nazw na importy nazwane", "Convert_require_to_import_95047": "Konwertuj wywołanie „require” na wywołanie „import”", "Convert_to_ES6_module_95017": "Konwertuj na moduł ES6", "Convert_to_default_import_95013": "Konwertuj na import domyślny", @@ -580,6 +586,7 @@ "Not_all_code_paths_return_a_value_7030": "Nie wszystkie ścieżki kodu zwracają wartość.", "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413": "Nie można przypisać typu indeksu numerycznego „{0}” do typu indeksu ciągu „{1}”.", "Numeric_separators_are_not_allowed_here_6188": "Separatory liczbowe nie są dozwolone w tym miejscu.", + "Object_is_of_type_unknown_2571": "Obiekt jest typu „nieznany”.", "Object_is_possibly_null_2531": "Obiekt ma prawdopodobnie wartość „null”.", "Object_is_possibly_null_or_undefined_2533": "Obiekt ma prawdopodobnie wartość „null” lub „undefined”.", "Object_is_possibly_undefined_2532": "Obiekt ma prawdopodobnie wartość „undefined”.", @@ -708,10 +715,13 @@ "Redirect_output_structure_to_the_directory_6006": "Przekieruj strukturę wyjściową do katalogu.", "Referenced_project_0_must_have_setting_composite_Colon_true_6306": "Przywoływany projekt „{0}” musi mieć ustawienie „composite” o wartości true.", "Remove_all_unreachable_code_95051": "Usuń cały nieosiągalny kod", + "Remove_all_unused_labels_95054": "Usuń wszystkie nieużywane etykiety", "Remove_declaration_for_Colon_0_90004": "Usuń deklarację dla: „{0}”", "Remove_destructuring_90009": "Usuń usuwanie struktury", "Remove_import_from_0_90005": "Usuń import z „{0}”", "Remove_unreachable_code_95050": "Usuń nieosiągalny kod", + "Remove_unused_label_95053": "Usuń nieużywaną etykietę", + "Remove_variable_statement_90010": "Usuń instrukcję zmiennej", "Replace_import_with_0_95015": "Zamień import na element „{0}”.", "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Zgłoś błąd, gdy nie wszystkie ścieżki kodu zwracają wartość.", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "Zgłoś błędy dla przepuszczających klauzul case w instrukcji switch.", diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index dc13cb5f575..b75a2c10e52 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -3,6 +3,7 @@ */ declare namespace ts.server.protocol { const enum CommandTypes { + JsxClosingTag = "jsxClosingTag", Brace = "brace", BraceCompletion = "braceCompletion", GetSpanOfEnclosingComment = "getSpanOfEnclosingComment", @@ -672,6 +673,15 @@ declare namespace ts.server.protocol { */ openingBrace: string; } + interface JsxClosingTagRequest extends FileLocationRequest { + readonly command: CommandTypes.JsxClosingTag; + readonly arguments: JsxClosingTagRequestArgs; + } + interface JsxClosingTagRequestArgs extends FileLocationRequestArgs { + } + interface JsxClosingTagResponse extends Response { + readonly body: TextInsertion; + } /** * @deprecated * Get occurrences request; value of command field is @@ -1363,7 +1373,7 @@ declare namespace ts.server.protocol { } interface CompletionEntryIdentifier { name: string; - source: string; + source?: string; } /** * Completion entry details request; value of command field is @@ -1403,7 +1413,7 @@ declare namespace ts.server.protocol { /** * Optional modifiers for the kind (such as 'public'). */ - kindModifiers: string; + kindModifiers?: string; /** * A string that is used for comparing completion items so that they can be ordered. This * is often the same as the name but may be different in certain circumstances. @@ -1460,11 +1470,11 @@ declare namespace ts.server.protocol { /** * Documentation strings for the symbol. */ - documentation: SymbolDisplayPart[]; + documentation?: SymbolDisplayPart[]; /** * JSDoc tags for the symbol. */ - tags: JSDocTagInfo[]; + tags?: JSDocTagInfo[]; /** * The associated code actions for this entry */ diff --git a/lib/pt-br/diagnosticMessages.generated.json b/lib/pt-br/diagnosticMessages.generated.json index fd953b416a9..e4a7dfc1ee6 100644 --- a/lib/pt-br/diagnosticMessages.generated.json +++ b/lib/pt-br/diagnosticMessages.generated.json @@ -106,7 +106,7 @@ "Add_initializer_to_property_0_95019": "Adicionar inicializador à propriedade '{0}'", "Add_initializers_to_all_uninitialized_properties_95027": "Adicionar inicializadores a todas as propriedades não inicializadas", "Add_missing_super_call_90001": "Adicionar chamada 'super()' ausente", - "Add_missing_typeof_95052": "Adicionar typeof ausente", + "Add_missing_typeof_95052": "Adicionar 'typeof' ausente", "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "Adicionar um qualificador a todas as variáveis não resolvidas correspondentes a um nome de membro", "Add_to_all_uncalled_decorators_95044": "Adicionar '()' a todos os decoradores não chamados", "Add_ts_ignore_to_all_error_messages_95042": "Adicionar '@ts-ignore' a todas as mensagens de erro", @@ -120,6 +120,7 @@ "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Todas as declarações de um método abstrato devem ser consecutivas.", "All_destructured_elements_are_unused_6198": "Todos os elementos desestruturados são inutilizados.", "All_imports_in_import_declaration_are_unused_6192": "Nenhuma das importações na declaração de importação está sendo utilizada.", + "All_variables_are_unused_6199": "Nenhuma das variáveis está sendo utilizada.", "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011": "Permita importações padrão de módulos sem exportação padrão. Isso não afeta a emissão do código, apenas a verificação de digitação.", "Allow_javascript_files_to_be_compiled_6102": "Permita que arquivos javascript sejam compilados.", "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "As enumerações de constante de ambiente não são permitidas quando o sinalizador '--isolatedModules' é fornecido.", @@ -256,6 +257,7 @@ "Class_0_used_before_its_declaration_2449": "Classe '{0}' usada antes de sua declaração.", "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "Declarações de classe não podem ter mais de uma marca `@augments` ou `@extends`.", "Class_name_cannot_be_0_2414": "O nome de classe não pode ser '{0}'.", + "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725": "O nome da classe não pode ser 'Object' ao direcionar ES5 com módulo {0}.", "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417": "O lado estático da classe '{0}' incorretamente estende o lado estático da classe base '{1}'.", "Classes_can_only_extend_a_single_class_1174": "Classes só podem estender uma única classe.", "Classes_containing_abstract_methods_must_be_marked_abstract_2514": "As classes que contêm métodos abstratos devem ser marcadas como abstratas.", @@ -274,11 +276,14 @@ "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674": "O construtor de classe '{0}' é protegido e somente acessível na declaração de classe.", "Constructors_for_derived_classes_must_contain_a_super_call_2377": "Construtores para classes derivadas devem conter uma chamada 'super'.", "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126": "O arquivo contido não foi especificado e o diretório raiz não pode ser determinado, ignorando a pesquisa na pasta 'node_modules'.", + "Convert_0_to_mapped_object_type_95055": "Converter '{0}' para o tipo de objeto mapeado", "Convert_all_constructor_functions_to_classes_95045": "Converter todas as funções de construtor em classes", "Convert_all_require_to_import_95048": "Converter todos os 'require' em 'import'", "Convert_all_to_default_imports_95035": "Converter tudo para importações padrão", "Convert_function_0_to_class_95002": "Converter função '{0}' em classe", "Convert_function_to_an_ES2015_class_95001": "Converter função em uma classe ES2015", + "Convert_named_imports_to_namespace_import_95057": "Converter importações nomeadas em importação de namespace", + "Convert_namespace_import_to_named_imports_95056": "Converter importação de namespace em importações nomeadas", "Convert_require_to_import_95047": "Converter 'require' em 'import'", "Convert_to_ES6_module_95017": "Converter em módulo ES6", "Convert_to_default_import_95013": "Converter para importação padrão", @@ -581,6 +586,7 @@ "Not_all_code_paths_return_a_value_7030": "Nem todos os caminhos de código retornam um valor.", "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413": "O tipo de índice numérico '{0}' não é atribuível ao tipo de índice de cadeia de caracteres '{1}'.", "Numeric_separators_are_not_allowed_here_6188": "Separadores numéricos não são permitidos aqui.", + "Object_is_of_type_unknown_2571": "O objeto é do tipo 'desconhecido'.", "Object_is_possibly_null_2531": "Possivelmente, o objeto é 'nulo'.", "Object_is_possibly_null_or_undefined_2533": "Possivelmente, o objeto é 'nulo' ou 'indefinido'.", "Object_is_possibly_undefined_2532": "Possivelmente, o objeto é 'nulo'.", @@ -709,10 +715,13 @@ "Redirect_output_structure_to_the_directory_6006": "Redirecione a estrutura de saída para o diretório.", "Referenced_project_0_must_have_setting_composite_Colon_true_6306": "O projeto referenciado '{0}' deve ter a configuração de \"composite\": true.", "Remove_all_unreachable_code_95051": "Remover todo o código inacessível", + "Remove_all_unused_labels_95054": "Remover todos os rótulos não utilizados", "Remove_declaration_for_Colon_0_90004": "Remover declaração para: '{0}'", "Remove_destructuring_90009": "Remover desestruturação", "Remove_import_from_0_90005": "Remover importação do '{0}'", "Remove_unreachable_code_95050": "Remover código inacessível", + "Remove_unused_label_95053": "Remover rótulo não utilizado", + "Remove_variable_statement_90010": "Remover instrução de variável", "Replace_import_with_0_95015": "Substitua a importação com '{0}'.", "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Relate erro quando nem todos os caminhos de código na função retornarem um valor.", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "Relate erros para casos de fallthrough na instrução switch.", diff --git a/lib/ru/diagnosticMessages.generated.json b/lib/ru/diagnosticMessages.generated.json index dc4efb499e5..fbae0dbc63a 100644 --- a/lib/ru/diagnosticMessages.generated.json +++ b/lib/ru/diagnosticMessages.generated.json @@ -106,6 +106,7 @@ "Add_initializer_to_property_0_95019": "Добавить инициализатор к свойству \"{0}\"", "Add_initializers_to_all_uninitialized_properties_95027": "Добавить инициализаторы ко всем неинициализированным свойствам", "Add_missing_super_call_90001": "Добавьте отсутствующий вызов \"super()\"", + "Add_missing_typeof_95052": "Добавить отсутствующий \"typeof\"", "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "Добавить квалификатор ко всем неразрешенным переменным, соответствующим имени члена", "Add_to_all_uncalled_decorators_95044": "Добавить \"()\" ко всем невызванным декораторам", "Add_ts_ignore_to_all_error_messages_95042": "Добавить \"@ts-ignore\" ко всем сообщениям об ошибках", @@ -119,6 +120,7 @@ "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Все объявления абстрактных методов должны быть последовательными.", "All_destructured_elements_are_unused_6198": "Все деструктурированные элементы не используются.", "All_imports_in_import_declaration_are_unused_6192": "Ни один из импортов в объявлении импорта не используется.", + "All_variables_are_unused_6199": "Ни одна переменная не используется.", "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011": "Разрешить импорт по умолчанию из модулей без экспорта по умолчанию. Это не повлияет на выведение кода — только на проверку типов.", "Allow_javascript_files_to_be_compiled_6102": "Разрешить компиляцию файлов javascript.", "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "Перечисление внешних констант не разрешено, если задан флаг \"--isolatedModules\".", @@ -255,6 +257,7 @@ "Class_0_used_before_its_declaration_2449": "Класс \"{0}\" использован прежде, чем объявлен.", "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "В объявлении класса не может использоваться более одного тега \"@augments\" или \"@extends\".", "Class_name_cannot_be_0_2414": "Имя класса не может иметь значение \"{0}\".", + "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725": "Класс не может иметь имя \"Object\" при выборе ES5 с модулем {0} в качестве целевого.", "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417": "Статическая сторона класса \"{0}\" неправильно расширяет статическую сторону базового класса \"{1}\".", "Classes_can_only_extend_a_single_class_1174": "Классы могут расширить только один класс.", "Classes_containing_abstract_methods_must_be_marked_abstract_2514": "Классы, содержащие абстрактные методы, должны быть отмечены как абстрактные.", @@ -273,11 +276,14 @@ "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674": "Конструктор класса \"{0}\" защищен и доступен только в объявлении класса.", "Constructors_for_derived_classes_must_contain_a_super_call_2377": "Конструкторы производных классов должны содержать вызов super.", "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126": "Содержащий файл не указан, корневой каталог невозможно определить. Выполняется пропуск поиска в папке node_modules.", + "Convert_0_to_mapped_object_type_95055": "Преобразовать \"{0}\" в тип сопоставленного объекта", "Convert_all_constructor_functions_to_classes_95045": "Преобразовать все функции конструктора в классы", "Convert_all_require_to_import_95048": "Преобразовать все \"require\" в \"import\"", "Convert_all_to_default_imports_95035": "Преобразовать все в импорт по умолчанию", "Convert_function_0_to_class_95002": "Преобразование функции \"{0}\" в класс", "Convert_function_to_an_ES2015_class_95001": "Преобразование функции в класс ES2015", + "Convert_named_imports_to_namespace_import_95057": "Преобразовать операции импорта имен в импорт пространства имен", + "Convert_namespace_import_to_named_imports_95056": "Преобразовать импорт пространства имен в операции импорта имен", "Convert_require_to_import_95047": "Преобразовать \"require\" в \"import\"", "Convert_to_ES6_module_95017": "Преобразовать в модуль ES6", "Convert_to_default_import_95013": "Преобразовать в импорт по умолчанию", @@ -580,6 +586,7 @@ "Not_all_code_paths_return_a_value_7030": "Не все пути кода возвращают значение.", "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413": "Тип числового индекса \"{0}\" нельзя назначить типу строкового индекса \"{1}\".", "Numeric_separators_are_not_allowed_here_6188": "Числовые разделители здесь запрещены.", + "Object_is_of_type_unknown_2571": "Объект имеет тип \"Неизвестный\".", "Object_is_possibly_null_2531": "Возможно, объект равен null.", "Object_is_possibly_null_or_undefined_2533": "Возможно, объект равен null или undefined.", "Object_is_possibly_undefined_2532": "Возможно, объект равен undefined.", @@ -708,10 +715,13 @@ "Redirect_output_structure_to_the_directory_6006": "Перенаправить структуру вывода в каталог.", "Referenced_project_0_must_have_setting_composite_Colon_true_6306": "Указанный в ссылке проект \"{0}\" должен иметь следующее значение параметра composite: true.", "Remove_all_unreachable_code_95051": "Удалить весь недостижимый код", + "Remove_all_unused_labels_95054": "Удалить все неиспользуемые метки", "Remove_declaration_for_Colon_0_90004": "Удалите объявление: \"{0}\"", "Remove_destructuring_90009": "Удалить деструктурирование", "Remove_import_from_0_90005": "Удалить импорт из \"{0}\"", "Remove_unreachable_code_95050": "Удалить недостижимый код", + "Remove_unused_label_95053": "Удалить неиспользуемую метку", + "Remove_variable_statement_90010": "Удалить оператор с переменной", "Replace_import_with_0_95015": "Замена импорта на \"{0}\".", "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Сообщать об ошибке, если не все пути кода в функции возвращают значение.", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "Сообщать об ошибках для случаев передачи управления в операторе switch.", diff --git a/lib/tr/diagnosticMessages.generated.json b/lib/tr/diagnosticMessages.generated.json index d037f7d0d20..7ebbf4a0622 100644 --- a/lib/tr/diagnosticMessages.generated.json +++ b/lib/tr/diagnosticMessages.generated.json @@ -106,6 +106,7 @@ "Add_initializer_to_property_0_95019": "'{0}' özelliğine başlatıcı ekle", "Add_initializers_to_all_uninitialized_properties_95027": "Tüm başlatılmamış özelliklere başlatıcılar ekle", "Add_missing_super_call_90001": "Eksik 'super()' çağrısını ekle", + "Add_missing_typeof_95052": "Eksik 'typeof' öğesini ekle", "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "Bir üye adıyla eşleşen tüm çözülmemiş değişkenlere niteleyici ekle", "Add_to_all_uncalled_decorators_95044": "Çağrılmayan tüm dekoratörlere '()' ekle", "Add_ts_ignore_to_all_error_messages_95042": "Tüm hata iletilerine '@ts-ignore' ekle", @@ -119,6 +120,7 @@ "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "Soyut metoda ait tüm bildirimler ardışık olmalıdır.", "All_destructured_elements_are_unused_6198": "Yok edilen öğelerin hiçbiri kullanılmamış.", "All_imports_in_import_declaration_are_unused_6192": "İçeri aktarma bildirimindeki hiçbir içeri aktarma kullanılmadı.", + "All_variables_are_unused_6199": "Hiçbir değişken kullanılmıyor.", "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011": "Varsayılan dışarı aktarmaya sahip olmayan modüllerde varsayılan içeri aktarmalara izin verin. Bu işlem kod üretimini etkilemez, yalnızca tür denetimini etkiler.", "Allow_javascript_files_to_be_compiled_6102": "Javascript dosyalarının derlenmesine izin ver.", "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "'--isolatedModules' bayrağı sağlandığında çevresel const sabit listesi değerlerine izin verilmez.", @@ -255,6 +257,7 @@ "Class_0_used_before_its_declaration_2449": "'{0}' sınıfı, bildiriminden önce kullanıldı.", "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "Sınıf bildirimlerinde birden fazla `@augments` veya `@extends` etiketi olamaz.", "Class_name_cannot_be_0_2414": "Sınıf adı '{0}' olamaz.", + "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725": "Modül {0} ile ES5 hedeflendiğinde sınıf adı 'Object' olamaz.", "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417": "'{0}' statik sınıf tarafı, '{1}' statik temel sınıf tarafını yanlış genişletiyor.", "Classes_can_only_extend_a_single_class_1174": "Sınıflar yalnızca bir sınıfı genişletebilir.", "Classes_containing_abstract_methods_must_be_marked_abstract_2514": "Soyut metotlar içeren sınıflar abstract olarak işaretlenmelidir.", @@ -273,6 +276,7 @@ "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674": "'{0}' sınıfının oluşturucusu korumalı olduğundan, oluşturucuya yalnızca sınıf bildiriminden erişilebilir.", "Constructors_for_derived_classes_must_contain_a_super_call_2377": "Türetilmiş sınıflara ilişkin oluşturucular bir 'super' çağrısı içermelidir.", "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126": "Kapsayıcı dosya belirtilmedi ve kök dizini belirlenemiyor; 'node_modules' klasöründe arama atlanıyor.", + "Convert_0_to_mapped_object_type_95055": "'{0}' öğesini eşlenen nesne türüne dönüştür", "Convert_all_constructor_functions_to_classes_95045": "Tüm oluşturucu işlevleri sınıflara dönüştür", "Convert_all_require_to_import_95048": "Tüm 'require' öğelerini 'import' olarak dönüştür", "Convert_all_to_default_imports_95035": "Tümünü varsayılan içeri aktarmalara dönüştür", @@ -708,10 +712,13 @@ "Redirect_output_structure_to_the_directory_6006": "Çıktı yapısını dizine yeniden yönlendir.", "Referenced_project_0_must_have_setting_composite_Colon_true_6306": "Başvurulan proje '{0}' \"composite\": true ayarına sahip olmalıdır.", "Remove_all_unreachable_code_95051": "Tüm erişilemeyen kodları kaldır", + "Remove_all_unused_labels_95054": "Kullanılmayan tüm etiketleri kaldır", "Remove_declaration_for_Colon_0_90004": "'{0}' bildirimini kaldır", "Remove_destructuring_90009": "Yıkmayı kaldır", "Remove_import_from_0_90005": "'{0}' öğesinden içeri aktarmayı kaldır", "Remove_unreachable_code_95050": "Erişilemeyen kodları kaldır", + "Remove_unused_label_95053": "Kullanılmayan etiketi kaldır", + "Remove_variable_statement_90010": "Değişken deyimini kaldır", "Replace_import_with_0_95015": "İçeri aktarma işlemini '{0}' ile değiştirin.", "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "İşlevdeki tüm kod yolları bir değer döndürmediğinde hata bildir.", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "switch deyiminde sonraki ifadelere geçiş ile ilgili hataları bildir.", diff --git a/lib/tsc.js b/lib/tsc.js index f39c393bfd1..bed2ef28383 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -173,7 +173,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.versionMajorMinor = "2.9"; + ts.versionMajorMinor = "3.0"; ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); (function (ts) { @@ -304,6 +304,10 @@ var ts; return array ? array.length : 0; } ts.length = length; + function hasEntries(map) { + return !!map && !!map.size; + } + ts.hasEntries = hasEntries; function forEach(array, callback) { if (array) { for (var i = 0; i < array.length; i++) { @@ -444,7 +448,7 @@ var ts; return result; } } - Debug.fail(); + return Debug.fail(); } ts.findMap = findMap; function contains(array, value, equalityComparer) { @@ -974,15 +978,6 @@ var ts; return to; } ts.addRange = addRange; - function prependRange(to, from) { - if (from === undefined || from.length === 0) - return to; - if (to === undefined) - return from.slice(); - to.unshift.apply(to, from); - return to; - } - ts.prependRange = prependRange; function pushIfUnique(array, toAdd, equalityComparer) { if (contains(array, toAdd, equalityComparer)) { return false; @@ -1375,10 +1370,10 @@ var ts; if (value !== undefined && test(value)) return value; if (value && typeof value.kind === "number") { - Debug.fail("Invalid cast. The supplied " + Debug.showSyntaxKind(value) + " did not pass the test '" + Debug.getFunctionName(test) + "'."); + return Debug.fail("Invalid cast. The supplied " + Debug.showSyntaxKind(value) + " did not pass the test '" + Debug.getFunctionName(test) + "'."); } else { - Debug.fail("Invalid cast. The supplied value did not pass the test '" + Debug.getFunctionName(test) + "'."); + return Debug.fail("Invalid cast. The supplied value did not pass the test '" + Debug.getFunctionName(test) + "'."); } } ts.cast = cast; @@ -1458,7 +1453,7 @@ var ts; } ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { - baseIndex = baseIndex || 0; + if (baseIndex === void 0) { baseIndex = 0; } return text.replace(/{(\d+)}/g, function (_match, index) { return Debug.assertDefined(args[+index + baseIndex]); }); } ts.formatStringFromArgs = formatStringFromArgs; @@ -1695,7 +1690,9 @@ var ts; return compareValues(a ? 1 : 0, b ? 1 : 0); } ts.compareBooleans = compareBooleans; - function compareMessageText(text1, text2) { + function compareMessageText(t1, t2) { + var text1 = t1; + var text2 = t2; while (text1 && text2) { var string1 = isString(text1) ? text1 : text1.messageText; var string2 = isString(text2) ? text2 : text2.messageText; @@ -1729,6 +1726,14 @@ var ts; return moduleResolution; } ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; + function unreachableCodeIsError(options) { + return options.allowUnreachableCode === false; + } + ts.unreachableCodeIsError = unreachableCodeIsError; + function unusedLabelIsError(options) { + return options.allowUnusedLabels === false; + } + ts.unusedLabelIsError = unusedLabelIsError; function getAreDeclarationMapsEnabled(options) { return !!(options.declaration && options.declarationMap); } @@ -1747,7 +1752,7 @@ var ts; } ts.getEmitDeclarations = getEmitDeclarations; function getStrictOptionValue(compilerOptions, flag) { - return compilerOptions[flag] === undefined ? compilerOptions.strict : compilerOptions[flag]; + return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; } ts.getStrictOptionValue = getStrictOptionValue; function hasZeroOrOneAsteriskCharacter(str) { @@ -2125,6 +2130,23 @@ var ts; return startsWith(str, prefix) ? str.substr(prefix.length) : str; } ts.removePrefix = removePrefix; + function tryRemovePrefix(str, prefix) { + return startsWith(str, prefix) ? str.substring(prefix.length) : undefined; + } + ts.tryRemovePrefix = tryRemovePrefix; + function tryRemoveDirectoryPrefix(path, dirPath) { + var a = tryRemovePrefix(path, dirPath); + if (a === undefined) + return undefined; + switch (a.charCodeAt(0)) { + case 47: + case 92: + return a.slice(1); + default: + return undefined; + } + } + ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; function endsWith(str, suffix) { var expectedPos = str.length - suffix.length; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; @@ -2134,6 +2156,10 @@ var ts; return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str; } ts.removeSuffix = removeSuffix; + function tryRemoveSuffix(str, suffix) { + return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : undefined; + } + ts.tryRemoveSuffix = tryRemoveSuffix; function stringContains(str, substring) { return str.indexOf(substring) !== -1; } @@ -2207,7 +2233,7 @@ var ts; var subpattern = ""; var hasWrittenComponent = false; var components = getNormalizedPathComponents(spec, basePath); - var lastComponent = lastOrUndefined(components); + var lastComponent = last(components); if (usage !== "exclude" && lastComponent === "**") { return undefined; } @@ -2273,14 +2299,17 @@ var ts; }; } ts.getFileMatcherPatterns = getFileMatcherPatterns; + function getRegexFromPattern(pattern, useCaseSensitiveFileNames) { + return new RegExp(pattern, useCaseSensitiveFileNames ? "" : "i"); + } + ts.getRegexFromPattern = getRegexFromPattern; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); - var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); - var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); - var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return getRegexFromPattern(pattern, useCaseSensitiveFileNames); }); + var includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames); + var excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames); var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; @@ -2398,11 +2427,11 @@ var ts; return scriptKind === 1 || scriptKind === 2; } function hasJavaScriptFileExtension(fileName) { - return forEach(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + return some(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); } ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; function hasTypeScriptFileExtension(fileName) { - return forEach(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + return some(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); } ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) { @@ -2576,7 +2605,8 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { - assert(value !== undefined && value !== null, message); + if (value === undefined || value === null) + return fail(message); return value; } Debug.assertDefined = assertDefined; @@ -2734,10 +2764,7 @@ var ts; ts.resolutionExtensionIsTypeScriptOrJson = resolutionExtensionIsTypeScriptOrJson; function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - if (ext !== undefined) { - return ext; - } - Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : Debug.fail("File " + path + " has unknown extension."); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -3286,6 +3313,7 @@ var ts; return watchDirectoryRecursively(directoryName, callback); } watchDirectory(directoryName, callback); + return undefined; }; } function createNonPollingWatchFile() { @@ -3516,6 +3544,7 @@ var ts; switch (entryKind) { case 0: return stat.isFile(); case 1: return stat.isDirectory(); + default: return false; } } catch (e) { @@ -3694,6 +3723,7 @@ var ts; The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), + Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), @@ -4145,6 +4175,7 @@ var ts; Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2568, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators_2568", "Type '{0}' is not an array type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: diag(2570, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await_2570", "Property '{0}' does not exist on type '{1}'. Did you forget to use 'await'?"), + Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."), JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -4198,7 +4229,7 @@ var ts; _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: diag(2692, ts.DiagnosticCategory.Error, "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible."), _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: diag(2693, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", "'{0}' only refers to a type, but is being used as a value here."), 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."), + 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."), 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."), @@ -4228,6 +4259,7 @@ var ts; Cannot_invoke_an_object_which_is_possibly_undefined: diag(2722, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_undefined_2722", "Cannot invoke an object which is possibly 'undefined'."), Cannot_invoke_an_object_which_is_possibly_null_or_undefined: diag(2723, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_null_or_undefined_2723", "Cannot invoke an object which is possibly 'null' or 'undefined'."), Module_0_has_no_exported_member_1_Did_you_mean_2: diag(2724, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_2_2724", "Module '{0}' has no exported member '{1}'. Did you mean '{2}'?"), + Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."), 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}'."), @@ -4526,6 +4558,7 @@ var ts; _0_is_declared_but_never_used: diag(6196, ts.DiagnosticCategory.Error, "_0_is_declared_but_never_used_6196", "'{0}' is declared but never used.", true), Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"), All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", true), + All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", true), 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"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -4553,7 +4586,7 @@ var ts; Function_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: diag(7024, ts.DiagnosticCategory.Error, "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", "Function 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."), Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: diag(7025, ts.DiagnosticCategory.Error, "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type."), JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: diag(7026, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists."), - Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected."), + Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected.", true), Unused_label: diag(7028, ts.DiagnosticCategory.Error, "Unused_label_7028", "Unused label.", true), Fallthrough_case_in_switch: diag(7029, ts.DiagnosticCategory.Error, "Fallthrough_case_in_switch_7029", "Fallthrough case in switch."), Not_all_code_paths_return_a_value: diag(7030, ts.DiagnosticCategory.Error, "Not_all_code_paths_return_a_value_7030", "Not all code paths return a value."), @@ -4634,6 +4667,7 @@ var ts; Implement_inherited_abstract_class: diag(90007, ts.DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"), Add_0_to_unresolved_variable: diag(90008, ts.DiagnosticCategory.Message, "Add_0_to_unresolved_variable_90008", "Add '{0}.' to unresolved variable"), Remove_destructuring: diag(90009, ts.DiagnosticCategory.Message, "Remove_destructuring_90009", "Remove destructuring"), + Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"), Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""), Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"), Add_0_to_existing_import_declaration_from_1: diag(90015, ts.DiagnosticCategory.Message, "Add_0_to_existing_import_declaration_from_1_90015", "Add '{0}' to existing import declaration from \"{1}\""), @@ -4703,6 +4737,9 @@ var ts; Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing 'typeof'"), Remove_unused_label: diag(95053, ts.DiagnosticCategory.Message, "Remove_unused_label_95053", "Remove unused label"), Remove_all_unused_labels: diag(95054, ts.DiagnosticCategory.Message, "Remove_all_unused_labels_95054", "Remove all unused labels"), + Convert_0_to_mapped_object_type: diag(95055, ts.DiagnosticCategory.Message, "Convert_0_to_mapped_object_type_95055", "Convert '{0}' to mapped object type"), + Convert_namespace_import_to_named_imports: diag(95056, ts.DiagnosticCategory.Message, "Convert_namespace_import_to_named_imports_95056", "Convert namespace import to named imports"), + Convert_named_imports_to_namespace_import: diag(95057, ts.DiagnosticCategory.Message, "Convert_named_imports_to_namespace_import_95057", "Convert named imports to namespace import"), }; })(ts || (ts = {})); var ts; @@ -4739,7 +4776,7 @@ var ts; "false": 86, "finally": 87, "for": 88, - "from": 142, + "from": 143, "function": 89, "get": 125, "if": 90, @@ -4765,7 +4802,7 @@ var ts; "public": 114, "readonly": 132, "require": 133, - "global": 143, + "global": 144, "return": 96, "set": 136, "static": 115, @@ -4781,6 +4818,7 @@ var ts; "typeof": 103, "undefined": 140, "unique": 141, + "unknown": 142, "var": 104, "void": 105, "while": 106, @@ -4788,7 +4826,7 @@ var ts; "yield": 116, "async": 120, "await": 121, - "of": 144, + "of": 145, "{": 17, "}": 18, "(": 19, @@ -5294,8 +5332,9 @@ var ts; return true; } ts.isIdentifierText = isIdentifierText; - function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { if (languageVariant === void 0) { languageVariant = 0; } + var text = textInitial; var pos; var end; var startPos; @@ -6493,7 +6532,7 @@ var ts; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function packageIdIsEqual(a, b) { - return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; + return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; } function packageIdToString(_a) { var name = _a.name, subModuleName = _a.subModuleName, version = _a.version; @@ -6536,7 +6575,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 273) { + while (node && node.kind !== 274) { node = node.parent; } return node; @@ -6544,11 +6583,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 212: - case 240: - case 219: + case 213: + case 241: case 220: case 221: + case 222: return true; } return false; @@ -6584,9 +6623,8 @@ var ts; } } ts.getEndLinePosition = getEndLinePosition; - function isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) { - return !(hasGlobalName && hasGlobalName(name)) - && !currentSourceFile.identifiers.has(name); + function isFileLevelUniqueName(sourceFile, name, hasGlobalName) { + return !(hasGlobalName && hasGlobalName(name)) && !sourceFile.identifiers.has(name); } ts.isFileLevelUniqueName = isFileLevelUniqueName; function nodeIsMissing(node) { @@ -6600,6 +6638,19 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + function prependStatements(to, from) { + if (from === undefined || from.length === 0) + return to; + if (to === undefined) + return from.slice(); + var prologue = to.length && isPrologueDirective(to[0]) && to.shift(); + to.unshift.apply(to, from); + if (prologue) { + to.unshift(prologue); + } + return to; + } + ts.prependStatements = prependStatements; function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { if (text.charCodeAt(commentPos + 1) === 47 && commentPos + 2 < commentEnd && @@ -6629,7 +6680,7 @@ var ts; if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 298 && node._children.length > 0) { + if (node.kind === 299 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -6669,7 +6720,7 @@ var ts; ts.indexOfNode = indexOfNode; function getEmitFlags(node) { var emitNode = node.emitNode; - return emitNode && emitNode.flags; + return emitNode && emitNode.flags || 0; } ts.getEmitFlags = getEmitFlags; function getLiteralText(node, sourceFile) { @@ -6697,7 +6748,7 @@ var ts; case 12: return node.text; } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); } ts.getLiteralText = getLiteralText; function getTextOfConstantValue(value) { @@ -6723,7 +6774,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 231 && node.parent.kind === 268; + return node.kind === 232 && node.parent.kind === 269; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -6743,11 +6794,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node && node.kind === 238 && (!node.body); + return node && node.kind === 239 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 273 || - node.kind === 238 || + return node.kind === 274 || + node.kind === 239 || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6761,9 +6812,9 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isModuleAugmentationExternal(node) { switch (node.parent.kind) { - case 273: + case 274: return ts.isExternalModule(node.parent); - case 239: + case 240: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6775,51 +6826,51 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 273: - case 240: - case 268: - case 238: - case 219: + case 274: + case 241: + case 269: + case 239: case 220: case 221: - case 154: - case 153: + case 222: case 155: + case 154: case 156: - case 233: - case 191: + case 157: + case 234: case 192: + case 193: return true; - case 212: - return parentNode && !ts.isFunctionLike(parentNode); + case 213: + return !ts.isFunctionLike(parentNode); } return false; } ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 157: case 158: - case 152: case 159: - case 162: - case 163: - case 283: - case 234: - case 204: - case 235: - case 236: - case 295: - case 233: case 153: + case 160: + case 163: + case 164: + case 284: + case 235: + case 205: + case 236: + case 237: + case 296: + case 234: case 154: case 155: case 156: - case 191: + case 157: case 192: - case 291: - case 296: - case 287: + case 193: + case 292: + case 297: + case 288: return true; default: ts.assertTypeIsNever(node); @@ -6829,8 +6880,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { + case 244: case 243: - case 242: return true; default: return false; @@ -6839,15 +6890,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { + case 244: case 243: - case 242: - case 213: - case 234: - case 233: - case 238: - case 236: + case 214: case 235: + case 234: + case 239: case 237: + case 236: + case 238: return true; default: return false; @@ -6877,7 +6928,7 @@ var ts; case 9: case 8: return escapeLeadingUnderscores(name.text); - case 146: + case 147: return isStringOrNumericLiteral(name.expression) ? escapeLeadingUnderscores(name.expression.text) : undefined; default: ts.Debug.assertNever(name); @@ -6888,10 +6939,12 @@ var ts; switch (name.kind) { case 71: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 145: + case 146: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 184: + case 185: return entityNameToString(name.expression) + "." + entityNameToString(name.name); + default: + throw ts.Debug.assertNever(name); } } ts.entityNameToString = entityNameToString; @@ -6910,11 +6963,6 @@ var ts; return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3); } ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; - function createDiagnosticForNodeSpan(sourceFile, startNode, endNode, message, arg0, arg1, arg2, arg3) { - var start = ts.skipTrivia(sourceFile.text, startNode.pos); - return ts.createFileDiagnostic(sourceFile, start, endNode.end - start, message, arg0, arg1, arg2, arg3); - } - ts.createDiagnosticForNodeSpan = createDiagnosticForNodeSpan; function createDiagnosticForNodeFromMessageChain(node, messageChain) { var sourceFile = getSourceFileOfNode(node); var span = getErrorSpanForNode(sourceFile, node); @@ -6937,7 +6985,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 212) { + if (node.body && node.body.kind === 213) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -6949,31 +6997,31 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 273: + case 274: 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 231: - case 181: - case 234: - case 204: + case 232: + case 182: case 235: - case 238: - case 237: - case 272: - case 233: - case 191: - case 153: - case 155: - case 156: + case 205: case 236: + case 239: + case 238: + case 273: + case 234: + case 192: + case 154: + case 156: + case 157: + case 237: + case 152: case 151: - case 150: errorNode = node.name; break; - case 192: + case 193: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -7003,7 +7051,7 @@ var ts; } ts.isJsonSourceFile = isJsonSourceFile; function isConstEnumDeclaration(node) { - return node.kind === 237 && isConst(node); + return node.kind === 238 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -7016,21 +7064,21 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 186 && n.expression.kind === 97; + return n.kind === 187 && n.expression.kind === 97; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 186 && n.expression.kind === 91; + return n.kind === 187 && n.expression.kind === 91; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 178 && - n.argument.kind === 177 && + return n.kind === 179 && + n.argument.kind === 178 && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 215 + return node.kind === 216 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -7039,11 +7087,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 148 || - node.kind === 147 || - node.kind === 191 || + var commentRanges = (node.kind === 149 || + node.kind === 148 || node.kind === 192 || - node.kind === 190) ? + node.kind === 193 || + node.kind === 191) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); return ts.filter(commentRanges, function (comment) { @@ -7058,11 +7106,12 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (160 <= node.kind && node.kind <= 178) { + if (161 <= node.kind && node.kind <= 179) { return true; } switch (node.kind) { case 119: + case 142: case 134: case 137: case 122: @@ -7071,63 +7120,64 @@ var ts; case 131: return true; case 105: - return node.parent.kind !== 195; - case 206: + return node.parent.kind !== 196; + case 207: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 147: - return node.parent.kind === 176 || node.parent.kind === 171; + case 148: + return node.parent.kind === 177 || node.parent.kind === 172; case 71: - if (node.parent.kind === 145 && node.parent.right === node) { + if (node.parent.kind === 146 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 184 && node.parent.name === node) { + else if (node.parent.kind === 185 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 71 || node.kind === 145 || node.kind === 184, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 145: - case 184: - case 99: + ts.Debug.assert(node.kind === 71 || node.kind === 146 || node.kind === 185, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 146: + case 185: + case 99: { var parent = node.parent; - if (parent.kind === 164) { + if (parent.kind === 165) { return false; } - if (parent.kind === 178) { + if (parent.kind === 179) { return !parent.isTypeOf; } - if (160 <= parent.kind && parent.kind <= 178) { + if (161 <= parent.kind && parent.kind <= 179) { return true; } switch (parent.kind) { - case 206: + case 207: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 147: - return node === parent.constraint; - case 151: - case 150: case 148: - case 231: + return node === parent.constraint; + case 152: + case 151: + case 149: + case 232: return node === parent.type; - case 233: - case 191: + case 234: case 192: + case 193: + case 155: case 154: case 153: - case 152: - case 155: case 156: - return node === parent.type; case 157: + return node === parent.type; case 158: case 159: + case 160: return node === parent.type; - case 189: + case 190: return node === parent.type; - case 186: case 187: - return ts.contains(parent.typeArguments, node); case 188: + return ts.contains(parent.typeArguments, node); + case 189: return false; } + } } return false; } @@ -7146,23 +7196,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224: + case 225: return visitor(node); - case 240: - case 212: - case 216: + case 241: + case 213: case 217: case 218: case 219: case 220: case 221: - case 225: + case 222: case 226: - case 265: - case 266: case 227: - case 229: - case 268: + case 266: + case 267: + case 228: + case 230: + case 269: return ts.forEachChild(node, traverse); } } @@ -7172,23 +7222,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202: + case 203: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 237: - case 235: case 238: case 236: - case 234: - case 204: + case 239: + case 237: + case 235: + case 205: return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 146) { + if (node.name && node.name.kind === 147) { traverse(node.name.expression); return; } @@ -7201,10 +7251,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 166) { + if (node && node.kind === 167) { return node.elementType; } - else if (node && node.kind === 161) { + else if (node && node.kind === 162) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -7214,12 +7264,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { + case 236: case 235: - case 234: - case 204: - case 165: + case 205: + case 166: return node.members; - case 183: + case 184: return node.properties; } } @@ -7227,14 +7277,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 181: - case 272: - case 148: - case 269: - case 151: - case 150: + case 182: + case 273: + case 149: case 270: - case 231: + case 152: + case 151: + case 271: + case 232: return true; } } @@ -7246,8 +7296,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 232 - && node.parent.parent.kind === 213; + return node.parent.kind === 233 + && node.parent.parent.kind === 214; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -7258,13 +7308,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 153: - case 152: case 154: + case 153: case 155: case 156: - case 233: - case 191: + case 157: + case 234: + case 192: return true; } return false; @@ -7275,7 +7325,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 227) { + if (node.statement.kind !== 228) { return node.statement; } node = node.statement; @@ -7283,17 +7333,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 212 && ts.isFunctionLike(node.parent); + return node && node.kind === 213 && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 153 && node.parent.kind === 183; + return node && node.kind === 154 && node.parent.kind === 184; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 153 && - (node.parent.kind === 183 || - node.parent.kind === 204); + return node.kind === 154 && + (node.parent.kind === 184 || + node.parent.kind === 205); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7305,31 +7355,35 @@ var ts; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { - return ts.filter(objectLiteral.properties, function (property) { - if (property.kind === 269) { + return objectLiteral.properties.filter(function (property) { + if (property.kind === 270) { var propName = getTextOfPropertyName(property.name); - return key === propName || (key2 && key2 === propName); + return key === propName || (!!key2 && key2 === propName); } + return false; }); } ts.getPropertyAssignment = getPropertyAssignment; function getTsConfigObjectLiteralExpression(tsConfigSourceFile) { if (tsConfigSourceFile && tsConfigSourceFile.statements.length) { var expression = tsConfigSourceFile.statements[0].expression; - return ts.isObjectLiteralExpression(expression) && expression; + return ts.tryCast(expression, ts.isObjectLiteralExpression); } } ts.getTsConfigObjectLiteralExpression = getTsConfigObjectLiteralExpression; function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) { - var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile); - return jsonObjectLiteral && - ts.firstDefined(getPropertyAssignment(jsonObjectLiteral, propKey), function (property) { - return ts.isArrayLiteralExpression(property.initializer) ? - ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) : - undefined; - }); + return ts.firstDefined(getTsConfigPropArray(tsConfigSourceFile, propKey), function (property) { + return ts.isArrayLiteralExpression(property.initializer) ? + ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) : + undefined; + }); } ts.getTsConfigPropArrayElementValue = getTsConfigPropArrayElementValue; + function getTsConfigPropArray(tsConfigSourceFile, propKey) { + var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile); + return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : ts.emptyArray; + } + ts.getTsConfigPropArray = getTsConfigPropArray; function getContainingFunction(node) { return ts.findAncestor(node.parent, ts.isFunctionLike); } @@ -7339,45 +7393,46 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { + ts.Debug.assert(node.kind !== 274); while (true) { node = node.parent; if (!node) { - return undefined; + return ts.Debug.fail(); } switch (node.kind) { - case 146: + case 147: if (ts.isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 149: - if (node.parent.kind === 148 && ts.isClassElement(node.parent.parent)) { + case 150: + if (node.parent.kind === 149 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { node = node.parent; } break; - case 192: + case 193: if (!includeArrowFunctions) { continue; } - case 233: - case 191: - case 238: - case 151: - case 150: - case 153: + case 234: + case 192: + case 239: case 152: + case 151: case 154: + case 153: case 155: case 156: case 157: case 158: case 159: - case 237: - case 273: + case 160: + case 238: + case 274: return node; } } @@ -7387,9 +7442,9 @@ var ts; var container = getThisContainer(node, false); if (container) { switch (container.kind) { - case 154: - case 233: - case 191: + case 155: + case 234: + case 192: return container; } } @@ -7403,25 +7458,25 @@ var ts; return node; } switch (node.kind) { - case 146: + case 147: node = node.parent; break; - case 233: - case 191: + case 234: case 192: + case 193: if (!stopOnFunctions) { continue; } - case 151: - case 150: - case 153: case 152: + case 151: case 154: + case 153: case 155: case 156: + case 157: return node; - case 149: - if (node.parent.kind === 148 && ts.isClassElement(node.parent.parent)) { + case 150: + if (node.parent.kind === 149 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { @@ -7433,14 +7488,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 191 || func.kind === 192) { + if (func.kind === 192 || func.kind === 193) { var prev = func; var parent = func.parent; - while (parent.kind === 190) { + while (parent.kind === 191) { prev = parent; parent = parent.parent; } - if (parent.kind === 186 && parent.expression === prev) { + if (parent.kind === 187 && parent.expression === prev) { return parent; } } @@ -7448,26 +7503,26 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 184 || kind === 185) + return (kind === 185 || kind === 186) && node.expression.kind === 97; } ts.isSuperProperty = isSuperProperty; function isThisProperty(node) { var kind = node.kind; - return (kind === 184 || kind === 185) + return (kind === 185 || kind === 186) && node.expression.kind === 99; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 161: + case 162: return node.typeName; - case 206: + case 207: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 71: - case 145: + case 146: return node; } return undefined; @@ -7475,10 +7530,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 188: + case 189: return node.tag; + case 257: case 256: - case 255: return node.tagName; default: return node.expression; @@ -7487,21 +7542,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 234: + case 235: return true; - case 151: - return parent.kind === 234; - case 155: + case 152: + return parent.kind === 235; case 156: - case 153: + case 157: + case 154: return node.body !== undefined - && parent.kind === 234; - case 148: + && parent.kind === 235; + case 149: return parent.body !== undefined - && (parent.kind === 154 - || parent.kind === 153 - || parent.kind === 156) - && grandparent.kind === 234; + && (parent.kind === 155 + || parent.kind === 154 + || parent.kind === 157) + && grandparent.kind === 235; } return false; } @@ -7517,19 +7572,21 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 234: - return ts.forEach(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); - case 153: - case 156: - return ts.forEach(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); + case 235: + return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); + case 154: + case 157: + return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); + default: + return false; } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 256 || - parent.kind === 255 || - parent.kind === 257) { + if (parent.kind === 257 || + parent.kind === 256 || + parent.kind === 258) { return parent.tagName === node; } return false; @@ -7542,45 +7599,45 @@ var ts; case 101: case 86: case 12: - case 182: case 183: case 184: case 185: case 186: case 187: case 188: - case 207: case 189: case 208: case 190: + case 209: case 191: - case 204: case 192: - case 195: + case 205: case 193: + case 196: case 194: - case 197: + case 195: case 198: case 199: case 200: - case 203: case 201: - case 13: - case 205: - case 254: - case 255: - case 258: + case 204: case 202: - case 196: - case 209: + case 13: + case 206: + case 255: + case 256: + case 259: + case 203: + case 197: + case 210: return true; - case 145: - while (node.parent.kind === 145) { + case 146: + while (node.parent.kind === 146) { node = node.parent; } - return node.parent.kind === 164 || isJSXTagName(node); + return node.parent.kind === 165 || isJSXTagName(node); case 71: - if (node.parent.kind === 164 || isJSXTagName(node)) { + if (node.parent.kind === 165 || isJSXTagName(node)) { return true; } case 8: @@ -7595,47 +7652,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 231: - case 148: + case 232: + case 149: + case 152: case 151: - case 150: - case 272: - case 269: - case 181: + case 273: + case 270: + case 182: return parent.initializer === node; - case 215: case 216: case 217: case 218: - case 224: + case 219: case 225: case 226: - case 265: - case 228: + case 227: + case 266: + case 229: return parent.expression === node; - case 219: + case 220: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 232) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 233) || forStatement.condition === node || forStatement.incrementor === node; - case 220: case 221: + case 222: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 232) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233) || forInStatement.expression === node; - case 189: - case 207: + case 190: + case 208: return node === parent.expression; - case 210: + case 211: return node === parent.expression; - case 146: + case 147: return node === parent.expression; - case 149: + case 150: + case 265: case 264: - case 263: - case 271: + case 272: return true; - case 206: + case 207: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -7643,7 +7700,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 242 && node.moduleReference.kind === 253; + return node.kind === 243 && node.moduleReference.kind === 254; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7652,7 +7709,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 242 && node.moduleReference.kind !== 253; + return node.kind === 243 && node.moduleReference.kind !== 254; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7664,15 +7721,15 @@ var ts; } ts.isSourceFileNotJavaScript = isSourceFileNotJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 65536); + return !!node && !!(node.flags & 65536); } ts.isInJavaScriptFile = isInJavaScriptFile; function isInJsonFile(node) { - return node && !!(node.flags & 16777216); + return !!node && !!(node.flags & 16777216); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return node && !!(node.flags & 2097152); + return !!node && !!(node.flags & 2097152); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -7684,7 +7741,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 186) { + if (callExpression.kind !== 187) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -7706,22 +7763,48 @@ var ts; return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34; } ts.isStringDoubleQuoted = isStringDoubleQuoted; - function getJSInitializerSymbol(symbol) { - if (!symbol || !symbol.valueDeclaration) { - return symbol; + function getDeclarationOfJSInitializer(node) { + if (!isInJavaScriptFile(node) || !node.parent) { + return undefined; } - var declaration = symbol.valueDeclaration; - var e = getDeclaredJavascriptInitializer(declaration) || getAssignedJavascriptInitializer(declaration); - return e && e.symbol ? e.symbol : symbol; - } - ts.getJSInitializerSymbol = getJSInitializerSymbol; - function getDeclaredJavascriptInitializer(node) { - if (node && ts.isVariableDeclaration(node) && node.initializer) { - return getJavascriptInitializer(node.initializer, false) || - ts.isIdentifier(node.name) && getDefaultedJavascriptInitializer(node.name, node.initializer, false); + var name; + var decl; + if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) { + name = node.parent.name; + decl = node.parent; } + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 && node.parent.right === node) { + name = node.parent.left; + decl = name; + } + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 54) { + if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { + name = node.parent.parent.name; + decl = node.parent.parent; + } + else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 58 && node.parent.parent.right === node.parent) { + name = node.parent.parent.left; + decl = name; + } + if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { + return undefined; + } + } + if (!name || !getJavascriptInitializer(node, isPrototypeAccess(name))) { + return undefined; + } + return decl; } - ts.getDeclaredJavascriptInitializer = getDeclaredJavascriptInitializer; + ts.getDeclarationOfJSInitializer = getDeclarationOfJSInitializer; + function getEffectiveInitializer(node) { + if (isInJavaScriptFile(node) && node.initializer && + ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 54 && + node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { + return node.initializer.right; + } + return node.initializer; + } + ts.getEffectiveInitializer = getEffectiveInitializer; function getAssignedJavascriptInitializer(node) { if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); @@ -7733,11 +7816,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 191 || e.kind === 192 ? initializer : undefined; + return e.kind === 192 || e.kind === 193 ? initializer : undefined; } - if (initializer.kind === 191 || - initializer.kind === 204 || - initializer.kind === 192) { + if (initializer.kind === 192 || + initializer.kind === 205 || + initializer.kind === 193) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -7751,6 +7834,13 @@ var ts; return e; } } + function isDefaultedJavascriptInitializer(node) { + var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 ? node.parent.left : + undefined; + return name && getJavascriptInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); + } + ts.isDefaultedJavascriptInitializer = isDefaultedJavascriptInitializer; function getOuterNameOfJsInitializer(node) { if (ts.isBinaryExpression(node.parent)) { var parent = (node.parent.operatorToken.kind === 54 && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; @@ -7843,7 +7933,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 215 && + expr.parent && expr.parent.kind === 216 && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -7853,14 +7943,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 243: - case 249: + case 244: + case 250: return node.parent; - case 253: + case 254: return node.parent.parent; - case 186: + case 187: return node.parent; - case 177: + case 178: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -7870,12 +7960,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 243: - case 249: + case 244: + case 250: return node.moduleSpecifier; - case 242: - return node.moduleReference.kind === 253 ? node.moduleReference.expression : undefined; - case 178: + case 243: + return node.moduleReference.kind === 254 ? node.moduleReference.expression : undefined; + case 179: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -7884,11 +7974,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 243: + case 244: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 242: + case 243: return node; - case 249: + case 250: return undefined; default: return ts.Debug.assertNever(node); @@ -7896,19 +7986,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 243 && node.importClause && !!node.importClause.name; + return node.kind === 244 && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 148: + case 149: + case 154: case 153: - case 152: + case 271: case 270: - case 269: + case 152: case 151: - case 150: return node.questionToken !== undefined; } } @@ -7916,14 +8006,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 283 && + return node.kind === 284 && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 296 || node.kind === 291; + return node.kind === 297 || node.kind === 292; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -7933,38 +8023,39 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 58 && - node.expression.right; + node.expression.operatorToken.kind === 58 + ? node.expression.right + : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && getSpecialPropertyAssignmentKind(node.expression) !== 0 && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 54 && - node.expression.right.right; + node.expression.right.operatorToken.kind === 54 + ? node.expression.right.right + : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 213: + case 214: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 151: + case 152: return node.initializer; - case 269: + case 270: return node.initializer; } } function getSingleVariableOfVariableStatement(node) { - return ts.isVariableStatement(node) && - node.declarationList.declarations.length > 0 && - node.declarationList.declarations[0]; + return ts.isVariableStatement(node) ? ts.firstOrUndefined(node.declarationList.declarations) : undefined; } function getNestedModuleDeclaration(node) { - return node.kind === 238 && + return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 238 && - node.body; + node.body.kind === 239 + ? node.body + : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; @@ -7974,7 +8065,7 @@ var ts; var parent = node.parent; if (!parent) return; - if (parent.kind === 269 || parent.kind === 151 || getNestedModuleDeclaration(parent)) { + if (parent.kind === 270 || parent.kind === 152 || getNestedModuleDeclaration(parent)) { getJSDocCommentsAndTagsWorker(parent); } if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) { @@ -7988,10 +8079,10 @@ var ts; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 || ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 || - node.kind === 184 && node.parent && node.parent.kind === 215) { + node.kind === 185 && node.parent && node.parent.kind === 216) { getJSDocCommentsAndTagsWorker(parent); } - if (node.kind === 148) { + if (node.kind === 149) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); } if (isVariableLike(node) && ts.hasInitializer(node) && node.initializer !== hostNode && ts.hasJSDocNodes(node.initializer)) { @@ -8045,43 +8136,43 @@ var ts; ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { var last = ts.lastOrUndefined(s.parameters); - return last && isRestParameter(last); + return !!last && isRestParameter(last); } 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 === 284; + return node.dotDotDotToken !== undefined || !!type && type.kind === 285; } ts.isRestParameter = isRestParameter; function getAssignmentTargetKind(node) { var parent = node.parent; while (true) { switch (parent.kind) { - case 199: + case 200: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 ? 1 : 2 : 0; - case 197: case 198: + case 199: var unaryOperator = parent.operator; return unaryOperator === 43 || unaryOperator === 44 ? 2 : 0; - case 220: case 221: + case 222: return parent.initializer === node ? 1 : 0; - case 190: - case 182: - case 203: - case 208: + case 191: + case 183: + case 204: + case 209: node = parent; break; - case 270: + case 271: if (parent.name !== node) { return 0; } node = parent.parent; break; - case 269: + case 270: if (parent.name === node) { return 0; } @@ -8100,22 +8191,22 @@ var ts; ts.isAssignmentTarget = isAssignmentTarget; function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 212: case 213: - case 225: - case 216: + case 214: case 226: - case 240: - case 265: - case 266: + case 217: case 227: - case 219: + case 241: + case 266: + case 267: + case 228: case 220: case 221: - case 217: + case 222: case 218: - case 229: - case 268: + case 219: + case 230: + case 269: return true; } return false; @@ -8132,26 +8223,26 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 172); + return walkUp(node, 173); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 190); + return walkUp(node, 191); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 190) { + while (node.kind === 191) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function isDeleteTarget(node) { - if (node.kind !== 184 && node.kind !== 185) { + if (node.kind !== 185 && node.kind !== 186) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 193; + return node && node.kind === 194; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -8171,9 +8262,10 @@ var ts; switch (name.kind) { case 71: case 9: - case 8: - if (ts.isDeclaration(name.parent)) { - return name.parent.name === name; + case 8: { + var parent = name.parent; + if (ts.isDeclaration(parent)) { + return parent.name === name; } else if (ts.isQualifiedName(name.parent)) { var tag = name.parent.parent; @@ -8183,6 +8275,7 @@ var ts; var binExp = name.parent.parent; return ts.isBinaryExpression(binExp) && getSpecialPropertyAssignmentKind(binExp) !== 0 && ts.getNameOfDeclaration(binExp) === name; } + } default: return false; } @@ -8190,49 +8283,49 @@ var ts; ts.isAnyDeclarationName = isAnyDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 146 && + node.parent.kind === 147 && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 151: - case 150: - case 153: case 152: - case 155: + case 151: + case 154: + case 153: case 156: - case 272: - case 269: - case 184: + case 157: + case 273: + case 270: + case 185: return parent.name === node; - case 145: + case 146: if (parent.right === node) { - while (parent.kind === 145) { + while (parent.kind === 146) { parent = parent.parent; } - return parent.kind === 164 || parent.kind === 161; + return parent.kind === 165 || parent.kind === 162; } return false; - case 181: - case 247: + case 182: + case 248: return parent.propertyName === node; - case 251: - case 261: + case 252: + case 262: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 242 || - node.kind === 241 || - node.kind === 244 && !!node.name || - node.kind === 245 || - node.kind === 247 || - node.kind === 251 || - node.kind === 248 && exportAssignmentIsAlias(node) || + return node.kind === 243 || + node.kind === 242 || + node.kind === 245 && !!node.name || + node.kind === 246 || + node.kind === 248 || + node.kind === 252 || + node.kind === 249 && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -8292,11 +8385,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 72 <= token && token <= 144; + return 72 <= token && token <= 145; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 117 <= token && token <= 144; + return 117 <= token && token <= 145; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -8318,13 +8411,13 @@ var ts; } var flags = 0; switch (node.kind) { - case 233: - case 191: - case 153: + case 234: + case 192: + case 154: if (node.asteriskToken) { flags |= 1; } - case 192: + case 193: if (hasModifier(node, 256)) { flags |= 2; } @@ -8338,10 +8431,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 233: - case 191: + case 234: case 192: - case 153: + case 193: + case 154: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256); @@ -8357,11 +8450,11 @@ var ts; ts.isStringOrNumericLiteral = isStringOrNumericLiteral; function hasDynamicName(declaration) { var name = ts.getNameOfDeclaration(declaration); - return name && isDynamicName(name); + return !!name && isDynamicName(name); } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 146 && + return name.kind === 147 && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -8377,7 +8470,7 @@ var ts; if (name.kind === 9 || name.kind === 8) { return escapeLeadingUnderscores(name.text); } - if (name.kind === 146) { + if (name.kind === 147) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -8427,11 +8520,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 148; + return root.kind === 149; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 181) { + while (node.kind === 182) { node = node.parent.parent; } return node; @@ -8439,15 +8532,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 154 - || kind === 191 - || kind === 233 + return kind === 155 || kind === 192 - || kind === 153 - || kind === 155 + || kind === 234 + || kind === 193 + || kind === 154 || kind === 156 - || kind === 238 - || kind === 273; + || kind === 157 + || kind === 239 + || kind === 274; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -8461,23 +8554,23 @@ var ts; ts.getOriginalSourceFile = getOriginalSourceFile; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 187 && expression.arguments !== undefined; + var hasArguments = expression.kind === 188 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 187: + case 188: return hasArguments ? 0 : 1; - case 197: - case 194: + case 198: case 195: - case 193: case 196: - case 200: - case 202: + case 194: + case 197: + case 201: + case 203: return 1; - case 199: + case 200: switch (operator) { case 40: case 58: @@ -8501,15 +8594,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 187 && expression.arguments !== undefined; + var hasArguments = expression.kind === 188 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 199) { + if (expression.kind === 200) { return expression.operatorToken.kind; } - else if (expression.kind === 197 || expression.kind === 198) { + else if (expression.kind === 198 || expression.kind === 199) { return expression.operator; } else { @@ -8519,15 +8612,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 301: + case 302: return 0; - case 203: + case 204: return 1; - case 202: + case 203: return 2; - case 200: + case 201: return 4; - case 199: + case 200: switch (operatorKind) { case 26: return 0; @@ -8548,21 +8641,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 197: - case 194: - case 195: - case 193: - case 196: - return 16; case 198: + case 195: + case 196: + case 194: + case 197: + return 16; + case 199: return 17; - case 186: - return 18; case 187: - return hasArguments ? 19 : 18; + return 18; case 188: - case 184: + return hasArguments ? 19 : 18; + case 189: case 185: + case 186: return 19; case 99: case 97: @@ -8572,19 +8665,19 @@ var ts; case 86: case 8: case 9: - case 182: case 183: - case 191: + case 184: case 192: - case 204: - case 254: + case 193: + case 205: case 255: - case 258: + case 256: + case 259: case 12: case 13: - case 201: - case 190: - case 205: + case 202: + case 191: + case 206: return 20; default: return -1; @@ -8784,7 +8877,7 @@ var ts; var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + linePos = output.length - s.length + ts.last(lineStartsOfS); } } } @@ -8943,7 +9036,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 71 && identifierIsThisKeyword(node); + return !!node && node.kind === 71 && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { @@ -8957,10 +9050,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 155) { + if (accessor.kind === 156) { getAccessor = accessor; } - else if (accessor.kind === 156) { + else if (accessor.kind === 157) { setAccessor = accessor; } else { @@ -8969,7 +9062,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 155 || member.kind === 156) + if ((member.kind === 156 || member.kind === 157) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -8980,10 +9073,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 155 && !getAccessor) { + if (member.kind === 156 && !getAccessor) { getAccessor = member; } - if (member.kind === 156 && !setAccessor) { + if (member.kind === 157 && !setAccessor) { setAccessor = member; } } @@ -9018,24 +9111,19 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 285); - var templateTags = ts.flatMap(ts.filter(node.parent.tags, ts.isJSDocTemplateTag), function (tag) { return tag.typeParameters; }); - var templateTagNodes = templateTags; - templateTagNodes.pos = templateTagNodes.length > 0 ? ts.first(templateTagNodes).pos : node.pos; - templateTagNodes.end = templateTagNodes.length > 0 ? ts.last(templateTagNodes).end : node.end; - templateTagNodes.hasTrailingComma = false; - return templateTagNodes; + ts.Debug.assert(node.parent.kind === 286); + return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray); } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getJSDocTypeParameterDeclarations(node) { - var tag = ts.find(ts.getJSDocTags(node), function (tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 285 && tag.parent.tags.some(isJSDocTypeAlias)); - }); - return (tag && tag.typeParameters) || ts.emptyArray; + return ts.flatMap(ts.getJSDocTags(node), function (tag) { return isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined; }); } ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; + function isNonTypeAliasTemplate(tag) { + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 286 && tag.parent.tags.some(isJSDocTypeAlias)); + } function getEffectiveSetAccessorTypeAnnotationNode(node) { var parameter = getSetAccessorValueParameter(node); return parameter && getEffectiveTypeAnnotationNode(parameter); @@ -9112,12 +9200,12 @@ var ts; lastComment = comment; } if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.last(detachedComments).end); var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); if (nodeLine >= lastCommentLine + 2) { emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); - currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.last(detachedComments).end }; } } } @@ -9260,7 +9348,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 206 && + if (ts.isExpressionWithTypeArguments(node) && node.parent.token === 85 && ts.isClassLike(node.parent.parent)) { return node.parent.parent; @@ -9278,8 +9366,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 183 - || kind === 182; + return kind === 184 + || kind === 183; } return false; } @@ -9289,7 +9377,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 206 + return node.kind === 207 && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 @@ -9310,17 +9398,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 145 && node.parent.right === node) || - (node.parent.kind === 184 && node.parent.name === node); + return (node.parent.kind === 146 && node.parent.right === node) || + (node.parent.kind === 185 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 183 && + return expression.kind === 184 && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 182 && + return expression.kind === 183 && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -9417,14 +9505,14 @@ var ts; return output; } function base64encode(host, input) { - if (host.base64encode) { + if (host && host.base64encode) { return host.base64encode(input); } return convertToBase64(input); } ts.base64encode = base64encode; function base64decode(host, input) { - if (host.base64decode) { + if (host && host.base64decode) { return host.base64decode(input); } var length = input.length; @@ -9600,8 +9688,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 237: case 238: + case 239: return parseNode === parseNode.parent.name; } } @@ -9663,20 +9751,20 @@ var ts; if (!parent) return 0; switch (parent.kind) { + case 199: case 198: - case 197: var operator = parent.operator; return operator === 43 || operator === 44 ? writeOrReadWrite() : 0; - case 199: + case 200: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0; - case 184: + case 185: return parent.name !== node ? 0 : accessKind(parent); default: return 0; } function writeOrReadWrite() { - return parent.parent && parent.parent.kind === 215 ? 1 : 2; + return parent.parent && parent.parent.kind === 216 ? 1 : 2; } } function compareDataObjects(dst, src) { @@ -9753,7 +9841,7 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 65536 ? type.objectFlags : 0; + return type.flags & 131072 ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { @@ -9932,9 +10020,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 147) { + if (d && d.kind === 148) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 235) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236) { return current; } } @@ -9942,7 +10030,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 154; + return ts.hasModifier(node, 92) && node.parent.kind === 155; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -9960,7 +10048,7 @@ var ts; } ts.isEmptyBindingElement = isEmptyBindingElement; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 181 || ts.isBindingPattern(node))) { + while (node && (node.kind === 182 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -9968,14 +10056,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 231) { + if (node.kind === 232) { node = node.parent; } - if (node && node.kind === 232) { + if (node && node.kind === 233) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 213) { + if (node && node.kind === 214) { flags |= ts.getModifierFlags(node); } return flags; @@ -9984,14 +10072,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 231) { + if (node.kind === 232) { node = node.parent; } - if (node && node.kind === 232) { + if (node && node.kind === 233) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 213) { + if (node && node.kind === 214) { flags |= node.flags; } return flags; @@ -10035,7 +10123,7 @@ var ts; try { ts.localizedDiagnosticMessages = JSON.parse(fileContents); } - catch (e) { + catch (_a) { if (errors) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath)); } @@ -10095,17 +10183,17 @@ var ts; return getDeclarationIdentifier(hostNode); } switch (hostNode.kind) { - case 213: + case 214: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 215: + case 216: var expr = hostNode.expression; switch (expr.kind) { - case 184: - return expr.name; case 185: + return expr.name; + case 186: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -10114,10 +10202,10 @@ var ts; return undefined; case 1: return undefined; - case 190: { + case 191: { return getDeclarationIdentifier(hostNode.expression); } - case 227: { + case 228: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -10144,23 +10232,23 @@ var ts; return undefined; } switch (declaration.kind) { - case 204: - case 191: + case 205: + case 192: if (!declaration.name) { return getAssignedName(declaration); } break; case 71: return declaration; - case 297: - case 292: { + case 298: + case 293: { var name = declaration.name; - if (name.kind === 145) { + if (name.kind === 146) { return name.right; } break; } - case 199: { + case 200: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1: @@ -10172,11 +10260,11 @@ var ts; return undefined; } } - case 291: + case 292: return declaration.name; - case 296: + case 297: return getNameOfJSDocTypedef(declaration); - case 248: { + case 249: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -10315,628 +10403,628 @@ var ts; } ts.isIdentifier = isIdentifier; function isQualifiedName(node) { - return node.kind === 145; + return node.kind === 146; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 146; + return node.kind === 147; } ts.isComputedPropertyName = isComputedPropertyName; function isTypeParameterDeclaration(node) { - return node.kind === 147; + return node.kind === 148; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 148; + return node.kind === 149; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 149; + return node.kind === 150; } ts.isDecorator = isDecorator; function isPropertySignature(node) { - return node.kind === 150; + return node.kind === 151; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 151; + return node.kind === 152; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 152; + return node.kind === 153; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 153; + return node.kind === 154; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 154; + return node.kind === 155; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 155; + return node.kind === 156; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 156; + return node.kind === 157; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 157; + return node.kind === 158; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 158; + return node.kind === 159; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 159; + return node.kind === 160; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; function isGetOrSetAccessorDeclaration(node) { - return node.kind === 156 || node.kind === 155; + return node.kind === 157 || node.kind === 156; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isTypePredicateNode(node) { - return node.kind === 160; + return node.kind === 161; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 161; + return node.kind === 162; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 162; + return node.kind === 163; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 163; + return node.kind === 164; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 164; + return node.kind === 165; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 165; + return node.kind === 166; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 166; + return node.kind === 167; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 167; + return node.kind === 168; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 168; + return node.kind === 169; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 169; + return node.kind === 170; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 170; + return node.kind === 171; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 171; + return node.kind === 172; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 172; + return node.kind === 173; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 173; + return node.kind === 174; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 174; + return node.kind === 175; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 175; + return node.kind === 176; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 176; + return node.kind === 177; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 177; + return node.kind === 178; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 178; + return node.kind === 179; } ts.isImportTypeNode = isImportTypeNode; function isObjectBindingPattern(node) { - return node.kind === 179; + return node.kind === 180; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 180; + return node.kind === 181; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 181; + return node.kind === 182; } ts.isBindingElement = isBindingElement; function isArrayLiteralExpression(node) { - return node.kind === 182; + return node.kind === 183; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 183; + return node.kind === 184; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 184; + return node.kind === 185; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 185; + return node.kind === 186; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 186; + return node.kind === 187; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 187; + return node.kind === 188; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 188; + return node.kind === 189; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 189; + return node.kind === 190; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 190; + return node.kind === 191; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 300) { + while (node.kind === 301) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 191; + return node.kind === 192; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 192; + return node.kind === 193; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 194; + return node.kind === 195; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 195; + return node.kind === 196; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 196; + return node.kind === 197; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 197; + return node.kind === 198; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 198; + return node.kind === 199; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 199; + return node.kind === 200; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 200; + return node.kind === 201; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 201; + return node.kind === 202; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 202; + return node.kind === 203; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 203; + return node.kind === 204; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 204; + return node.kind === 205; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 205; + return node.kind === 206; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 206; + return node.kind === 207; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 207; + return node.kind === 208; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 208; + return node.kind === 209; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 209; + return node.kind === 210; } ts.isMetaProperty = isMetaProperty; function isTemplateSpan(node) { - return node.kind === 210; + return node.kind === 211; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 211; + return node.kind === 212; } ts.isSemicolonClassElement = isSemicolonClassElement; function isBlock(node) { - return node.kind === 212; + return node.kind === 213; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 213; + return node.kind === 214; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 214; + return node.kind === 215; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 215; + return node.kind === 216; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 216; + return node.kind === 217; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 217; + return node.kind === 218; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 218; + return node.kind === 219; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 219; + return node.kind === 220; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 220; + return node.kind === 221; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 221; + return node.kind === 222; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 222; + return node.kind === 223; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 223; + return node.kind === 224; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 223 || node.kind === 222; + return node.kind === 224 || node.kind === 223; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 224; + return node.kind === 225; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 225; + return node.kind === 226; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 226; + return node.kind === 227; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 227; + return node.kind === 228; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 228; + return node.kind === 229; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 229; + return node.kind === 230; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 230; + return node.kind === 231; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 231; + return node.kind === 232; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 232; + return node.kind === 233; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 233; + return node.kind === 234; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 234; + return node.kind === 235; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 235; + return node.kind === 236; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 236; + return node.kind === 237; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 237; + return node.kind === 238; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 238; + return node.kind === 239; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 239; + return node.kind === 240; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 240; + return node.kind === 241; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 241; + return node.kind === 242; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 242; + return node.kind === 243; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 243; + return node.kind === 244; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 244; + return node.kind === 245; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 245; + return node.kind === 246; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 246; + return node.kind === 247; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 247; + return node.kind === 248; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 248; + return node.kind === 249; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 249; + return node.kind === 250; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 250; + return node.kind === 251; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 251; + return node.kind === 252; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 252; + return node.kind === 253; } ts.isMissingDeclaration = isMissingDeclaration; function isExternalModuleReference(node) { - return node.kind === 253; + return node.kind === 254; } ts.isExternalModuleReference = isExternalModuleReference; function isJsxElement(node) { - return node.kind === 254; + return node.kind === 255; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 255; + return node.kind === 256; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 256; + return node.kind === 257; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 257; + return node.kind === 258; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 258; + return node.kind === 259; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 259; + return node.kind === 260; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 260; + return node.kind === 261; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 261; + return node.kind === 262; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 262; + return node.kind === 263; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 263; + return node.kind === 264; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 264; + return node.kind === 265; } ts.isJsxExpression = isJsxExpression; function isCaseClause(node) { - return node.kind === 265; + return node.kind === 266; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 266; + return node.kind === 267; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 267; + return node.kind === 268; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 268; + return node.kind === 269; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 269; + return node.kind === 270; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 270; + return node.kind === 271; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 271; + return node.kind === 272; } ts.isSpreadAssignment = isSpreadAssignment; function isEnumMember(node) { - return node.kind === 272; + return node.kind === 273; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 273; + return node.kind === 274; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 274; + return node.kind === 275; } ts.isBundle = isBundle; function isJSDocTypeExpression(node) { - return node.kind === 277; + return node.kind === 278; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 278; + return node.kind === 279; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 279; + return node.kind === 280; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 280; + return node.kind === 281; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 281; + return node.kind === 282; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 282; + return node.kind === 283; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 283; + return node.kind === 284; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 284; + return node.kind === 285; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 285; + return node.kind === 286; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 289; + return node.kind === 290; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 290; + return node.kind === 291; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocParameterTag(node) { - return node.kind === 292; + return node.kind === 293; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 293; + return node.kind === 294; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 294; + return node.kind === 295; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 295; + return node.kind === 296; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 296; + return node.kind === 297; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 297; + return node.kind === 298; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 297 || node.kind === 292; + return node.kind === 298 || node.kind === 293; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 286; + return node.kind === 287; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 291; + return node.kind === 292; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 287; + return node.kind === 288; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); (function (ts) { function isSyntaxList(n) { - return n.kind === 298; + return n.kind === 299; } ts.isSyntaxList = isSyntaxList; function isNode(node) { @@ -10944,11 +11032,11 @@ var ts; } ts.isNode = isNode; function isNodeKind(kind) { - return kind >= 145; + return kind >= 146; } ts.isNodeKind = isNodeKind; function isToken(n) { - return n.kind >= 0 && n.kind <= 144; + return n.kind >= 0 && n.kind <= 145; } ts.isToken = isToken; function isNodeArray(array) { @@ -10967,6 +11055,10 @@ var ts; return 13 <= kind && kind <= 16; } ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isTemplateLiteralToken(node) { + return isTemplateLiteralKind(node.kind); + } + ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; return kind === 15 @@ -11013,7 +11105,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 145 + return kind === 146 || kind === 71; } ts.isEntityName = isEntityName; @@ -11022,14 +11114,14 @@ var ts; return kind === 71 || kind === 9 || kind === 8 - || kind === 146; + || kind === 147; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 71 - || kind === 179 - || kind === 180; + || kind === 180 + || kind === 181; } ts.isBindingName = isBindingName; function isFunctionLike(node) { @@ -11042,13 +11134,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 233: - case 153: + case 234: case 154: case 155: case 156: - case 191: + case 157: case 192: + case 193: return true; default: return false; @@ -11056,14 +11148,14 @@ var ts; } function isFunctionLikeKind(kind) { switch (kind) { - case 152: - case 157: - case 287: + case 153: case 158: + case 288: case 159: - case 162: - case 283: + case 160: case 163: + case 284: + case 164: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -11076,28 +11168,28 @@ var ts; ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock; function isClassElement(node) { var kind = node.kind; - return kind === 154 - || kind === 151 - || kind === 153 - || kind === 155 + return kind === 155 + || kind === 152 + || kind === 154 || kind === 156 - || kind === 159 - || kind === 211; + || kind === 157 + || kind === 160 + || kind === 212; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 234 || node.kind === 204); + return node && (node.kind === 235 || node.kind === 205); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 155 || node.kind === 156); + return node && (node.kind === 156 || node.kind === 157); } ts.isAccessor = isAccessor; function isMethodOrAccessor(node) { switch (node.kind) { - case 153: - case 155: + case 154: case 156: + case 157: return true; default: return false; @@ -11106,11 +11198,11 @@ var ts; ts.isMethodOrAccessor = isMethodOrAccessor; function isTypeElement(node) { var kind = node.kind; - return kind === 158 - || kind === 157 - || kind === 150 - || kind === 152 - || kind === 159; + return kind === 159 + || kind === 158 + || kind === 151 + || kind === 153 + || kind === 160; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -11119,17 +11211,18 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 269 - || kind === 270 + return kind === 270 || kind === 271 - || kind === 153 - || kind === 155 - || kind === 156; + || kind === 272 + || kind === 154 + || kind === 156 + || kind === 157; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 160 && kind <= 178) + return (kind >= 161 && kind <= 179) || kind === 119 + || kind === 142 || kind === 134 || kind === 135 || kind === 122 @@ -11140,14 +11233,14 @@ var ts; || kind === 140 || kind === 95 || kind === 131 - || kind === 206 - || kind === 278 + || kind === 207 || kind === 279 || kind === 280 || kind === 281 || kind === 282 || kind === 283 - || kind === 284; + || kind === 284 + || kind === 285; } function isTypeNode(node) { return isTypeNodeKind(node.kind); @@ -11155,8 +11248,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 162: case 163: + case 164: return true; } return false; @@ -11165,29 +11258,29 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 180 - || kind === 179; + return kind === 181 + || kind === 180; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 182 - || kind === 183; + return kind === 183 + || kind === 184; } ts.isAssignmentPattern = isAssignmentPattern; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 181 - || kind === 205; + return kind === 182 + || kind === 206; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 231: - case 148: - case 181: + case 232: + case 149: + case 182: return true; } return false; @@ -11200,8 +11293,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 179: - case 183: + case 180: + case 184: return true; } return false; @@ -11209,8 +11302,8 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180: - case 182: + case 181: + case 183: return true; } return false; @@ -11218,25 +11311,25 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 184 - || kind === 145 - || kind === 178; + return kind === 185 + || kind === 146 + || kind === 179; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 184 - || kind === 145; + return kind === 185 + || kind === 146; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { + case 257: case 256: - case 255: - case 186: case 187: case 188: - case 149: + case 189: + case 150: return true; default: return false; @@ -11244,12 +11337,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 186 || node.kind === 187; + return node.kind === 187 || node.kind === 188; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 201 + return kind === 202 || kind === 13; } ts.isTemplateLiteral = isTemplateLiteral; @@ -11259,32 +11352,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 184: case 185: - case 187: case 186: - case 254: - case 255: - case 258: case 188: - case 182: - case 190: + case 187: + case 255: + case 256: + case 259: + case 189: case 183: - case 204: case 191: + case 184: + case 205: + case 192: case 71: case 12: case 8: case 9: case 13: - case 201: + case 202: case 86: case 95: case 99: case 101: case 97: - case 208: case 209: + case 210: case 91: return true; default: @@ -11297,13 +11390,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 197: case 198: - case 193: + case 199: case 194: case 195: case 196: - case 189: + case 197: + case 190: return true; default: return isLeftHandSideExpressionKind(kind); @@ -11311,9 +11404,9 @@ var ts; } function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 198: + case 199: return true; - case 197: + case 198: return expr.operator === 43 || expr.operator === 44; default: @@ -11327,15 +11420,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 200: - case 202: - case 192: - case 199: + case 201: case 203: - case 207: - case 205: + case 193: + case 200: + case 204: + case 208: + case 206: + case 302: case 301: - case 300: return true; default: return isUnaryExpressionKind(kind); @@ -11343,16 +11436,16 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 189 - || kind === 207; + return kind === 190 + || kind === 208; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 300; + return node.kind === 301; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 299; + return node.kind === 300; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -11362,20 +11455,20 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 219: case 220: case 221: - case 217: + case 222: case 218: + case 219: return true; - case 227: + case 228: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isForInOrOfStatement(node) { - return node.kind === 220 || node.kind === 221; + return node.kind === 221 || node.kind === 222; } ts.isForInOrOfStatement = isForInOrOfStatement; function isConciseBody(node) { @@ -11394,108 +11487,108 @@ var ts; ts.isForInitializer = isForInitializer; function isModuleBody(node) { var kind = node.kind; - return kind === 239 - || kind === 238 + return kind === 240 + || kind === 239 || kind === 71; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 239 - || kind === 238; + return kind === 240 + || kind === 239; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 - || kind === 238; + || kind === 239; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 246 - || kind === 245; + return kind === 247 + || kind === 246; } ts.isNamedImportBindings = isNamedImportBindings; function isModuleOrEnumDeclaration(node) { - return node.kind === 238 || node.kind === 237; + return node.kind === 239 || node.kind === 238; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 192 - || kind === 181 - || kind === 234 - || kind === 204 - || kind === 154 - || kind === 237 - || kind === 272 - || kind === 251 - || kind === 233 - || kind === 191 - || kind === 155 - || kind === 244 - || kind === 242 - || kind === 247 + return kind === 193 + || kind === 182 || kind === 235 - || kind === 261 - || kind === 153 - || kind === 152 + || kind === 205 + || kind === 155 || kind === 238 - || kind === 241 - || kind === 245 - || kind === 148 - || kind === 269 - || kind === 151 - || kind === 150 - || kind === 156 - || kind === 270 - || kind === 236 - || kind === 147 - || kind === 231 - || kind === 296 - || kind === 291 - || kind === 297; - } - function isDeclarationStatementKind(kind) { - return kind === 233 + || kind === 273 || kind === 252 || kind === 234 + || kind === 192 + || kind === 156 + || kind === 245 + || kind === 243 + || kind === 248 + || kind === 236 + || kind === 262 + || kind === 154 + || kind === 153 + || kind === 239 + || kind === 242 + || kind === 246 + || kind === 149 + || kind === 270 + || kind === 152 + || kind === 151 + || kind === 157 + || kind === 271 + || kind === 237 + || kind === 148 + || kind === 232 + || kind === 297 + || kind === 292 + || kind === 298; + } + function isDeclarationStatementKind(kind) { + return kind === 234 + || kind === 253 || kind === 235 || kind === 236 || kind === 237 || kind === 238 + || kind === 239 + || kind === 244 || kind === 243 - || kind === 242 + || kind === 250 || kind === 249 - || kind === 248 - || kind === 241; + || kind === 242; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 223 - || kind === 222 - || kind === 230 - || kind === 217 - || kind === 215 - || kind === 214 - || kind === 220 - || kind === 221 - || kind === 219 - || kind === 216 - || kind === 227 - || kind === 224 - || kind === 226 - || kind === 228 - || kind === 229 - || kind === 213 + return kind === 224 + || kind === 223 + || kind === 231 || kind === 218 + || kind === 216 + || kind === 215 + || kind === 221 + || kind === 222 + || kind === 220 + || kind === 217 + || kind === 228 || kind === 225 - || kind === 299 - || kind === 303 - || kind === 302; + || kind === 227 + || kind === 229 + || kind === 230 + || kind === 214 + || kind === 219 + || kind === 226 + || kind === 300 + || kind === 304 + || kind === 303; } function isDeclaration(node) { - if (node.kind === 147) { - return node.parent.kind !== 295 || ts.isInJavaScriptFile(node); + if (node.kind === 148) { + return node.parent.kind !== 296 || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -11516,10 +11609,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 212) + if (node.kind !== 213) return false; if (node.parent !== undefined) { - if (node.parent.kind === 229 || node.parent.kind === 268) { + if (node.parent.kind === 230 || node.parent.kind === 269) { return false; } } @@ -11527,8 +11620,8 @@ var ts; } function isModuleReference(node) { var kind = node.kind; - return kind === 253 - || kind === 145 + return kind === 254 + || kind === 146 || kind === 71; } ts.isModuleReference = isModuleReference; @@ -11536,64 +11629,65 @@ var ts; var kind = node.kind; return kind === 99 || kind === 71 - || kind === 184; + || kind === 185; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 254 - || kind === 264 - || kind === 255 + return kind === 255 + || kind === 265 + || kind === 256 || kind === 10 - || kind === 258; + || kind === 259; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 261 - || kind === 263; + return kind === 262 + || kind === 264; } ts.isJsxAttributeLike = isJsxAttributeLike; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 264; + || kind === 265; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 256 - || kind === 255; + return kind === 257 + || kind === 256; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 265 - || kind === 266; + return kind === 266 + || kind === 267; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isJSDocNode(node) { - return node.kind >= 277 && node.kind <= 297; + return node.kind >= 278 && node.kind <= 298; } ts.isJSDocNode = isJSDocNode; function isJSDocCommentContainingNode(node) { - return node.kind === 285 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 286 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; function isJSDocTag(node) { - return node.kind >= 288 && node.kind <= 297; + return node.kind >= 289 && node.kind <= 298; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 156; + return node.kind === 157; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 155; + return node.kind === 156; } ts.isGetAccessor = isGetAccessor; function hasJSDocNodes(node) { - return !!node.jsDoc && node.jsDoc.length > 0; + var jsDoc = node.jsDoc; + return !!jsDoc && jsDoc.length > 0; } ts.hasJSDocNodes = hasJSDocNodes; function hasType(node) { @@ -11602,8 +11696,7 @@ var ts; ts.hasType = hasType; function couldHaveType(node) { switch (node.kind) { - case 148: - case 150: + case 149: case 151: case 152: case 153: @@ -11614,24 +11707,25 @@ var ts; case 158: case 159: case 160: - case 162: + case 161: case 163: - case 172: - case 174: - case 176: - case 189: - case 191: + case 164: + case 173: + case 175: + case 177: + case 190: case 192: - case 207: - case 231: - case 233: - case 236: - case 277: - case 280: + case 193: + case 208: + case 232: + case 234: + case 237: + case 278: case 281: case 282: case 283: case 284: + case 285: return true; } return false; @@ -11647,13 +11741,13 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 261: - case 263: - case 269: + case 262: + case 264: case 270: - case 153: - case 155: + case 271: + case 154: case 156: + case 157: return true; default: return false; @@ -11661,7 +11755,7 @@ var ts; } ts.isObjectLiteralElement = isObjectLiteralElement; function isTypeReferenceType(node) { - return node.kind === 161 || node.kind === 206; + return node.kind === 162 || node.kind === 207; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -11693,7 +11787,7 @@ var ts; } ts.isStringLiteralLike = isStringLiteralLike; function isNamedImportsOrExports(node) { - return node.kind === 246 || node.kind === 250; + return node.kind === 247 || node.kind === 251; } ts.isNamedImportsOrExports = isNamedImportsOrExports; })(ts || (ts = {})); @@ -11704,7 +11798,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 273) { + if (kind === 274) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71) { @@ -11742,28 +11836,28 @@ var ts; } ts.isJSDocLikeText = isJSDocLikeText; function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 144) { + if (!node || node.kind <= 145) { return; } switch (node.kind) { - case 145: + case 146: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 147: + case 148: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 270: + case 271: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 271: + case 272: return visitNode(cbNode, node.expression); - case 148: + case 149: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -11771,59 +11865,59 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); + case 152: + return visitNodes(cbNode, cbNodes, node.decorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.exclamationToken) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.initializer); case 151: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150: - 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 269: + case 270: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 231: + case 232: 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 181: + case 182: 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 162: case 163: - case 157: + case 164: case 158: case 159: + case 160: 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 153: - case 152: case 154: + case 153: case 155: case 156: - case 191: - case 233: + case 157: case 192: + case 234: + case 193: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -11834,187 +11928,180 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 161: + case 162: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 160: + case 161: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 164: - return visitNode(cbNode, node.exprName); case 165: - return visitNodes(cbNode, cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 166: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNode, cbNodes, node.members); case 167: - return visitNodes(cbNode, cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 168: + return visitNodes(cbNode, cbNodes, node.elementTypes); case 169: - return visitNodes(cbNode, cbNodes, node.types); case 170: + return visitNodes(cbNode, cbNodes, node.types); + case 171: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 171: + case 172: return visitNode(cbNode, node.typeParameter); - case 178: + case 179: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 172: - case 174: - return visitNode(cbNode, node.type); + case 173: case 175: + return visitNode(cbNode, node.type); + case 176: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 176: + case 177: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 177: + case 178: return visitNode(cbNode, node.literal); - case 179: case 180: - return visitNodes(cbNode, cbNodes, node.elements); - case 182: + case 181: return visitNodes(cbNode, cbNodes, node.elements); case 183: - return visitNodes(cbNode, cbNodes, node.properties); + return visitNodes(cbNode, cbNodes, node.elements); case 184: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNode, cbNodes, node.properties); case 185: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 186: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 187: + case 188: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 188: + case 189: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 189: + case 190: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 190: - return visitNode(cbNode, node.expression); - case 193: + case 191: return visitNode(cbNode, node.expression); case 194: return visitNode(cbNode, node.expression); case 195: return visitNode(cbNode, node.expression); - case 197: - return visitNode(cbNode, node.operand); - case 202: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 196: return visitNode(cbNode, node.expression); case 198: return visitNode(cbNode, node.operand); + case 203: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 197: + return visitNode(cbNode, node.expression); case 199: + return visitNode(cbNode, node.operand); + case 200: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 207: + case 208: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 208: - return visitNode(cbNode, node.expression); case 209: + return visitNode(cbNode, node.expression); + case 210: return visitNode(cbNode, node.name); - case 200: + case 201: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 203: + case 204: return visitNode(cbNode, node.expression); - case 212: - case 239: + case 213: + case 240: return visitNodes(cbNode, cbNodes, node.statements); - case 273: + case 274: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 213: + case 214: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 232: + case 233: return visitNodes(cbNode, cbNodes, node.declarations); - case 215: - return visitNode(cbNode, node.expression); case 216: + return visitNode(cbNode, node.expression); + case 217: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 217: + case 218: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 218: + case 219: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 219: + case 220: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 220: + case 221: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 221: + case 222: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222: case 223: - return visitNode(cbNode, node.label); case 224: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.label); case 225: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); + return visitNode(cbNode, node.expression); case 226: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 227: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 240: + case 241: return visitNodes(cbNode, cbNodes, node.clauses); - case 265: + case 266: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 266: + case 267: return visitNodes(cbNode, cbNodes, node.statements); - case 227: + case 228: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 228: - return visitNode(cbNode, node.expression); case 229: + return visitNode(cbNode, node.expression); + case 230: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 268: + case 269: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 149: + case 150: return visitNode(cbNode, node.expression); - case 234: - case 204: - 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 235: + case 205: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -12026,112 +12113,119 @@ var ts; visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNode, cbNodes, node.heritageClauses) || + visitNodes(cbNode, cbNodes, node.members); case 237: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNode, cbNodes, node.members); - case 272: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNode, cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 238: + return visitNodes(cbNode, cbNodes, node.decorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNode, cbNodes, node.members); + case 273: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 239: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 242: + case 243: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 243: + case 244: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 244: + case 245: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 241: - return visitNode(cbNode, node.name); - case 245: + case 242: return visitNode(cbNode, node.name); case 246: - case 250: + return visitNode(cbNode, node.name); + case 247: + case 251: return visitNodes(cbNode, cbNodes, node.elements); - case 249: + case 250: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 247: - case 251: + case 248: + case 252: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 248: + case 249: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 201: + case 202: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 210: + case 211: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 146: + case 147: return visitNode(cbNode, node.expression); - case 267: + case 268: return visitNodes(cbNode, cbNodes, node.types); - case 206: + case 207: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 253: - return visitNode(cbNode, node.expression); - case 252: - return visitNodes(cbNode, cbNodes, node.decorators); - case 301: - return visitNodes(cbNode, cbNodes, node.elements); case 254: + return visitNode(cbNode, node.expression); + case 253: + return visitNodes(cbNode, cbNodes, node.decorators); + case 302: + return visitNodes(cbNode, cbNodes, node.elements); + case 255: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 258: + case 259: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 255: case 256: + case 257: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 262: + case 263: return visitNodes(cbNode, cbNodes, node.properties); - case 261: + case 262: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 263: - return visitNode(cbNode, node.expression); case 264: + return visitNode(cbNode, node.expression); + case 265: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 257: + case 258: return visitNode(cbNode, node.tagName); - case 277: - return visitNode(cbNode, node.type); - case 281: - return visitNode(cbNode, node.type); - case 280: + case 278: return visitNode(cbNode, node.type); case 282: return visitNode(cbNode, node.type); + case 281: + return visitNode(cbNode, node.type); case 283: + return visitNode(cbNode, node.type); + case 284: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 284: - return visitNode(cbNode, node.type); case 285: + return visitNode(cbNode, node.type); + case 286: return visitNodes(cbNode, cbNodes, node.tags); - case 292: - case 297: + case 293: + case 298: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -12140,17 +12234,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 293: - return visitNode(cbNode, node.typeExpression); case 294: return visitNode(cbNode, node.typeExpression); - case 289: - return visitNode(cbNode, node.class); case 295: - return visitNodes(cbNode, cbNodes, node.typeParameters); + return visitNode(cbNode, node.typeExpression); + case 290: + return visitNode(cbNode, node.class); case 296: + return visitNodes(cbNode, cbNodes, node.typeParameters); + case 297: if (node.typeExpression && - node.typeExpression.kind === 277) { + node.typeExpression.kind === 278) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -12158,16 +12252,16 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 291: + case 292: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 287: + case 288: 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 286: + case 287: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -12175,7 +12269,7 @@ var ts; } } return; - case 300: + case 301: return visitNode(cbNode, node.expression); } } @@ -12208,6 +12302,7 @@ var ts; } ts.isExternalModule = isExternalModule; function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + if (aggressiveChecks === void 0) { aggressiveChecks = false; } var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); newSourceFile.flags |= (sourceFile.flags & 1572864); return newSourceFile; @@ -12245,6 +12340,7 @@ var ts; var contextFlags; var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { + if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); if (scriptKind === 6) { var result_1 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); @@ -12272,6 +12368,7 @@ var ts; if (languageVersion === void 0) { languageVersion = 2; } initializeState(sourceText, languageVersion, syntaxCursor, 6); sourceFile = createSourceFile(fileName, 2, 6, false); + sourceFile.flags = contextFlags; nextToken(); var pos = getNodePos(); if (token() === 1) { @@ -12279,7 +12376,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(215); + var statement = createNode(216); switch (token()) { case 21: statement.expression = parseArrayLiteralExpression(); @@ -12422,10 +12519,11 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { - var sourceFile = new SourceFileConstructor(273, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(274, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; + sourceFile.bindSuggestionDiagnostics = undefined; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); sourceFile.languageVariant = getLanguageVariant(scriptKind); @@ -12739,7 +12837,7 @@ var ts; return parsePropertyNameWorker(true); } function parseComputedPropertyName() { - var node = createNode(146); + var node = createNode(147); parseExpected(21); node.expression = allowInAnd(parseExpression); parseExpected(22); @@ -12853,7 +12951,7 @@ var ts; case 14: return true; } - ts.Debug.fail("Non-exhaustive case in 'isListElement'."); + return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { ts.Debug.assert(token() === 17); @@ -12929,6 +13027,8 @@ var ts; return token() === 29 || token() === 41; case 14: return token() === 27 && lookAhead(nextTokenIsSlash); + default: + return false; } } function isVariableDeclaratorListTerminator() { @@ -13047,14 +13147,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 154: - case 159: case 155: + case 160: case 156: - case 151: - case 211: + case 157: + case 152: + case 212: return true; - case 153: + case 154: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 71 && methodDeclaration.name.originalKeywordKind === 123; @@ -13066,8 +13166,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 265: case 266: + case 267: return true; } } @@ -13076,65 +13176,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 233: + case 234: + case 214: case 213: - case 212: + case 217: case 216: - case 215: - case 228: + case 229: + case 225: + case 227: case 224: - case 226: case 223: + case 221: case 222: case 220: - case 221: case 219: - case 218: - case 225: - case 214: - case 229: - case 227: - case 217: + case 226: + case 215: case 230: + case 228: + case 218: + case 231: + case 244: case 243: - case 242: + case 250: case 249: - case 248: - case 238: - case 234: + case 239: case 235: - case 237: case 236: + case 238: + case 237: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 272; + return node.kind === 273; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 158: - case 152: case 159: - case 150: - case 157: + case 153: + case 160: + case 151: + case 158: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 231) { + if (node.kind !== 232) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 148) { + if (node.kind !== 149) { return false; } var parameter = node; @@ -13173,6 +13273,7 @@ var ts; case 22: return ts.Diagnostics.Identifier_expected; case 13: return ts.Diagnostics.Identifier_expected; case 14: return ts.Diagnostics.Identifier_expected; + default: return undefined; } } function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { @@ -13241,7 +13342,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(145, entity.pos); + var node = createNode(146, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -13256,19 +13357,19 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(201); + var template = createNode(202); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14, "Template head has wrong token kind"); var list = []; var listPos = getNodePos(); do { list.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(list).literal.kind === 15); + } while (ts.last(list).literal.kind === 15); template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { - var span = createNode(210); + var span = createNode(211); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18) { @@ -13312,7 +13413,7 @@ var ts; return node; } function parseTypeReference() { - var node = createNode(161); + var node = createNode(162); node.typeName = parseEntityName(true, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token() === 27) { node.typeArguments = parseBracketedList(19, parseType, 27, 29); @@ -13321,20 +13422,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(160, lhs.pos); + var node = createNode(161, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(173); + var node = createNode(174); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(278); + var result = createNode(279); if (postFixEquals) { - return createJSDocPostfixType(282, result); + return createJSDocPostfixType(283, result); } else { nextToken(); @@ -13342,7 +13443,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(281); + var result = createNode(282); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -13356,28 +13457,28 @@ var ts; token() === 29 || token() === 58 || token() === 49) { - var result = createNode(279, pos); + var result = createNode(280, pos); return finishNode(result); } else { - var result = createNode(280, pos); + var result = createNode(281, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(283); + var result = createNodeWithJSDoc(284); nextToken(); fillSignature(56, 4 | 32, result); return finishNode(result); } - var node = createNode(161); + var node = createNode(162); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(148); + var parameter = createNode(149); if (token() === 99 || token() === 94) { parameter.name = parseIdentifierName(); parseExpected(56); @@ -13389,23 +13490,23 @@ var ts; var dotdotdot = parseOptionalToken(24); var type = parseType(); if (dotdotdot) { - var variadic = createNode(284, dotdotdot.pos); + var variadic = createNode(285, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58) { - return createJSDocPostfixType(282, type); + return createJSDocPostfixType(283, type); } return type; } function parseTypeQuery() { - var node = createNode(164); + var node = createNode(165); parseExpected(103); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(147); + var node = createNode(148); node.name = parseIdentifier(); if (parseOptional(85)) { if (isStartOfType() || !isStartOfExpression()) { @@ -13439,7 +13540,7 @@ var ts; isStartOfType(true); } function parseParameter() { - var node = createNodeWithJSDoc(148); + var node = createNodeWithJSDoc(149); if (token() === 99) { node.name = createIdentifier(true); node.type = parseParameterType(); @@ -13507,7 +13608,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 158) { + if (kind === 159) { parseExpected(94); } fillSignature(56, 4, node); @@ -13544,7 +13645,7 @@ var ts; return token() === 56 || token() === 26 || token() === 22; } function parseIndexSignatureDeclaration(node) { - node.kind = 159; + node.kind = 160; node.parameters = parseBracketedList(16, parseParameter, 21, 22); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -13554,11 +13655,11 @@ var ts; node.name = parsePropertyName(); node.questionToken = parseOptionalToken(55); if (token() === 19 || token() === 27) { - node.kind = 152; + node.kind = 153; fillSignature(56, 4, node); } else { - node.kind = 150; + node.kind = 151; node.type = parseTypeAnnotation(); if (token() === 58) { node.initializer = parseInitializer(); @@ -13571,7 +13672,7 @@ var ts; if (token() === 19 || token() === 27) { return true; } - var idToken; + var idToken = false; while (ts.isModifierKind(token())) { idToken = true; nextToken(); @@ -13595,10 +13696,10 @@ var ts; } function parseTypeMember() { if (token() === 19 || token() === 27) { - return parseSignatureMember(157); + return parseSignatureMember(158); } if (token() === 94 && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(158); + return parseSignatureMember(159); } var node = createNodeWithJSDoc(0); node.modifiers = parseModifiers(); @@ -13624,7 +13725,7 @@ var ts; return false; } function parseTypeLiteral() { - var node = createNode(165); + var node = createNode(166); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -13650,14 +13751,14 @@ var ts; return token() === 21 && nextTokenIsIdentifier() && nextToken() === 92; } function parseMappedTypeParameter() { - var node = createNode(147); + var node = createNode(148); node.name = parseIdentifier(); parseExpected(92); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(176); + var node = createNode(177); parseExpected(17); if (token() === 132 || token() === 37 || token() === 38) { node.readonlyToken = parseTokenNode(); @@ -13680,12 +13781,12 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(167); + var node = createNode(168); node.elementTypes = parseBracketedList(20, parseType, 21, 22); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(172); + var node = createNode(173); parseExpected(19); node.type = parseType(); if (!node.type) { @@ -13696,7 +13797,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 163) { + if (kind === 164) { parseExpected(94); } if (!fillSignature(36, 4 | (sourceFile.languageVariant === 1 ? 8 : 0), node)) { @@ -13712,10 +13813,10 @@ var ts; return token() === 23 ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(177); + var node = createNode(178); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(197); + unaryMinusExpression = createNode(198); unaryMinusExpression.operator = 38; nextToken(); } @@ -13736,7 +13837,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288; - var node = createNode(178); + var node = createNode(179); if (parseOptional(103)) { node.isTypeOf = true; } @@ -13756,6 +13857,7 @@ var ts; function parseNonArrayType() { switch (token()) { case 119: + case 142: case 137: case 134: case 138: @@ -13811,6 +13913,7 @@ var ts; function isStartOfType(inStartOfParameter) { switch (token()) { case 119: + case 142: case 137: case 134: case 122: @@ -13857,25 +13960,25 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51: - type = createJSDocPostfixType(281, type); + type = createJSDocPostfixType(282, type); break; case 55: if (!(contextFlags & 2097152) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createJSDocPostfixType(280, type); + type = createJSDocPostfixType(281, type); break; case 21: parseExpected(21); if (isStartOfType()) { - var node = createNode(175, type.pos); + var node = createNode(176, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22); type = finishNode(node); } else { - var node = createNode(166, type.pos); + var node = createNode(167, type.pos); node.elementType = type; parseExpected(22); type = finishNode(node); @@ -13894,16 +13997,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(174); + var node = createNode(175); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(171); + var node = createNode(172); parseExpected(126); - var typeParameter = createNode(147); + var typeParameter = createNode(148); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -13934,10 +14037,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(169, parseTypeOperatorOrHigher, 48); + return parseUnionOrIntersectionType(170, parseTypeOperatorOrHigher, 48); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(168, parseIntersectionTypeOrHigher, 49); + return parseUnionOrIntersectionType(169, parseIntersectionTypeOrHigher, 49); } function isStartOfFunctionType() { if (token() === 27) { @@ -13983,7 +14086,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(160, typePredicateVariable.pos); + var node = createNode(161, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -14004,14 +14107,14 @@ var ts; } function parseTypeWorker(noConditionalTypes) { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(162); + return parseFunctionOrConstructorType(163); } if (token() === 94) { - return parseFunctionOrConstructorType(163); + return parseFunctionOrConstructorType(164); } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85)) { - var node = createNode(170, type.pos); + var node = createNode(171, type.pos); node.checkType = type; node.extendsType = parseTypeWorker(true); parseExpected(55); @@ -14133,7 +14236,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(202); + var node = createNode(203); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 39 || isStartOfExpression())) { @@ -14149,13 +14252,13 @@ var ts; ts.Debug.assert(token() === 36, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(192, asyncModifier.pos); + node = createNode(193, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(192, identifier.pos); + node = createNode(193, identifier.pos); } - var parameter = createNode(148, identifier.pos); + var parameter = createNode(149, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); @@ -14301,7 +14404,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(192); + var node = createNodeWithJSDoc(193); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256) ? 2 : 0; if (!fillSignature(56, isAsync | (allowAmbiguity ? 0 : 8), node)) { @@ -14335,7 +14438,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(200, leftOperand.pos); + var node = createNode(201, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -14350,7 +14453,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 92 || t === 144; + return t === 92 || t === 145; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -14387,43 +14490,43 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(199, left.pos); + var node = createNode(200, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(207, left.pos); + var node = createNode(208, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(197); + var node = createNode(198); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(193); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(194); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(195); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(196); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { if (token() === 121) { if (inAwaitContext()) { @@ -14434,7 +14537,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(196); + var node = createNode(197); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14451,7 +14554,7 @@ var ts; if (token() === 40) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 189) { + if (simpleUnaryExpression.kind === 190) { 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 { @@ -14504,7 +14607,7 @@ var ts; } function parseUpdateExpression() { if (token() === 43 || token() === 44) { - var node = createNode(197); + var node = createNode(198); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -14516,7 +14619,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 || token() === 44) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(198, expression.pos); + var node = createNode(199, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -14535,7 +14638,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); nextToken(); - var node = createNode(209, fullStart); + var node = createNode(210, fullStart); node.keywordToken = 91; node.name = parseIdentifierName(); expression = finishNode(node); @@ -14559,30 +14662,17 @@ var ts; if (token() === 19 || token() === 23 || token() === 21) { return expression; } - var node = createNode(184, expression.pos); + var node = createNode(185, expression.pos); node.expression = expression; parseExpectedToken(23, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } - function tagNamesAreEquivalent(lhs, rhs) { - if (lhs.kind !== rhs.kind) { - return false; - } - if (lhs.kind === 71) { - return lhs.escapedText === rhs.escapedText; - } - if (lhs.kind === 99) { - return true; - } - return lhs.name.escapedText === rhs.name.escapedText && - tagNamesAreEquivalent(lhs.expression, rhs.expression); - } function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 256) { - var node = createNode(254, opening.pos); + if (opening.kind === 257) { + var node = createNode(255, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -14591,22 +14681,22 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 259) { - var node = createNode(258, opening.pos); + else if (opening.kind === 260) { + var node = createNode(259, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 255); + ts.Debug.assert(opening.kind === 256); result = opening; } if (inExpressionContext && token() === 27) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(199, result.pos); + var badNode = createNode(200, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -14662,7 +14752,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(262); + var jsxAttributes = createNode(263); jsxAttributes.properties = parseList(13, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -14670,7 +14760,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(27); if (token() === 29) { - var node_1 = createNode(259, fullStart); + var node_1 = createNode(260, fullStart); scanJsxText(); return finishNode(node_1); } @@ -14679,7 +14769,7 @@ var ts; var attributes = parseJsxAttributes(); var node; if (token() === 29) { - node = createNode(256, fullStart); + node = createNode(257, fullStart); scanJsxText(); } else { @@ -14691,7 +14781,7 @@ var ts; parseExpected(29, undefined, false); scanJsxText(); } - node = createNode(255, fullStart); + node = createNode(256, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -14703,7 +14793,7 @@ var ts; var expression = token() === 99 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23)) { - var propertyAccess = createNode(184, expression.pos); + var propertyAccess = createNode(185, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14711,7 +14801,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(264); + var node = createNode(265); if (!parseExpected(17)) { return undefined; } @@ -14733,7 +14823,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(261); + var node = createNode(262); node.name = parseIdentifierName(); if (token() === 58) { switch (scanJsxAttributeValue()) { @@ -14748,7 +14838,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(263); + var node = createNode(264); parseExpected(17); parseExpected(24); node.expression = parseExpression(); @@ -14756,7 +14846,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(257); + var node = createNode(258); parseExpected(28); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -14769,7 +14859,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(260); + var node = createNode(261); parseExpected(28); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -14784,7 +14874,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(189); + var node = createNode(190); parseExpected(27); node.type = parseType(); parseExpected(29); @@ -14795,7 +14885,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23); if (dotToken) { - var propertyAccess = createNode(184, expression.pos); + var propertyAccess = createNode(185, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14803,13 +14893,13 @@ var ts; } if (token() === 51 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(208, expression.pos); + var nonNullExpression = createNode(209, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(21)) { - var indexedAccess = createNode(185, expression.pos); + var indexedAccess = createNode(186, expression.pos); indexedAccess.expression = expression; if (token() === 22) { indexedAccess.argumentExpression = createMissingNode(71, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -14836,7 +14926,7 @@ var ts; return token() === 13 || token() === 14; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(188, tag.pos); + var tagExpression = createNode(189, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 @@ -14856,7 +14946,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(186, expression.pos); + var callExpr = createNode(187, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -14864,7 +14954,7 @@ var ts; continue; } else if (token() === 19) { - var callExpr = createNode(186, expression.pos); + var callExpr = createNode(187, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -14961,28 +15051,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(190); + var node = createNodeWithJSDoc(191); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); return finishNode(node); } function parseSpreadElement() { - var node = createNode(203); + var node = createNode(204); parseExpected(24); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 ? parseSpreadElement() : - token() === 26 ? createNode(205) : + token() === 26 ? createNode(206) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(182); + var node = createNode(183); parseExpected(21); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -14994,17 +15084,17 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0); if (parseOptionalToken(24)) { - node.kind = 271; + node.kind = 272; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); if (parseContextualModifier(125)) { - return parseAccessorDeclaration(node, 155); + return parseAccessorDeclaration(node, 156); } if (parseContextualModifier(136)) { - return parseAccessorDeclaration(node, 156); + return parseAccessorDeclaration(node, 157); } var asteriskToken = parseOptionalToken(39); var tokenIsIdentifier = isIdentifier(); @@ -15015,7 +15105,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 || token() === 18 || token() === 58); if (isShorthandPropertyAssignment) { - node.kind = 270; + node.kind = 271; var equalsToken = parseOptionalToken(58); if (equalsToken) { node.equalsToken = equalsToken; @@ -15023,14 +15113,14 @@ var ts; } } else { - node.kind = 269; + node.kind = 270; parseExpected(56); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(183); + var node = createNode(184); parseExpected(17); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15044,7 +15134,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNodeWithJSDoc(191); + var node = createNodeWithJSDoc(192); node.modifiers = parseModifiers(); parseExpected(89); node.asteriskToken = parseOptionalToken(39); @@ -15069,7 +15159,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94); if (parseOptional(23)) { - var node_2 = createNode(209, fullStart); + var node_2 = createNode(210, fullStart); node_2.keywordToken = 94; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -15086,7 +15176,7 @@ var ts; } break; } - var node = createNode(187, fullStart); + var node = createNode(188, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19) { @@ -15095,7 +15185,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(212); + var node = createNode(213); if (parseExpected(17, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15126,12 +15216,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(214); + var node = createNode(215); parseExpected(25); return finishNode(node); } function parseIfStatement() { - var node = createNode(216); + var node = createNode(217); parseExpected(90); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -15141,7 +15231,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(217); + var node = createNode(218); parseExpected(81); node.statement = parseStatement(); parseExpected(106); @@ -15152,7 +15242,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(218); + var node = createNode(219); parseExpected(106); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -15175,8 +15265,8 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(144) : parseOptional(144)) { - var forOfStatement = createNode(221, pos); + if (awaitToken ? parseExpected(145) : parseOptional(145)) { + var forOfStatement = createNode(222, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -15184,14 +15274,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92)) { - var forInStatement = createNode(220, pos); + var forInStatement = createNode(221, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(219, pos); + var forStatement = createNode(220, pos); forStatement.initializer = initializer; parseExpected(25); if (token() !== 25 && token() !== 20) { @@ -15209,7 +15299,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 223 ? 72 : 77); + parseExpected(kind === 224 ? 72 : 77); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -15217,7 +15307,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(224); + var node = createNode(225); parseExpected(96); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -15226,7 +15316,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(225); + var node = createNode(226); parseExpected(107); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -15235,7 +15325,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(265); + var node = createNode(266); parseExpected(73); node.expression = allowInAnd(parseExpression); parseExpected(56); @@ -15243,7 +15333,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(266); + var node = createNode(267); parseExpected(79); parseExpected(56); node.statements = parseList(3, parseStatement); @@ -15253,12 +15343,12 @@ var ts; return token() === 73 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(226); + var node = createNode(227); parseExpected(98); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); - var caseBlock = createNode(240); + var caseBlock = createNode(241); parseExpected(17); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(18); @@ -15266,14 +15356,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(228); + var node = createNode(229); parseExpected(100); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(229); + var node = createNode(230); parseExpected(102); node.tryBlock = parseBlock(false); node.catchClause = token() === 74 ? parseCatchClause() : undefined; @@ -15284,7 +15374,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(268); + var result = createNode(269); parseExpected(74); if (parseOptional(19)) { result.variableDeclaration = parseVariableDeclaration(); @@ -15297,7 +15387,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(230); + var node = createNode(231); parseExpected(78); parseSemicolon(); return finishNode(node); @@ -15306,12 +15396,12 @@ var ts; var node = createNodeWithJSDoc(0); var expression = allowInAnd(parseExpression); if (expression.kind === 71 && parseOptional(56)) { - node.kind = 227; + node.kind = 228; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 215; + node.kind = 216; node.expression = expression; parseSemicolon(); } @@ -15361,7 +15451,7 @@ var ts; return false; } continue; - case 143: + case 144: nextToken(); return token() === 17 || token() === 71 || token() === 84; case 91: @@ -15423,7 +15513,7 @@ var ts; case 129: case 130: case 139: - case 143: + case 144: return true; case 114: case 112: @@ -15449,16 +15539,16 @@ var ts; case 17: return parseBlock(false); case 104: - return parseVariableStatement(createNodeWithJSDoc(231)); + return parseVariableStatement(createNodeWithJSDoc(232)); case 110: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(231)); + return parseVariableStatement(createNodeWithJSDoc(232)); } break; case 89: - return parseFunctionDeclaration(createNodeWithJSDoc(233)); + return parseFunctionDeclaration(createNodeWithJSDoc(234)); case 75: - return parseClassDeclaration(createNodeWithJSDoc(234)); + return parseClassDeclaration(createNodeWithJSDoc(235)); case 90: return parseIfStatement(); case 81: @@ -15468,9 +15558,9 @@ var ts; case 88: return parseForOrForInOrForOfStatement(); case 77: - return parseBreakOrContinueStatement(222); - case 72: return parseBreakOrContinueStatement(223); + case 72: + return parseBreakOrContinueStatement(224); case 96: return parseReturnStatement(); case 107: @@ -15503,7 +15593,7 @@ var ts; case 117: case 115: case 132: - case 143: + case 144: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -15545,7 +15635,7 @@ var ts; return parseTypeAliasDeclaration(node); case 83: return parseEnumDeclaration(node); - case 143: + case 144: case 129: case 130: return parseModuleDeclaration(node); @@ -15564,12 +15654,13 @@ var ts; } default: if (node.decorators || node.modifiers) { - var missing = createMissingNode(252, true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(253, true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; return finishNode(missing); } + return undefined; } } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { @@ -15585,16 +15676,16 @@ var ts; } function parseArrayBindingElement() { if (token() === 26) { - return createNode(205); + return createNode(206); } - var node = createNode(181); + var node = createNode(182); node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(181); + var node = createNode(182); node.dotDotDotToken = parseOptionalToken(24); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -15610,14 +15701,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(179); + var node = createNode(180); parseExpected(17); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(18); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(180); + var node = createNode(181); parseExpected(21); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(22); @@ -15639,7 +15730,7 @@ var ts; return parseVariableDeclaration(true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(231); + var node = createNode(232); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 && token() === 51 && !scanner.hasPrecedingLineBreak()) { @@ -15652,7 +15743,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(232); + var node = createNode(233); switch (token()) { case 104: break; @@ -15666,7 +15757,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 144 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 145 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -15681,13 +15772,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20; } function parseVariableStatement(node) { - node.kind = 213; + node.kind = 214; node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 233; + node.kind = 234; parseExpected(89); node.asteriskToken = parseOptionalToken(39); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); @@ -15698,14 +15789,14 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(node) { - node.kind = 154; + node.kind = 155; parseExpected(123); fillSignature(56, 0, node); node.body = parseFunctionBlockOrSemicolon(0, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 153; + node.kind = 154; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 : 0; var isAsync = ts.hasModifier(node, 256) ? 2 : 0; @@ -15714,7 +15805,7 @@ var ts; return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 151; + node.kind = 152; if (!node.questionToken && token() === 51 && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } @@ -15789,7 +15880,7 @@ var ts; if (!parseOptional(57)) { break; } - var decorator = createNode(149, decoratorStart); + var decorator = createNode(150, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -15830,7 +15921,7 @@ var ts; } function parseClassElement() { if (token() === 25) { - var result = createNode(211); + var result = createNode(212); nextToken(); return finishNode(result); } @@ -15838,10 +15929,10 @@ var ts; node.decorators = parseDecorators(); node.modifiers = parseModifiers(true); if (parseContextualModifier(125)) { - return parseAccessorDeclaration(node, 155); + return parseAccessorDeclaration(node, 156); } if (parseContextualModifier(136)) { - return parseAccessorDeclaration(node, 156); + return parseAccessorDeclaration(node, 157); } if (token() === 123) { return parseConstructorDeclaration(node); @@ -15860,13 +15951,13 @@ var ts; node.name = createMissingNode(71, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } - ts.Debug.fail("Should not have attempted to parse class member declaration."); + return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 204); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 205); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 234); + return parseClassDeclarationOrExpression(node, 235); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -15899,17 +15990,15 @@ var ts; } function parseHeritageClause() { var tok = token(); - if (tok === 85 || tok === 108) { - var node = createNode(267); - node.token = tok; - nextToken(); - node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); - return finishNode(node); - } - return undefined; + ts.Debug.assert(tok === 85 || tok === 108); + var node = createNode(268); + node.token = tok; + nextToken(); + node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); + return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(206); + var node = createNode(207); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -15926,7 +16015,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 235; + node.kind = 236; parseExpected(109); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -15935,7 +16024,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 236; + node.kind = 237; parseExpected(139); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -15945,13 +16034,13 @@ var ts; return finishNode(node); } function parseEnumMember() { - var node = createNodeWithJSDoc(272); + var node = createNodeWithJSDoc(273); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 237; + node.kind = 238; parseExpected(83); node.name = parseIdentifier(); if (parseExpected(17)) { @@ -15964,7 +16053,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(239); + var node = createNode(240); if (parseExpected(17)) { node.statements = parseList(1, parseStatement); parseExpected(18); @@ -15975,7 +16064,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 238; + node.kind = 239; var namespaceFlag = flags & 16; node.flags |= flags; node.name = parseIdentifier(); @@ -15985,8 +16074,8 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 238; - if (token() === 143) { + node.kind = 239; + if (token() === 144) { node.name = parseIdentifier(); node.flags |= 512; } @@ -16004,7 +16093,7 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 143) { + if (token() === 144) { return parseAmbientExternalModuleDeclaration(node); } else if (parseOptional(130)) { @@ -16029,7 +16118,7 @@ var ts; return nextToken() === 41; } function parseNamespaceExportDeclaration(node) { - node.kind = 241; + node.kind = 242; parseExpected(118); parseExpected(130); node.name = parseIdentifier(); @@ -16042,23 +16131,23 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 26 && token() !== 142) { + if (token() !== 26 && token() !== 143) { return parseImportEqualsDeclaration(node, identifier); } } - node.kind = 243; + node.kind = 244; if (identifier || token() === 39 || token() === 17) { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(142); + parseExpected(143); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 242; + node.kind = 243; node.name = identifier; parseExpected(58); node.moduleReference = parseModuleReference(); @@ -16066,13 +16155,13 @@ var ts; return finishNode(node); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(244, fullStart); + var importClause = createNode(245, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(26)) { - importClause.namedBindings = token() === 39 ? parseNamespaceImport() : parseNamedImportsOrExports(246); + importClause.namedBindings = token() === 39 ? parseNamespaceImport() : parseNamedImportsOrExports(247); } return finishNode(importClause); } @@ -16082,7 +16171,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(253); + var node = createNode(254); parseExpected(133); parseExpected(19); node.expression = parseModuleSpecifier(); @@ -16100,7 +16189,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(245); + var namespaceImport = createNode(246); parseExpected(39); parseExpected(118); namespaceImport.name = parseIdentifier(); @@ -16108,14 +16197,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 246 ? parseImportSpecifier : parseExportSpecifier, 17, 18); + node.elements = parseBracketedList(22, kind === 247 ? parseImportSpecifier : parseExportSpecifier, 17, 18); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(251); + return parseImportOrExportSpecifier(252); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(247); + return parseImportOrExportSpecifier(248); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -16134,21 +16223,21 @@ var ts; else { node.name = identifierName; } - if (kind === 247 && checkIdentifierIsKeyword) { + if (kind === 248 && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 249; + node.kind = 250; if (parseOptional(39)) { - parseExpected(142); + parseExpected(143); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(250); - if (token() === 142 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(142); + node.exportClause = parseNamedImportsOrExports(251); + if (token() === 143 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(143); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -16156,7 +16245,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 248; + node.kind = 249; if (parseOptional(58)) { node.isExportEquals = true; } @@ -16174,10 +16263,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1) - || node.kind === 242 && node.moduleReference.kind === 253 - || node.kind === 243 - || node.kind === 248 + || node.kind === 243 && node.moduleReference.kind === 254 + || node.kind === 244 || node.kind === 249 + || node.kind === 250 ? node : undefined; } @@ -16206,7 +16295,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(277, scanner.getTokenPos()); + var result = createNode(278, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17); result.type = doInsideOfContext(2097152, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -16247,8 +16336,8 @@ var ts; } JSDocParser.parseJSDocComment = parseJSDocComment; function parseJSDocCommentWorker(start, length) { + if (start === void 0) { start = 0; } var content = sourceText; - start = start || 0; var end = length === undefined ? content.length : start + length; length = end - start; ts.Debug.assert(start >= 0); @@ -16273,17 +16362,15 @@ var ts; comments.push(text); indent += text.length; } - var t = nextJSDocToken(); - while (t === 5) { - t = nextJSDocToken(); - } - if (t === 4) { + nextJSDocToken(); + while (parseOptionalJsdoc(5)) + ; + if (parseOptionalJsdoc(4)) { state = 0; indent = 0; - t = nextJSDocToken(); } loop: while (true) { - switch (t) { + switch (token()) { case 57: if (state === 0 || state === 1) { removeTrailingNewlines(comments); @@ -16333,7 +16420,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - t = nextJSDocToken(); + nextJSDocToken(); } removeLeadingNewlines(comments); removeTrailingNewlines(comments); @@ -16351,7 +16438,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(285, start); + var result = createNode(286, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -16489,7 +16576,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(288, atToken.pos); + var result = createNode(289, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -16530,7 +16617,7 @@ var ts; switch (node.kind) { case 135: return true; - case 166: + case 167: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -16546,12 +16633,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 ? - createNode(297, atToken.pos) : - createNode(292, atToken.pos); + createNode(298, atToken.pos) : + createNode(293, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); - var nestedTypeLiteral = parseNestedTypeLiteral(typeExpression, name, target); + var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; @@ -16567,20 +16654,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(277, scanner.getTokenPos()); + var typeLiteralExpression = createNode(278, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) { - if (child.kind === 292 || child.kind === 297) { + if (child.kind === 293 || child.kind === 298) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(286, start_2); + jsdocTypeLiteral = createNode(287, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 166) { + if (typeExpression.type.kind === 167) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -16589,27 +16676,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 293; })) { - parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); - } - var result = createNode(293, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result); - } - function parseTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 294; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var result = createNode(294, atToken.pos); result.atToken = atToken; result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result); + } + function parseTypeTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 295; })) { + parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); + } + var result = createNode(295, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(289, atToken.pos); + var result = createNode(290, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -16617,7 +16704,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17); - var node = createNode(206); + var node = createNode(207); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -16629,7 +16716,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(true); while (parseOptional(23)) { - var prop = createNode(184, node.pos); + var prop = createNode(185, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -16637,7 +16724,7 @@ var ts; return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(290, atToken.pos); + var tag = createNode(291, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); @@ -16645,7 +16732,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(296, atToken.pos); + var typedefTag = createNode(297, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -16661,9 +16748,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(286, start_3); + jsdocTypeLiteral = createNode(287, start_3); } - if (child.kind === 294) { + if (child.kind === 295) { if (childTypeTag) { break; } @@ -16676,7 +16763,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 166) { + if (typeExpression && typeExpression.type.kind === 167) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -16691,7 +16778,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(23)) { - var jsDocNamespaceNode = createNode(238, pos); + var jsDocNamespaceNode = createNode(239, pos); if (nested) { jsDocNamespaceNode.flags |= 4; } @@ -16705,7 +16792,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(291, atToken.pos); + var callbackTag = createNode(292, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -16714,16 +16801,15 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(287, start); + var jsdocSignature = createNode(288, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (token() === 57) { - nextJSDocToken(); + if (parseOptionalJsdoc(57)) { var tag = parseTag(indent); - if (tag && tag.kind === 293) { + if (tag && tag.kind === 294) { return tag; } } @@ -16768,7 +16854,7 @@ var ts; case 57: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 292 && + if (child && child.kind === 293 && target !== 4 && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -16829,48 +16915,44 @@ var ts; return tag; } function parseTemplateTag(atToken, tagName) { - if (ts.some(tags, ts.isJSDocTemplateTag)) { - parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); + var constraint; + if (token() === 17) { + constraint = parseJSDocTypeExpression(); } var typeParameters = []; var typeParametersPos = getNodePos(); - while (true) { - var typeParameter = createNode(147); - var name = parseJSDocIdentifierNameWithOptionalBraces(); + do { skipWhitespace(); - if (!name) { - parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); + var typeParameter = createNode(148); + if (!ts.tokenIsIdentifierOrKeyword(token())) { + parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); return undefined; } - typeParameter.name = name; + typeParameter.name = parseJSDocIdentifierName(); + skipWhitespace(); finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 26) { - nextJSDocToken(); - skipWhitespace(); - } - else { - break; - } + } while (parseOptionalJsdoc(26)); + if (constraint) { + ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(295, atToken.pos); + var result = createNode(296, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); finishNode(result); return result; } - function parseJSDocIdentifierNameWithOptionalBraces() { - var parsedBrace = parseOptional(17); - var res = parseJSDocIdentifierName(); - if (parsedBrace) { - parseExpected(18); - } - return res; - } function nextJSDocToken() { return currentToken = scanner.scanJSDocToken(); } + function parseOptionalJsdoc(t) { + if (token() === t) { + nextJSDocToken(); + return true; + } + return false; + } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(true); if (parseOptional(21)) { @@ -17260,10 +17342,7 @@ var ts; break; } case "amd-dependency": { - context.amdDependencies = ts.map(ts.toArray(entryOrList), function (_a) { - var _b = _a.arguments, name = _b.name, path = _b.path; - return ({ name: name, path: path }); - }); + context.amdDependencies = ts.map(ts.toArray(entryOrList), function (x) { return ({ name: x.arguments.name, path: x.arguments.path }); }); break; } case "amd-module": { @@ -17395,6 +17474,20 @@ var ts; } return argMap; } + function tagNamesAreEquivalent(lhs, rhs) { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === 71) { + return lhs.escapedText === rhs.escapedText; + } + if (lhs.kind === 99) { + return true; + } + return lhs.name.escapedText === rhs.name.escapedText && + tagNamesAreEquivalent(lhs.expression, rhs.expression); + } + ts.tagNamesAreEquivalent = tagNamesAreEquivalent; })(ts || (ts = {})); var ts; (function (ts) { @@ -17404,21 +17497,21 @@ var ts; ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateWorker(node) { switch (node.kind) { - case 235: case 236: - return 0; case 237: + return 0; + case 238: if (ts.isConst(node)) { return 2; } break; + case 244: case 243: - case 242: if (!(ts.hasModifier(node, 1))) { return 0; } break; - case 239: { + case 240: { var state_1 = 0; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -17437,7 +17530,7 @@ var ts; }); return state_1; } - case 238: + case 239: return getModuleInstanceState(node); case 71: if (node.isInJSDocNamespace) { @@ -17548,13 +17641,13 @@ var ts; if (symbolFlags & 67216319) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 238)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 239)) { symbol.valueDeclaration = node; } } } function getDeclarationName(node) { - if (node.kind === 248) { + if (node.kind === 249) { return node.isExportEquals ? "export=" : "default"; } var name = ts.getNameOfDeclaration(node); @@ -17563,7 +17656,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 146) { + if (name.kind === 147) { var nameExpression = name.expression; if (ts.isStringOrNumericLiteral(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); @@ -17574,31 +17667,31 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 154: + case 155: return "__constructor"; - case 162: - case 157: - case 287: - return "__call"; case 163: case 158: - return "__new"; + case 288: + return "__call"; + case 164: case 159: + return "__new"; + case 160: return "__index"; - case 249: + case 250: return "__export"; - case 273: + case 274: return "export="; - case 199: + case 200: if (ts.getSpecialPropertyAssignmentKind(node) === 2) { return "export="; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 283: + case 284: return (ts.isJSDocConstructSignature(node) ? "__new" : "__call"); - case 148: - ts.Debug.assert(node.parent.kind === 283, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + case 149: + ts.Debug.assert(node.parent.kind === 284, "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; @@ -17648,7 +17741,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (node.kind === 248 && !node.isExportEquals)) { + (node.kind === 249 && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -17673,7 +17766,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 2097152) { - if (node.kind === 251 || (node.kind === 242 && hasExportModifier)) { + if (node.kind === 252 || (node.kind === 243 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -17703,7 +17796,7 @@ var ts; var saveThisParentContainer = thisParentContainer; var savedBlockScopeContainer = blockScopeContainer; if (containerFlags & 1) { - if (node.kind !== 192) { + if (node.kind !== 193) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -17731,7 +17824,7 @@ var ts; currentFlow.container = node; } } - currentReturnTarget = isIIFE || node.kind === 154 ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 155 ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -17743,13 +17836,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 273) { + if (node.kind === 274) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 154) { + if (node.kind === 155) { node.returnFlowNode = currentFlow; } } @@ -17792,8 +17885,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 233 ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 233 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 234 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 234 ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -17825,76 +17918,76 @@ var ts; return; } switch (node.kind) { - case 218: + case 219: bindWhileStatement(node); break; - case 217: + case 218: bindDoStatement(node); break; - case 219: + case 220: bindForStatement(node); break; - case 220: case 221: + case 222: bindForInOrForOfStatement(node); break; - case 216: + case 217: bindIfStatement(node); break; - case 224: - case 228: + case 225: + case 229: bindReturnOrThrow(node); break; + case 224: case 223: - case 222: bindBreakOrContinueStatement(node); break; - case 229: + case 230: bindTryStatement(node); break; - case 226: + case 227: bindSwitchStatement(node); break; - case 240: + case 241: bindCaseBlock(node); break; - case 265: + case 266: bindCaseClause(node); break; - case 227: + case 228: bindLabeledStatement(node); break; - case 197: + case 198: bindPrefixUnaryExpressionFlow(node); break; - case 198: + case 199: bindPostfixUnaryExpressionFlow(node); break; - case 199: + case 200: bindBinaryExpressionFlow(node); break; - case 193: + case 194: bindDeleteExpressionFlow(node); break; - case 200: + case 201: bindConditionalExpressionFlow(node); break; - case 231: + case 232: bindVariableDeclarationFlow(node); break; - case 186: + case 187: bindCallExpressionFlow(node); break; - case 296: - case 291: + case 297: + case 292: bindJSDocTypeAlias(node); break; - case 273: + case 274: bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 212: - case 239: + case 213: + case 240: bindEachFunctionsFirst(node.statements); break; default: @@ -17907,15 +18000,15 @@ var ts; switch (expr.kind) { case 71: case 99: - case 184: + case 185: return isNarrowableReference(expr); - case 186: + case 187: return hasNarrowableArgument(expr); - case 190: + case 191: return isNarrowingExpression(expr.expression); - case 199: + case 200: return isNarrowingBinaryExpression(expr); - case 197: + case 198: return expr.operator === 51 && isNarrowingExpression(expr.operand); } return false; @@ -17924,7 +18017,7 @@ var ts; return expr.kind === 71 || expr.kind === 99 || expr.kind === 97 || - expr.kind === 184 && isNarrowableReference(expr.expression); + expr.kind === 185 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -17935,7 +18028,7 @@ var ts; } } } - if (expr.expression.kind === 184 && + if (expr.expression.kind === 185 && isNarrowableReference(expr.expression.expression)) { return true; } @@ -17968,9 +18061,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 190: + case 191: return isNarrowableOperand(expr.expression); - case 199: + case 200: switch (expr.operatorToken.kind) { case 58: return isNarrowableOperand(expr.left); @@ -18047,33 +18140,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 216: - case 218: case 217: - return parent.expression === node; case 219: - case 200: + case 218: + return parent.expression === node; + case 220: + case 201: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 190) { + if (node.kind === 191) { node = node.expression; } - else if (node.kind === 197 && node.operator === 51) { + else if (node.kind === 198 && node.operator === 51) { node = node.operand; } else { - return node.kind === 199 && (node.operatorToken.kind === 53 || + return node.kind === 200 && (node.operatorToken.kind === 53 || node.operatorToken.kind === 54); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 190 || - node.parent.kind === 197 && + while (node.parent.kind === 191 || + node.parent.kind === 198 && node.parent.operator === 51) { node = node.parent; } @@ -18115,7 +18208,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 227 + var enclosingLabeledStatement = node.parent.kind === 228 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -18147,13 +18240,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 221) { + if (node.kind === 222) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 232) { + if (node.initializer.kind !== 233) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -18175,7 +18268,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 224) { + if (node.kind === 225) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -18195,7 +18288,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 223 ? breakTarget : continueTarget; + var flowLabel = node.kind === 224 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -18258,7 +18351,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 266; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -18280,6 +18373,7 @@ var ts; } var preCaseLabel = createBranchLabel(); addAntecedent(preCaseLabel, createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1)); + addAntecedent(preCaseLabel, createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1)); addAntecedent(preCaseLabel, fallthroughFlow); currentFlow = finishFlowLabel(preCaseLabel); var clause = clauses[i]; @@ -18321,15 +18415,15 @@ var ts; bind(node.statement); popActiveLabel(); if (!activeLabel.referenced && !options.allowUnusedLabels) { - file.bindDiagnostics.push(createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); + errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 217) { + if (!node.statement || node.statement.kind !== 218) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 199 && node.operatorToken.kind === 58) { + if (node.kind === 200 && node.operatorToken.kind === 58) { bindAssignmentTargetFlow(node.left); } else { @@ -18340,10 +18434,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 182) { + else if (node.kind === 183) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 203) { + if (e.kind === 204) { bindAssignmentTargetFlow(e.expression); } else { @@ -18351,16 +18445,16 @@ var ts; } } } - else if (node.kind === 183) { + else if (node.kind === 184) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 269) { + if (p.kind === 270) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 270) { + else if (p.kind === 271) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 271) { + else if (p.kind === 272) { bindAssignmentTargetFlow(p.expression); } } @@ -18416,7 +18510,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 && node.left.kind === 185) { + if (operator === 58 && node.left.kind === 186) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -18427,7 +18521,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 184) { + if (node.expression.kind === 185) { bindAssignmentTargetFlow(node.expression); } } @@ -18471,10 +18565,10 @@ var ts; } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 190) { + while (expr.kind === 191) { expr = expr.expression; } - if (expr.kind === 191 || expr.kind === 192) { + if (expr.kind === 192 || expr.kind === 193) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -18482,7 +18576,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 184) { + if (node.expression.kind === 185) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -18491,53 +18585,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 204: - case 234: - case 237: - case 183: - case 165: - case 286: - case 262: - return 1; + case 205: case 235: - return 1 | 64; case 238: + case 184: + case 166: + case 287: + case 263: + return 1; case 236: - case 176: + return 1 | 64; + case 239: + case 237: + case 177: return 1 | 32; - case 273: + case 274: return 1 | 4 | 32; - case 153: + case 154: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 154: - case 233: - case 152: case 155: + case 234: + case 153: case 156: case 157: - case 287: - case 283: - case 162: case 158: - case 159: + case 288: + case 284: case 163: + case 159: + case 160: + case 164: return 1 | 4 | 32 | 8; - case 191: case 192: + case 193: return 1 | 4 | 32 | 8 | 16; - case 239: + case 240: return 4; - case 151: + case 152: return node.initializer ? 4 : 0; - case 268: - case 219: + case 269: case 220: case 221: - case 240: + case 222: + case 241: return 2; - case 212: + case 213: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -18550,40 +18644,40 @@ var ts; } function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 238: + case 239: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 273: + case 274: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 204: - case 234: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 237: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 165: - case 286: - case 183: + case 205: case 235: - case 262: - return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 162: - case 163: - case 157: - case 158: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 238: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 166: case 287: + case 184: + case 236: + case 263: + return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + case 163: + case 164: + case 158: case 159: - case 153: - case 152: + case 288: + case 160: case 154: + case 153: case 155: case 156: - case 233: - case 191: + case 157: + case 234: case 192: - case 283: - case 296: - case 291: - case 236: - case 176: + case 193: + case 284: + case 297: + case 292: + case 237: + case 177: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -18598,11 +18692,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 273 ? node : node.body; - if (body && (body.kind === 273 || body.kind === 239)) { + var body = node.kind === 274 ? node : node.body; + if (body && (body.kind === 274 || body.kind === 240)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 249 || stat.kind === 248) { + if (stat.kind === 250 || stat.kind === 249) { return true; } } @@ -18670,11 +18764,11 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 271 || prop.name.kind !== 71) { + if (prop.kind === 272 || prop.name.kind !== 71) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 269 || prop.kind === 270 || prop.kind === 153 + var currentKind = prop.kind === 270 || prop.kind === 271 || prop.kind === 154 ? 1 : 2; var existingKind = seen.get(identifier.escapedText); @@ -18702,13 +18796,14 @@ var ts; symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); + return symbol; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 238: + case 239: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 273: + case 274: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -18828,8 +18923,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 273 && - blockScopeContainer.kind !== 238 && + if (blockScopeContainer.kind !== 274 && + blockScopeContainer.kind !== 239 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -18862,6 +18957,16 @@ var ts; var span = ts.getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } + function errorOrSuggestionOnFirstToken(isError, node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + var diag = ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2); + if (isError) { + file.bindDiagnostics.push(diag); + } + else { + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + } + } function bind(node) { if (!node) { return; @@ -18869,7 +18974,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 144) { + if (node.kind > 145) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -18933,11 +19038,11 @@ var ts; break; } case 99: - if (currentFlow && (ts.isExpression(node) || parent.kind === 270)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 271)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 184: + case 185: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -18945,7 +19050,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 199: + case 200: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1: @@ -18972,127 +19077,127 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 268: + case 269: return checkStrictModeCatchClause(node); - case 193: + case 194: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 198: + case 199: return checkStrictModePostfixUnaryExpression(node); - case 197: + case 198: return checkStrictModePrefixUnaryExpression(node); - case 225: + case 226: return checkStrictModeWithStatement(node); - case 173: + case 174: seenThisKeyword = true; return; - case 160: + case 161: break; - case 147: - return bindTypeParameter(node); case 148: + return bindTypeParameter(node); + case 149: return bindParameter(node); - case 231: + case 232: return bindVariableDeclarationOrBindingElement(node); - case 181: + case 182: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); + case 152: case 151: - case 150: return bindPropertyWorker(node); - case 269: case 270: + case 271: return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 272: + case 273: return bindPropertyOrMethodOrAccessor(node, 8, 68008959); - case 157: case 158: case 159: + case 160: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 153: - case 152: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 67208127); - case 233: - return bindFunctionDeclaration(node); case 154: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 153: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 67208127); + case 234: + return bindFunctionDeclaration(node); case 155: - return bindPropertyOrMethodOrAccessor(node, 32768, 67150783); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 156: + return bindPropertyOrMethodOrAccessor(node, 32768, 67150783); + case 157: return bindPropertyOrMethodOrAccessor(node, 65536, 67183551); - case 162: - case 283: - case 287: case 163: + case 284: + case 288: + case 164: return bindFunctionOrConstructorType(node); - case 165: - case 286: - case 176: + case 166: + case 287: + case 177: return bindAnonymousTypeWorker(node); - case 183: + case 184: return bindObjectLiteralExpression(node); - case 191: case 192: + case 193: return bindFunctionExpression(node); - case 186: + case 187: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 204: - case 234: + case 205: + case 235: inStrictMode = true; return bindClassLikeDeclaration(node); - case 235: - return bindBlockScopedDeclaration(node, 64, 67901832); case 236: - return bindBlockScopedDeclaration(node, 524288, 67901928); + return bindBlockScopedDeclaration(node, 64, 67901832); case 237: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 67901928); case 238: + return bindEnumDeclaration(node); + case 239: return bindModuleDeclaration(node); - case 262: + case 263: return bindJsxAttributes(node); - case 261: + case 262: return bindJsxAttribute(node, 4, 0); - case 242: - case 245: - case 247: - case 251: - return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); - case 241: - return bindNamespaceExportDeclaration(node); - case 244: - return bindImportClause(node); - case 249: - return bindExportDeclaration(node); + case 243: + case 246: case 248: + case 252: + return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); + case 242: + return bindNamespaceExportDeclaration(node); + case 245: + return bindImportClause(node); + case 250: + return bindExportDeclaration(node); + case 249: return bindExportAssignment(node); - case 273: + case 274: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 212: + case 213: if (!ts.isFunctionLike(node.parent)) { return; } - case 239: + case 240: return updateStrictModeStatementList(node.statements); - case 292: - if (node.parent.kind === 287) { + case 293: + if (node.parent.kind === 288) { return bindParameter(node); } - if (node.parent.kind !== 286) { + if (node.parent.kind !== 287) { break; } - case 297: + case 298: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 282 ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 ? 4 | 16777216 : 4; return declareSymbolAndAddToSymbolTable(propTag, flags, 0); - case 296: - case 291: + case 297: + case 292: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -19122,7 +19227,7 @@ var ts; bindAnonymousDeclaration(node, 2097152, getDeclarationName(node)); } else { - var flags = node.kind === 248 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 249 && ts.exportAssignmentIsAlias(node) ? 2097152 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863); @@ -19132,7 +19237,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 273) { + if (node.parent.kind !== 274) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -19174,13 +19279,11 @@ var ts; function bindExportsPropertyAssignment(node) { setCommonJsModuleIndicator(node); var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, function (id, original) { - if (!original) { - return undefined; + var symbol = forEachIdentifierInEntityName(lhs.expression, undefined, function (id, symbol) { + if (symbol) { + addDeclarationToSymbol(symbol, id, 1536 | 67108864); } - var s = ts.getJSInitializerSymbol(original); - addDeclarationToSymbol(s, id, 1536 | 67108864); - return s; + return symbol; }); if (symbol) { var flags = ts.isClassExpression(node.right) ? @@ -19205,13 +19308,13 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, false); switch (thisContainer.kind) { - case 233: - case 191: + case 234: + case 192: var constructorSymbol = thisContainer.symbol; if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 58) { var l = thisContainer.parent.left; if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { - constructorSymbol = getJSInitializerSymbolFromName(l.expression.expression, thisParentContainer); + constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } if (constructorSymbol) { @@ -19219,16 +19322,16 @@ var ts; declareSymbol(constructorSymbol.members, constructorSymbol, node, 4, 0 & ~4); } break; - case 154: - case 151: - case 153: case 155: + case 152: + case 154: case 156: + case 157: var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4, 0, true); break; - case 273: + case 274: break; default: ts.Debug.fail(ts.Debug.showSyntaxKind(thisContainer)); @@ -19238,7 +19341,7 @@ var ts; if (node.expression.kind === 99) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 273) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -19276,39 +19379,52 @@ var ts; node.expression.parent = node; bindPropertyAssignment(node.expression, node, false); } - function getJSInitializerSymbolFromName(name, lookupContainer) { - return ts.getJSInitializerSymbol(lookupSymbolForPropertyAccess(name, lookupContainer)); - } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { - var symbol = getJSInitializerSymbolFromName(name); + var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 273 && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 273; - if (!isPrototypeProperty && (!symbol || !(symbol.flags & 1920)) && isToplevelNamespaceableInitializer) { + : propertyAccess.parent.parent.kind === 274; + if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920)) && isToplevelNamespaceableInitializer) { var flags_1 = 1536 | 67108864; var excludeFlags_1 = 67215503 & ~67108864; - forEachIdentifierInEntityName(propertyAccess.expression, function (id, original) { - if (original) { - addDeclarationToSymbol(original, id, flags_1); - return original; + namespaceSymbol = forEachIdentifierInEntityName(propertyAccess.expression, namespaceSymbol, function (id, symbol, parent) { + if (symbol) { + addDeclarationToSymbol(symbol, id, flags_1); + return symbol; } else { - return symbol = declareSymbol(symbol ? symbol.exports : container.locals, symbol, id, flags_1, excludeFlags_1); + return declareSymbol(parent ? parent.exports : container.locals, parent, id, flags_1, excludeFlags_1); } }); } - if (!symbol || !(symbol.flags & (16 | 32 | 1024 | 4096))) { + if (!namespaceSymbol || !isJavascriptContainer(namespaceSymbol)) { return; } var symbolTable = isPrototypeProperty ? - (symbol.members || (symbol.members = ts.createSymbolTable())) : - (symbol.exports || (symbol.exports = ts.createSymbolTable())); + (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : + (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); var jsContainerFlag = isToplevelNamespaceableInitializer ? 67108864 : 0; var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedJavascriptInitializer(propertyAccess)); var symbolFlags = (isMethod ? 8192 : 4) | jsContainerFlag; var symbolExcludes = (isMethod ? 67208127 : 0) & ~jsContainerFlag; - declareSymbol(symbolTable, symbol, propertyAccess, symbolFlags, symbolExcludes); + declareSymbol(symbolTable, namespaceSymbol, propertyAccess, symbolFlags, symbolExcludes); + } + function isJavascriptContainer(symbol) { + if (symbol.flags & (16 | 32 | 1024)) { + return true; + } + var node = symbol.valueDeclaration; + var init = !node ? undefined : + ts.isVariableDeclaration(node) ? node.initializer : + ts.isBinaryExpression(node) ? node.right : + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) ? node.parent.right : + undefined; + if (init) { + var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); + return !!ts.getJavascriptInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 54 ? init.right : init, isPrototypeAssignment); + } + return false; } function getParentOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.parent)) { @@ -19322,21 +19438,22 @@ var ts; return lookupSymbolForNameWorker(lookupContainer, node.escapedText); } else { - var symbol = ts.getJSInitializerSymbol(lookupSymbolForPropertyAccess(node.expression)); + var symbol = lookupSymbolForPropertyAccess(node.expression); return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); } } - function forEachIdentifierInEntityName(e, action) { + function forEachIdentifierInEntityName(e, parent, action) { if (isExportsOrModuleExportsOrAlias(file, e)) { return file.symbol; } else if (ts.isIdentifier(e)) { - return action(e, lookupSymbolForPropertyAccess(e)); + return action(e, lookupSymbolForPropertyAccess(e), parent); } else { - var s = ts.getJSInitializerSymbol(forEachIdentifierInEntityName(e.expression, action)); - ts.Debug.assert(!!s && !!s.exports); - return action(e.name, s.exports.get(e.name.escapedText)); + var s = forEachIdentifierInEntityName(e.expression, parent, action); + if (!s || !s.exports) + return ts.Debug.fail(); + return action(e.name, s.exports.get(e.name.escapedText), s); } } function bindCallExpression(node) { @@ -19345,7 +19462,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 234) { + if (node.kind === 235) { bindBlockScopedDeclaration(node, 32, 68008383); } else { @@ -19389,7 +19506,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 292 && container.kind !== 287) { + if (node.kind === 293 && container.kind !== 288) { return; } if (inStrictMode && !(node.flags & 4194304)) { @@ -19462,7 +19579,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144, 67639784); } } - else if (node.parent.kind === 171) { + else if (node.parent.kind === 172) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -19480,26 +19597,26 @@ var ts; } function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 || (instanceState === 2 && options.preserveConstEnums); + return instanceState === 1 || (instanceState === 2 && !!options.preserveConstEnums); } function checkUnreachable(node) { if (!(currentFlow.flags & 1)) { return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 214) || - node.kind === 234 || - (node.kind === 238 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 237 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 215) || + node.kind === 235 || + (node.kind === 239 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 238 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; - var reportUnreachableCode = !options.allowUnreachableCode && - !(node.flags & 4194304) && - (node.kind !== 213 || - ts.getCombinedNodeFlags(node.declarationList) & 3 || - ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); - if (reportUnreachableCode) { - errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); + if (!options.allowUnreachableCode) { + var isError = ts.unreachableCodeIsError(options) && + !(node.flags & 4194304) && + (!ts.isVariableStatement(node) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3) || + node.declarationList.declarations.some(function (d) { return !!d.initializer; })); + errorOrSuggestionOnFirstToken(isError, node, ts.Diagnostics.Unreachable_code_detected); } } } @@ -19514,8 +19631,8 @@ var ts; ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias; function isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node) { var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText); - return symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && - symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer); + return !!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && + !!symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer); } function isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node) { return isExportsOrModuleExportsOrAlias(sourceFile, node) || @@ -19531,58 +19648,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 186: - return computeCallExpression(node, subtreeFlags); case 187: + return computeCallExpression(node, subtreeFlags); + case 188: return computeNewExpression(node, subtreeFlags); - case 238: + case 239: return computeModuleDeclaration(node, subtreeFlags); - case 190: - return computeParenthesizedExpression(node, subtreeFlags); - case 199: - return computeBinaryExpression(node, subtreeFlags); - case 215: - return computeExpressionStatement(node, subtreeFlags); - case 148: - return computeParameter(node, subtreeFlags); - case 192: - return computeArrowFunction(node, subtreeFlags); case 191: + return computeParenthesizedExpression(node, subtreeFlags); + case 200: + return computeBinaryExpression(node, subtreeFlags); + case 216: + return computeExpressionStatement(node, subtreeFlags); + case 149: + return computeParameter(node, subtreeFlags); + case 193: + return computeArrowFunction(node, subtreeFlags); + case 192: return computeFunctionExpression(node, subtreeFlags); - case 233: - return computeFunctionDeclaration(node, subtreeFlags); - case 231: - return computeVariableDeclaration(node, subtreeFlags); - case 232: - return computeVariableDeclarationList(node, subtreeFlags); - case 213: - return computeVariableStatement(node, subtreeFlags); - case 227: - return computeLabeledStatement(node, subtreeFlags); case 234: + return computeFunctionDeclaration(node, subtreeFlags); + case 232: + return computeVariableDeclaration(node, subtreeFlags); + case 233: + return computeVariableDeclarationList(node, subtreeFlags); + case 214: + return computeVariableStatement(node, subtreeFlags); + case 228: + return computeLabeledStatement(node, subtreeFlags); + case 235: return computeClassDeclaration(node, subtreeFlags); - case 204: + case 205: return computeClassExpression(node, subtreeFlags); - case 267: - return computeHeritageClause(node, subtreeFlags); case 268: + return computeHeritageClause(node, subtreeFlags); + case 269: return computeCatchClause(node, subtreeFlags); - case 206: + case 207: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 154: - return computeConstructor(node, subtreeFlags); - case 151: - return computePropertyDeclaration(node, subtreeFlags); - case 153: - return computeMethod(node, subtreeFlags); case 155: + return computeConstructor(node, subtreeFlags); + case 152: + return computePropertyDeclaration(node, subtreeFlags); + case 154: + return computeMethod(node, subtreeFlags); case 156: + case 157: return computeAccessor(node, subtreeFlags); - case 242: + case 243: return computeImportEquals(node, subtreeFlags); - case 184: - return computePropertyAccess(node, subtreeFlags); case 185: + return computePropertyAccess(node, subtreeFlags); + case 186: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -19626,10 +19743,10 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 && leftKind === 183) { + if (operatorTokenKind === 58 && leftKind === 184) { transformFlags |= 8 | 192 | 3072; } - else if (operatorTokenKind === 58 && leftKind === 182) { + else if (operatorTokenKind === 58 && leftKind === 183) { transformFlags |= 192 | 3072; } else if (operatorTokenKind === 40 @@ -19667,8 +19784,8 @@ var ts; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 207 - || expressionKind === 189) { + if (expressionKind === 208 + || expressionKind === 190) { transformFlags |= 3; } if (expressionTransformFlags & 1024) { @@ -19967,12 +20084,12 @@ var ts; var excludeFlags = 939525441; switch (kind) { case 120: - case 196: + case 197: transformFlags |= 8 | 16; break; - case 189: - case 207: - case 300: + case 190: + case 208: + case 301: transformFlags |= 3; excludeFlags = 536872257; break; @@ -19982,17 +20099,16 @@ var ts; case 117: case 124: case 76: - case 237: - case 272: - case 208: + case 238: + case 273: + case 209: case 132: transformFlags |= 3; break; - case 254: case 255: case 256: - case 10: case 257: + case 10: case 258: case 259: case 260: @@ -20000,17 +20116,18 @@ var ts; case 262: case 263: case 264: + case 265: transformFlags |= 4; break; case 13: case 14: case 15: case 16: - case 201: - case 188: - case 270: + case 202: + case 189: + case 271: case 115: - case 209: + case 210: transformFlags |= 192; break; case 9: @@ -20023,13 +20140,13 @@ var ts; transformFlags |= 192; } break; - case 221: + case 222: if (node.awaitModifier) { transformFlags |= 8; } transformFlags |= 192; break; - case 202: + case 203: transformFlags |= 8 | 192 | 16777216; break; case 119: @@ -20040,10 +20157,9 @@ var ts; case 122: case 138: case 105: - case 147: - case 150: - case 152: - case 157: + case 148: + case 151: + case 153: case 158: case 159: case 160: @@ -20059,27 +20175,28 @@ var ts; case 170: case 171: case 172: - case 235: - case 236: case 173: + case 236: + case 237: case 174: case 175: case 176: case 177: - case 241: + case 178: + case 242: transformFlags = 3; excludeFlags = -3; break; - case 146: + case 147: transformFlags |= 2097152; if (subtreeFlags & 16384) { transformFlags |= 65536; } break; - case 203: + case 204: transformFlags |= 192 | 524288; break; - case 271: + case 272: transformFlags |= 8 | 1048576; break; case 97: @@ -20089,27 +20206,27 @@ var ts; case 99: transformFlags |= 16384; break; - case 179: + case 180: transformFlags |= 192 | 8388608; if (subtreeFlags & 524288) { transformFlags |= 8 | 1048576; } excludeFlags = 940049729; break; - case 180: + case 181: transformFlags |= 192 | 8388608; excludeFlags = 940049729; break; - case 181: + case 182: transformFlags |= 192; if (node.dotDotDotToken) { transformFlags |= 524288; } break; - case 149: + case 150: transformFlags |= 3 | 4096; break; - case 183: + case 184: excludeFlags = 942740801; if (subtreeFlags & 2097152) { transformFlags |= 192; @@ -20121,29 +20238,31 @@ var ts; transformFlags |= 8; } break; - case 182: - case 187: + case 183: + case 188: excludeFlags = 940049729; if (subtreeFlags & 524288) { transformFlags |= 192; } break; - case 217: case 218: case 219: case 220: + case 221: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 273: + case 274: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 224: - case 222: + case 225: + transformFlags |= 33554432 | 8; + break; case 223: + case 224: transformFlags |= 33554432; break; } @@ -20151,33 +20270,33 @@ var ts; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 160 && kind <= 178) { + if (kind >= 161 && kind <= 179) { return -3; } switch (kind) { - case 186: case 187: - case 182: + case 188: + case 183: return 940049729; - case 238: + case 239: return 977327425; - case 148: + case 149: return 939525441; - case 192: + case 193: return 1003902273; - case 191: - case 233: - return 1003935041; - case 232: - return 948962625; + case 192: case 234: - case 204: + return 1003935041; + case 233: + return 948962625; + case 235: + case 205: return 942011713; - case 154: - return 1003668801; - case 153: case 155: + return 1003668801; + case 154: case 156: + case 157: return 1003668801; case 119: case 134: @@ -20187,30 +20306,30 @@ var ts; case 122: case 138: case 105: - case 147: - case 150: - case 152: - case 157: + case 148: + case 151: + case 153: case 158: case 159: - case 235: + case 160: case 236: + case 237: return -3; - case 183: + case 184: return 942740801; - case 268: + case 269: return 940574017; - case 179: case 180: + case 181: return 940049729; - case 189: - case 207: - case 300: case 190: + case 208: + case 301: + case 191: case 97: return 536872257; - case 184: case 185: + case 186: return 671089985; default: return 939525441; @@ -20263,7 +20382,7 @@ var ts; var shouldBail = visitSymbol(type.symbol); if (shouldBail) return; - if (type.flags & 65536) { + if (type.flags & 131072) { var objectType = type; var objectFlags = objectType.objectFlags; if (objectFlags & 4) { @@ -20279,16 +20398,16 @@ var ts; visitObjectType(objectType); } } - if (type.flags & 32768) { + if (type.flags & 65536) { visitTypeParameter(type); } - if (type.flags & 393216) { + if (type.flags & 786432) { visitUnionOrIntersectionType(type); } - if (type.flags & 524288) { + if (type.flags & 1048576) { visitIndexType(type); } - if (type.flags & 1048576) { + if (type.flags & 2097152) { visitIndexedAccessType(type); } } @@ -20356,11 +20475,11 @@ var ts; } function visitSymbol(symbol) { if (!symbol) { - return; + return false; } var symbolId = ts.getSymbolId(symbol); if (visitedSymbols[symbolId]) { - return; + return false; } visitedSymbols[symbolId] = symbol; if (!accept(symbol)) { @@ -20372,12 +20491,13 @@ var ts; symbol.exports.forEach(visitSymbol); } ts.forEach(symbol.declarations, function (d) { - if (d.type && d.type.kind === 164) { + if (d.type && d.type.kind === 165) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); } }); + return false; } } } @@ -20390,7 +20510,7 @@ var ts; } ts.trace = trace; function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; + return !!compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; function withPackageId(packageId, r) { @@ -20551,14 +20671,13 @@ var ts; } } function secondaryLookup() { - var resolvedFile; var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); if (initialLocationForSecondaryLookup !== undefined) { if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); - resolvedFile = resolvedTypeScriptOnly(result && result.value); + var resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -20710,7 +20829,7 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); break; default: - ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } if (perFolderCache) { perFolderCache.set(moduleName, result); @@ -20888,7 +21007,7 @@ var ts; var originalPath = void 0; if (!compilerOptions.preserveSymlinks && resolvedValue) { originalPath = resolvedValue.path; - var path = realPath(resolved_1.value.path, host, traceEnabled); + var path = realPath(resolvedValue.path, host, traceEnabled); if (path === originalPath) { originalPath = undefined; } @@ -20988,7 +21107,7 @@ var ts; function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (extensions === Extensions.Json) { var extensionLess = ts.tryRemoveExtension(candidate, ".json"); - return extensionLess && tryAddingExtensions(extensionLess, extensions, failedLookupLocations, onlyRecordFailures, state); + return extensionLess === undefined ? undefined : tryAddingExtensions(extensionLess, extensions, failedLookupLocations, onlyRecordFailures, state); } var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); if (resolvedByAddingExtension) { @@ -21022,7 +21141,7 @@ var ts; } function tryExtension(ext) { var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); - return path && { path: path, ext: ext }; + return path === undefined ? undefined : { path: path, ext: ext }; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { @@ -21393,11 +21512,12 @@ var ts; getGlobalDiagnostics: getGlobalDiagnostics, getTypeOfSymbolAtLocation: function (symbol, location) { location = ts.getParseTreeNode(location); - return location ? getTypeOfSymbolAtLocation(symbol, location) : unknownType; + return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType; }, - getSymbolsOfParameterPropertyDeclaration: function (parameter, parameterName) { - parameter = ts.getParseTreeNode(parameter, ts.isParameter); - ts.Debug.assert(parameter !== undefined, "Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); + getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) { + var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter); + if (parameter === undefined) + return ts.Debug.fail("Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); return getSymbolsOfParameterPropertyDeclaration(parameter, ts.escapeLeadingUnderscores(parameterName)); }, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, @@ -21409,9 +21529,9 @@ var ts; getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, getWidenedType: getWidenedType, - getTypeFromTypeNode: function (node) { - node = ts.getParseTreeNode(node, ts.isTypeNode); - return node ? getTypeFromTypeNode(node) : unknownType; + getTypeFromTypeNode: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode); + return node ? getTypeFromTypeNode(node) : errorType; }, getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, @@ -21437,8 +21557,8 @@ var ts; node = ts.getParseTreeNode(node); return node ? getShorthandAssignmentValueSymbol(node) : undefined; }, - getExportSpecifierLocalTargetSymbol: function (node) { - node = ts.getParseTreeNode(node, ts.isExportSpecifier); + getExportSpecifierLocalTargetSymbol: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isExportSpecifier); return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; }, getExportSymbolOfSymbol: function (symbol) { @@ -21446,10 +21566,10 @@ var ts; }, getTypeAtLocation: function (node) { node = ts.getParseTreeNode(node); - return node ? getTypeOfNode(node) : unknownType; + return node ? getTypeOfNode(node) : errorType; }, - getPropertySymbolOfDestructuringAssignment: function (location) { - location = ts.getParseTreeNode(location, ts.isIdentifier); + getPropertySymbolOfDestructuringAssignment: function (locationIn) { + var location = ts.getParseTreeNode(locationIn, ts.isIdentifier); return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined; }, signatureToString: function (signature, enclosingDeclaration, flags, kind) { @@ -21479,41 +21599,41 @@ var ts; getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: function (node) { - node = ts.getParseTreeNode(node, ts.isExpression); + getContextualType: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isExpression); return node ? getContextualType(node) : undefined; }, - getContextualTypeForArgumentAtIndex: function (node, argIndex) { - node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) { + var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); return node && getContextualTypeForArgumentAtIndex(node, argIndex); }, - getContextualTypeForJsxAttribute: function (node) { - node = ts.getParseTreeNode(node, ts.isJsxAttributeLike); + getContextualTypeForJsxAttribute: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike); return node && getContextualTypeForJsxAttribute(node); }, isContextSensitive: isContextSensitive, getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: function (node, candidatesOutArray, theArgumentCount) { - node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + getResolvedSignature: function (nodeIn, candidatesOutArray, theArgumentCount) { + var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); apparentArgumentCount = theArgumentCount; var res = node ? getResolvedSignature(node, candidatesOutArray) : undefined; apparentArgumentCount = undefined; return res; }, - getConstantValue: function (node) { - node = ts.getParseTreeNode(node, canHaveConstantValue); + getConstantValue: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue); return node ? getConstantValue(node) : undefined; }, - isValidPropertyAccess: function (node, propertyName) { - node = ts.getParseTreeNode(node, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode); + isValidPropertyAccess: function (nodeIn, propertyName) { + var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode); return !!node && isValidPropertyAccess(node, ts.escapeLeadingUnderscores(propertyName)); }, - isValidPropertyAccessForCompletions: function (node, type, property) { - node = ts.getParseTreeNode(node, ts.isPropertyAccessExpression); + isValidPropertyAccessForCompletions: function (nodeIn, type, property) { + var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessExpression); return !!node && isValidPropertyAccessForCompletions(node, type, property); }, - getSignatureFromDeclaration: function (declaration) { - declaration = ts.getParseTreeNode(declaration, ts.isFunctionLike); + getSignatureFromDeclaration: function (declarationIn) { + var declaration = ts.getParseTreeNode(declarationIn, ts.isFunctionLike); return declaration ? getSignatureFromDeclaration(declaration) : undefined; }, isImplementationOfOverload: function (node) { @@ -21525,7 +21645,8 @@ var ts; var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); + if (!node) + return ts.Debug.fail(); links.immediateTarget = getTargetOfAliasDeclaration(node, true); } return links.immediateTarget; @@ -21536,13 +21657,13 @@ var ts; getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { - node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); + getAllAttributesTypeFromJsxOpeningLikeElement: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isJsxOpeningLikeElement); return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; }, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, - isOptionalParameter: function (node) { - node = ts.getParseTreeNode(node, ts.isParameter); + isOptionalParameter: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isParameter); return node ? isOptionalParameter(node) : false; }, tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); }, @@ -21574,7 +21695,7 @@ var ts; getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, getSuggestionForNonexistentModule: function (node, target) { return getSuggestionForNonexistentModule(node, target); }, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 32768 ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 65536 ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined, false, excludeGlobals); }, @@ -21586,24 +21707,31 @@ var ts; node = ts.getParseTreeNode(node); return node && tryGetThisTypeAt(node); }, - getTypeArgumentConstraint: function (node) { - node = ts.getParseTreeNode(node, ts.isTypeNode); + getTypeArgumentConstraint: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode); return node && getTypeArgumentConstraint(node); }, - getSuggestionDiagnostics: function (file) { - return (suggestionDiagnostics.get(file.fileName) || ts.emptyArray).concat(getUnusedDiagnostics()); - function getUnusedDiagnostics() { - if (file.isDeclarationFile) - return ts.emptyArray; + getSuggestionDiagnostics: function (file, ct) { + var diagnostics; + try { + cancellationToken = ct; checkSourceFile(file); - var diagnostics = []; ts.Debug.assert(!!(getNodeLinks(file).flags & 1)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + if (!file.isDeclarationFile && (!unusedIsError(0) || !unusedIsError(1))) { + addUnusedDiagnostics(); + } + return diagnostics || ts.emptyArray; + } + finally { + cancellationToken = undefined; + } + function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (kind, diag) { if (!unusedIsError(kind)) { - diagnostics.push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); } }); - return diagnostics; } }, runWithCancellationToken: function (token, callback) { @@ -21628,22 +21756,23 @@ var ts; var anyType = createIntrinsicType(1, "any"); var autoType = createIntrinsicType(1, "any"); var wildcardType = createIntrinsicType(1, "any"); - var unknownType = createIntrinsicType(1, "unknown"); - var undefinedType = createIntrinsicType(4096, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(4096 | 16777216, "undefined"); - var nullType = createIntrinsicType(8192, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(8192 | 16777216, "null"); - var stringType = createIntrinsicType(2, "string"); - var numberType = createIntrinsicType(4, "number"); - var trueType = createIntrinsicType(128, "true"); - var falseType = createIntrinsicType(128, "false"); + var errorType = createIntrinsicType(1, "error"); + var unknownType = createIntrinsicType(2, "unknown"); + var undefinedType = createIntrinsicType(8192, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(8192 | 134217728, "undefined"); + var nullType = createIntrinsicType(16384, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(16384 | 134217728, "null"); + var stringType = createIntrinsicType(4, "string"); + var numberType = createIntrinsicType(8, "number"); + var trueType = createIntrinsicType(256, "true"); + var falseType = createIntrinsicType(256, "false"); var booleanType = createBooleanType([trueType, falseType]); - var esSymbolType = createIntrinsicType(512, "symbol"); - var voidType = createIntrinsicType(2048, "void"); - var neverType = createIntrinsicType(16384, "never"); - var silentNeverType = createIntrinsicType(16384, "never"); - var implicitNeverType = createIntrinsicType(16384, "never"); - var nonPrimitiveType = createIntrinsicType(134217728, "object"); + var esSymbolType = createIntrinsicType(1024, "symbol"); + var voidType = createIntrinsicType(4096, "void"); + var neverType = createIntrinsicType(32768, "never"); + var silentNeverType = createIntrinsicType(32768, "never"); + var implicitNeverType = createIntrinsicType(32768, "never"); + var nonPrimitiveType = createIntrinsicType(16777216, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -21653,17 +21782,17 @@ var ts; var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); emptyGenericType.instantiations = ts.createMap(); var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - anyFunctionType.flags |= 67108864; + anyFunctionType.flags |= 536870912; 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); - var markerSuperType = createType(32768); - var markerSubType = createType(32768); + var markerSuperType = createType(65536); + var markerSubType = createType(65536); markerSubType.constraint = markerSuperType; - var markerOtherType = createType(32768); + var markerOtherType = createType(65536); var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, unknownType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, undefined, 0, false, false); var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, false, false); var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, undefined, 0, false, false); var resolvingSignaturesArray = [resolvingSignature]; @@ -21773,6 +21902,7 @@ var ts; typeToString(type, enclosingDeclaration, flags, emitTextWriterWrapper(writer)); }, buildSymbolDisplay: function (symbol, writer, enclosingDeclaration, meaning, flags) { + if (flags === void 0) { flags = 0; } symbolToString(symbol, enclosingDeclaration, meaning, flags | 4, emitTextWriterWrapper(writer)); }, buildSignatureDisplay: function (signature, writer, enclosing, flags, kind) { @@ -22022,15 +22152,17 @@ var ts; function mergeSymbol(target, source) { if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864) { - var targetValueDeclaration = target.valueDeclaration; - ts.Debug.assert(!!(target.flags & 33554432)); + ts.Debug.assert(source !== target); + if (!(target.flags & 33554432)) { + target = cloneSymbol(target); + } if (source.flags & 512 && target.flags & 512 && target.constEnumOnlyModule && !source.constEnumOnlyModule) { target.constEnumOnlyModule = false; } target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 238 && source.valueDeclaration.kind !== 238))) { + (target.valueDeclaration.kind === 239 && source.valueDeclaration.kind !== 239))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -22044,18 +22176,6 @@ var ts; target.exports = ts.createSymbolTable(); mergeSymbolTable(target.exports, source.exports); } - if ((source.flags | target.flags) & 67108864) { - var sourceInitializer = ts.getJSInitializerSymbol(source); - var init = ts.getDeclaredJavascriptInitializer(targetValueDeclaration) || ts.getAssignedJavascriptInitializer(targetValueDeclaration); - var targetInitializer = init && init.symbol ? init.symbol : target; - if (!(targetInitializer.flags & 33554432)) { - var mergedInitializer = getMergedSymbol(targetInitializer); - targetInitializer = mergedInitializer === targetInitializer ? cloneSymbol(targetInitializer) : mergedInitializer; - } - if (sourceInitializer !== source || targetInitializer !== target) { - mergeSymbol(targetInitializer, sourceInitializer); - } - } recordMergedSymbol(target, source); } else if (target.flags & 1024) { @@ -22076,11 +22196,12 @@ var ts; error(errorNode, message_2, symbolToString(source)); }); } + return target; } function combineSymbolTables(first, second) { - if (!first || first.size === 0) + if (!ts.hasEntries(first)) return second; - if (!second || second.size === 0) + if (!ts.hasEntries(second)) return first; var combined = ts.createSymbolTable(); mergeSymbolTable(combined, first); @@ -22089,17 +22210,7 @@ var ts; } function mergeSymbolTable(target, source) { source.forEach(function (sourceSymbol, id) { - var targetSymbol = target.get(id); - if (!targetSymbol) { - target.set(id, sourceSymbol); - } - else { - if (!(targetSymbol.flags & 33554432)) { - targetSymbol = cloneSymbol(targetSymbol); - target.set(id, targetSymbol); - } - mergeSymbol(targetSymbol, sourceSymbol); - } + target.set(id, target.has(id) ? mergeSymbol(target.get(id), sourceSymbol) : sourceSymbol); }); } function mergeModuleAugmentation(moduleName) { @@ -22121,8 +22232,7 @@ var ts; } mainModule = resolveExternalModuleSymbol(mainModule); if (mainModule.flags & 1920) { - mainModule = mainModule.flags & 33554432 ? mainModule : cloneSymbol(mainModule); - mergeSymbol(mainModule, moduleAugmentation.symbol); + mainModule = mergeSymbol(mainModule, moduleAugmentation.symbol); } else { error(moduleName, ts.Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text); @@ -22154,7 +22264,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 273 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 274 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -22181,7 +22291,7 @@ var ts; if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } - ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration"); + return ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration"); } function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { var declarationFile = ts.getSourceFileOfNode(declaration); @@ -22200,15 +22310,15 @@ var ts; return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } if (declaration.pos <= usage.pos) { - if (declaration.kind === 181) { - var errorBindingElement = ts.getAncestor(usage, 181); + if (declaration.kind === 182) { + var errorBindingElement = ts.getAncestor(usage, 182); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 231), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 232), usage); } - else if (declaration.kind === 231) { + else if (declaration.kind === 232) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } else if (ts.isClassDeclaration(declaration)) { @@ -22216,10 +22326,10 @@ var ts; } return true; } - if (usage.parent.kind === 251 || (usage.parent.kind === 248 && usage.parent.isExportEquals)) { + if (usage.parent.kind === 252 || (usage.parent.kind === 249 && usage.parent.isExportEquals)) { return true; } - if (usage.kind === 248 && usage.isExportEquals) { + if (usage.kind === 249 && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -22227,15 +22337,16 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 213: - case 219: - case 221: + case 214: + case 220: + case 222: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } - return ts.isForInOrOfStatement(declaration.parent.parent) && isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container); + var grandparent = declaration.parent.parent; + return ts.isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, container); } function isUsedInFunctionOrInstanceProperty(usage, declaration, container) { return !!ts.findAncestor(usage, function (current) { @@ -22246,21 +22357,22 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 151 && + current.parent.kind === 152 && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32)) { - if (declaration.kind === 153) { + if (declaration.kind === 154) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 151 && !ts.hasModifier(declaration, 32); + var isDeclarationInstanceProperty = declaration.kind === 152 && !ts.hasModifier(declaration, 32); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } } } + return false; }); } } @@ -22282,21 +22394,21 @@ var ts; if (result = lookup(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 67901928 && lastLocation.kind !== 285) { + if (meaning & result.flags & 67901928 && lastLocation.kind !== 286) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 148 || - lastLocation.kind === 147 + lastLocation.kind === 149 || + lastLocation.kind === 148 : false; } if (meaning & 67216319 && result.flags & 1) { useResult = - lastLocation.kind === 148 || + lastLocation.kind === 149 || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 170) { + else if (location.kind === 171) { useResult = lastLocation === location.trueType; } if (useResult) { @@ -22308,13 +22420,13 @@ var ts; } } switch (location.kind) { - case 273: + case 274: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 238: + case 239: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 273 || ts.isAmbientModule(location)) { + if (location.kind === 274 || ts.isAmbientModule(location)) { if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { @@ -22325,21 +22437,26 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 && - ts.getDeclarationOfKind(moduleExport, 251)) { + ts.getDeclarationOfKind(moduleExport, 252)) { break; } } if (name !== "default" && (result = lookup(moduleExports, name, meaning & 2623475))) { - break loop; + if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) { + result = undefined; + } + else { + break loop; + } } break; - case 237: + case 238: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 152: case 151: - case 150: if (ts.isClassLike(location.parent) && !ts.hasModifier(location, 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -22349,9 +22466,9 @@ var ts; } } break; - case 234: - case 204: case 235: + case 205: + case 236: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { result = undefined; @@ -22363,7 +22480,7 @@ var ts; } break loop; } - if (location.kind === 204 && meaning & 32) { + if (location.kind === 205 && meaning & 32) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -22371,7 +22488,7 @@ var ts; } } break; - case 206: + case 207: if (lastLocation === location.expression && location.parent.token === 85) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67901928))) { @@ -22382,28 +22499,28 @@ var ts; } } break; - case 146: + case 147: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 235) { + if (ts.isClassLike(grandparent) || grandparent.kind === 236) { if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67901928)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 153: - case 152: case 154: + case 153: case 155: case 156: - case 233: - case 192: + case 157: + case 234: + case 193: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 191: + case 192: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -22416,19 +22533,18 @@ var ts; } } break; - case 149: - if (location.parent && location.parent.kind === 148) { + case 150: + if (location.parent && location.parent.kind === 149) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { location = location.parent; } break; - case 296: - case 291: - lastLocation = location; - location = ts.getJSDocHost(location).parent; - continue; + case 297: + case 292: + location = ts.getJSDocHost(location); + break; } if (isSelfReferenceLocation(location)) { lastSelfReferenceLocation = location; @@ -22441,7 +22557,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 273); + ts.Debug.assert(lastLocation.kind === 274); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -22500,7 +22616,7 @@ var ts; } if (result && isInExternalModule && (meaning & 67216319) === 67216319 && !(originalLocation.flags & 2097152)) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 241) { + if (decls && decls.length === 1 && decls[0].kind === 242) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } @@ -22509,12 +22625,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 233: case 234: case 235: - case 237: case 236: case 238: + case 237: + case 239: return true; default: return false; @@ -22526,7 +22642,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 147) { + if (decl.kind === 148) { 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)); @@ -22566,18 +22682,18 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - var isError = !!(expression && resolveEntityName(expression, 64, true)); - if (isError) { + if (expression && resolveEntityName(expression, 64, true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); + return true; } - return isError; + return false; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71: - case 184: + case 185: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 206: + case 207: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -22639,8 +22755,9 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384)); - var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 237) ? d : undefined; }); - ts.Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined"); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 238) ? d : undefined; }); + if (declaration === undefined) + return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { if (result.flags & 2) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); @@ -22654,17 +22771,17 @@ var ts; } } function isSameScopeDescendentOf(initial, parent, stopAt) { - return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); + return !!parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); } function getAnyImportSyntax(node) { switch (node.kind) { - case 242: + case 243: return node; - case 244: - return node.parent; case 245: + return node.parent; + case 246: return node.parent.parent; - case 247: + case 248: return node.parent.parent.parent; default: return undefined; @@ -22674,7 +22791,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 253) { + if (node.moduleReference.kind === 254) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -22686,7 +22803,7 @@ var ts; : resolveSymbol(moduleSymbol.exports.get(name), dontResolveAlias); } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasModifier(node, 512)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasModifier(node, 512) || ts.isExportSpecifier(node)); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias) { if (!allowSyntheticDefaultImports) { @@ -22764,6 +22881,7 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { + if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); if (targetSymbol) { @@ -22826,33 +22944,35 @@ var ts; return getNodeLinks(expression).resolvedSymbol; } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { + if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 242: + case 243: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 244: - return getTargetOfImportClause(node, dontRecursivelyResolve); case 245: + return getTargetOfImportClause(node, dontRecursivelyResolve); + case 246: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 247: - return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 251: - return getTargetOfExportSpecifier(node, 67216319 | 67901928 | 1920, dontRecursivelyResolve); case 248: - case 199: + return getTargetOfImportSpecifier(node, dontRecursivelyResolve); + case 252: + return getTargetOfExportSpecifier(node, 67216319 | 67901928 | 1920, dontRecursivelyResolve); + case 249: + case 200: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 241: + case 242: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + default: + return ts.Debug.fail(); } } function isNonLocalAlias(symbol, excludes) { if (excludes === void 0) { excludes = 67216319 | 67901928 | 1920; } if (!symbol) return false; - return (symbol.flags & (2097152 | excludes)) === 2097152 || (symbol.flags & 2097152 && symbol.flags & 67108864); + return (symbol.flags & (2097152 | excludes)) === 2097152 || !!(symbol.flags & 2097152 && symbol.flags & 67108864); } function resolveSymbol(symbol, dontResolveAlias) { - var shouldResolve = !dontResolveAlias && isNonLocalAlias(symbol); - return shouldResolve ? resolveAlias(symbol) : symbol; + return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here."); @@ -22860,7 +22980,8 @@ var ts; if (!links.target) { links.target = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); + if (!node) + return ts.Debug.fail(); var target = getTargetOfAliasDeclaration(node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; @@ -22890,11 +23011,12 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); - if (node.kind === 248) { + if (!node) + return ts.Debug.fail(); + if (node.kind === 249) { checkExpressionCached(node.expression); } - else if (node.kind === 251) { + else if (node.kind === 252) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -22906,11 +23028,11 @@ var ts; if (entityName.kind === 71 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 71 || entityName.parent.kind === 145) { + if (entityName.kind === 71 || entityName.parent.kind === 146) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 242); + ts.Debug.assert(entityName.parent.kind === 243); return resolveEntityName(entityName, 67216319 | 67901928 | 1920, false, dontResolveAlias); } } @@ -22931,9 +23053,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 145 || name.kind === 184) { - var left = name.kind === 145 ? name.left : name.expression; - var right = name.kind === 145 ? name.right : name.name; + else if (name.kind === 146 || name.kind === 185) { + var left = name.kind === 146 ? name.left : name.expression; + var right = name.kind === 146 ? name.right : name.name; var namespace_1 = resolveEntityName(left, namespaceMeaning, ignoreErrors, false, location); if (!namespace_1 || ts.nodeIsMissing(right)) { return undefined; @@ -22942,13 +23064,6 @@ var ts; return namespace_1; } if (ts.isInJavaScriptFile(name)) { - var initializer = ts.getDeclaredJavascriptInitializer(namespace_1.valueDeclaration) || ts.getAssignedJavascriptInitializer(namespace_1.valueDeclaration); - if (initializer) { - namespace_1 = getSymbolOfNode(initializer); - } - if (!namespace_1) { - return undefined; - } if (namespace_1.valueDeclaration && ts.isVariableDeclaration(namespace_1.valueDeclaration) && namespace_1.valueDeclaration.initializer && @@ -22972,7 +23087,7 @@ var ts; } } else { - ts.Debug.assertNever(name, "Unknown entity name kind."); + throw ts.Debug.assertNever(name, "Unknown entity name kind."); } ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -23110,14 +23225,7 @@ var ts; moduleSymbol.exports.forEach(function (s, name) { if (name === "export=") return; - if (!merged.exports.has(name)) { - merged.exports.set(name, s); - } - else { - var ms = cloneSymbol(merged.exports.get(name)); - mergeSymbol(ms, s); - merged.exports.set(name, ms); - } + merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); return merged; } @@ -23191,7 +23299,7 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 16382 ? undefined : getPropertyOfType(type, memberName); + return type.flags & 32764 ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { return symbol.flags & 32 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") : @@ -23272,6 +23380,38 @@ var ts; function getParentOfSymbol(symbol) { return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent)); } + function getContainerOfSymbol(symbol) { + var container = getParentOfSymbol(symbol); + if (container) { + return container; + } + var candidate = ts.forEach(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + if (!candidate) { + return undefined; + } + var alias = getAliasForSymbolInContainer(candidate, symbol); + return alias ? candidate : undefined; + } + function getAliasForSymbolInContainer(container, symbol) { + if (container === getParentOfSymbol(symbol)) { + return symbol; + } + var exports = getExportsOfSymbol(container); + var quick = exports.get(symbol.escapedName); + if (quick && symbolRefersToTarget(quick)) { + return quick; + } + return ts.forEachEntry(exports, function (exported) { + if (symbolRefersToTarget(exported)) { + return exported; + } + }); + function symbolRefersToTarget(s) { + if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { + return s; + } + } + } function getExportSymbolOfValueSymbolIfExported(symbol) { return symbol && (symbol.flags & 1048576) !== 0 ? getMergedSymbol(symbol.exportSymbol) @@ -23284,7 +23424,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 154 && ts.nodeIsPresent(member.body)) { + if (member.kind === 155 && ts.nodeIsPresent(member.body)) { return member; } } @@ -23302,12 +23442,12 @@ var ts; } function createBooleanType(trueFalseTypes) { var type = getUnionType(trueFalseTypes); - type.flags |= 8; + type.flags |= 16; type.intrinsicName = "boolean"; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(65536); + var type = createType(131072); type.objectFlags = objectFlags; type.symbol = symbol; return type; @@ -23357,11 +23497,11 @@ var ts; } } switch (location.kind) { - case 273: + case 274: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 238: + case 239: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -23398,7 +23538,7 @@ var ts; } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && - !ts.some(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); } function trySymbolTable(symbols, ignoreQualification) { @@ -23421,20 +23561,25 @@ var ts; return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); } } + if (symbolFromSymbolTable.escapedName === symbol.escapedName && symbolFromSymbolTable.exportSymbol) { + if (isAccessible(getMergedSymbol(symbolFromSymbolTable.exportSymbol), undefined, ignoreQualification)) { + return [symbol]; + } + } }); } } function needsQualification(symbol, enclosingDeclaration, meaning) { var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { - var symbolFromSymbolTable = symbolTable.get(symbol.escapedName); + var symbolFromSymbolTable = getMergedSymbol(symbolTable.get(symbol.escapedName)); if (!symbolFromSymbolTable) { return false; } if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 251)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 252)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -23448,10 +23593,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 151: - case 153: - case 155: + case 152: + case 154: case 156: + case 157: continue; default: return false; @@ -23487,14 +23632,14 @@ var ts; return hasAccessibleDeclarations; } else { - if (ts.some(symbol.declarations, hasExternalModuleSymbol)) { + if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return { accessibility: 0 }; } } meaningToLook = getQualifiedLeftMeaning(meaning); - symbol = getParentOfSymbol(symbol); + symbol = getContainerOfSymbol(symbol); } var symbolExternalModule = ts.forEach(initialSymbol.declarations, getExternalModuleContainer); if (symbolExternalModule) { @@ -23519,7 +23664,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 273 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 274 && ts.isExternalOrCommonJsModule(declaration)); + } + function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -23559,13 +23707,13 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 164 || + if (entityName.parent.kind === 165 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 146) { + entityName.parent.kind === 147) { meaning = 67216319 | 1048576; } - else if (entityName.kind === 145 || entityName.kind === 184 || - entityName.parent.kind === 242) { + else if (entityName.kind === 146 || entityName.kind === 185 || + entityName.parent.kind === 243) { meaning = 1920; } else { @@ -23602,14 +23750,15 @@ var ts; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { + if (flags === void 0) { flags = 0; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144) { - sigOutput = kind === 1 ? 163 : 162; + sigOutput = kind === 1 ? 164 : 163; } else { - sigOutput = kind === 1 ? 158 : 157; + sigOutput = kind === 1 ? 159 : 158; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 | 512); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); @@ -23619,10 +23768,11 @@ var ts; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576; } + if (flags === void 0) { flags = 1048576 | 16384; } if (writer === void 0) { writer = ts.createTextWriter(""); } var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960, writer); - ts.Debug.assert(typeNode !== undefined, "should always get typenode"); + if (typeNode === undefined) + return ts.Debug.fail("should always get typenode"); var options = { removeComments: true }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); @@ -23635,6 +23785,7 @@ var ts; return result; } function toNodeBuilderFlags(flags) { + if (flags === void 0) { flags = 0; } return flags & 9469291; } function createNodeBuilder() { @@ -23699,7 +23850,7 @@ var ts; function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { return { enclosingDeclaration: enclosingDeclaration, - flags: flags, + flags: flags || 0, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, encounteredError: false, visitedSymbols: undefined, @@ -23720,34 +23871,37 @@ var ts; return ts.createKeywordTypeNode(119); } if (type.flags & 2) { - return ts.createKeywordTypeNode(137); + return ts.createKeywordTypeNode(142); } if (type.flags & 4) { - return ts.createKeywordTypeNode(134); + return ts.createKeywordTypeNode(137); } if (type.flags & 8) { + return ts.createKeywordTypeNode(134); + } + if (type.flags & 16) { return ts.createKeywordTypeNode(122); } - if (type.flags & 256 && !(type.flags & 131072)) { + if (type.flags & 512 && !(type.flags & 262144)) { var parentSymbol = getParentOfSymbol(type.symbol); var parentName = symbolToName(parentSymbol, context, 67901928, false); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : ts.createQualifiedName(parentName, ts.symbolName(type.symbol)); return ts.createTypeReferenceNode(enumLiteralName, undefined); } - if (type.flags & 272) { + if (type.flags & 544) { var name = symbolToName(type.symbol, context, 67901928, false); return ts.createTypeReferenceNode(name, undefined); } - if (type.flags & (32)) { + if (type.flags & (64)) { return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value), 16777216)); } - if (type.flags & (64)) { + if (type.flags & (128)) { return ts.createLiteralTypeNode((ts.createLiteral(type.value))); } - if (type.flags & 128) { + if (type.flags & 256) { return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); } - if (type.flags & 1024) { + if (type.flags & 2048) { if (!(context.flags & 1048576)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return symbolToTypeNode(type.symbol, context, 67216319); @@ -23758,25 +23912,25 @@ var ts; } return ts.createTypeOperatorNode(141, ts.createKeywordTypeNode(138)); } - if (type.flags & 2048) { + if (type.flags & 4096) { return ts.createKeywordTypeNode(105); } - if (type.flags & 4096) { + if (type.flags & 8192) { return ts.createKeywordTypeNode(140); } - if (type.flags & 8192) { + if (type.flags & 16384) { return ts.createKeywordTypeNode(95); } - if (type.flags & 16384) { + if (type.flags & 32768) { return ts.createKeywordTypeNode(131); } - if (type.flags & 512) { + if (type.flags & 1024) { return ts.createKeywordTypeNode(138); } - if (type.flags & 134217728) { + if (type.flags & 16777216) { return ts.createKeywordTypeNode(135); } - if (type.flags & 32768 && type.isThisType) { + if (type.flags & 65536 && type.isThisType) { if (context.flags & 4194304) { if (!context.encounteredError && !(context.flags & 32768)) { context.encounteredError = true; @@ -23789,23 +23943,24 @@ var ts; } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4) { - ts.Debug.assert(!!(type.flags & 65536)); + ts.Debug.assert(!!(type.flags & 131072)); return typeReferenceToTypeNode(type); } - if (type.flags & 32768 || objectFlags & 3) { - if (type.flags & 32768 && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 65536 || objectFlags & 3) { + if (type.flags & 65536 && ts.contains(context.inferTypeParameters, type)) { return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, undefined)); } if (context.flags & 4 && - type.flags & 32768 && + type.flags & 65536 && ts.length(type.symbol.declarations) && ts.isTypeParameterDeclaration(type.symbol.declarations[0]) && typeParameterShadowsNameInScope(type, context) && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return ts.createTypeReferenceNode(ts.getGeneratedNameForNode(type.symbol.declarations[0].name, 16 | 8), undefined); } - var name = type.symbol ? symbolToName(type.symbol, context, 67901928, false) : ts.createIdentifier("?"); - return ts.createTypeReferenceNode(name, undefined); + return type.symbol + ? symbolToTypeNode(type.symbol, context, 67901928) + : ts.createTypeReferenceNode(ts.createIdentifier("?"), undefined); } if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); @@ -23813,11 +23968,11 @@ var ts; return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); return symbolToTypeNode(type.aliasSymbol, context, 67901928, typeArgumentNodes); } - if (type.flags & (131072 | 262144)) { - var types = type.flags & 131072 ? formatUnionTypes(type.types) : type.types; + if (type.flags & (262144 | 524288)) { + var types = type.flags & 262144 ? formatUnionTypes(type.types) : type.types; var typeNodes = mapToTypeNodes(types, context); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 131072 ? 168 : 169, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 ? 169 : 170, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -23828,20 +23983,20 @@ var ts; } } if (objectFlags & (16 | 32)) { - ts.Debug.assert(!!(type.flags & 65536)); + ts.Debug.assert(!!(type.flags & 131072)); return createAnonymousTypeNode(type); } - if (type.flags & 524288) { + if (type.flags & 1048576) { var indexedType = type.type; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); return ts.createTypeOperatorNode(indexTypeNode); } - if (type.flags & 1048576) { + if (type.flags & 2097152) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 2097152) { + if (type.flags & 4194304) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -23851,12 +24006,12 @@ var ts; var falseTypeNode = typeToTypeNodeHelper(getFalseTypeFromConditionalType(type), context); return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } - if (type.flags & 4194304) { + if (type.flags & 8388608) { return typeToTypeNodeHelper(type.typeVariable, context); } - ts.Debug.fail("Should be unreachable."); + return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 65536)); + ts.Debug.assert(!!(type.flags & 131072)); var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -23881,7 +24036,7 @@ var ts; var isInstanceType = type === getInferredClassType(symbol) ? 67901928 : 67216319; return symbolToTypeNode(symbol, context, isInstanceType); } - else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 204 && context.flags & 2048) || + else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 205 && context.flags & 2048) || symbol.flags & (384 | 512) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319); @@ -23914,7 +24069,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 273 || declaration.parent.kind === 239; + return declaration.parent.kind === 274 || declaration.parent.kind === 240; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return (!!(context.flags & 4096) || (context.visitedSymbols && context.visitedSymbols.has(id))) && @@ -23933,12 +24088,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 162, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 163, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 163, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 164, context); return signatureNode; } } @@ -24052,11 +24207,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 157, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 158, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 158, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 159, context)); } if (resolvedType.stringIndexInfo) { var indexInfo = resolvedType.objectFlags & 2048 ? @@ -24086,7 +24241,7 @@ var ts; var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; if (ts.getCheckFlags(propertySymbol) & 1024) { - var decl = ts.firstOrUndefined(propertySymbol.declarations); + var decl = ts.first(propertySymbol.declarations); var name = hasLateBindableName(decl) && resolveEntityName(decl.name.expression, 67216319); if (name && context.tracker.trackSymbol) { context.tracker.trackSymbol(name, saveEnclosingDeclaration, 67216319); @@ -24099,7 +24254,7 @@ var ts; var signatures = getSignaturesOfType(propertyType, 0); for (var _e = 0, signatures_1 = signatures; _e < signatures_1.length; _e++) { var signature = signatures_1[_e]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 152, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 153, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -24141,7 +24296,7 @@ var ts; var name = ts.getNameFromIndexInfo(indexInfo) || "x"; var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 137 : 134); var indexingParameter = ts.createParameter(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined); - var typeNode = indexInfo.type ? typeToTypeNodeHelper(indexInfo.type, context) : typeToTypeNodeHelper(anyType, context); + var typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); if (!indexInfo.type && !(context.flags & 2097152)) { context.encounteredError = true; } @@ -24156,7 +24311,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 154); }); + var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -24208,22 +24363,22 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 148); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 292); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); - var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(ts.getSynthesizedClone); + var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration ? ts.isRestParameter(parameterDeclaration) : parameterSymbol.isRestParameter; var dotDotDotToken = isRest ? ts.createToken(24) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? parameterDeclaration.name.kind === 71 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) : - parameterDeclaration.name.kind === 145 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) : + parameterDeclaration.name.kind === 146 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -24235,7 +24390,7 @@ var ts; function elideInitializerAndSetEmitFlags(node) { var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 181) { + if (clone.kind === 182) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 | 16777216); @@ -24247,7 +24402,7 @@ var ts; var chain; var isTypeParameter = symbol.flags & 262144; if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64)) { - chain = getSymbolChain(symbol, meaning, true); + chain = ts.Debug.assertDefined(getSymbolChain(symbol, meaning, true)); ts.Debug.assert(chain && chain.length > 0); } else { @@ -24259,12 +24414,12 @@ var ts; var parentSymbol; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + var parent = getContainerOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); if (parent) { var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false); if (parentChain) { parentSymbol = parent; - accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); } } } @@ -24272,7 +24427,7 @@ var ts; return accessibleSymbolChain; } if (endOfChain || - (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol))) && + (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol))) && !(symbol.flags & (2048 | 4096))) { return [symbol]; } @@ -24443,6 +24598,7 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { + if (flags === void 0) { flags = 16384; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 | 512)); @@ -24458,10 +24614,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 12288)) { - if (t.flags & (128 | 256)) { - var baseType = t.flags & 128 ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 131072) { + if (!(t.flags & 24576)) { + if (t.flags & (256 | 512)) { + var baseType = t.flags & 256 ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 262144) { var count = baseType.types.length; if (i + count <= types.length && types[i + count - 1] === baseType.types[count - 1]) { result.push(baseType); @@ -24473,9 +24629,9 @@ var ts; result.push(t); } } - if (flags & 8192) + if (flags & 16384) result.push(nullType); - if (flags & 4096) + if (flags & 8192) result.push(undefinedType); return result || types; } @@ -24490,8 +24646,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 172; }); - if (node.kind === 236) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 173; }); + if (node.kind === 237) { return getSymbolOfNode(node); } } @@ -24499,11 +24655,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 239 && + node.parent.kind === 240 && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 273 || ts.isAmbientModule(location); + return location.kind === 274 || ts.isAmbientModule(location); } function getNameOfSymbolAsWritten(symbol, context) { if (context && symbol.escapedName === "default" && !(context.flags & 16384) && @@ -24514,7 +24670,7 @@ var ts; } if (symbol.declarations && symbol.declarations.length) { if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { - var file_3 = ts.getDeclarationOfKind(symbol, 273); + var file_3 = ts.getDeclarationOfKind(symbol, 274); if (!file_3 || !context.tracker.moduleResolverHost) { if (context.tracker.trackReferencedAmbientModule) { var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); @@ -24535,26 +24691,26 @@ var ts; if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 231) { + if (declaration.parent && declaration.parent.kind === 232) { return ts.declarationNameToString(declaration.parent.name); } if (context && !context.encounteredError && !(context.flags & 131072)) { context.encounteredError = true; } switch (declaration.kind) { - case 204: + case 205: return "(Anonymous class)"; - case 191: case 192: + case 193: return "(Anonymous function)"; } } var nameType = symbol.nameType; if (nameType) { - if (nameType.flags & 32 && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { + if (nameType.flags & 64 && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { return "\"" + ts.escapeString(nameType.value, 34) + "\""; } - if (nameType && nameType.flags & 1024) { + if (nameType && nameType.flags & 2048) { return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; } } @@ -24571,67 +24727,67 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 291: - case 296: + case 292: + case 297: return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 181: + case 182: return isDeclarationVisible(node.parent.parent); - case 231: + case 232: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 238: - case 234: + case 239: case 235: case 236: - case 233: case 237: - case 242: + case 234: + case 238: + case 243: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 242 && parent.kind !== 273 && parent.flags & 4194304)) { + !(node.kind !== 243 && parent.kind !== 274 && parent.flags & 4194304)) { return isGlobalSourceFile(parent); } return isDeclarationVisible(parent); - case 151: - case 150: - case 155: - case 156: - case 153: case 152: + case 151: + case 156: + case 157: + case 154: + case 153: if (ts.hasModifier(node, 8 | 16)) { return false; } - case 154: - case 158: - case 157: + case 155: case 159: - case 148: - case 239: - case 162: + case 158: + case 160: + case 149: + case 240: case 163: - case 165: - case 161: + case 164: case 166: + case 162: case 167: case 168: case 169: - case 172: + case 170: + case 173: return isDeclarationVisible(node.parent); - case 244: case 245: - case 247: - return false; - case 147: - case 273: - case 241: - return true; + case 246: case 248: return false; + case 148: + case 274: + case 242: + return true; + case 249: + return false; default: return false; } @@ -24639,10 +24795,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 248) { + if (node.parent && node.parent.kind === 249) { exportSymbol = resolveName(node, node.escapedText, 67216319 | 67901928 | 1920 | 2097152, undefined, node, false); } - else if (node.parent.kind === 251) { + else if (node.parent.kind === 252) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 | 67901928 | 1920 | 2097152); } var result; @@ -24698,22 +24854,22 @@ var ts; } function hasType(target, propertyName) { if (propertyName === 0) { - return getSymbolLinks(target).type; + return !!getSymbolLinks(target).type; } if (propertyName === 2) { - return getSymbolLinks(target).declaredType; + return !!getSymbolLinks(target).declaredType; } if (propertyName === 1) { - return target.resolvedBaseConstructorType; + return !!target.resolvedBaseConstructorType; } if (propertyName === 3) { - return target.resolvedReturnType; + return !!target.resolvedReturnType; } if (propertyName === 4) { var bc = target.resolvedBaseConstraint; - return bc && bc !== circularConstraintType; + return !!bc && bc !== circularConstraintType; } - ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + return ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); } function popTypeResolution() { resolutionTargets.pop(); @@ -24721,20 +24877,19 @@ var ts; return resolutionResults.pop(); } function getDeclarationContainer(node) { - node = ts.findAncestor(ts.getRootDeclaration(node), function (node) { + return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 231: case 232: + case 233: + case 248: case 247: case 246: case 245: - case 244: return false; default: return true; } - }); - return node && node.parent; + }).parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype)); @@ -24752,14 +24907,14 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 146 && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 147 && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 12288); }); - if (source.flags & 16384) { + source = filterType(source, function (t) { return !(t.flags & 24576); }); + if (source.flags & 32768) { return emptyObjectType; } - if (source.flags & 131072) { + if (source.flags & 262144) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var members = ts.createSymbolTable(); @@ -24784,8 +24939,8 @@ var ts; function getTypeForBindingElement(declaration) { var pattern = declaration.parent; var parentType = getTypeForBindingElementParent(pattern.parent); - if (parentType === unknownType) { - return unknownType; + if (parentType === errorType) { + return errorType; } if (!parentType) { return declaration.initializer ? checkDeclarationInitializer(declaration) : parentType; @@ -24794,11 +24949,11 @@ var ts; return parentType; } var type; - if (pattern.kind === 179) { + if (pattern.kind === 180) { if (declaration.dotDotDotToken) { - if (!isValidSpreadType(parentType)) { + if (parentType.flags & 2 || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); - return unknownType; + return errorType; } var literalMembers = []; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { @@ -24815,13 +24970,13 @@ var ts; var isWellKnown = ts.isComputedPropertyName(name) && ts.isWellKnownSymbolSyntactically(name.expression); if (!isLate && !isWellKnown && isComputedNonLiteralName(name)) { var exprType = checkExpression(name.expression); - if (isTypeAssignableToKind(exprType, 1536)) { + if (isTypeAssignableToKind(exprType, 3072)) { if (noImplicitAny) { error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(exprType), typeToString(parentType)); } return anyType; } - var indexerType = isTypeAssignableToKind(exprType, 84) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); + var indexerType = isTypeAssignableToKind(exprType, 168) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!indexerType && noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { if (getIndexTypeOfType(parentType, 1)) { error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); @@ -24832,14 +24987,14 @@ var ts; } return indexerType || anyType; } - var nameType = isLate && checkComputedPropertyName(name); + var nameType = isLate ? checkComputedPropertyName(name) : undefined; var text = isLate ? getLateBoundNameFromType(nameType) : isWellKnown ? ts.getPropertyNameForKnownSymbolName(ts.idText(name.expression.name)) : ts.getTextOfPropertyName(name); if (strictNullChecks && declaration.flags & 4194304 && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } - if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 1536)) { + if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 3072)) { if (noImplicitAny) { error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(nameType), typeToString(parentType)); } @@ -24851,7 +25006,7 @@ var ts; getIndexTypeOfType(parentType, 0); if (!type) { error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); - return unknownType; + return errorType; } } } @@ -24872,11 +25027,11 @@ var ts; else { error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); } - return unknownType; + return errorType; } } } - if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 4096)) { + if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192)) { type = getTypeWithFacts(type, 131072); } return declaration.initializer ? @@ -24896,18 +25051,18 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 182 && expr.elements.length === 0; + return expr.kind === 183 && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 220) { - var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); - return indexType.flags & (32768 | 524288) ? getExtractStringType(indexType) : stringType; - } if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 221) { + var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); + return indexType.flags & (65536 | 1048576) ? getExtractStringType(indexType) : stringType; + } + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 222) { var forOfStatement = declaration.parent.parent; return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; } @@ -24921,7 +25076,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 231 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 232 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 4194304)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -24930,10 +25085,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 148) { + if (declaration.kind === 149) { var func = declaration.parent; - if (func.kind === 156 && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 155); + if (func.kind === 157 && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 156); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -24979,18 +25134,18 @@ var ts; var jsDocType; var _loop_3 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 199 ? declaration : - declaration.kind === 184 ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = declaration.kind === 200 ? declaration : + declaration.kind === 185 ? ts.cast(declaration.parent, ts.isBinaryExpression) : undefined; if (!expression) { - return { value: unknownType }; + return { value: errorType }; } var special = ts.getSpecialPropertyAssignmentKind(expression); if (special === 4) { var thisContainer = ts.getThisContainer(expression, false); - declarationInConstructor = thisContainer.kind === 154 || - thisContainer.kind === 233 || - (thisContainer.kind === 191 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + declarationInConstructor = thisContainer.kind === 155 || + thisContainer.kind === 234 || + (thisContainer.kind === 192 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -25004,7 +25159,7 @@ var ts; if (!jsDocType) { jsDocType = declarationType; } - else if (jsDocType !== unknownType && declarationType !== unknownType && + else if (jsDocType !== errorType && declarationType !== errorType && !isTypeIdenticalTo(jsDocType, declarationType) && !(symbol.flags & 67108864)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); @@ -25059,11 +25214,11 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(12288 | 16777216)); }) ? constructorTypes : types; + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(24576 | 134217728)); }) ? constructorTypes : types; type = getUnionType(sourceTypes, 2); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~12288); }) === neverType) { + if (filterType(widened, function (t) { return !!(t.flags & ~24576); }) === neverType) { if (noImplicitAny) { reportImplicitAnyError(symbol.valueDeclaration, anyType); } @@ -25118,7 +25273,7 @@ var ts; members.set(symbol.escapedName, symbol); }); var result = createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); - result.flags |= 33554432; + result.flags |= 268435456; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; @@ -25128,7 +25283,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (elements.length === 0 || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); @@ -25140,7 +25295,9 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 179 + if (includePatternInType === void 0) { includePatternInType = false; } + if (reportErrors === void 0) { reportErrors = false; } + return pattern.kind === 180 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -25150,7 +25307,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (type.flags & 1024 && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 2048 && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -25165,7 +25322,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 148 ? root.parent : root; + var memberDeclaration = root.kind === 149 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -25191,23 +25348,25 @@ var ts; var jsonSourceFile = ts.cast(declaration, ts.isJsonSourceFile); return links.type = jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType; } - if (declaration.kind === 248) { + if (declaration.kind === 249) { return links.type = checkExpression(declaration.expression); } if (ts.isInJavaScriptFile(declaration) && ts.isJSDocPropertyLikeTag(declaration) && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { - return unknownType; + return errorType; } var type = void 0; - if (declaration.kind === 199 || - declaration.kind === 184 && declaration.parent.kind === 199) { + if (declaration.kind === 200 || + declaration.kind === 185 && declaration.parent.kind === 200) { type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isClassDeclaration(declaration) + || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) || ts.isMethodSignature(declaration)) { if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) { @@ -25235,7 +25394,7 @@ var ts; type = getWidenedTypeForVariableLikeDeclaration(declaration, true); } else { - ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration)); + return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol)); } if (!popTypeResolution()) { type = reportCircularityError(symbol); @@ -25246,7 +25405,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 155) { + if (accessor.kind === 156) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation && getTypeFromTypeNode(getterTypeAnnotation); } @@ -25267,8 +25426,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 155); - var setter = ts.getDeclarationOfKind(symbol, 156); + var getter = ts.getDeclarationOfKind(symbol, 156); + var setter = ts.getDeclarationOfKind(symbol, 157); if (getter && ts.isInJavaScriptFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -25276,7 +25435,7 @@ var ts; } } if (!pushTypeResolution(symbol, 0)) { - return unknownType; + return errorType; } var type = void 0; var getterReturnType = getAnnotatedAccessorType(getter); @@ -25309,7 +25468,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 155); + var getter_1 = ts.getDeclarationOfKind(symbol, 156); error(getter_1, 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)); } } @@ -25319,16 +25478,32 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 1081344 ? baseConstructorType : undefined; + return baseConstructorType.flags & 2162688 ? baseConstructorType : undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { + var jsDeclaration = ts.getDeclarationOfJSInitializer(symbol.valueDeclaration); + if (jsDeclaration) { + var jsSymbol = getSymbolOfNode(jsDeclaration); + if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { + symbol = cloneSymbol(symbol); + links = symbol; + if (ts.hasEntries(jsSymbol.exports)) { + symbol.exports = symbol.exports || ts.createSymbolTable(); + mergeSymbolTable(symbol.exports, jsSymbol.exports); + } + if (ts.hasEntries(jsSymbol.members)) { + symbol.members = symbol.members || ts.createSymbolTable(); + mergeSymbolTable(symbol.members, jsSymbol.members); + } + } + } if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 199 || - symbol.valueDeclaration.kind === 184 && symbol.valueDeclaration.parent.kind === 199) { + else if (symbol.valueDeclaration.kind === 200 || + symbol.valueDeclaration.kind === 185 && symbol.valueDeclaration.parent.kind === 200) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -25357,7 +25532,7 @@ var ts; var targetSymbol = resolveAlias(symbol); links.type = targetSymbol.flags & 67216319 ? getTypeOfSymbol(targetSymbol) - : unknownType; + : errorType; } return links.type; } @@ -25366,11 +25541,11 @@ var ts; if (!links.type) { if (symbolInstantiationDepth === 100) { error(symbol.valueDeclaration, ts.Diagnostics.Generic_type_instantiation_is_excessively_deep_and_possibly_infinite); - links.type = unknownType; + links.type = errorType; } else { if (!pushTypeResolution(symbol, 0)) { - return unknownType; + return errorType; } symbolInstantiationDepth++; var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); @@ -25386,7 +25561,7 @@ var ts; function reportCircularityError(symbol) { if (ts.getEffectiveTypeAnnotationNode(symbol.valueDeclaration)) { error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); - return unknownType; + return errorType; } if (noImplicitAny) { 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)); @@ -25415,7 +25590,7 @@ var ts; if (symbol.flags & 2097152) { return getTypeOfAlias(symbol); } - return unknownType; + return errorType; } function isReferenceToType(type, target) { return type !== undefined @@ -25431,11 +25606,12 @@ var ts; function check(type) { if (ts.getObjectFlags(type) & (3 | 4)) { var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 262144) { - return ts.forEach(type.types, check); + else if (type.flags & 524288) { + return ts.some(type.types, check); } + return false; } } function appendTypeParameters(typeParameters, declarations) { @@ -25452,51 +25628,51 @@ var ts; return undefined; } switch (node.kind) { - case 234: - case 204: case 235: - case 157: - case 158: - case 152: - case 162: - case 163: - case 283: - case 233: - case 153: - case 191: - case 192: + case 205: case 236: - case 295: + case 158: + case 159: + case 153: + case 163: + case 164: + case 284: + case 234: + case 154: + case 192: + case 193: + case 237: case 296: - case 291: - case 176: - case 170: + case 297: + case 292: + case 177: + case 171: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 176) { + if (node.kind === 177) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 170) { + else if (node.kind === 171) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 234 || node.kind === 204 || node.kind === 235) && + (node.kind === 235 || node.kind === 205 || node.kind === 236) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 235); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 236); return getOuterTypeParameters(declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 235 || - node.kind === 234 || - node.kind === 204 || + if (node.kind === 236 || + node.kind === 235 || + node.kind === 205 || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -25519,9 +25695,9 @@ var ts; if (isValidBaseType(type) && getSignaturesOfType(type, 1).length > 0) { return true; } - if (type.flags & 1081344) { + if (type.flags & 2162688) { var constraint = getBaseConstraintOfType(type); - return constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } return false; } @@ -25554,23 +25730,23 @@ var ts; return type.resolvedBaseConstructorType = undefinedType; } if (!pushTypeResolution(type, 1)) { - return unknownType; + return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); if (extended && baseTypeNode !== extended) { ts.Debug.assert(!extended.typeArguments); checkExpression(extended.expression); } - if (baseConstructorType.flags & (65536 | 262144)) { + if (baseConstructorType.flags & (131072 | 524288)) { resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); - return type.resolvedBaseConstructorType = unknownType; + return type.resolvedBaseConstructorType = errorType; } if (!(baseConstructorType.flags & 1) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - return type.resolvedBaseConstructorType = unknownType; + return type.resolvedBaseConstructorType = errorType; } type.resolvedBaseConstructorType = baseConstructorType; } @@ -25598,7 +25774,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (65536 | 262144 | 1))) { + if (!(baseConstructorType.flags & (131072 | 524288 | 1))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -25620,7 +25796,7 @@ var ts; } baseType = getReturnTypeOfSignature(constructors[0]); } - if (baseType === unknownType) { + if (baseType === errorType) { return type.resolvedBaseTypes = ts.emptyArray; } if (!isValidBaseType(baseType)) { @@ -25646,18 +25822,18 @@ var ts; return true; } function isValidBaseType(type) { - return type.flags & (65536 | 134217728 | 1) && !isGenericMappedType(type) || - type.flags & 262144 && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + return !!(type.flags & (131072 | 16777216 | 1)) && !isGenericMappedType(type) || + !!(type.flags & 524288) && !ts.some(type.types, function (t) { return !isValidBaseType(t); }); } 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 === 235 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 236 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); - if (baseType !== unknownType) { + if (baseType !== errorType) { if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === ts.emptyArray) { @@ -25682,7 +25858,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 235) { + if (declaration.kind === 236) { if (declaration.flags & 64) { return false; } @@ -25718,7 +25894,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(32768); + type.thisType = createType(65536); type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; @@ -25730,13 +25906,13 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { if (!pushTypeResolution(symbol, 2)) { - return unknownType; + return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 236; + return ts.isJSDocTypeAlias(d) || d.kind === 237; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; - var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType; + var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { @@ -25746,7 +25922,7 @@ var ts; } } else { - type = unknownType; + type = errorType; error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; @@ -25757,7 +25933,7 @@ var ts; if (expr.kind === 9) { return true; } - else if (expr.kind === 199) { + else if (expr.kind === 200) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -25771,12 +25947,12 @@ var ts; case 9: case 8: return true; - case 197: + case 198: return expr.operator === 38 && expr.operand.kind === 8; case 71: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 199: + case 200: return isStringConcatExpression(expr); default: return false; @@ -25790,7 +25966,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 237) { + if (declaration.kind === 238) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9) { @@ -25805,7 +25981,7 @@ var ts; return links.enumKind = hasNonLiteralMember ? 0 : 1; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 256 && !(type.flags & 131072) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 512 && !(type.flags & 262144) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); @@ -25817,7 +25993,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 237) { + if (declaration.kind === 238) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); @@ -25828,14 +26004,14 @@ var ts; } if (memberTypeList.length) { var enumType_1 = getUnionType(memberTypeList, 1, symbol, undefined); - if (enumType_1.flags & 131072) { - enumType_1.flags |= 256; + if (enumType_1.flags & 262144) { + enumType_1.flags |= 512; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(16); + var enumType = createType(32); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -25852,7 +26028,7 @@ var ts; function getDeclaredTypeOfTypeParameter(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(32768); + var type = createType(65536); type.symbol = symbol; links.declaredType = type; } @@ -25866,7 +26042,7 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - return tryGetDeclaredTypeOfSymbol(symbol) || unknownType; + return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { if (symbol.flags & (32 | 64)) { @@ -25892,6 +26068,7 @@ var ts; function isThislessType(node) { switch (node.kind) { case 119: + case 142: case 137: case 134: case 122: @@ -25901,11 +26078,11 @@ var ts; case 140: case 95: case 131: - case 177: + case 178: return true; - case 166: + case 167: return isThislessType(node.elementType); - case 161: + case 162: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -25920,7 +26097,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 154 || (returnType && isThislessType(returnType))) && + return (node.kind === 155 || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -25929,12 +26106,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 151: - case 150: - return isThislessVariableLikeDeclaration(declaration); - case 153: case 152: + case 151: + return isThislessVariableLikeDeclaration(declaration); case 154: + case 153: + case 155: return isThislessFunctionLikeDeclaration(declaration); } } @@ -25972,7 +26149,7 @@ var ts; return type; } function isTypeUsableAsLateBoundName(type) { - return !!(type.flags & 1120); + return !!(type.flags & 2240); } function isLateBindableName(node) { return ts.isComputedPropertyName(node) @@ -25981,7 +26158,7 @@ var ts; } function hasLateBindableName(node) { var name = ts.getNameOfDeclaration(node); - return name && isLateBindableName(name); + return !!name && isLateBindableName(name); } function hasNonBindableDynamicName(node) { return ts.hasDynamicName(node) && !hasLateBindableName(node); @@ -25990,12 +26167,13 @@ var ts; return ts.isDynamicName(node) && !isLateBindableName(node); } function getLateBoundNameFromType(type) { - if (type.flags & 1024) { + if (type.flags & 2048) { return "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); } - if (type.flags & 96) { + if (type.flags & 192) { return ts.escapeLeadingUnderscores("" + type.value); } + return ts.Debug.fail(); } function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) { ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 1024), "Expected a late-bound symbol."); @@ -26008,8 +26186,7 @@ var ts; symbol.declarations.push(member); } if (symbolFlags & 67216319) { - var valueDeclaration = symbol.valueDeclaration; - if (!valueDeclaration || valueDeclaration.kind !== member.kind) { + if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } } @@ -26101,7 +26278,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 262144) { + else if (type.flags & 524288) { return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); })); } return needApparentType ? getApparentType(type) : type; @@ -26360,7 +26537,7 @@ var ts; if (symbol.flags & 32) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (65536 | 262144 | 1081344)) { + if (baseConstructorType.flags & (131072 | 524288 | 2162688)) { members = ts.createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -26412,7 +26589,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 32 : 1120; + var include = keyofStringsOnly ? 64 : 2240; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { var prop = _a[_i]; @@ -26426,15 +26603,15 @@ var ts; } } else { - var keyType = constraintType.flags & 7372800 ? getApparentType(constraintType) : constraintType; - var iterationType = keyType.flags & 524288 ? getIndexType(getApparentType(keyType.type)) : keyType; + var keyType = constraintType.flags & 14745600 ? getApparentType(constraintType) : constraintType; + var iterationType = keyType.flags & 1048576 ? getIndexType(getApparentType(keyType.type)) : keyType; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); function addMemberForKeyType(t, _index, origin) { var templateMapper = combineTypeMappers(type.mapper, createTypeMapper([typeParameter], [t])); var propType = instantiateType(templateType, templateMapper); - if (t.flags & 1120) { + if (t.flags & 2240) { var propName = getLateBoundNameFromType(t); var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = !!(templateModifiers & 4 || @@ -26452,10 +26629,10 @@ var ts; prop.nameType = t; members.set(propName, prop); } - else if (t.flags & (1 | 2)) { + else if (t.flags & (1 | 4)) { stringIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1)); } - else if (t.flags & 4) { + else if (t.flags & 8) { numberIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1)); } } @@ -26466,20 +26643,20 @@ var ts; } function getConstraintTypeFromMappedType(type) { return type.constraintType || - (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || unknownType); + (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || errorType); } function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4)), type.mapper || identityMapper) : - unknownType); + errorType); } function getConstraintDeclarationForMappedType(type) { return type.declaration.typeParameter.constraint; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); - return constraintDeclaration.kind === 174 && + return constraintDeclaration.kind === 175 && constraintDeclaration.operator === 128; } function getModifiersTypeFromMappedType(type) { @@ -26490,8 +26667,8 @@ var ts; else { var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 32768 ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 524288 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 65536 ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 1048576 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -26514,11 +26691,11 @@ var ts; return !!(ts.getObjectFlags(type) & 32 && getMappedTypeModifiers(type) & 4); } function isGenericMappedType(type) { - return ts.getObjectFlags(type) & 32 && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 65536) { + if (type.flags & 131072) { if (type.objectFlags & 4) { resolveTypeReferenceMembers(type); } @@ -26535,23 +26712,23 @@ var ts; resolveMappedTypeMembers(type); } } - else if (type.flags & 131072) { + else if (type.flags & 262144) { resolveUnionTypeMembers(type); } - else if (type.flags & 262144) { + else if (type.flags & 524288) { resolveIntersectionTypeMembers(type); } } return type; } function getPropertiesOfObjectType(type) { - if (type.flags & 65536) { + if (type.flags & 131072) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; } function getPropertyOfObjectType(type, name) { - if (type.flags & 65536) { + if (type.flags & 131072) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -26573,7 +26750,7 @@ var ts; } } } - if (type.flags & 131072) { + if (type.flags & 262144) { break; } } @@ -26583,13 +26760,13 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 393216 ? + return type.flags & 786432 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 131072)) { + if (!(unionType.flags & 262144)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -26607,9 +26784,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 32768 ? getConstraintOfTypeParameter(type) : - type.flags & 1048576 ? getConstraintOfIndexedAccess(type) : - type.flags & 2097152 ? getConstraintOfConditionalType(type) : + return type.flags & 65536 ? getConstraintOfTypeParameter(type) : + type.flags & 2097152 ? getConstraintOfIndexedAccess(type) : + type.flags & 4194304 ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -26619,12 +26796,12 @@ var ts; var objectType = getBaseConstraintOfType(type.objectType) || type.objectType; var indexType = getBaseConstraintOfType(type.indexType) || type.indexType; var constraint = !isGenericObjectType(objectType) && !isGenericIndexType(indexType) ? getIndexedAccessType(objectType, indexType) : undefined; - return constraint && constraint !== unknownType ? constraint : undefined; + return constraint && constraint !== errorType ? constraint : undefined; } function getDefaultConstraintOfConditionalType(type) { if (!type.resolvedDefaultConstraint) { var rootTrueType = type.root.trueType; - var rootTrueConstraint = rootTrueType.flags & 4194304 ? rootTrueType.substitute : rootTrueType; + var rootTrueConstraint = rootTrueType.flags & 8388608 ? rootTrueType.substitute : rootTrueType; type.resolvedDefaultConstraint = getUnionType([instantiateType(rootTrueConstraint, type.combinedMapper || type.mapper), getFalseTypeFromConditionalType(type)]); } return type.resolvedDefaultConstraint; @@ -26635,7 +26812,7 @@ var ts; if (constraint) { var mapper = makeUnaryTypeMapper(type.root.checkType, constraint); var instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper)); - if (!(instantiated.flags & 16384)) { + if (!(instantiated.flags & 32768)) { return instantiated; } } @@ -26650,19 +26827,19 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 7897088) { + if (t.flags & 15794176) { var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (32768 | 524288 | 2097152)) { + while (constraint && constraint.flags & (65536 | 1048576 | 4194304)) { constraint = getConstraintOfType(constraint); } if (constraint) { - if (!(constraint.flags & 131072)) { + if (!(constraint.flags & 262144)) { return undefined; } constraints = ts.append(constraints, constraint); } } - else if (t.flags & 134233854) { + else if (t.flags & 16809468) { hasDisjointDomainType = true; } } @@ -26670,7 +26847,7 @@ var ts; if (hasDisjointDomainType) { for (var _b = 0, _c = type.types; _b < _c.length; _b++) { var t = _c[_b]; - if (t.flags & 134233854) { + if (t.flags & 16809468) { constraints = ts.append(constraints, t); } } @@ -26680,7 +26857,7 @@ var ts; return undefined; } function getBaseConstraintOfInstantiableNonPrimitiveUnionOrIntersection(type) { - if (type.flags & (7372800 | 393216)) { + if (type.flags & (14745600 | 786432)) { var constraint = getResolvedBaseConstraint(type); if (constraint !== noConstraintType && constraint !== circularConstraintType) { return constraint; @@ -26689,7 +26866,7 @@ var ts; } function getBaseConstraintOfType(type) { var constraint = getBaseConstraintOfInstantiableNonPrimitiveUnionOrIntersection(type); - if (!constraint && type.flags & 524288) { + if (!constraint && type.flags & 1048576) { return keyofConstraintType; } return constraint; @@ -26720,13 +26897,13 @@ var ts; return result; } function computeBaseConstraint(t) { - if (t.flags & 32768) { + if (t.flags & 65536) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 393216) { + if (t.flags & 786432) { var types = t.types; var baseTypes = []; for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { @@ -26736,24 +26913,24 @@ var ts; baseTypes.push(baseType); } } - return t.flags & 131072 && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 262144 && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 262144 && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 524288 && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 524288) { + if (t.flags & 1048576) { return keyofConstraintType; } - if (t.flags & 1048576) { + if (t.flags & 2097152) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; - return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + return baseIndexedAccess && baseIndexedAccess !== errorType ? getBaseConstraint(baseIndexedAccess) : undefined; } - if (t.flags & 2097152) { + if (t.flags & 4194304) { var constraint = getConstraintOfConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 4194304) { + if (t.flags & 8388608) { return getBaseConstraint(t.substitute); } if (isGenericMappedType(t)) { @@ -26796,19 +26973,19 @@ var ts; return !!(typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameterDeclaration(decl) && decl.default; })); } function getApparentType(type) { - var t = type.flags & 7897088 ? getBaseConstraintOfType(type) || emptyObjectType : type; - return t.flags & 262144 ? getApparentTypeOfIntersectionType(t) : - t.flags & 34 ? globalStringType : - t.flags & 84 ? globalNumberType : - t.flags & 136 ? globalBooleanType : - t.flags & 1536 ? getGlobalESSymbolType(languageVersion >= 2) : - t.flags & 134217728 ? emptyObjectType : - t.flags & 524288 ? keyofConstraintType : + var t = type.flags & 15794176 ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 524288 ? getApparentTypeOfIntersectionType(t) : + t.flags & 68 ? globalStringType : + t.flags & 168 ? globalNumberType : + t.flags & 272 ? globalBooleanType : + t.flags & 3072 ? getGlobalESSymbolType(languageVersion >= 2) : + t.flags & 16777216 ? emptyObjectType : + t.flags & 1048576 ? keyofConstraintType : t; } function createUnionOrIntersectionProperty(containingType, name) { var props; - var isUnion = containingType.flags & 131072; + var isUnion = containingType.flags & 262144; var excludeModifiers = isUnion ? 24 : 0; var commonFlags = isUnion ? 0 : 16777216; var syntheticFlag = 4; @@ -26816,7 +26993,7 @@ var ts; for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var current = _a[_i]; var type = getApparentType(current); - if (type !== unknownType) { + if (type !== errorType) { var prop = getPropertyOfType(type, name); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop && !(modifiers & excludeModifiers)) { @@ -26898,7 +27075,7 @@ var ts; } function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 65536) { + if (type.flags & 131072) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -26912,13 +27089,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 393216) { + if (type.flags & 786432) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 458752) { + if (type.flags & 917504) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.callSignatures : resolved.constructSignatures; } @@ -26928,7 +27105,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 458752) { + if (type.flags & 917504) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -26976,10 +27153,10 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - return ts.isInJavaScriptFile(node) && (node.type && node.type.kind === 282 + return ts.isInJavaScriptFile(node) && (node.type && node.type.kind === 283 || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 282; + return isBracketed || !!typeExpression && typeExpression.type.kind === 283; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -27012,7 +27189,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 282; + return isBracketed || !!typeExpression && typeExpression.type.kind === 283; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -27072,7 +27249,7 @@ var ts; var hasLiteralTypes = false; var minArgumentCount = 0; var thisParameter = void 0; - var hasThisParameter = void 0; + var hasThisParameter = false; var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); var isUntypedSignatureInJSFile = !iife && @@ -27095,7 +27272,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 177) { + if (type && type.kind === 178) { hasLiteralTypes = true; } var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) || @@ -27107,16 +27284,16 @@ var ts; minArgumentCount = parameters.length; } } - if ((declaration.kind === 155 || declaration.kind === 156) && + if ((declaration.kind === 156 || declaration.kind === 157) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 155 ? 156 : 155; + var otherKind = declaration.kind === 156 ? 157 : 156; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 154 ? + var classType = declaration.kind === 155 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -27155,8 +27332,8 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 155 && !hasNonBindableDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 156); + if (declaration.kind === 156 && !hasNonBindableDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 157); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -27180,14 +27357,14 @@ var ts; switch (node.kind) { case 71: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 151: - case 153: - case 155: + case 152: + case 154: case 156: - return node.name.kind === 146 + case 157: + return node.name.kind === 147 && traverse(node.name); default: - return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && ts.forEachChild(node, traverse); + return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); } } } @@ -27197,16 +27374,15 @@ var ts; var result = []; for (var i = 0; i < symbol.declarations.length; i++) { var decl = symbol.declarations[i]; - var node = ts.isPropertyAccessExpression(decl) ? ts.getAssignedJavascriptInitializer(decl) : decl; - if (!ts.isFunctionLike(node)) + if (!ts.isFunctionLike(decl)) continue; - if (i > 0 && node.body) { + if (i > 0 && decl.body) { var previous = symbol.declarations[i - 1]; - if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { + if (decl.parent === previous.parent && decl.kind === previous.kind && decl.pos === previous.end) { continue; } } - result.push(getSignatureFromDeclaration(node)); + result.push(getSignatureFromDeclaration(decl)); } return result; } @@ -27239,7 +27415,7 @@ var ts; } else { var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 160 ? + signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 ? createTypePredicateFromTypePredicateNode(declaration.type) : noTypePredicate; } @@ -27250,7 +27426,7 @@ var ts; function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3)) { - return unknownType; + return errorType; } var type = void 0; if (signature.target) { @@ -27284,7 +27460,7 @@ var ts; } function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); + var type = getTypeOfSymbol(ts.last(signature.parameters)); if (ts.getObjectFlags(type) & 4 && type.target === globalArrayType) { return type.typeArguments[0]; } @@ -27334,7 +27510,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 154 || signature.declaration.kind === 158; + var isConstructor = signature.declaration.kind === 155 || signature.declaration.kind === 159; var type = createObjectType(16); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -27375,7 +27551,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 147); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 148); return decl && decl.constraint; } function getInferredTypeParameterConstraint(typeParameter) { @@ -27383,7 +27559,7 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 171 && declaration.parent.parent.kind === 161) { + if (declaration.parent.kind === 172 && declaration.parent.parent.kind === 162) { var typeReference = declaration.parent.parent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -27419,7 +27595,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 147).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 148).parent); } function getTypeListId(types) { var result = ""; @@ -27452,7 +27628,7 @@ var ts; result |= type.flags; } } - return result & 117440512; + return result & 939524096; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -27486,7 +27662,7 @@ var ts; var isJs = ts.isInJavaScriptFile(node); var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { - var missingAugmentsTag = isJs && node.parent.kind !== 289; + var missingAugmentsTag = isJs && node.parent.kind !== 290; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -27497,13 +27673,13 @@ var ts; var typeStr = typeToString(type, undefined, 2); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { - return unknownType; + return errorType; } } var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } - return checkNoTypeArguments(node, symbol) ? type : unknownType; + return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeAliasInstantiation(symbol, typeArguments) { var type = getDeclaredTypeOfSymbol(symbol); @@ -27526,17 +27702,17 @@ var ts; error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); - return unknownType; + return errorType; } return getTypeAliasInstantiation(symbol, typeArguments); } - return checkNoTypeArguments(node, symbol) ? type : unknownType; + return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 161: + case 162: return node.typeName; - case 206: + case 207: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -27553,7 +27729,7 @@ var ts; function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); if (symbol === unknownSymbol) { - return unknownType; + return errorType; } var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); if (type) { @@ -27562,11 +27738,11 @@ var ts; var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { return checkNoTypeArguments(node, symbol) ? - res.flags & 32768 ? getConstrainedTypeVariable(res, node) : res : - unknownType; + res.flags & 65536 ? getConstrainedTypeVariable(res, node) : res : + errorType; } if (!(symbol.flags & 67216319 && isJSDocTypeReference(node))) { - return unknownType; + return errorType; } var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); if (jsdocType) { @@ -27580,7 +27756,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var referenceType = valueType.symbol && valueType.symbol !== symbol && !isInferredClassType(valueType) && getTypeReferenceTypeWorker(node, valueType.symbol, typeArguments); if (referenceType || assignedType) { - return referenceType && assignedType ? getIntersectionType([assignedType, referenceType]) : referenceType || assignedType; + return (referenceType && assignedType ? getIntersectionType([assignedType, referenceType]) : referenceType || assignedType); } } function getTypeReferenceTypeWorker(node, symbol, typeArguments) { @@ -27603,13 +27779,13 @@ var ts; } } function getSubstitutionType(typeVariable, substitute) { - var result = createType(4194304); + var result = createType(8388608); result.typeVariable = typeVariable; result.substitute = substitute; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 167 && node.elementTypes.length === 1; + return node.kind === 168 && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -27618,9 +27794,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 285) { + while (node && !ts.isStatement(node) && node.kind !== 286) { var parent = node.parent; - if (parent.kind === 170 && node === parent.trueType) { + if (parent.kind === 171 && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -27631,7 +27807,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return node.flags & 2097152 && node.kind === 161; + return !!(node.flags & 2097152) && node.kind === 162; } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -27678,7 +27854,7 @@ var ts; var indexed = getTypeFromTypeNode(typeArgs[0]); var target = getTypeFromTypeNode(typeArgs[1]); var index = createIndexInfo(target, false); - return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType && index, indexed === numberType && index); + return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType ? index : undefined, indexed === numberType ? index : undefined); } return anyType; } @@ -27689,7 +27865,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 8192) : type; + return strictNullChecks ? getNullableType(type, 16384) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -27726,9 +27902,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 234: case 235: - case 237: + case 236: + case 238: return declaration; } } @@ -27737,7 +27913,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 65536)) { + if (!(type.flags & 131072)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -27842,7 +28018,7 @@ var ts; var typeParameters = []; var properties = []; for (var i = 0; i < arity; i++) { - var typeParameter = createType(32768); + var typeParameter = createType(65536); typeParameters.push(typeParameter); var property = createSymbol(4, "" + i); property.type = typeParameter; @@ -27859,7 +28035,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(32768); + type.thisType = createType(65536); type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; @@ -27892,16 +28068,16 @@ var ts; var combined = 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 13536 && combined & 13536) { + if (t.flags & 27072 && combined & 27072) { return true; } combined |= t.flags; - if (combined & 12288 && combined & (65536 | 134217728) || - combined & 134217728 && combined & (134233854 & ~134217728) || - combined & 34 && combined & (134233854 & ~34) || - combined & 84 && combined & (134233854 & ~84) || - combined & 1536 && combined & (134233854 & ~1536) || - combined & 6144 && combined & (134233854 & ~6144)) { + if (combined & 24576 && combined & (131072 | 16777216) || + combined & 16777216 && combined & (16809468 & ~16777216) || + combined & 68 && combined & (16809468 & ~68) || + combined & 168 && combined & (16809468 & ~168) || + combined & 3072 && combined & (16809468 & ~3072) || + combined & 12288 && combined & (16809468 & ~12288)) { return true; } } @@ -27909,24 +28085,24 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 131072) { + if (flags & 262144) { return addTypesToUnion(typeSet, includes, type.types); } - if (!(flags & 16384 || flags & 262144 && isEmptyIntersectionType(type))) { - includes |= flags & ~117440512; - if (flags & 1) { + if (!(flags & 32768 || flags & 524288 && isEmptyIntersectionType(type))) { + includes |= flags & ~939524096; + if (flags & 3) { if (type === wildcardType) - includes |= 33554432; + includes |= 268435456; } - else if (!strictNullChecks && flags & 12288) { - if (!(flags & 16777216)) - includes |= 16777216; + else if (!strictNullChecks && flags & 24576) { + if (!(flags & 134217728)) + includes |= 134217728; } else { var len = typeSet.length; var index = len && type.id > typeSet[len - 1].id ? ~len : ts.binarySearch(typeSet, type, getTypeId, ts.compareValues); if (index < 0) { - if (!(flags & 65536 && type.objectFlags & 16 && + if (!(flags & 131072 && type.objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { typeSet.splice(~index, 0, type); } @@ -27964,11 +28140,11 @@ var ts; } function isSetOfLiteralsFromSameEnum(types) { var first = types[0]; - if (first.flags & 256) { + if (first.flags & 512) { var firstEnum = getParentOfSymbol(first.symbol); for (var i = 1; i < types.length; i++) { var other = types[i]; - if (!(other.flags & 256) || (firstEnum !== getParentOfSymbol(other.symbol))) { + if (!(other.flags & 512) || (firstEnum !== getParentOfSymbol(other.symbol))) { return false; } } @@ -27993,10 +28169,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 32 && includes & 2 || - t.flags & 64 && includes & 4 || - t.flags & 1024 && includes & 512 || - t.flags & 96 && t.flags & 8388608 && containsType(types, t.regularType); + var remove = t.flags & 64 && includes & 4 || + t.flags & 128 && includes & 8 || + t.flags & 2048 && includes & 1024 || + t.flags & 192 && t.flags & 33554432 && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -28012,12 +28188,12 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (includes & 1) { - return includes & 33554432 ? wildcardType : anyType; + if (includes & 3) { + return includes & 1 ? includes & 268435456 ? wildcardType : anyType : unknownType; } switch (unionReduction) { case 1: - if (includes & 1120) { + if (includes & 2240) { removeRedundantLiteralTypes(typeSet, includes); } break; @@ -28026,11 +28202,11 @@ var ts; break; } if (typeSet.length === 0) { - return includes & 8192 ? includes & 16777216 ? nullType : nullWideningType : - includes & 4096 ? includes & 16777216 ? undefinedType : undefinedWideningType : + return includes & 16384 ? includes & 134217728 ? nullType : nullWideningType : + includes & 8192 ? includes & 134217728 ? undefinedType : undefinedWideningType : neverType; } - return getUnionTypeFromSortedList(typeSet, includes & 8374815 ? 0 : 268435456, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, includes & 16749629 ? 0 : 67108864, aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -28074,8 +28250,8 @@ var ts; var id = getTypeListId(types); var type = unionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(types, 12288); - type = createType(131072 | propagatedFlags | unionOfUnitTypes); + var propagatedFlags = getPropagatingFlagsOfTypes(types, 24576); + type = createType(262144 | propagatedFlags | unionOfUnitTypes); unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; @@ -28093,20 +28269,20 @@ var ts; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 262144) { + if (flags & 524288) { return addTypesToIntersection(typeSet, includes, type.types); } if (ts.getObjectFlags(type) & 16 && isEmptyObjectType(type)) { - includes |= 67108864; + includes |= 536870912; } else { - includes |= flags & ~117440512; - if (flags & 1) { + includes |= flags & ~939524096; + if (flags & 3) { if (type === wildcardType) - includes |= 33554432; + includes |= 268435456; } - else if ((strictNullChecks || !(flags & 12288)) && !ts.contains(typeSet, type) && - !(flags & 65536 && type.objectFlags & 16 && + else if ((strictNullChecks || !(flags & 24576)) && !ts.contains(typeSet, type) && + !(flags & 131072 && type.objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { typeSet.push(type); @@ -28126,22 +28302,22 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 2 && includes & 32 || - t.flags & 4 && includes & 64 || - t.flags & 512 && includes & 1024; + var remove = t.flags & 4 && includes & 64 || + t.flags & 8 && includes & 128 || + t.flags & 1024 && includes & 2048; if (remove) { ts.orderedRemoveItemAt(types, i); } } } function intersectUnionsOfUnitTypes(types) { - var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 268435456) !== 0; }); + var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 67108864) !== 0; }); var unionType = types[unionIndex]; var intersection = unionType.types; var i = types.length - 1; var _loop_5 = function () { var t = types[i]; - if (t.flags & 268435456) { + if (t.flags & 67108864) { intersection = ts.filter(intersection, function (u) { return containsType(t.types, u); }); ts.orderedRemoveItemAt(types, i); } @@ -28153,45 +28329,48 @@ var ts; if (intersection === unionType.types) { return false; } - types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 268435456); + types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 67108864); return true; } function getIntersectionType(types, aliasSymbol, aliasTypeArguments) { - if (types.length === 0) { - return emptyObjectType; - } var typeSet = []; var includes = addTypesToIntersection(typeSet, 0, types); - if (includes & 16384) { + if (includes & 32768) { return neverType; } if (includes & 1) { - return includes & 33554432 ? wildcardType : anyType; + return includes & 268435456 ? wildcardType : anyType; } - if (includes & 2 && includes & 32 || - includes & 4 && includes & 64 || - includes & 512 && includes & 1024) { + if (!strictNullChecks && includes & 24576) { + return includes & 8192 ? undefinedType : nullType; + } + if (includes & 4 && includes & 64 || + includes & 8 && includes & 128 || + includes & 1024 && includes & 2048) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 67108864 && !(includes & 65536)) { + if (includes & 536870912 && !(includes & 131072)) { typeSet.push(emptyObjectType); } + if (typeSet.length === 0) { + return unknownType; + } if (typeSet.length === 1) { return typeSet[0]; } - if (includes & 131072) { - if (includes & 268435456 && intersectUnionsOfUnitTypes(typeSet)) { + if (includes & 262144) { + if (includes & 67108864 && intersectUnionsOfUnitTypes(typeSet)) { return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } - var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 131072) !== 0; }); + var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 262144) !== 0; }); var unionType = typeSet[unionIndex_1]; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); var type = intersectionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 12288); - type = createType(262144 | propagatedFlags); + var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 24576); + type = createType(524288 | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; @@ -28208,7 +28387,7 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(524288); + var result = createType(1048576); result.type = type; result.stringsOnly = stringsOnly; return result; @@ -28224,7 +28403,7 @@ var ts; if (!type && !ts.isKnownSymbol(prop)) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : - name && name.kind === 146 && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : + name && name.kind === 147 && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); } if (type && type.flags & include) { @@ -28242,16 +28421,16 @@ var ts; } function getIndexType(type, stringsOnly) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } - return type.flags & 131072 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - type.flags & 262144 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - maybeTypeOfKind(type, 7372800) ? getIndexTypeForGenericType(type, stringsOnly) : + return type.flags & 262144 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + type.flags & 524288 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + maybeTypeOfKind(type, 14745600) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 ? getConstraintTypeFromMappedType(type) : type === wildcardType ? wildcardType : type.flags & 1 ? keyofConstraintType : - stringsOnly ? getIndexInfoOfType(type, 0) ? stringType : getLiteralTypeFromPropertyNames(type, 32) : - getIndexInfoOfType(type, 0) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 1024)]) : - getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 32 | 1024)]) : - getLiteralTypeFromPropertyNames(type, 1120); + stringsOnly ? getIndexInfoOfType(type, 0) ? stringType : getLiteralTypeFromPropertyNames(type, 64) : + getIndexInfoOfType(type, 0) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 2048)]) : + getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 64 | 2048)]) : + getLiteralTypeFromPropertyNames(type, 2240); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -28262,7 +28441,7 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 16384 ? stringType : indexType; + return indexType.flags & 32768 ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); @@ -28274,20 +28453,20 @@ var ts; case 141: links.resolvedType = node.type.kind === 138 ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) - : unknownType; + : errorType; break; } } return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { - var type = createType(1048576); + var type = createType(2097152); type.objectType = objectType; type.indexType = indexType; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 185 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 186 ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -28299,7 +28478,7 @@ var ts; markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 99); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); - return unknownType; + return errorType; } if (cacheSymbol) { getNodeLinks(accessNode).resolvedSymbol = prop; @@ -28308,16 +28487,16 @@ var ts; return getTypeOfSymbol(prop); } } - if (!(indexType.flags & 12288) && isTypeAssignableToKind(indexType, 34 | 84 | 1536)) { + if (!(indexType.flags & 24576) && isTypeAssignableToKind(indexType, 68 | 168 | 3072)) { if (isTypeAny(objectType)) { return objectType; } - var indexInfo = isTypeAssignableToKind(indexType, 84) && getIndexInfoOfType(objectType, 1) || + var indexInfo = isTypeAssignableToKind(indexType, 168) && getIndexInfoOfType(objectType, 1) || getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { - if (accessNode && !isTypeAssignableToKind(indexType, 2 | 4)) { - var indexNode = accessNode.kind === 185 ? accessNode.argumentExpression : accessNode.indexType; + if (accessNode && !isTypeAssignableToKind(indexType, 4 | 8)) { + var indexNode = accessNode.kind === 186 ? accessNode.argumentExpression : accessNode.indexType; error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -28325,7 +28504,7 @@ var ts; } return indexInfo.type; } - if (indexType.flags & 16384) { + if (indexType.flags & 32768) { return neverType; } if (accessExpression && !isConstEnumObjectType(objectType)) { @@ -28341,47 +28520,47 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 185 ? accessNode.argumentExpression : accessNode.indexType; - if (indexType.flags & (32 | 64)) { + var indexNode = accessNode.kind === 186 ? accessNode.argumentExpression : accessNode.indexType; + if (indexType.flags & (64 | 128)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (2 | 4)) { + else if (indexType.flags & (4 | 8)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } } - return unknownType; + return errorType; } function isGenericObjectType(type) { - return maybeTypeOfKind(type, 7372800 | 536870912); + return maybeTypeOfKind(type, 14745600 | 134217728); } function isGenericIndexType(type) { - return maybeTypeOfKind(type, 7372800 | 524288); + return maybeTypeOfKind(type, 14745600 | 1048576); } function isStringIndexOnlyType(type) { - if (type.flags & 65536 && !isGenericMappedType(type)) { + if (type.flags & 131072 && !isGenericMappedType(type)) { var t = resolveStructuredTypeMembers(type); return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && - t.stringIndexInfo && !t.numberIndexInfo; + !!t.stringIndexInfo && !t.numberIndexInfo; } return false; } function isMappedTypeToNever(type) { - return ts.getObjectFlags(type) & 32 && getTemplateTypeFromMappedType(type) === neverType; + return !!(ts.getObjectFlags(type) & 32) && getTemplateTypeFromMappedType(type) === neverType; } function getSimplifiedType(type) { - return type.flags & 1048576 ? getSimplifiedIndexedAccessType(type) : type; + return type.flags & 2097152 ? getSimplifiedIndexedAccessType(type) : type; } function getSimplifiedIndexedAccessType(type) { if (type.simplified) { return type.simplified === circularConstraintType ? type : type.simplified; } type.simplified = circularConstraintType; - var objectType = type.objectType; - if (objectType.flags & 262144 && isGenericObjectType(objectType)) { + var objectType = getSimplifiedType(type.objectType); + if (objectType.flags & 524288 && isGenericObjectType(objectType)) { if (ts.some(objectType.types, isStringIndexOnlyType)) { var regularTypes = []; var stringIndexTypes = []; @@ -28407,7 +28586,7 @@ var ts; if (isGenericMappedType(objectType)) { return type.simplified = substituteIndexedMappedType(objectType, type); } - if (objectType.flags & 32768) { + if (objectType.flags & 65536) { var constraint = getConstraintFromTypeParameter(objectType); if (constraint && isGenericMappedType(constraint)) { return type.simplified = substituteIndexedMappedType(constraint, type); @@ -28424,8 +28603,8 @@ var ts; if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 185) && isGenericObjectType(objectType)) { - if (objectType.flags & 1) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 186) && isGenericObjectType(objectType)) { + if (objectType.flags & 3) { return objectType; } var id = objectType.id + "," + indexType.id; @@ -28436,13 +28615,13 @@ var ts; return type; } var apparentObjectType = getApparentType(objectType); - if (indexType.flags & 131072 && !(indexType.flags & 8)) { + if (indexType.flags & 262144 && !(indexType.flags & 16)) { var propTypes = []; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; var propType = getPropertyTypeForIndexType(apparentObjectType, t, accessNode, false); - if (propType === unknownType) { - return unknownType; + if (propType === errorType) { + return errorType; } propTypes.push(propType); } @@ -28456,7 +28635,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var resolved = getIndexedAccessType(objectType, indexType, node); - links.resolvedType = resolved.flags & 1048576 && + links.resolvedType = resolved.flags & 2097152 && resolved.objectType === objectType && resolved.indexType === indexType ? getConstrainedTypeVariable(resolved, node) : resolved; @@ -28476,7 +28655,7 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - return type.flags & 4194304 ? type.typeVariable : type; + return type.flags & 8388608 ? type.typeVariable : type; } function getConditionalType(root, mapper) { var checkType = instantiateType(root.checkType, mapper); @@ -28484,7 +28663,7 @@ var ts; if (checkType === wildcardType || extendsType === wildcardType) { return wildcardType; } - var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 7897088); + var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 15794176); var combinedMapper; if (root.inferTypeParameters) { var context_1 = createInferenceContext(root.inferTypeParameters, undefined, 0); @@ -28494,6 +28673,9 @@ var ts; combinedMapper = combineTypeMappers(mapper, context_1); } if (!isDeferred) { + if (extendsType.flags & 3) { + return instantiateType(root.trueType, mapper); + } if (checkType.flags & 1) { return getUnionType([instantiateType(root.trueType, combinedMapper || mapper), instantiateType(root.falseType, mapper)]); } @@ -28506,7 +28688,7 @@ var ts; } } var erasedCheckType = getActualTypeVariable(checkType); - var result = createType(2097152); + var result = createType(4194304); result.root = root; result.checkType = erasedCheckType; result.extendsType = extendsType; @@ -28538,7 +28720,7 @@ var ts; return true; } while (node) { - if (node.kind === 170) { + if (node.kind === 171) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -28561,7 +28743,7 @@ var ts; extendsType: getTypeFromTypeNode(node.extendsType), trueType: getTypeFromTypeNode(node.trueType), falseType: getTypeFromTypeNode(node.falseType), - isDistributive: !!(checkType.flags & 32768), + isDistributive: !!(checkType.flags & 65536), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -28597,12 +28779,12 @@ var ts; if (node.isTypeOf && node.typeArguments) { error(node, ts.Diagnostics.Type_arguments_cannot_be_used_here); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } if (!ts.isLiteralImportTypeNode(node)) { error(node.argument, ts.Diagnostics.String_literal_expected); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } var argumentType = getTypeFromTypeNode(node.argument); var targetMeaning = node.isTypeOf ? 67216319 : 67901928; @@ -28610,7 +28792,7 @@ var ts; var innerModuleSymbol = resolveExternalModule(node, moduleName, ts.Diagnostics.Cannot_find_module_0, node, false); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } var moduleSymbol_1 = resolveExternalModuleSymbol(innerModuleSymbol, false); if (!ts.nodeIsMissing(node.qualifier)) { @@ -28622,7 +28804,7 @@ var ts; var next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning); if (!next) { error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current)); - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } getNodeLinks(current).resolvedSymbol = next; getNodeLinks(current.parent).resolvedSymbol = next; @@ -28637,7 +28819,7 @@ var ts; else { error(node, targetMeaning === 67216319 ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); links.resolvedSymbol = unknownSymbol; - links.resolvedType = unknownType; + links.resolvedType = errorType; } } } @@ -28681,19 +28863,22 @@ var ts; if (left.flags & 1 || right.flags & 1) { return anyType; } - if (left.flags & 16384) { + if (left.flags & 2 || right.flags & 2) { + return unknownType; + } + if (left.flags & 32768) { return right; } - if (right.flags & 16384) { + if (right.flags & 32768) { return left; } - if (left.flags & 131072) { + if (left.flags & 262144) { return mapType(left, function (t) { return getSpreadType(t, right, symbol, typeFlags, objectFlags); }); } - if (right.flags & 131072) { + if (right.flags & 262144) { return mapType(right, function (t) { return getSpreadType(left, t, symbol, typeFlags, objectFlags); }); } - if (right.flags & (136 | 84 | 34 | 272 | 134217728 | 524288)) { + if (right.flags & (272 | 168 | 68 | 544 | 16777216 | 1048576)) { return left; } var members = ts.createSymbolTable(); @@ -28745,7 +28930,7 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getNonReadonlyIndexSignature(stringIndexInfo), getNonReadonlyIndexSignature(numberIndexInfo)); - spread.flags |= typeFlags | 33554432; + spread.flags |= typeFlags | 268435456; spread.objectFlags |= objectFlags | (128 | 1024); return spread; } @@ -28777,9 +28962,9 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 96 && !(type.flags & 8388608)) { + if (type.flags & 192 && !(type.flags & 33554432)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 8388608, type.value, type.symbol); + var freshType = createLiteralType(type.flags | 33554432, type.value, type.symbol); freshType.regularType = type; type.freshType = freshType; } @@ -28788,14 +28973,16 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 && type.flags & 8388608 ? type.regularType : type; + return type.flags & 192 && type.flags & 33554432 ? type.regularType : + type.flags & 262144 ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : + type; } function getLiteralType(value, enumId, symbol) { var qualifier = typeof value === "number" ? "#" : "@"; var key = enumId ? enumId + qualifier + value : qualifier + value; var type = literalTypes.get(key); if (!type) { - var flags = (typeof value === "number" ? 64 : 32) | (enumId ? 256 : 0); + var flags = (typeof value === "number" ? 128 : 64) | (enumId ? 512 : 0); literalTypes.set(key, type = createLiteralType(flags, value, symbol)); } return type; @@ -28808,7 +28995,7 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(1024); + var type = createType(2048); type.symbol = symbol; return type; } @@ -28823,14 +29010,14 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 235)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 236)) { if (!ts.hasModifier(container, 32) && - (container.kind !== 154 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 155 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); - return unknownType; + return errorType; } function getTypeFromThisTypeNode(node) { var links = getNodeLinks(node); @@ -28842,9 +29029,11 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119: - case 278: case 279: + case 280: return anyType; + case 142: + return unknownType; case 137: return stringType; case 134: @@ -28863,62 +29052,62 @@ var ts; return neverType; case 135: return node.flags & 65536 ? anyType : nonPrimitiveType; - case 173: + case 174: case 99: return getTypeFromThisTypeNode(node); - case 177: - return getTypeFromLiteralTypeNode(node); - case 161: - return getTypeFromTypeReference(node); - case 160: - return booleanType; - case 206: - return getTypeFromTypeReference(node); - case 164: - return getTypeFromTypeQueryNode(node); - case 166: - return getTypeFromArrayTypeNode(node); - case 167: - return getTypeFromTupleTypeNode(node); - case 168: - return getTypeFromUnionTypeNode(node); - case 169: - return getTypeFromIntersectionTypeNode(node); - case 280: - return getTypeFromJSDocNullableTypeNode(node); - case 282: - return addOptionality(getTypeFromTypeNode(node.type)); - case 172: - case 281: - case 277: - return getTypeFromTypeNode(node.type); - case 284: - return getTypeFromJSDocVariadicType(node); - case 162: - case 163: - case 165: - case 286: - case 283: - case 287: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 174: - return getTypeFromTypeOperatorNode(node); - case 175: - return getTypeFromIndexedAccessTypeNode(node); - case 176: - return getTypeFromMappedTypeNode(node); - case 170: - return getTypeFromConditionalTypeNode(node); - case 171: - return getTypeFromInferTypeNode(node); case 178: + return getTypeFromLiteralTypeNode(node); + case 162: + return getTypeFromTypeReference(node); + case 161: + return booleanType; + case 207: + return getTypeFromTypeReference(node); + case 165: + return getTypeFromTypeQueryNode(node); + case 167: + return getTypeFromArrayTypeNode(node); + case 168: + return getTypeFromTupleTypeNode(node); + case 169: + return getTypeFromUnionTypeNode(node); + case 170: + return getTypeFromIntersectionTypeNode(node); + case 281: + return getTypeFromJSDocNullableTypeNode(node); + case 283: + return addOptionality(getTypeFromTypeNode(node.type)); + case 173: + case 282: + case 278: + return getTypeFromTypeNode(node.type); + case 285: + return getTypeFromJSDocVariadicType(node); + case 163: + case 164: + case 166: + case 287: + case 284: + case 288: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + case 175: + return getTypeFromTypeOperatorNode(node); + case 176: + return getTypeFromIndexedAccessTypeNode(node); + case 177: + return getTypeFromMappedTypeNode(node); + case 171: + return getTypeFromConditionalTypeNode(node); + case 172: + return getTypeFromInferTypeNode(node); + case 179: return getTypeFromImportTypeNode(node); case 71: - case 145: + case 146: var symbol = getSymbolAtLocation(node); - return symbol && getDeclaredTypeOfSymbol(symbol); + return (symbol && getDeclaredTypeOfSymbol(symbol)); default: - return unknownType; + return errorType; } } function instantiateList(items, mapper, instantiator) { @@ -28991,10 +29180,10 @@ var ts; return function (t) { return t === source ? target : baseMapper(t); }; } function wildcardMapper(type) { - return type.flags & 32768 ? wildcardType : type; + return type.flags & 65536 ? wildcardType : type; } function cloneTypeParameter(typeParameter) { - var result = createType(32768); + var result = createType(65536); result.symbol = typeParameter.symbol; result.target = typeParameter; return result; @@ -29032,7 +29221,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 65536 | 7897088)) { + if (links.type && !maybeTypeOfKind(links.type, 131072 | 15794176)) { return symbol; } if (ts.getCheckFlags(symbol) & 1) { @@ -29103,35 +29292,35 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 145 || - node.parent.kind === 161 && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 146 || + node.parent.kind === 162 && node.parent.typeArguments && node === node.parent.typeName); } function isTypeParameterPossiblyReferenced(tp, node) { if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 212 ? "quit" : n === container_3; })) { - return ts.forEachChild(node, containsReference); + if (ts.findAncestor(node, function (n) { return n.kind === 213 ? "quit" : n === container_3; })) { + return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 173: - return tp.isThisType; + case 174: + return !!tp.isThisType; case 71: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 164: + case 165: return true; } - return ts.forEachChild(node, containsReference); + return !!ts.forEachChild(node, containsReference); } } function instantiateMappedType(type, mapper) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 524288) { + if (constraintType.flags & 1048576) { var typeVariable_1 = constraintType.type; - if (typeVariable_1.flags & 32768) { + if (typeVariable_1.flags & 65536) { var mappedTypeVariable = instantiateType(typeVariable_1, mapper); if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { @@ -29146,7 +29335,7 @@ var ts; return instantiateAnonymousType(type, mapper); } function isMappableType(type) { - return type.flags & (1 | 7372800 | 65536 | 262144); + return type.flags & (3 | 14745600 | 131072 | 524288); } function instantiateAnonymousType(type, mapper) { var result = createObjectType(type.objectFlags | 64, type.symbol); @@ -29178,7 +29367,7 @@ var ts; if (root.isDistributive) { var checkType_1 = root.checkType; var instantiatedType = mapper(checkType_1); - if (checkType_1 !== instantiatedType && instantiatedType.flags & (131072 | 16384)) { + if (checkType_1 !== instantiatedType && instantiatedType.flags & (262144 | 32768)) { return mapType(instantiatedType, function (t) { return getConditionalType(root, createReplacementMapper(checkType_1, t, mapper)); }); } } @@ -29186,10 +29375,10 @@ var ts; } function instantiateType(type, mapper) { if (type && mapper && mapper !== identityMapper) { - if (type.flags & 32768) { + if (type.flags & 65536) { return mapper(type); } - if (type.flags & 65536) { + if (type.flags & 131072) { if (type.objectFlags & 16) { return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations ? getAnonymousTypeInstantiation(type, mapper) : type; @@ -29203,65 +29392,69 @@ var ts; return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; } } - if (type.flags & 131072 && !(type.flags & 16382)) { + if (type.flags & 262144 && !(type.flags & 32764)) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getUnionType(newTypes, 1, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (type.flags & 262144) { + if (type.flags & 524288) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (type.flags & 524288) { + if (type.flags & 1048576) { return getIndexType(instantiateType(type.type, mapper)); } - if (type.flags & 1048576) { + if (type.flags & 2097152) { return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - if (type.flags & 2097152) { + if (type.flags & 4194304) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); } - if (type.flags & 4194304) { + if (type.flags & 8388608) { return instantiateType(type.typeVariable, mapper); } } return type; } function getWildcardInstantiation(type) { - return type.flags & (16382 | 1 | 16384) ? type : + return type.flags & (32764 | 3 | 32768) ? type : type.wildcardInstantiation || (type.wildcardInstantiation = instantiateType(type, wildcardMapper)); } function instantiateIndexInfo(info, mapper) { return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 153 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 191: case 192: - case 153: + case 193: + case 154: return isContextSensitiveFunctionLikeDeclaration(node); + case 184: + return ts.some(node.properties, isContextSensitive); case 183: - return ts.forEach(node.properties, isContextSensitive); - case 182: - return ts.forEach(node.elements, isContextSensitive); - case 200: + return ts.some(node.elements, isContextSensitive); + case 201: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 199: + case 200: return node.operatorToken.kind === 54 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 269: + case 270: return isContextSensitive(node.initializer); - case 190: + case 191: return isContextSensitive(node.expression); - case 262: - return ts.forEach(node.properties, isContextSensitive); - case 261: - return node.initializer && isContextSensitive(node.initializer); - case 264: - return node.expression && isContextSensitive(node.expression); + case 263: + return ts.some(node.properties, isContextSensitive); + case 262: { + var initializer = node.initializer; + return !!initializer && isContextSensitive(initializer); + } + case 265: { + var expression = node.expression; + return !!expression && isContextSensitive(expression); + } } return false; } @@ -29269,23 +29462,24 @@ var ts; if (node.typeParameters) { return false; } - if (ts.forEach(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { + if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 192) { + if (node.kind !== 193) { var parameter = ts.firstOrUndefined(node.parameters); if (!(parameter && ts.parameterIsThisKeyword(parameter))) { return true; } } - return node.body.kind === 212 ? false : isContextSensitive(node.body); + var body = node.body; + return body.kind === 213 ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 65536) { + if (type.flags & 131072) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(16, type.symbol); @@ -29296,7 +29490,7 @@ var ts; return result; } } - else if (type.flags & 262144) { + else if (type.flags & 524288) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -29317,9 +29511,9 @@ var ts; return isTypeRelatedTo(source, target, assignableRelation); } function isTypeDerivedFrom(source, target) { - return source.flags & 131072 ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 131072 ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 7372800 ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : + return source.flags & 262144 ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 262144 ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 14745600 ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : target === globalObjectType || target === globalFunctionType ? isTypeSubtypeOf(source, target) : hasBaseType(source, getTargetType(target)); } @@ -29350,8 +29544,8 @@ var ts; source = instantiateSignatureInContextOf(source, target, undefined, compareTypes); } var kind = target.declaration ? target.declaration.kind : 0; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 153 && - kind !== 152 && kind !== 154; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 && + kind !== 153 && kind !== 155; var result = -1; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -29379,7 +29573,7 @@ var ts; var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && - (getFalsyFlags(sourceType) & 12288) === (getFalsyFlags(targetType) & 12288); + (getFalsyFlags(sourceType) & 24576) === (getFalsyFlags(targetType) & 24576); var related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 : 1, false, reportErrors, errorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors); @@ -29484,10 +29678,10 @@ var ts; !t.numberIndexInfo; } function isEmptyObjectType(type) { - return type.flags & 65536 ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 134217728 ? true : - type.flags & 131072 ? ts.forEach(type.types, isEmptyObjectType) : - type.flags & 262144 ? !ts.forEach(type.types, function (t) { return !isEmptyObjectType(t); }) : + return type.flags & 131072 ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 16777216 ? true : + type.flags & 262144 ? ts.some(type.types, isEmptyObjectType) : + type.flags & 524288 ? !ts.some(type.types, function (t) { return !isEmptyObjectType(t); }) : false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -29523,71 +29717,71 @@ var ts; function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 1 || s & 16384 || source === wildcardType) + if (t & 3 || s & 32768 || source === wildcardType) return true; - if (t & 16384) + if (t & 32768) return false; - if (s & 34 && t & 2) + if (s & 68 && t & 4) return true; - if (s & 32 && s & 256 && - t & 32 && !(t & 256) && + if (s & 64 && s & 512 && + t & 64 && !(t & 512) && source.value === target.value) return true; - if (s & 84 && t & 4) + if (s & 168 && t & 8) return true; - if (s & 64 && s & 256 && - t & 64 && !(t & 256) && + if (s & 128 && s & 512 && + t & 128 && !(t & 512) && source.value === target.value) return true; - if (s & 136 && t & 8) + if (s & 272 && t & 16) return true; - if (s & 1536 && t & 512) + if (s & 3072 && t & 1024) return true; - if (s & 16 && t & 16 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 && t & 32 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 256 && t & 256) { - if (s & 131072 && t & 131072 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 512 && t & 512) { + if (s & 262144 && t & 262144 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 224 && t & 224 && + if (s & 448 && t & 448 && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } - if (s & 4096 && (!strictNullChecks || t & (4096 | 2048))) + if (s & 8192 && (!strictNullChecks || t & (8192 | 4096))) return true; - if (s & 8192 && (!strictNullChecks || t & 8192)) + if (s & 16384 && (!strictNullChecks || t & 16384)) return true; - if (s & 65536 && t & 134217728) + if (s & 131072 && t & 16777216) return true; - if (s & 1024 || t & 1024) + if (s & 2048 || t & 2048) return false; if (relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) { if (s & 1) return true; - if (s & (4 | 64) && !(s & 256) && (t & 16 || t & 64 && t & 256)) + if (s & (8 | 128) && !(s & 512) && (t & 32 || t & 128 && t & 512)) return true; } return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 && source.flags & 8388608) { + if (source.flags & 192 && source.flags & 33554432) { source = source.regularType; } - if (target.flags & 96 && target.flags & 8388608) { + if (target.flags & 192 && target.flags & 33554432) { target = target.regularType; } if (source === target || - relation === comparableRelation && !(target.flags & 16384) && isSimpleTypeRelatedTo(target, source, relation) || + relation === comparableRelation && !(target.flags & 32768) && isSimpleTypeRelatedTo(target, source, relation) || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 65536 && target.flags & 65536) { + if (source.flags & 131072 && target.flags & 131072) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1; } } - if (source.flags & 8355840 || target.flags & 8355840) { + if (source.flags & 16711680 || target.flags & 16711680) { return checkTypeRelatedTo(source, target, relation, undefined); } return false; @@ -29664,13 +29858,13 @@ var ts; } } function isUnionOrIntersectionTypeWithoutNullableConstituents(type) { - if (!(type.flags & 393216)) { + if (!(type.flags & 786432)) { return false; } var seenNonNullable = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 12288) { + if (t.flags & 24576) { continue; } if (seenNonNullable) { @@ -29681,22 +29875,23 @@ var ts; return false; } function isRelatedTo(source, target, reportErrors, headMessage) { - if (source.flags & 96 && source.flags & 8388608) { + if (reportErrors === void 0) { reportErrors = false; } + if (source.flags & 192 && source.flags & 33554432) { source = source.regularType; } - if (target.flags & 96 && target.flags & 8388608) { + if (target.flags & 192 && target.flags & 33554432) { target = target.regularType; } - if (source.flags & 4194304) { + if (source.flags & 8388608) { source = relation === definitelyAssignableRelation ? source.typeVariable : source.substitute; } - if (target.flags & 4194304) { + if (target.flags & 8388608) { target = target.typeVariable; } - if (source.flags & 1048576) { + if (source.flags & 2097152) { source = getSimplifiedType(source); } - if (target.flags & 1048576) { + if (target.flags & 2097152) { target = getSimplifiedType(target); } if (source === target) @@ -29704,11 +29899,11 @@ var ts; if (relation === identityRelation) { return isIdenticalTo(source, target); } - if (relation === comparableRelation && !(target.flags & 16384) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 32768) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1; - if (isObjectLiteralType(source) && source.flags & 8388608) { - var discriminantType = target.flags & 131072 ? findMatchingDiscriminantType(source, target) : undefined; + if (isObjectLiteralType(source) && source.flags & 33554432) { + var discriminantType = target.flags & 262144 ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -29720,8 +29915,8 @@ var ts; } } if (relation !== comparableRelation && - !(source.flags & 393216) && - !(target.flags & 131072) && + !(source.flags & 786432) && + !(target.flags & 262144) && !isIntersectionConstituent && source !== globalObjectType && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && @@ -29744,30 +29939,30 @@ var ts; var saveErrorInfo = errorInfo; var saveIsIntersectionConstituent = isIntersectionConstituent; isIntersectionConstituent = false; - if (source.flags & 131072) { + if (source.flags & 262144) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 16382)) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 16382)); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764)) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764)); } else { - if (target.flags & 131072) { - result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 16382) && !(target.flags & 16382)); + if (target.flags & 262144) { + result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 32764) && !(target.flags & 32764)); } - else if (target.flags & 262144) { + else if (target.flags & 524288) { isIntersectionConstituent = true; result = typeRelatedToEachType(source, target, reportErrors); } - else if (source.flags & 262144) { + else if (source.flags & 524288) { result = someTypeRelatedToType(source, target, false); } - if (!result && (source.flags & 8355840 || target.flags & 8355840)) { + if (!result && (source.flags & 16711680 || target.flags & 16711680)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { errorInfo = saveErrorInfo; } } } - if (!result && source.flags & 262144) { - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 131072)); + if (!result && source.flags & 524288) { + var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 262144)); if (constraint) { if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; @@ -29776,12 +29971,21 @@ var ts; } isIntersectionConstituent = saveIsIntersectionConstituent; if (!result && reportErrors) { - if (source.flags & 65536 && target.flags & 16382) { + if (source.flags & 131072 && target.flags & 32764) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 65536 && globalObjectType === source) { + else if (source.symbol && source.flags & 131072 && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } + else if (ts.getObjectFlags(source) & 4096 && target.flags & 524288) { + var targetTypes = target.types; + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); + var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); + if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType && + (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) { + return result; + } + } reportRelationError(headMessage, source, target); } return result; @@ -29789,27 +29993,27 @@ var ts; function isIdenticalTo(source, target) { var result; var flags = source.flags & target.flags; - if (flags & 65536) { + if (flags & 131072) { return recursiveTypeRelatedTo(source, target, false); } - if (flags & (131072 | 262144)) { + if (flags & (262144 | 524288)) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } } - if (flags & 524288) { + if (flags & 1048576) { return isRelatedTo(source.type, target.type, false); } - if (flags & 1048576) { + if (flags & 2097152) { if (result = isRelatedTo(source.objectType, target.objectType, false)) { if (result &= isRelatedTo(source.indexType, target.indexType, false)) { return result; } } } - if (flags & 2097152) { + if (flags & 4194304) { if (source.root.isDistributive === target.root.isDistributive) { if (result = isRelatedTo(source.checkType, target.checkType, false)) { if (result &= isRelatedTo(source.extendsType, target.extendsType, false)) { @@ -29822,13 +30026,13 @@ var ts; } } } - if (flags & 4194304) { + if (flags & 8388608) { return isRelatedTo(source.substitute, target.substitute, false); } return 0; } function hasExcessProperties(source, target, discriminant, reportErrors) { - if (maybeTypeOfKind(target, 65536) && !(ts.getObjectFlags(target) & 512)) { + if (maybeTypeOfKind(target, 131072) && !(ts.getObjectFlags(target) & 512)) { var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096); if ((relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { @@ -29840,7 +30044,8 @@ var ts; var _loop_6 = function (prop) { if (!isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { - ts.Debug.assert(!!errorNode); + if (!errorNode) + return { value: ts.Debug.fail() }; if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); } @@ -29851,8 +30056,9 @@ var ts; var propDeclaration = prop.valueDeclaration; ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike); errorNode = propDeclaration; - if (ts.isIdentifier(propDeclaration.name)) { - suggestion = getSuggestionForNonexistentProperty(propDeclaration.name, target); + var name = propDeclaration.name; + if (ts.isIdentifier(name)) { + suggestion = getSuggestionForNonexistentProperty(name, target); } } if (suggestion !== undefined) { @@ -29890,7 +30096,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 131072 && containsType(targetTypes, source)) { + if (target.flags & 262144 && containsType(targetTypes, source)) { return -1; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { @@ -29947,7 +30153,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 131072 && containsType(sourceTypes, target)) { + if (source.flags & 262144 && containsType(sourceTypes, target)) { return -1; } var len = sourceTypes.length; @@ -30077,7 +30283,7 @@ var ts; var result; var originalErrorInfo; var saveErrorInfo = errorInfo; - if (target.flags & 32768) { + if (target.flags & 65536) { if (ts.getObjectFlags(source) & 32 && getConstraintTypeFromMappedType(source) === getIndexType(target)) { if (!(getMappedTypeModifiers(source) & 4)) { var templateType = getTemplateTypeFromMappedType(source); @@ -30088,8 +30294,8 @@ var ts; } } } - else if (target.flags & 524288) { - if (source.flags & 524288) { + else if (target.flags & 1048576) { + if (source.flags & 1048576) { if (result = isRelatedTo(target.type, source.type, false)) { return result; } @@ -30104,7 +30310,7 @@ var ts; } } } - else if (target.flags & 1048576) { + else if (target.flags & 2097152) { var constraint = getConstraintForRelation(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { @@ -30117,7 +30323,7 @@ var ts; var template = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); if (!(modifiers & 8)) { - if (template.flags & 1048576 && template.objectType === source && + if (template.flags & 2097152 && template.objectType === source && template.indexType === getTypeParameterFromMappedType(target)) { return -1; } @@ -30131,8 +30337,8 @@ var ts; } } } - if (source.flags & 1081344) { - if (source.flags & 1048576 && target.flags & 1048576) { + if (source.flags & 2162688) { + if (source.flags & 2097152 && target.flags & 2097152) { if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } @@ -30142,8 +30348,8 @@ var ts; } } var constraint = getConstraintForRelation(source); - if (!constraint || (source.flags & 32768 && constraint.flags & 1)) { - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~134217728))) { + if (!constraint || (source.flags & 65536 && constraint.flags & 3)) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~16777216))) { errorInfo = saveErrorInfo; return result; } @@ -30156,14 +30362,14 @@ var ts; } } } - else if (source.flags & 524288) { + else if (source.flags & 1048576) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 2097152) { - if (target.flags & 2097152) { + else if (source.flags & 4194304) { + if (target.flags & 4194304) { if (isTypeIdenticalTo(source.extendsType, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { @@ -30207,11 +30413,11 @@ var ts; errorInfo = saveErrorInfo; } } - var sourceIsPrimitive = !!(source.flags & 16382); + var sourceIsPrimitive = !!(source.flags & 32764); if (relation !== identityRelation) { source = getApparentType(source); } - if (source.flags & (65536 | 262144) && target.flags & 65536) { + if (source.flags & (131072 | 524288) && target.flags & 131072) { var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; if (isPartialMappedType(target) && !isGenericMappedType(source) && isEmptyObjectType(source)) { result = -1; @@ -30349,14 +30555,14 @@ var ts; return result; } function isWeakType(type) { - if (type.flags & 65536) { + if (type.flags & 131072) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo && resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216); }); } - if (type.flags & 262144) { + if (type.flags & 524288) { return ts.every(type.types, isWeakType); } return false; @@ -30372,7 +30578,7 @@ var ts; return false; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 65536 && target.flags & 65536)) { + if (!(source.flags & 131072 && target.flags & 131072)) { return 0; } var sourceProperties = getPropertiesOfObjectType(source); @@ -30427,7 +30633,7 @@ var ts; } } else if (sourceSignatures.length === 1 && targetSignatures.length === 1) { - var eraseGenerics = relation === comparableRelation || compilerOptions.noStrictGenericChecks; + var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); } else { @@ -30478,7 +30684,7 @@ var ts; if (isIgnoredJsxProperty(source, prop, undefined)) { continue; } - if (prop.nameType && prop.nameType.flags & 1024) { + if (prop.nameType && prop.nameType.flags & 2048) { continue; } if (kind === 0 || isNumericLiteralName(prop.escapedName)) { @@ -30506,7 +30712,7 @@ var ts; return indexTypesIdenticalTo(source, target, kind); } var targetInfo = getIndexInfoOfType(target, kind); - if (!targetInfo || targetInfo.type.flags & 1 && !sourceIsPrimitive) { + if (!targetInfo || targetInfo.type.flags & 3 && !sourceIsPrimitive) { return -1; } var sourceInfo = getIndexInfoOfType(source, kind) || @@ -30515,7 +30721,7 @@ var ts; return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } if (isGenericMappedType(source)) { - return kind === 0 && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors); + return (kind === 0 && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); } if (isObjectTypeWithInferableIndex(source)) { var related = -1; @@ -30603,17 +30809,17 @@ var ts; } function hasCovariantVoidArgument(type, variances) { for (var i = 0; i < variances.length; i++) { - if (variances[i] === 1 && type.typeArguments[i].flags & 2048) { + if (variances[i] === 1 && type.typeArguments[i].flags & 4096) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 32768 && !getConstraintFromTypeParameter(type); + return type.flags & 65536 && !getConstraintFromTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { - return ts.getObjectFlags(type) & 4 && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return !!(ts.getObjectFlags(type) & 4) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } @@ -30681,13 +30887,13 @@ var ts; !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } function isDeeplyNestedType(type, stack, depth) { - if (depth >= 5 && type.flags & 65536) { + if (depth >= 5 && type.flags & 131072) { var symbol = type.symbol; if (symbol) { var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 65536 && t.symbol === symbol) { + if (t.flags & 131072 && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -30812,20 +31018,20 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 12288); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 24576); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 12288) : + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 24576) : getUnionType(types, 2); } function getCommonSubtype(types) { return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return ts.getObjectFlags(type) & 4 && type.target === globalArrayType; + return !!(ts.getObjectFlags(type) & 4) && type.target === globalArrayType; } function isArrayLikeType(type) { return ts.getObjectFlags(type) & 4 && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || - !(type.flags & 12288) && isTypeAssignableTo(type, anyReadonlyArrayType); + !(type.flags & 24576) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; @@ -30835,35 +31041,35 @@ var ts; return !!getPropertyOfType(type, "0"); } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (13536 | 16384)); + return !(type.flags & (27072 | 32768)); } function isUnitType(type) { - return !!(type.flags & 13536); + return !!(type.flags & 27072); } function isLiteralType(type) { - return type.flags & 8 ? true : - type.flags & 131072 ? type.flags & 256 ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : + return type.flags & 16 ? true : + type.flags & 262144 ? type.flags & 512 ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 256 ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 32 ? stringType : - type.flags & 64 ? numberType : - type.flags & 128 ? booleanType : - type.flags & 131072 ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + return type.flags & 512 ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 64 ? stringType : + type.flags & 128 ? numberType : + type.flags & 256 ? booleanType : + type.flags & 262144 ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { - return type.flags & 256 ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 32 && type.flags & 8388608 ? stringType : - type.flags & 64 && type.flags & 8388608 ? numberType : - type.flags & 128 ? booleanType : - type.flags & 131072 ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + return type.flags & 512 ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 64 && type.flags & 33554432 ? stringType : + type.flags & 128 && type.flags & 33554432 ? numberType : + type.flags & 256 ? booleanType : + type.flags & 262144 ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 1024 ? esSymbolType : - type.flags & 131072 ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : + return type.flags & 2048 ? esSymbolType : + type.flags & 262144 ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -30884,39 +31090,39 @@ var ts; return result; } function getFalsyFlags(type) { - return type.flags & 131072 ? getFalsyFlagsOfTypes(type.types) : - type.flags & 32 ? type.value === "" ? 32 : 0 : - type.flags & 64 ? type.value === 0 ? 64 : 0 : - type.flags & 128 ? type === falseType ? 128 : 0 : - type.flags & 14574; + return type.flags & 262144 ? getFalsyFlagsOfTypes(type.types) : + type.flags & 64 ? type.value === "" ? 64 : 0 : + type.flags & 128 ? type.value === 0 ? 128 : 0 : + type.flags & 256 ? type === falseType ? 256 : 0 : + type.flags & 29148; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 14560 ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 14560); }) : + return getFalsyFlags(type) & 29120 ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 29120); }) : type; } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 2 ? emptyStringType : - type.flags & 4 ? zeroType : - type.flags & 8 || type === falseType ? falseType : - type.flags & (2048 | 4096 | 8192) || - type.flags & 32 && type.value === "" || - type.flags & 64 && type.value === 0 ? type : + return type.flags & 4 ? emptyStringType : + type.flags & 8 ? zeroType : + type.flags & 16 || type === falseType ? falseType : + type.flags & (4096 | 8192 | 16384) || + type.flags & 64 && type.value === "" || + type.flags & 128 && type.value === 0 ? type : neverType; } function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (4096 | 8192); + var missing = (flags & ~type.flags) & (8192 | 16384); return missing === 0 ? type : - missing === 4096 ? getUnionType([type, undefinedType]) : - missing === 8192 ? getUnionType([type, nullType]) : + missing === 8192 ? getUnionType([type, undefinedType]) : + missing === 16384 ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type) { ts.Debug.assert(strictNullChecks); - return type.flags & 4096 ? type : getUnionType([type, undefinedType]); + return type.flags & 8192 ? type : getUnionType([type, undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { @@ -30959,7 +31165,7 @@ var ts; return members; } function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && type.flags & 8388608)) { + if (!(isObjectLiteralType(type) && type.flags & 33554432)) { return type; } var regularType = type.regularType; @@ -30969,7 +31175,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~8388608; + regularNew.flags = resolved.flags & ~33554432; regularNew.objectFlags |= 128; type.regularType = regularNew; return regularNew; @@ -31049,16 +31255,16 @@ var ts; return getWidenedTypeWithContext(type, undefined); } function getWidenedTypeWithContext(type, context) { - if (type.flags & 50331648) { - if (type.flags & 12288) { + if (type.flags & 402653184) { + if (type.flags & 24576) { return anyType; } if (isObjectLiteralType(type)) { return getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 131072) { + if (type.flags & 262144) { var unionContext_1 = context || createWideningContext(undefined, undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 12288 ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 24576 ? t : getWidenedTypeWithContext(t, unionContext_1); }); return getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 : 1); } if (isArrayType(type) || isTupleType(type)) { @@ -31069,8 +31275,8 @@ var ts; } function reportWideningErrorsInType(type) { var errorReported = false; - if (type.flags & 16777216) { - if (type.flags & 131072) { + if (type.flags & 134217728) { + if (type.flags & 262144) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -31095,7 +31301,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 16777216) { + if (t.flags & 134217728) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -31110,33 +31316,33 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 199: + case 200: + case 152: case 151: - case 150: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 148: + case 149: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 181: + case 182: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 233: + case 234: + case 154: case 153: - case 152: - case 155: case 156: - case 191: + case 157: case 192: + case 193: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 176: + case 177: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -31145,7 +31351,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && noImplicitAny && type.flags & 16777216) { + if (produceDiagnostics && noImplicitAny && type.flags & 134217728) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -31214,25 +31420,25 @@ var ts; } function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - return !!(type.flags & 7897088 || + return !!(type.flags & 15794176 || objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 2048 | 32) || objectFlags & 32 || - type.flags & 393216 && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 786432 && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { - type.couldContainTypeVariables = ts.forEach(type.types, couldContainTypeVariables); + type.couldContainTypeVariables = ts.some(type.types, couldContainTypeVariables); } return type.couldContainTypeVariables; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || type.flags & 393216 && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || !!(type.flags & 786432) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); } function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 32)) { + if (!(t.flags & 64)) { return; } var name = ts.escapeLeadingUnderscores(t.value); @@ -31244,7 +31450,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfo = type.flags & 2 ? createIndexInfo(emptyObjectType, false) : undefined; + var indexInfo = type.flags & 4 ? createIndexInfo(emptyObjectType, false) : undefined; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfo, undefined); } function inferTypeForHomomorphicMappedType(source, target) { @@ -31264,7 +31470,7 @@ var ts; } for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; - if (getTypeOfSymbol(prop).flags & 67108864) { + if (getTypeOfSymbol(prop).flags & 536870912) { return undefined; } } @@ -31284,7 +31490,7 @@ var ts; return getTypeFromInference(inference); } function getUnmatchedProperty(source, target, requireOptionalProperties) { - var properties = target.flags & 262144 ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); + var properties = target.flags & 524288 ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { var targetProp = properties_5[_i]; if (requireOptionalProperties || !(targetProp.flags & 16777216)) { @@ -31331,8 +31537,8 @@ var ts; } return; } - if (source.flags & 131072 && target.flags & 131072 && !(source.flags & 256 && target.flags & 256) || - source.flags & 262144 && target.flags & 262144) { + if (source.flags & 262144 && target.flags & 262144 && !(source.flags & 512 && target.flags & 512) || + source.flags & 524288 && target.flags & 524288) { if (source === target) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -31347,7 +31553,7 @@ var ts; (matchingTypes || (matchingTypes = [])).push(t); inferFromTypes(t, t); } - else if (t.flags & (64 | 32)) { + else if (t.flags & (128 | 64)) { var b = getBaseTypeOfLiteralType(t); if (typeIdenticalToSomeType(b, target.types)) { (matchingTypes || (matchingTypes = [])).push(t, b); @@ -31359,8 +31565,8 @@ var ts; target = removeTypesFromUnionOrIntersection(target, matchingTypes); } } - if (target.flags & 1081344) { - if (source.flags & 67108864 || source === silentNeverType) { + if (target.flags & 2162688) { + if (source.flags & 536870912 || source === silentNeverType) { return; } var inference = getInferenceInfoForType(target); @@ -31380,7 +31586,7 @@ var ts; inference.candidates = ts.append(inference.candidates, candidate); } } - if (!(priority & 8) && target.flags & 32768 && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 8) && target.flags & 65536 && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; } } @@ -31401,12 +31607,12 @@ var ts; } } } - else if (source.flags & 524288 && target.flags & 524288) { + else if (source.flags & 1048576 && target.flags & 1048576) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 2) && target.flags & 524288) { + else if ((isLiteralType(source) || source.flags & 4) && target.flags & 1048576) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; var savePriority = priority; @@ -31415,17 +31621,17 @@ var ts; priority = savePriority; contravariant = !contravariant; } - else if (source.flags & 1048576 && target.flags & 1048576) { + else if (source.flags & 2097152 && target.flags & 2097152) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 2097152 && target.flags & 2097152) { + else if (source.flags & 4194304 && target.flags & 4194304) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } - else if (target.flags & 393216) { + else if (target.flags & 786432) { var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; @@ -31446,7 +31652,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 131072) { + else if (source.flags & 262144) { var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { var sourceType = sourceTypes_3[_e]; @@ -31454,16 +31660,16 @@ var ts; } } else { - if (!(priority & 32 && source.flags & (262144 | 7897088))) { + if (!(priority & 32 && source.flags & (524288 | 15794176))) { source = getApparentType(source); } - if (source.flags & (65536 | 262144)) { + if (source.flags & (131072 | 524288)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; } (visited || (visited = ts.createMap())).set(key, true); - var isNonConstructorObject = target.flags & 65536 && + var isNonConstructorObject = target.flags & 131072 && !(ts.getObjectFlags(target) & 16 && target.symbol && target.symbol.flags & 32); var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { @@ -31491,7 +31697,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 1081344) { + if (type.flags & 2162688) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { var inference = inferences_1[_i]; if (type === inference.typeParameter) { @@ -31508,7 +31714,7 @@ var ts; } if (ts.getObjectFlags(target) & 32) { var constraintType = getConstraintTypeFromMappedType(target); - if (constraintType.flags & 524288) { + if (constraintType.flags & 1048576) { var inference = getInferenceInfoForType(constraintType.type); if (inference && !inference.isFixed) { var inferredType = inferTypeForHomomorphicMappedType(source, target); @@ -31521,7 +31727,7 @@ var ts; } return; } - if (constraintType.flags & 32768) { + if (constraintType.flags & 65536) { var savePriority = priority; priority |= 4; inferFromTypes(getIndexType(source), constraintType); @@ -31605,11 +31811,11 @@ var ts; reducedTypes.push(t); } } - return type.flags & 131072 ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 262144 ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return constraint && maybeTypeOfKind(constraint, 16382 | 524288); + return !!constraint && maybeTypeOfKind(constraint, 32764 | 1048576); } function isObjectLiteralType(type) { return !!(ts.getObjectFlags(type) & 128); @@ -31629,10 +31835,12 @@ var ts; } function getCovariantInference(inference, context, signature) { var candidates = widenObjectLiteralCandidates(inference.candidates); - var widenLiteralTypes = inference.topLevel && - !hasPrimitiveConstraint(inference.typeParameter) && + var primitiveConstraint = hasPrimitiveConstraint(inference.typeParameter); + var widenLiteralTypes = !primitiveConstraint && inference.topLevel && (inference.isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), inference.typeParameter)); - var baseCandidates = widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) : candidates; + var baseCandidates = primitiveConstraint ? ts.sameMap(candidates, getRegularTypeOfLiteralType) : + widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) : + candidates; var unwidenedType = context.flags & 1 || inference.priority & 28 ? getUnionType(baseCandidates, 2) : getCommonSupertype(baseCandidates); @@ -31646,7 +31854,7 @@ var ts; if (signature) { if (inference.candidates) { inferredType = getCovariantInference(inference, context, signature); - if (inferredType.flags & 16384 && inference.contraCandidates) { + if (inferredType.flags & 32768 && inference.contraCandidates) { inferredType = getContravariantInference(inference); } } @@ -31699,7 +31907,7 @@ var ts; return links.resolvedSymbol; } function isInTypeQuery(node) { - return !!ts.findAncestor(node, function (n) { return n.kind === 164 ? true : n.kind === 71 || n.kind === 145 ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 165 ? true : n.kind === 71 || n.kind === 146 ? false : "quit"; }); } function getFlowCacheKey(node) { if (node.kind === 71) { @@ -31709,13 +31917,13 @@ var ts; if (node.kind === 99) { return "0"; } - if (node.kind === 184) { + if (node.kind === 185) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 181) { + if (node.kind === 182) { var container = node.parent.parent; - var key = container.kind === 181 ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 182 ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -31723,12 +31931,13 @@ var ts; return undefined; } function getBindingElementNameText(element) { - if (element.parent.kind === 179) { + var parent = element.parent; + if (parent.kind === 180) { var name = element.propertyName || element.name; switch (name.kind) { case 71: return ts.idText(name); - case 146: + case 147: return ts.isStringOrNumericLiteral(name.expression) ? name.expression.text : undefined; case 9: case 8: @@ -31738,41 +31947,41 @@ var ts; } } else { - return "" + element.parent.elements.indexOf(element); + return "" + parent.elements.indexOf(element); } } function isMatchingReference(source, target) { switch (source.kind) { case 71: return target.kind === 71 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 231 || target.kind === 181) && + (target.kind === 232 || target.kind === 182) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99: return target.kind === 99; case 97: return target.kind === 97; - case 184: - return target.kind === 184 && + case 185: + return target.kind === 185 && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 181: - if (target.kind !== 184) + case 182: + if (target.kind !== 185) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 181 && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 182 && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 231) { + if (source.parent.parent.kind === 232) { var maybeId = source.parent.parent.initializer; - return maybeId && isMatchingReference(maybeId, t.expression); + return !!maybeId && isMatchingReference(maybeId, t.expression); } } return false; } function containsMatchingReference(source, target) { - while (source.kind === 184) { + while (source.kind === 185) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -31781,7 +31990,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 184 && + return target.kind === 185 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -31789,18 +31998,18 @@ var ts; if (expr.kind === 71) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 184) { + if (expr.kind === 185) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } return undefined; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 131072) { + if (type && type.flags & 262144) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && ts.getCheckFlags(prop) & 2) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.checkFlags & 32 && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = !!(prop.checkFlags & 32) && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -31833,7 +32042,7 @@ var ts; } } } - if (callExpression.expression.kind === 184 && + if (callExpression.expression.kind === 185 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -31847,7 +32056,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 131072)) { + if (!(source.flags & 262144)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -31860,11 +32069,11 @@ var ts; } function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 16384) { + if (assignedType.flags & 32768) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (!(reducedType.flags & 16384)) { + if (!(reducedType.flags & 32768)) { return reducedType; } } @@ -31885,53 +32094,53 @@ var ts; } function getTypeFacts(type) { var flags = type.flags; - if (flags & 2) { + if (flags & 4) { return strictNullChecks ? 4079361 : 4194049; } - if (flags & 32) { + if (flags & 64) { var isEmpty = type.value === ""; return strictNullChecks ? isEmpty ? 3030785 : 1982209 : isEmpty ? 3145473 : 4194049; } - if (flags & (4 | 16)) { + if (flags & (8 | 32)) { return strictNullChecks ? 4079234 : 4193922; } - if (flags & 64) { + if (flags & 128) { var isZero = type.value === 0; return strictNullChecks ? isZero ? 3030658 : 1982082 : isZero ? 3145346 : 4193922; } - if (flags & 8) { + if (flags & 16) { return strictNullChecks ? 4078980 : 4193668; } - if (flags & 136) { + if (flags & 272) { return strictNullChecks ? type === falseType ? 3030404 : 1981828 : type === falseType ? 3145092 : 4193668; } - if (flags & 65536) { + if (flags & 131072) { return isFunctionObjectType(type) ? strictNullChecks ? 1970144 : 4181984 : strictNullChecks ? 1972176 : 4184016; } - if (flags & (2048 | 4096)) { + if (flags & (4096 | 8192)) { return 2457472; } - if (flags & 8192) { + if (flags & 16384) { return 2340752; } - if (flags & 1536) { + if (flags & 3072) { return strictNullChecks ? 1981320 : 4193160; } - if (flags & 134217728) { + if (flags & 16777216) { return strictNullChecks ? 1972176 : 4184016; } - if (flags & 7897088) { + if (flags & 15794176) { return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } - if (flags & 393216) { + if (flags & 786432) { return getTypeFactsOfTypes(type.types); } return 4194303; @@ -31951,26 +32160,26 @@ var ts; return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || isNumericLiteralName(text) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || - unknownType; + errorType; } function getTypeOfDestructuredArrayElement(type, index) { return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || checkIteratedTypeOrElementType(type, undefined, false, false) || - unknownType; + errorType; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(type, undefined, false, false) || unknownType); + return createArrayType(checkIteratedTypeOrElementType(type, undefined, false, false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 182 && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 269 && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 183 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 270 && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 199 && parent.parent.left === parent || - parent.parent.kind === 221 && parent.parent.initializer === parent; + return parent.parent.kind === 200 && parent.parent.left === parent || + parent.parent.kind === 222 && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -31987,29 +32196,29 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 220: - return stringType; case 221: - return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || unknownType; - case 199: + return stringType; + case 222: + return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; + case 200: return getAssignedTypeOfBinaryExpression(parent); - case 193: + case 194: return undefinedType; - case 182: + case 183: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 203: + case 204: return getAssignedTypeOfSpreadExpression(parent); - case 269: - return getAssignedTypeOfPropertyAssignment(parent); case 270: + return getAssignedTypeOfPropertyAssignment(parent); + case 271: return getAssignedTypeOfShorthandPropertyAssignment(parent); } - return unknownType; + return errorType; } function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 179 ? + var type = pattern.kind === 180 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -32024,35 +32233,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 220) { + if (node.parent.parent.kind === 221) { return stringType; } - if (node.parent.parent.kind === 221) { - return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || unknownType; + if (node.parent.parent.kind === 222) { + return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } - return unknownType; + return errorType; } function getInitialType(node) { - return node.kind === 231 ? + return node.kind === 232 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 231 || node.kind === 181 ? + return node.kind === 232 || node.kind === 182 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 231 && node.initializer && + return node.kind === 232 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 181 && node.parent.kind === 199 && + node.kind !== 182 && node.parent.kind === 200 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 190: + case 191: return getReferenceCandidate(node.expression); - case 199: + case 200: switch (node.operatorToken.kind) { case 58: return getReferenceCandidate(node.left); @@ -32064,13 +32273,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 190 || - parent.kind === 199 && parent.operatorToken.kind === 58 && parent.left === node || - parent.kind === 199 && parent.operatorToken.kind === 26 && parent.right === node ? + return parent.kind === 191 || + parent.kind === 200 && parent.operatorToken.kind === 58 && parent.left === node || + parent.kind === 200 && parent.operatorToken.kind === 26 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 265) { + if (clause.kind === 266) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -32087,13 +32296,13 @@ var ts; return links.switchTypes; } function eachTypeContainedIn(source, types) { - return source.flags & 131072 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 262144 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 131072 && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 262144 && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 131072) { + if (source.flags & 262144) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -32102,27 +32311,27 @@ var ts; } return true; } - if (source.flags & 256 && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 512 && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 131072 ? ts.forEach(type.types, f) : f(type); + return type.flags & 262144 ? ts.forEach(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 131072) { + if (type.flags & 262144) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 268435456); + return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 67108864); } return f(type) ? type : neverType; } function mapType(type, mapper, noReductions) { - if (type.flags & 16384) { + if (type.flags & 32768) { return type; } - if (!(type.flags & 131072)) { + if (!(type.flags & 262144)) { return mapper(type); } var types = type.types; @@ -32149,11 +32358,11 @@ var ts; return filterType(type, function (t) { return (t.flags & kind) !== 0; }); } function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 32) || - isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64)) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 2 ? extractTypesOfKind(typeWithLiterals, 2 | 32) : - t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 64) : + return t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 64) : + t.flags & 8 ? extractTypesOfKind(typeWithLiterals, 8 | 128) : t; }); } @@ -32181,9 +32390,9 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 16384 ? + return elementType.flags & 32768 ? autoArrayType : - createArrayType(elementType.flags & 131072 ? + createArrayType(elementType.flags & 262144 ? getUnionType(elementType.types, 2) : elementType); } @@ -32200,7 +32409,7 @@ var ts; var hasEvolvingArrayType = false; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var t = types_14[_i]; - if (!(t.flags & 16384)) { + if (!(t.flags & 32768)) { if (!(ts.getObjectFlags(t) & 256)) { return false; } @@ -32217,15 +32426,15 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 184 && (parent.name.escapedText === "length" || - parent.parent.kind === 186 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 185 && + var isLengthPushOrUnshift = parent.kind === 185 && (parent.name.escapedText === "length" || + parent.parent.kind === 187 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 186 && parent.expression === root && - parent.parent.kind === 199 && + parent.parent.kind === 200 && parent.parent.operatorToken.kind === 58 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 84); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 168); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -32240,7 +32449,7 @@ var ts; var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); - return apparentType !== unknownType && ts.some(getSignaturesOfType(apparentType, 0), signatureHasTypePredicate); + return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0), signatureHasTypePredicate); } } return false; @@ -32256,16 +32465,16 @@ var ts; var key; var flowDepth = 0; if (flowAnalysisDisabled) { - return unknownType; + return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 142575359)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 33492479)) { return declaredType; } var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 208 && getTypeWithFacts(resultType, 524288).flags & 16384) { + if (reference.parent && reference.parent.kind === 209 && getTypeWithFacts(resultType, 524288).flags & 32768) { return declaredType; } return resultType; @@ -32273,7 +32482,7 @@ var ts; if (flowDepth === 2500) { flowAnalysisDisabled = true; reportFlowControlError(reference); - return unknownType; + return errorType; } flowDepth++; while (true) { @@ -32327,7 +32536,7 @@ var ts; } else if (flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 184 && reference.kind !== 99) { + if (container && container !== flowContainer && reference.kind !== 185 && reference.kind !== 99) { flow = container.flowNode; continue; } @@ -32359,7 +32568,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 131072) { + if (declaredType.flags & 262144) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); } return declaredType; @@ -32372,7 +32581,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 186 ? + var expr = node.kind === 187 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -32380,7 +32589,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 186) { + if (node.kind === 187) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -32388,7 +32597,7 @@ var ts; } else { var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 84)) { + if (isTypeAssignableToKind(indexType, 168)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -32402,7 +32611,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 16384) { + if (type.flags & 32768) { return flowType; } var assumeTrue = (flow.flags & 32) !== 0; @@ -32412,7 +32621,7 @@ var ts; return flowType; } var incomplete = isIncomplete(flowType); - var resultType = incomplete && narrowedType.flags & 16384 ? silentNeverType : narrowedType; + var resultType = incomplete && narrowedType.flags & 32768 ? silentNeverType : narrowedType; return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { @@ -32504,8 +32713,8 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 184 && - computedType.flags & 131072 && + return expr.kind === 185 && + computedType.flags & 262144 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); } @@ -32538,7 +32747,7 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if ((type.flags & (131072 | 65536)) || (type.flags & 32768 && type.isThisType)) { + if ((type.flags & (262144 | 131072)) || (type.flags & 65536 && type.isThisType)) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); }); } @@ -32555,10 +32764,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 194 && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 195 && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 194 && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 195 && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -32598,24 +32807,24 @@ var ts; assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (valueType.flags & 12288) { + if (valueType.flags & 24576) { if (!strictNullChecks) { return type; } var doubleEquals = operator === 32 || operator === 33; var facts = doubleEquals ? assumeTrue ? 65536 : 524288 : - valueType.flags & 8192 ? + valueType.flags & 16384 ? assumeTrue ? 32768 : 262144 : assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); } - if (type.flags & 134283777) { + if (type.flags & 16909315) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 16384 ? type : replacePrimitivesWithLiterals(narrowedType, valueType); + return narrowedType.flags & 32768 ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -32634,13 +32843,16 @@ var ts; if (operator === 33 || operator === 35) { assumeTrue = !assumeTrue; } - if (assumeTrue && !(type.flags & 131072)) { - var targetType = typeofTypesByName.get(literal.text); + if (type.flags & 1 && literal.text === "function") { + return type; + } + if (assumeTrue && !(type.flags & 262144)) { + var targetType = literal.text === "function" ? globalFunctionType : typeofTypesByName.get(literal.text); if (targetType) { if (isTypeSubtypeOf(targetType, type)) { return targetType; } - if (type.flags & 7897088) { + if (type.flags & 15794176) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(targetType, constraint)) { return getIntersectionType([type, targetType]); @@ -32661,13 +32873,13 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 16384 ? neverType : + var caseType = discriminantType.flags & 32768 ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); - return caseType.flags & 16384 ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 32768 ? defaultType : getUnionType([caseType, defaultType]); } function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); @@ -32713,9 +32925,9 @@ var ts; if (!assumeTrue) { return filterType(type, function (t) { return !isRelated(t, candidate); }); } - if (type.flags & 131072) { + if (type.flags & 262144) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 16384)) { + if (!(assignableType.flags & 32768)) { return assignableType; } } @@ -32749,7 +32961,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 185 || invokedExpression.kind === 184) { + if (invokedExpression.kind === 186 || invokedExpression.kind === 185) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -32767,15 +32979,15 @@ var ts; case 71: case 99: case 97: - case 184: + case 185: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 186: + case 187: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 190: + case 191: return narrowType(type, expr.expression, assumeTrue); - case 199: + case 200: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 197: + case 198: if (expr.operator === 51) { return narrowType(type, expr.operand, !assumeTrue); } @@ -32802,9 +33014,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 239 || - node.kind === 273 || - node.kind === 151; + node.kind === 240 || + node.kind === 274 || + node.kind === 152; }); } function isParameterAssigned(symbol) { @@ -32825,7 +33037,7 @@ var ts; if (node.kind === 71) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 148) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 149) { symbol.isAssigned = true; } } @@ -32839,21 +33051,21 @@ var ts; } function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 148 && + declaration.kind === 149 && declaration.initializer && - getFalsyFlags(declaredType) & 4096 && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 4096); + getFalsyFlags(declaredType) & 8192 && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 8192); return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072) : declaredType; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 184 || + return parent.kind === 185 || + parent.kind === 187 && parent.expression === node || parent.kind === 186 && parent.expression === node || - parent.kind === 185 && parent.expression === node || - parent.kind === 181 && parent.name === node && !!parent.initializer; + parent.kind === 182 && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { - return type.flags & 7372800 && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 12288); + return type.flags & 14745600 && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576); } function getConstraintForLocation(type, node) { if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) { @@ -32869,12 +33081,12 @@ var ts; function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { - return unknownType; + return errorType; } if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 192) { + if (container.kind === 193) { 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.hasModifier(container, 256)) { @@ -32890,7 +33102,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var declaration = localOrExportSymbol.valueDeclaration; if (localOrExportSymbol.flags & 32) { - if (declaration.kind === 234 + if (declaration.kind === 235 && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -32902,11 +33114,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 204) { + else if (declaration.kind === 205) { var container = ts.getThisContainer(node, false); - while (container !== undefined) { + while (container.kind !== 274) { if (container.parent === declaration) { - if (container.kind === 151 && ts.hasModifier(container, 32)) { + if (container.kind === 152 && ts.hasModifier(container, 32)) { getNodeLinks(declaration).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -32923,11 +33135,11 @@ var ts; if (!(localOrExportSymbol.flags & 3) && !(ts.isInJavaScriptFile(node) && localOrExportSymbol.flags & 512)) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); - return unknownType; + return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(symbol)); - return unknownType; + return errorType; } } var isAlias = localOrExportSymbol.flags & 2097152; @@ -32945,21 +33157,21 @@ var ts; if (!declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 148; + var isParameter = ts.getRootDeclaration(declaration).kind === 149; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; var isSpreadDestructuringAsignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); - while (flowContainer !== declarationContainer && (flowContainer.kind === 191 || - flowContainer.kind === 192 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 192 || + flowContainer.kind === 193 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAsignmentTarget || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || - isInTypeQuery(node) || node.parent.kind === 251) || - node.parent.kind === 208 || - declaration.kind === 231 && declaration.exclamationToken || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3) !== 0 || + isInTypeQuery(node) || node.parent.kind === 252) || + node.parent.kind === 209 || + declaration.kind === 232 && declaration.exclamationToken || declaration.flags & 4194304; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -32974,7 +33186,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 4096) && getFalsyFlags(flowType) & 4096) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 8192) && getFalsyFlags(flowType) & 8192) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); return type; } @@ -32986,7 +33198,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 268) { + symbol.valueDeclaration.parent.kind === 269) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -33004,8 +33216,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 219 && - ts.getAncestor(symbol.valueDeclaration, 232).parent === container && + if (container.kind === 220 && + ts.getAncestor(symbol.valueDeclaration, 233).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -33017,14 +33229,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 190) { + while (current.parent.kind === 191) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 197 || current.parent.kind === 198)) { + else if ((current.parent.kind === 198 || current.parent.kind === 199)) { var expr = current.parent; isAssigned = expr.operator === 43 || expr.operator === 44; } @@ -33035,7 +33247,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 151 || container.kind === 154) { + if (container.kind === 152 || container.kind === 155) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -33079,32 +33291,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 154) { + if (container.kind === 155) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 192) { + if (container.kind === 193) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 238: + case 239: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 237: + case 238: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 154: + case 155: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 152: case 151: - case 150: if (ts.hasModifier(container, 32)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 146: + case 147: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -33121,8 +33333,8 @@ var ts; if (container === void 0) { container = ts.getThisContainer(node, false); } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 191 && - container.parent.kind === 199 && + if (container.kind === 192 && + container.parent.kind === 200 && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent .left @@ -33145,14 +33357,14 @@ var ts; } if (ts.isInJavaScriptFile(node)) { var type = getTypeForThisExpressionFromJSDoc(container); - if (type && type !== unknownType) { + if (type && type !== errorType) { return getFlowTypeOfReference(node, type); } } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 283) { + if (jsdocType && jsdocType.kind === 284) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -33162,14 +33374,14 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 148; }); + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 186 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 187 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 192) { + while (container && container.kind === 193) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -33177,22 +33389,22 @@ var ts; var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; if (!canUseSuperExpression) { - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 146; }); - if (current && current.kind === 146) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 147; }); + if (current && current.kind === 147) { 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 === 183)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 184)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); } - return unknownType; + return errorType; } - if (!isCallExpression && container.kind === 154) { + if (!isCallExpression && container.kind === 155) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.hasModifier(container, 32) || isCallExpression) { @@ -33202,7 +33414,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 153 && ts.hasModifier(container, 256)) { + if (container.kind === 154 && ts.hasModifier(container, 256)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -33213,10 +33425,10 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 183) { + if (container.parent.kind === 184) { 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 unknownType; + return errorType; } else { return anyType; @@ -33225,16 +33437,16 @@ var ts; var classLikeDeclaration = container.parent; if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); - return unknownType; + return errorType; } var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classLikeDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; if (!baseClassType) { - return unknownType; + return errorType; } - if (container.kind === 154 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 155 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - return unknownType; + return errorType; } return nodeCheckFlag === 512 ? getBaseConstructorTypeOfClass(classType) @@ -33244,24 +33456,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 154; + return container.kind === 155; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 183) { + if (ts.isClassLike(container.parent) || container.parent.kind === 184) { if (ts.hasModifier(container, 32)) { - return container.kind === 153 || - container.kind === 152 || - container.kind === 155 || - container.kind === 156; + return container.kind === 154 || + container.kind === 153 || + container.kind === 156 || + container.kind === 157; } else { - return container.kind === 153 || - container.kind === 152 || - container.kind === 155 || + return container.kind === 154 || + container.kind === 153 || container.kind === 156 || + container.kind === 157 || + container.kind === 152 || container.kind === 151 || - container.kind === 150 || - container.kind === 154; + container.kind === 155; } } } @@ -33269,10 +33481,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 153 || - func.kind === 155 || - func.kind === 156) && func.parent.kind === 183 ? func.parent : - func.kind === 191 && func.parent.kind === 269 ? func.parent.parent : + return (func.kind === 154 || + func.kind === 156 || + func.kind === 157) && func.parent.kind === 184 ? func.parent : + func.kind === 192 && func.parent.kind === 270 ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -33280,11 +33492,11 @@ var ts; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 262144 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 524288 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 192) { + if (func.kind === 193) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -33308,7 +33520,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 269) { + if (literal.parent.kind !== 270) { break; } literal = literal.parent.parent; @@ -33317,9 +33529,9 @@ var ts; return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); } var parent = func.parent; - if (parent.kind === 199 && parent.operatorToken.kind === 58) { + if (parent.kind === 200 && parent.operatorToken.kind === 58) { var target = parent.left; - if (target.kind === 184 || target.kind === 185) { + if (target.kind === 185 || target.kind === 186) { var expression = target.expression; if (inJs && ts.isIdentifier(expression)) { var sourceFile = ts.getSourceFileOfNode(parent); @@ -33372,7 +33584,7 @@ var ts; if (funcHasRestParameters && indexOfParameter === (func.parameters.length - 1) && isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); + return getTypeOfSymbol(ts.last(contextualSignature.parameters)); } } } @@ -33383,7 +33595,7 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 148) { + if (declaration.kind === 149) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -33395,7 +33607,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 181) { + if (parentDeclaration.kind !== 182) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -33449,7 +33661,7 @@ var ts; return false; } function getContextualReturnType(functionDecl) { - if (functionDecl.kind === 154 || + if (functionDecl.kind === 155 || ts.getEffectiveReturnTypeNode(functionDecl) || isGetAccessorWithAnnotatedSetAccessor(functionDecl)) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); @@ -33470,7 +33682,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 188) { + if (template.parent.kind === 189) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -33483,7 +33695,7 @@ var ts; return node === right && isContextSensitiveAssignment(binaryExpression) ? getTypeOfExpression(left) : undefined; case 54: var type = getContextualType(binaryExpression); - return !type && node === right && !ts.getDeclaredJavascriptInitializer(binaryExpression.parent) && !ts.getAssignedJavascriptInitializer(binaryExpression) ? + return !type && node === right && !ts.isDefaultedJavascriptInitializer(binaryExpression) ? getTypeOfExpression(left) : type; case 53: case 26: @@ -33506,12 +33718,12 @@ var ts; case 6: return false; default: - ts.Debug.assertNever(kind); + return ts.Debug.assertNever(kind); } } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 458752 ? getPropertyOfType(t, name) : undefined; + var prop = t.flags & 917504 ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }, true); } @@ -33519,7 +33731,7 @@ var ts; return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }, true); } function contextualTypeIsTupleLikeType(type) { - return !!(type.flags & 131072 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); + return !!(type.flags & 262144 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } function getContextualTypeForObjectLiteralMethod(node) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); @@ -33578,10 +33790,26 @@ var ts; return getContextualType(attribute.parent); } } + function isPossiblyDiscriminantValue(node) { + switch (node.kind) { + case 9: + case 8: + case 13: + case 101: + case 86: + case 95: + case 71: + return true; + case 185: + case 191: + return isPossiblyDiscriminantValue(node.expression); + } + return false; + } function getApparentTypeOfContextualType(node) { var contextualType = getContextualType(node); contextualType = contextualType && mapType(contextualType, getApparentType); - if (!(contextualType && contextualType.flags & 131072 && ts.isObjectLiteralExpression(node))) { + if (!(contextualType && contextualType.flags & 262144 && ts.isObjectLiteralExpression(node))) { return contextualType; } var match; @@ -33589,10 +33817,10 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 269) + if (prop.kind !== 270) continue; - if (isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { - var discriminatingType = getTypeOfNode(prop.initializer); + if (isPossiblyDiscriminantValue(prop.initializer) && isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { + var discriminatingType = checkExpression(prop.initializer); for (var _b = 0, _c = contextualType.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, prop.symbol.escapedName); @@ -33619,58 +33847,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 231: - case 148: + case 232: + case 149: + case 152: case 151: - case 150: - case 181: + case 182: return getContextualTypeForInitializerExpression(node); - case 192: - case 224: + case 193: + case 225: return getContextualTypeForReturnExpression(node); - case 202: + case 203: return getContextualTypeForYieldOperand(parent); - case 186: case 187: + case 188: return getContextualTypeForArgument(parent, node); - case 189: - case 207: + case 190: + case 208: return getTypeFromTypeNode(parent.type); - case 199: + case 200: return getContextualTypeForBinaryOperand(node); - case 269: case 270: - return getContextualTypeForObjectLiteralElement(parent); case 271: + return getContextualTypeForObjectLiteralElement(parent); + case 272: return getApparentTypeOfContextualType(parent.parent); - case 182: { + case 183: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 200: + case 201: return getContextualTypeForConditionalOperand(node); - case 210: - ts.Debug.assert(parent.parent.kind === 201); + case 211: + ts.Debug.assert(parent.parent.kind === 202); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 190: { + case 191: { var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 264: + case 265: return getContextualTypeForJsxExpression(parent); - case 261: - case 263: + case 262: + case 264: return getContextualTypeForJsxAttribute(parent); + case 257: case 256: - case 255: return getContextualJsxElementAttributesType(parent); } return undefined; } function getContextualMapper(node) { - node = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); - return node ? node.contextualMapper : identityMapper; + var ancestor = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); + return ancestor ? ancestor.contextualMapper : identityMapper; } function getContextualJsxElementAttributesType(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { @@ -33684,12 +33912,12 @@ var ts; return mapType(valueType, function (t) { return getJsxSignaturesParameterTypes(t, isJs, node); }); } function getJsxSignaturesParameterTypes(valueType, isJs, context) { - if (valueType.flags & 2) { + if (valueType.flags & 4) { return anyType; } - else if (valueType.flags & 32) { + else if (valueType.flags & 64) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, context); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { var stringLiteralTypeName = valueType.value; var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); if (intrinsicProp) { @@ -33708,7 +33936,7 @@ var ts; signatures = getSignaturesOfType(valueType, 0); ctor = false; if (signatures.length === 0) { - return unknownType; + return errorType; } } var links = getNodeLinks(context); @@ -33729,7 +33957,7 @@ var ts; function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); - if (intrinsicAttribs !== unknownType) { + if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); } return propsType; @@ -33757,7 +33985,7 @@ var ts; else { var apparentAttributesType = attributesType; var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context); - if (intrinsicClassAttribs !== unknownType) { + if (intrinsicClassAttribs !== errorType) { var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol); var hostClassType = getReturnTypeOfSignature(sig); apparentAttributesType = intersectTypes(typeParams @@ -33765,7 +33993,7 @@ var ts; : intrinsicClassAttribs, apparentAttributesType); } var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); - if (intrinsicAttribs !== unknownType) { + if (intrinsicAttribs !== errorType) { apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType); } return apparentAttributesType; @@ -33795,7 +34023,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 191 || node.kind === 192; + return node.kind === 192 || node.kind === 193; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -33808,7 +34036,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 153 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 || ts.isObjectLiteralMethod(node)); var type; if (ts.isInJavaScriptFile(node)) { var jsdoc = ts.getJSDocType(node); @@ -33822,7 +34050,7 @@ var ts; if (!type) { return undefined; } - if (!(type.flags & 131072)) { + if (!(type.flags & 262144)) { return getContextualCallSignature(type, node); } var signatureList; @@ -33857,8 +34085,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false, false); } function hasDefaultValue(node) { - return (node.kind === 181 && !!node.initializer) || - (node.kind === 199 && node.operatorToken.kind === 58); + return (node.kind === 182 && !!node.initializer) || + (node.kind === 200 && node.operatorToken.kind === 58); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; @@ -33868,7 +34096,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); for (var index = 0; index < elements.length; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 203) { + if (inDestructuringPattern && e.kind === 204) { var restArrayType = checkExpression(e.expression, checkMode); var restElementType = getIndexTypeOfType(restArrayType, 1) || getIteratedTypeOrElementType(restArrayType, undefined, false, false, false); @@ -33881,7 +34109,7 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 203; + hasSpreadElement = hasSpreadElement || e.kind === 204; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -33891,7 +34119,7 @@ var ts; } if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 180 || pattern.kind === 182)) { + if (pattern && (pattern.kind === 181 || pattern.kind === 183)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -33899,7 +34127,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 205) { + if (patternElement.kind !== 206) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); @@ -33917,7 +34145,7 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 146: + case 147: return isNumericComputedName(name); case 71: return isNumericLiteralName(name.escapedText); @@ -33929,7 +34157,7 @@ var ts; } } function isNumericComputedName(name) { - return isTypeAssignableToKind(checkComputedPropertyName(name), 84); + return isTypeAssignableToKind(checkComputedPropertyName(name), 168); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -33941,8 +34169,8 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (links.resolvedType.flags & 12288 || - !isTypeAssignableToKind(links.resolvedType, 34 | 84 | 1536) && + if (links.resolvedType.flags & 24576 || + !isTypeAssignableToKind(links.resolvedType, 68 | 168 | 3072) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -33968,22 +34196,25 @@ var ts; var propertiesTable; var propertiesArray = []; var spread = emptyObjectType; - var propagatedFlags = 8388608; + var propagatedFlags = 33554432; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 179 || contextualType.pattern.kind === 183); + (contextualType.pattern.kind === 180 || contextualType.pattern.kind === 184); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; var hasComputedNumberProperty = false; - if (isInJSFile && node.properties.length === 0) { - var symbol = getSymbolOfNode(node); - if (symbol.exports) { - propertiesTable = symbol.exports; - symbol.exports.forEach(function (symbol) { return propertiesArray.push(getMergedSymbol(symbol)); }); - return createObjectLiteralType(); + if (isInJSFile) { + var decl = ts.getDeclarationOfJSInitializer(node); + if (decl) { + var symbol = getMergedSymbol(decl.symbol); + if (symbol && ts.hasEntries(symbol.exports)) { + propertiesTable = symbol.exports; + symbol.exports.forEach(function (symbol) { return propertiesArray.push(getMergedSymbol(symbol)); }); + return createObjectLiteralType(); + } } } propertiesTable = ts.createSymbolTable(); @@ -33991,13 +34222,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 146 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 147 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 269 || - memberDecl.kind === 270 || + if (memberDecl.kind === 270 || + memberDecl.kind === 271 || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 269 ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 270 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 270 ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 271 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -34007,7 +34238,7 @@ var ts; } } typeFlags |= type.flags; - var nameType = computedNameType && computedNameType.flags & 1120 ? + var nameType = computedNameType && computedNameType.flags & 2240 ? computedNameType : undefined; var prop = nameType ? createSymbol(4 | member.flags, getLateBoundNameFromType(nameType), 1024) : @@ -34016,8 +34247,8 @@ var ts; prop.nameType = nameType; } if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 269 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 270 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 270 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 271 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216; } @@ -34040,7 +34271,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 271) { + else if (memberDecl.kind === 272) { if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } @@ -34055,17 +34286,17 @@ var ts; var type = checkExpression(memberDecl.expression); if (!isValidSpreadType(type)) { error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); - return unknownType; + return errorType; } spread = getSpreadType(spread, type, node.symbol, propagatedFlags, 0); offset = i + 1; continue; } else { - ts.Debug.assert(memberDecl.kind === 155 || memberDecl.kind === 156); + ts.Debug.assert(memberDecl.kind === 156 || memberDecl.kind === 157); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 1120)) { + if (computedNameType && !(computedNameType.flags & 2240)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -34106,8 +34337,8 @@ var ts; var stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0) : undefined; var numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8388608; - result.flags |= 33554432 | freshObjectLiteralFlag | (typeFlags & 117440512); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 33554432; + result.flags |= 268435456 | freshObjectLiteralFlag | (typeFlags & 939524096); result.objectFlags |= 128; if (patternWithComputedProperties) { result.objectFlags |= 512; @@ -34115,17 +34346,17 @@ var ts; if (inDestructuringPattern) { result.pattern = node; } - if (!(result.flags & 12288)) { - propagatedFlags |= (result.flags & 117440512); + if (!(result.flags & 24576)) { + propagatedFlags |= (result.flags & 939524096); } return result; } } function isValidSpreadType(type) { - return !!(type.flags & (1 | 134217728) || - getFalsyFlags(type) & 14560 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || - type.flags & 65536 && !isGenericMappedType(type) || - type.flags & 393216 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); + return !!(type.flags & (3 | 16777216) || + getFalsyFlags(type) & 29120 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || + type.flags & 131072 && !isGenericMappedType(type) || + type.flags & 786432 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } function checkJsxSelfClosingElement(node, checkMode) { checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); @@ -34155,13 +34386,13 @@ var ts; } function isJsxIntrinsicIdentifier(tagName) { switch (tagName.kind) { - case 184: + case 185: case 99: return false; case 71: return ts.isIntrinsicJsxName(tagName.escapedText); default: - ts.Debug.fail(); + return ts.Debug.fail(); } } function checkJsxAttribute(node, checkMode) { @@ -34196,7 +34427,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 263); + ts.Debug.assert(attributeDecl.kind === 264); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, 0, 4096); attributesTable = ts.createSymbolTable(); @@ -34218,7 +34449,7 @@ var ts; spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, 0, 4096); } } - var parent = openingLikeElement.parent.kind === 254 ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 255 ? openingLikeElement.parent : undefined; if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { @@ -34243,7 +34474,7 @@ var ts; return typeToIntersect || (spread === emptyObjectType ? createJsxAttributesType() : spread); function createJsxAttributesType() { var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, undefined, undefined); - result.flags |= 33554432; + result.flags |= 268435456; result.objectFlags |= 128 | 4096; return result; } @@ -34270,13 +34501,13 @@ var ts; var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); var typeSymbol = exports && getSymbol(exports, name, 67901928); - return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : unknownType; + return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } function getIntrinsicTagSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { if (!ts.isIdentifier(node.tagName)) return ts.Debug.fail(); var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText); @@ -34338,6 +34569,7 @@ var ts; return instantiatedSignatures; } function getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, reportErrors) { + if (reportErrors === void 0) { reportErrors = false; } if (!node.typeArguments) { return; } @@ -34388,7 +34620,7 @@ var ts; if (!propsType) { return undefined; } - if (propsType.flags & 262144) { + if (propsType.flags & 524288) { var propsApparentType = []; for (var _i = 0, _a = propsType.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -34399,7 +34631,7 @@ var ts; return getApparentType(propsType); } function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 131072)); + ts.Debug.assert(!(elementType.flags & 262144)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); if (jsxStatelessElementType) { @@ -34410,7 +34642,7 @@ var ts; paramType = getApparentTypeOfJsxPropsType(paramType); if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== unknownType) { + if (intrinsicAttributes !== errorType) { paramType = intersectTypes(intrinsicAttributes, paramType); } return paramType; @@ -34421,7 +34653,7 @@ var ts; return undefined; } function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 131072)); + ts.Debug.assert(!(elementType.flags & 262144)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); if (jsxStatelessElementType) { @@ -34455,7 +34687,7 @@ var ts; result = allMatchingAttributesType; } var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== unknownType) { + if (intrinsicAttributes !== errorType) { result = intersectTypes(intrinsicAttributes, result); } return result; @@ -34491,7 +34723,7 @@ var ts; return results; } function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (elementType.flags & 131072) { + if (elementType.flags & 262144) { var types = elementType.types; return getUnionType(types.map(function (type) { return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); @@ -34500,12 +34732,12 @@ var ts; if (isTypeAny(elementType)) { return elementType; } - else if (elementType.flags & 2) { + else if (elementType.flags & 4) { return anyType; } - else if (elementType.flags & 32) { + else if (elementType.flags & 64) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, openingLikeElement); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { var stringLiteralTypeName = elementType.value; var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); if (intrinsicProp) { @@ -34521,9 +34753,9 @@ var ts; } var instantiatedSignatures = getInstantiatedJsxSignatures(openingLikeElement, elementType, true); if (!ts.length(instantiatedSignatures)) { - return unknownType; + return errorType; } - var elemInstanceType = getUnionType(ts.map(instantiatedSignatures, getReturnTypeOfSignature), 2); + var elemInstanceType = getUnionType(instantiatedSignatures.map(getReturnTypeOfSignature), 2); var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); @@ -34534,7 +34766,7 @@ var ts; checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } var isJs = ts.isInJavaScriptFile(openingLikeElement); - return getUnionType(ts.map(instantiatedSignatures, function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, true); })); + return getUnionType(instantiatedSignatures.map(function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, true); })); } function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) { ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName)); @@ -34548,7 +34780,7 @@ var ts; return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0).type; } else { - return links.resolvedJsxElementAttributesType = unknownType; + return links.resolvedJsxElementAttributesType = errorType; } } return links.resolvedJsxElementAttributesType; @@ -34579,7 +34811,7 @@ var ts; } function getJsxElementClassTypeAt(location) { var type = getJsxType(JsxNames.ElementClass, location); - if (type === unknownType) + if (type === errorType) return undefined; return type; } @@ -34630,7 +34862,7 @@ var ts; } } function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 65536) { + if (targetType.flags & 131072) { var resolved = resolveStructuredTypeMembers(targetType); if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || @@ -34639,7 +34871,7 @@ var ts; return true; } } - else if (targetType.flags & 393216) { + else if (targetType.flags & 786432) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -34703,11 +34935,11 @@ var ts; return type; } else { - return unknownType; + return errorType; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 151; + return s.valueDeclaration ? s.valueDeclaration.kind : 152; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; @@ -34724,9 +34956,9 @@ var ts; } function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 184 || node.kind === 231 ? + var errorNode = node.kind === 185 || node.kind === 232 ? node.name : - node.kind === 178 ? + node.kind === 179 ? node : node.right; if (ts.getCheckFlags(prop) & 256) { @@ -34777,7 +35009,7 @@ var ts; if (flags & 32) { return true; } - if (type.flags & 32768) { + if (type.flags & 65536) { type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); } if (!type || !hasBaseType(type, enclosingClass)) { @@ -34789,21 +35021,25 @@ var ts; function symbolHasNonMethodDeclaration(symbol) { return forEachProperty(symbol, function (prop) { var propKind = getDeclarationKindFromSymbol(prop); - return propKind !== 153 && propKind !== 152; + return propKind !== 154 && propKind !== 153; }); } function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 12288; + if (type.flags & 2) { + error(node, ts.Diagnostics.Object_is_of_type_unknown); + return errorType; + } + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 24576; if (kind) { - error(node, kind & 4096 ? kind & 8192 ? + error(node, kind & 8192 ? kind & 16384 ? (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); var t = getNonNullableType(type); - return t.flags & (12288 | 16384) ? unknownType : t; + return t.flags & (24576 | 32768) ? errorType : t; } return type; } @@ -34833,9 +35069,9 @@ var ts; var indexInfo = getIndexInfoOfType(apparentType, 0); if (!(indexInfo && indexInfo.type)) { if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, leftType.flags & 32768 && leftType.isThisType ? apparentType : leftType); + reportNonexistentProperty(right, leftType.flags & 65536 && leftType.isThisType ? apparentType : leftType); } - return unknownType; + return errorType; } if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) { error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType)); @@ -34850,14 +35086,14 @@ var ts; if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, ts.idText(right)); - return unknownType; + return errorType; } } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); } - if (node.kind !== 184 || + if (node.kind !== 185 || assignmentKind === 1 || - prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 131072)) { + prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 262144)) { return propType; } var assumeUninitialized = false; @@ -34865,13 +35101,13 @@ var ts; var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 154 && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 155 && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 4096) && getFalsyFlags(flowType) & 4096) { + if (assumeUninitialized && !(getFalsyFlags(propType) & 8192) && getFalsyFlags(flowType) & 8192) { error(right, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); return propType; } @@ -34887,8 +35123,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); } - else if (valueDeclaration.kind === 234 && - node.parent.kind !== 161 && + else if (valueDeclaration.kind === 235 && + node.parent.kind !== 162 && !(valueDeclaration.flags & 4194304) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.idText(right)); @@ -34897,9 +35133,9 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 151: + case 152: return true; - case 269: + case 270: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -34931,7 +35167,7 @@ var ts; } function reportNonexistentProperty(propNode, containingType) { var errorInfo; - if (containingType.flags & 131072 && !(containingType.flags & 16382)) { + if (containingType.flags & 262144 && !(containingType.flags & 32764)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText)) { @@ -35064,20 +35300,20 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 184: + case 185: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); - case 145: + case 146: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 178: + case 179: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 178 ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 179 ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { - var propType = getTypeOfFuncClassEnumModule(method); + var propType = getTypeOfPropertyOfType(actualThisType, method.escapedName); var signatures = getSignaturesOfType(getNonNullableType(propType), 0); ts.Debug.assert(signatures.length !== 0); return signatures.some(function (sig) { @@ -35094,16 +35330,16 @@ var ts; return instantiateType(signatureThisType, createSignatureTypeMapper(sig, getInferredTypes(context))); } function isValidPropertyAccessWithType(node, left, propertyName, type) { - if (type === unknownType || isTypeAny(type)) { + if (type === errorType || isTypeAny(type)) { return true; } var prop = getPropertyOfType(type, propertyName); return prop ? checkPropertyAccessibility(node, left, type, prop) - : ts.isInJavaScriptFile(node) && (type.flags & 131072) && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, left, propertyName, elementType); }); + : ts.isInJavaScriptFile(node) && (type.flags & 262144) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, left, propertyName, elementType); }); } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 232) { + if (initializer.kind === 233) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -35125,7 +35361,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 220 && + if (node.kind === 221 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -35143,7 +35379,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 187 && node.parent.expression === node) { + if (node.parent.kind === 188 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -35153,26 +35389,26 @@ var ts; var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); } - return unknownType; + return errorType; } var indexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : checkExpression(indexExpression); - if (objectType === unknownType || objectType === silentNeverType) { + if (objectType === errorType || objectType === silentNeverType) { return objectType; } if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); - return unknownType; + return errorType; } return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === unknownType) { + if (expressionType === errorType) { return false; } if (!ts.isWellKnownSymbolSyntactically(expression)) { return false; } - if ((expressionType.flags & 1536) === 0) { + if ((expressionType.flags & 3072) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -35202,10 +35438,10 @@ var ts; if (callLikeExpressionMayHaveTypeArguments(node)) { ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 188) { + if (node.kind === 189) { checkExpression(node.template); } - else if (node.kind !== 149) { + else if (node.kind !== 150) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -35230,7 +35466,7 @@ var ts; var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { if (lastParent && parent === lastParent) { - index++; + index = index + 1; } else { lastParent = parent; @@ -35256,7 +35492,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 203) { + if (arg && arg.kind === 204) { return i; } } @@ -35266,17 +35502,16 @@ var ts; if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } var argCount; var typeArguments; - var callIsIncomplete; + var callIsIncomplete = false; var spreadArgIndex = -1; if (ts.isJsxOpeningLikeElement(node)) { return true; } - if (node.kind === 188) { + if (node.kind === 189) { argCount = args.length; - typeArguments = undefined; - if (node.template.kind === 201) { - var lastSpan = ts.lastOrUndefined(node.template.templateSpans); - ts.Debug.assert(lastSpan !== undefined); + typeArguments = node.typeArguments; + if (node.template.kind === 202) { + var lastSpan = ts.last(node.template.templateSpans); callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; } else { @@ -35285,13 +35520,13 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 149) { + else if (node.kind === 150) { typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); } else { if (!node.arguments) { - ts.Debug.assert(node.kind === 187); + ts.Debug.assert(node.kind === 188); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -35319,7 +35554,7 @@ var ts; (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); } function getSingleCallSignature(type) { - if (type.flags & 65536) { + if (type.flags & 131072) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -35354,7 +35589,7 @@ var ts; inference.inferredType = undefined; } } - if (node.kind !== 149) { + if (node.kind !== 150) { var contextualType = getContextualType(node); if (contextualType) { var instantiatedType = instantiateType(contextualType, cloneTypeMapper(getContextualMapper(node))); @@ -35375,7 +35610,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 205) { + if (arg === undefined || arg.kind !== 206) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -35406,7 +35641,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (!constraint) continue; - var errorInfo = reportErrors && headMessage && (function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }); + var errorInfo = reportErrors && headMessage ? (function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }) : undefined; var typeArgumentHeadMessage = headMessage || ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; if (!mapper) { mapper = createTypeMapper(typeParameters, typeArgumentTypes); @@ -35440,12 +35675,12 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 187) { + if (thisType && thisType !== voidType && node.kind !== 188) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; 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, getThisTypeOfSignature(signature), relation, errorNode, headMessage_1)) { + if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1)) { return false; } } @@ -35453,7 +35688,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 205) { + if (arg === undefined || arg.kind !== 206) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i) || checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); @@ -35467,25 +35702,25 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 186) { + if (node.kind === 187) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 184 || callee.kind === 185) { + if (callee.kind === 185 || callee.kind === 186) { return callee.expression; } } } function getEffectiveCallArguments(node) { - if (node.kind === 188) { + if (node.kind === 189) { var template = node.template; var args_4 = [undefined]; - if (template.kind === 201) { + if (template.kind === 202) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); } return args_4; } - else if (node.kind === 149) { + else if (node.kind === 150) { return undefined; } else if (ts.isJsxOpeningLikeElement(node)) { @@ -35496,22 +35731,24 @@ var ts; } } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 149) { + if (node.kind === 150) { switch (node.parent.kind) { - case 234: - case 204: + case 235: + case 205: return 1; - case 151: + case 152: return 2; - case 153: - case 155: + case 154: case 156: + case 157: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 148: + case 149: return 3; + default: + return ts.Debug.fail(); } } else { @@ -35519,51 +35756,52 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 234) { + if (node.kind === 235) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 148) { + if (node.kind === 149) { node = node.parent; - if (node.kind === 154) { + if (node.kind === 155) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 151 || - node.kind === 153 || - node.kind === 155 || - node.kind === 156) { + if (node.kind === 152 || + node.kind === 154 || + node.kind === 156 || + node.kind === 157) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 234) { + if (node.kind === 235) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 148) { + if (node.kind === 149) { node = node.parent; - if (node.kind === 154) { + if (node.kind === 155) { return anyType; } } - if (node.kind === 151 || - node.kind === 153 || - node.kind === 155 || - node.kind === 156) { + if (node.kind === 152 || + node.kind === 154 || + node.kind === 156 || + node.kind === 157) { var element = node; - switch (element.name.kind) { + var name = element.name; + switch (name.kind) { case 71: - return getLiteralType(ts.idText(element.name)); + return getLiteralType(ts.idText(name)); case 8: case 9: - return getLiteralType(element.name.text); - case 146: - var nameType = checkComputedPropertyName(element.name); - if (isTypeAssignableToKind(nameType, 1536)) { + return getLiteralType(name.text); + case 147: + var nameType = checkComputedPropertyName(name); + if (isTypeAssignableToKind(nameType, 3072)) { return nameType; } else { @@ -35571,32 +35809,32 @@ var ts; } default: ts.Debug.fail("Unsupported property name."); - return unknownType; + return errorType; } } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 234) { + if (node.kind === 235) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 148) { + if (node.kind === 149) { return numberType; } - if (node.kind === 151) { + if (node.kind === 152) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 153 || - node.kind === 155 || - node.kind === 156) { + if (node.kind === 154 || + node.kind === 156 || + node.kind === 157) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } function getEffectiveDecoratorArgumentType(node, argIndex) { if (argIndex === 0) { @@ -35609,29 +35847,29 @@ var ts; return getEffectiveDecoratorThirdArgumentType(node.parent); } ts.Debug.fail("Decorators should not have a fourth synthetic argument."); - return unknownType; + return errorType; } function getEffectiveArgumentType(node, argIndex) { - if (node.kind === 149) { + if (node.kind === 150) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 188) { + else if (argIndex === 0 && node.kind === 189) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 149 || - (argIndex === 0 && node.kind === 188)) { + if (node.kind === 150 || + (argIndex === 0 && node.kind === 189)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 149) { + if (node.kind === 150) { return node.expression; } - else if (argIndex === 0 && node.kind === 188) { + else if (argIndex === 0 && node.kind === 189) { return node.template; } else { @@ -35650,8 +35888,8 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, fallbackError) { - var isTaggedTemplate = node.kind === 188; - var isDecorator = node.kind === 149; + var isTaggedTemplate = node.kind === 189; + var isDecorator = node.kind === 150; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; if (!isDecorator) { @@ -35684,7 +35922,7 @@ var ts; var candidateForArgumentError; var candidateForTypeArgumentError; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 186 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 187 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -35835,9 +36073,10 @@ var ts; if (node.expression.kind === 97) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { + ts.forEach(node.arguments, checkExpression); return anySignature; } - if (superType !== unknownType) { + if (superType !== errorType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); @@ -35851,13 +36090,13 @@ var ts; return silentNeverSignature; } var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { + if (apparentType === errorType) { return resolveErrorCall(node); } var callSignatures = getSignaturesOfType(apparentType, 0); var constructSignatures = getSignaturesOfType(apparentType, 1); if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, constructSignatures.length)) { - if (funcType !== unknownType && node.typeArguments) { + if (funcType !== errorType && node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); } return resolveUntypedCall(node); @@ -35874,8 +36113,8 @@ var ts; return resolveCall(node, callSignatures, candidatesOutArray); } function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { - return isTypeAny(funcType) || isTypeAny(apparentFuncType) && funcType.flags & 32768 || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (131072 | 16384)) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && funcType.flags & 65536 || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (262144 | 32768)) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray) { if (node.arguments && languageVersion < 1) { @@ -35889,7 +36128,7 @@ var ts; return silentNeverSignature; } expressionType = getApparentType(expressionType); - if (expressionType === unknownType) { + if (expressionType === errorType) { return resolveErrorCall(node); } if (isTypeAny(expressionType)) { @@ -35980,7 +36219,7 @@ var ts; function resolveTaggedTemplateExpression(node, candidatesOutArray) { var tagType = checkExpression(node.tag); var apparentType = getApparentType(tagType); - if (apparentType === unknownType) { + if (apparentType === errorType) { return resolveErrorCall(node); } var callSignatures = getSignaturesOfType(apparentType, 0); @@ -35996,23 +36235,25 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 234: - case 204: + case 235: + case 205: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 148: + case 149: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 151: + case 152: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 153: - case 155: + case 154: case 156: + case 157: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; + default: + return ts.Debug.fail(); } } function resolveDecorator(node, candidatesOutArray) { var funcType = checkExpression(node.expression); var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { + if (apparentType === errorType) { return resolveErrorCall(node); } var callSignatures = getSignaturesOfType(apparentType, 0); @@ -36027,8 +36268,7 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorInfo = void 0; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); + var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); invocationErrorRecovery(apparentType, 0); @@ -36044,7 +36284,7 @@ var ts; }); } function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { - ts.Debug.assert(!(elementType.flags & 131072)); + ts.Debug.assert(!(elementType.flags & 262144)); var callSignatures = elementType && getSignaturesOfType(elementType, 0); if (callSignatures && callSignatures.length > 0) { return resolveCall(openingLikeElement, callSignatures, candidatesOutArray); @@ -36053,16 +36293,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 186: - return resolveCallExpression(node, candidatesOutArray); case 187: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 188: + return resolveNewExpression(node, candidatesOutArray); + case 189: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 149: + case 150: return resolveDecorator(node, candidatesOutArray); + case 257: case 256: - case 255: var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { var sfcResult = getResolvedJsxStatelessFunctionSignature(node, exprType, candidatesOutArray); @@ -36076,7 +36316,7 @@ var ts; return ts.length(sigs) ? sigs[0] : unknownSignature; }) || unknownSignature; } - ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); + throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } function getResolvedSignature(node, candidatesOutArray) { var links = getNodeLinks(node); @@ -36096,15 +36336,11 @@ var ts; var symbol = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? getSymbolOfNode(node) : ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : undefined; - return symbol && symbol.members !== undefined; + return !!symbol && symbol.members !== undefined; } return false; } function getJavaScriptClassType(symbol) { - var initializer = ts.getDeclaredJavascriptInitializer(symbol.valueDeclaration); - if (initializer) { - symbol = getSymbolOfNode(initializer); - } var inferred; if (isJavaScriptConstructor(symbol.valueDeclaration)) { inferred = getInferredClassType(symbol); @@ -36135,7 +36371,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 184) { + while (parent && parent.kind === 185) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58) { @@ -36162,12 +36398,12 @@ var ts; if (node.expression.kind === 97) { return voidType; } - if (node.kind === 187) { + if (node.kind === 188) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 154 && - declaration.kind !== 158 && - declaration.kind !== 163 && + declaration.kind !== 155 && + declaration.kind !== 159 && + declaration.kind !== 164 && !ts.isJSDocConstructSignature(declaration)) { var funcSymbol = checkExpression(node.expression).symbol; if (!funcSymbol && node.expression.kind === 71) { @@ -36187,10 +36423,20 @@ var ts; return resolveExternalModuleTypeByLiteral(node.arguments[0]); } var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1536 && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 3072 && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - return returnType; + var jsAssignmentType; + if (ts.isInJavaScriptFile(node)) { + var decl = ts.getDeclarationOfJSInitializer(node); + if (decl) { + var jsSymbol = getSymbolOfNode(decl); + if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { + jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, jsObjectLiteralIndexInfo, undefined); + } + } + } + return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -36219,7 +36465,7 @@ var ts; for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 4096 || specifierType.flags & 8192 || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 8192 || specifierType.flags & 16384 || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } var moduleSymbol = resolveExternalModuleName(node, specifier); @@ -36232,7 +36478,7 @@ var ts; return createPromiseReturnType(node, anyType); } function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) { - if (allowSyntheticDefaultImports && type && type !== unknownType) { + if (allowSyntheticDefaultImports && type && type !== errorType) { var synthType = type; if (!synthType.syntheticType) { var file_4 = ts.find(originalSymbol.declarations, ts.isSourceFile); @@ -36269,9 +36515,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 233 + ? 234 : resolvedRequire.flags & 3 - ? 231 + ? 232 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -36293,7 +36539,7 @@ var ts; var exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(checkExpression(expression, checkMode))); checkSourceElement(type); var targetType = getTypeFromTypeNode(type); - if (produceDiagnostics && targetType !== unknownType) { + if (produceDiagnostics && targetType !== errorType) { var widenedType = getWidenedType(exprType); if (!isTypeComparableTo(targetType, widenedType)) { checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Type_0_cannot_be_converted_to_type_1); @@ -36312,14 +36558,15 @@ var ts; if (node.keywordToken === 91) { return checkImportMetaProperty(node); } + return ts.Debug.assertNever(node.keywordToken); } function checkNewTargetMetaProperty(node) { var container = ts.getNewTargetContainer(node); if (!container) { error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); - return unknownType; + return errorType; } - else if (container.kind === 154) { + else if (container.kind === 155) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -36335,7 +36582,7 @@ var ts; var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 1048576), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); - return node.name.escapedText === "meta" ? getGlobalImportMetaType() : unknownType; + return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); @@ -36390,9 +36637,9 @@ var ts; } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { - var parameter = ts.lastOrUndefined(signature.parameters); + var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -36437,7 +36684,7 @@ var ts; error(func, ts.isImportCall(func) ? ts.Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option : ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); - return unknownType; + return errorType; } else if (!getGlobalPromiseConstructorSymbol(true)) { error(func, ts.isImportCall(func) ? @@ -36448,11 +36695,11 @@ var ts; } function getReturnTypeFromBody(func, checkMode) { if (!func.body) { - return unknownType; + return errorType; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 212) { + if (func.body.kind !== 213) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2) { type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -36555,7 +36802,7 @@ var ts; if (!(func.flags & 128)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 226 && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -36572,7 +36819,7 @@ var ts; if (functionFlags & 2) { type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - if (type.flags & 16384) { + if (type.flags & 32768) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -36592,11 +36839,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 191: case 192: + case 193: return true; - case 153: - return func.parent.kind === 183; + case 154: + return func.parent.kind === 184; default: return false; } @@ -36605,14 +36852,14 @@ var ts; if (!produceDiagnostics) { return; } - if (returnType && maybeTypeOfKind(returnType, 1 | 2048)) { + if (returnType && maybeTypeOfKind(returnType, 3 | 4096)) { return; } - if (func.kind === 152 || ts.nodeIsMissing(func.body) || func.body.kind !== 212 || !functionHasImplicitReturn(func)) { + if (func.kind === 153 || ts.nodeIsMissing(func.body) || func.body.kind !== 213 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; - if (returnType && returnType.flags & 16384) { + if (returnType && returnType.flags & 32768) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (returnType && !hasExplicitReturn) { @@ -36635,12 +36882,12 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 153 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 || ts.isObjectLiteralMethod(node)); if (checkMode === 1 && isContextSensitive(node)) { return anyFunctionType; } var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 191) { + if (!hasGrammarError && node.kind === 192) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -36677,7 +36924,7 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 153 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnTypeNode = ts.getEffectiveReturnTypeNode(node); var returnOrPromisedType = returnTypeNode && @@ -36691,7 +36938,7 @@ var ts; if (!returnTypeNode) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 212) { + if (node.body.kind === 213) { checkSourceElement(node.body); } else { @@ -36709,7 +36956,7 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAssignableToKind(type, 84)) { + if (!isTypeAssignableToKind(type, 168)) { error(operand, diagnostic); return false; } @@ -36725,10 +36972,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 184 || expr.kind === 185) && + (expr.kind === 185 || expr.kind === 186) && expr.expression.kind === 99) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 154)) { + if (!(func && func.kind === 155)) { return true; } return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); @@ -36738,13 +36985,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 184 || expr.kind === 185) { + if (expr.kind === 185 || expr.kind === 186) { var node = ts.skipParentheses(expr.expression); if (node.kind === 71) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 245; + return !!declaration && declaration.kind === 246; } } } @@ -36752,7 +36999,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipOuterExpressions(expr, 2 | 1); - if (node.kind !== 71 && node.kind !== 184 && node.kind !== 185) { + if (node.kind !== 71 && node.kind !== 185 && node.kind !== 186) { error(expr, invalidReferenceMessage); return false; } @@ -36761,7 +37008,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 184 && expr.kind !== 185) { + if (expr.kind !== 185 && expr.kind !== 186) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -36810,7 +37057,7 @@ var ts; case 38: case 52: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKind(operandType, 1536)) { + if (maybeTypeOfKind(operandType, 3072)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; @@ -36827,7 +37074,7 @@ var ts; } return numberType; } - return unknownType; + return errorType; } function checkPostfixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -36841,10 +37088,10 @@ var ts; return numberType; } function maybeTypeOfKind(type, kind) { - if (type.flags & kind || kind & 536870912 && isGenericMappedType(type)) { + if (type.flags & kind & ~134217728 || kind & 134217728 && isGenericMappedType(type)) { return true; } - if (type.flags & 393216) { + if (type.flags & 786432) { var types = type.types; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; @@ -36859,26 +37106,26 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (1 | 2048 | 4096 | 8192)) { + if (strict && source.flags & (3 | 4096 | 8192 | 16384)) { return false; } - return (kind & 84 && isTypeAssignableTo(source, numberType)) || - (kind & 34 && isTypeAssignableTo(source, stringType)) || - (kind & 136 && isTypeAssignableTo(source, booleanType)) || - (kind & 2048 && isTypeAssignableTo(source, voidType)) || - (kind & 16384 && isTypeAssignableTo(source, neverType)) || - (kind & 8192 && isTypeAssignableTo(source, nullType)) || - (kind & 4096 && isTypeAssignableTo(source, undefinedType)) || - (kind & 512 && isTypeAssignableTo(source, esSymbolType)) || - (kind & 134217728 && isTypeAssignableTo(source, nonPrimitiveType)); + return !!(kind & 168) && isTypeAssignableTo(source, numberType) || + !!(kind & 68) && isTypeAssignableTo(source, stringType) || + !!(kind & 272) && isTypeAssignableTo(source, booleanType) || + !!(kind & 4096) && isTypeAssignableTo(source, voidType) || + !!(kind & 32768) && isTypeAssignableTo(source, neverType) || + !!(kind & 16384) && isTypeAssignableTo(source, nullType) || + !!(kind & 8192) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 1024) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 16777216) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 131072 ? + return source.flags & 262144 ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return ts.getObjectFlags(type) & 16 && type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { return (symbol.flags & 128) !== 0; @@ -36888,7 +37135,7 @@ var ts; return silentNeverType; } if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 16382)) { + allTypesAssignableToKind(leftType, 32764)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { @@ -36902,10 +37149,10 @@ var ts; } leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 84 | 1536))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 168 | 3072))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAssignableToKind(rightType, 134217728 | 7372800)) { + if (!isTypeAssignableToKind(rightType, 16777216 | 14745600)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; @@ -36923,9 +37170,9 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 269 || property.kind === 270) { + if (property.kind === 270 || property.kind === 271) { var name = property.name; - if (name.kind === 146) { + if (name.kind === 147) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -36938,7 +37185,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 270) { + if (property.kind === 271) { return checkDestructuringAssignment(property, type); } else { @@ -36949,7 +37196,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 271) { + else if (property.kind === 272) { if (languageVersion < 6) { checkExternalEmitHelpers(property, 4); } @@ -36972,7 +37219,7 @@ var ts; if (languageVersion < 2 && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512); } - var elementType = checkIteratedTypeOrElementType(sourceType, node, false, false) || unknownType; + var elementType = checkIteratedTypeOrElementType(sourceType, node, false, false) || errorType; for (var i = 0; i < elements.length; i++) { checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); } @@ -36981,8 +37228,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 205) { - if (element.kind !== 203) { + if (element.kind !== 206) { + if (element.kind !== 204) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -37008,7 +37255,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 199 && restExpression.operatorToken.kind === 58) { + if (restExpression.kind === 200 && restExpression.operatorToken.kind === 58) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -37021,11 +37268,11 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 270) { + if (exprOrAssignment.kind === 271) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && - !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 4096)) { + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 8192)) { sourceType = getTypeWithFacts(sourceType, 131072); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); @@ -37035,21 +37282,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 199 && target.operatorToken.kind === 58) { + if (target.kind === 200 && target.operatorToken.kind === 58) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 183) { + if (target.kind === 184) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 182) { + if (target.kind === 183) { 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 === 271 ? + var error = target.parent.kind === 272 ? 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; if (checkReferenceExpression(target, error)) { @@ -37063,35 +37310,35 @@ var ts; case 71: case 9: case 12: - case 188: - case 201: + case 189: + case 202: case 13: case 8: case 101: case 86: case 95: case 140: - case 191: - case 204: case 192: - case 182: + case 205: + case 193: case 183: - case 194: - case 208: + case 184: + case 195: + case 209: + case 256: case 255: - case 254: return true; - case 200: + case 201: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 199: + case 200: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 197: case 198: + case 199: switch (node.operator) { case 51: case 37: @@ -37100,15 +37347,15 @@ var ts; return true; } return false; - case 195: - case 189: - case 207: + case 196: + case 190: + case 208: default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 12288) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 24576) !== 0 || isTypeComparableTo(source, target); } function checkBinaryExpression(node, checkMode) { if (ts.isInJavaScriptFile(node) && ts.getAssignedJavascriptInitializer(node)) { @@ -37118,7 +37365,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 && (left.kind === 183 || left.kind === 182)) { + if (operator === 58 && (left.kind === 184 || left.kind === 183)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -37152,8 +37399,8 @@ var ts; leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); var suggestedOperator = void 0; - if ((leftType.flags & 136) && - (rightType.flags & 136) && + if ((leftType.flags & 272) && + (rightType.flags & 272) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } @@ -37170,19 +37417,19 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 34) && !isTypeAssignableToKind(rightType, 34)) { + if (!isTypeAssignableToKind(leftType, 68) && !isTypeAssignableToKind(rightType, 68)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 84, true) && isTypeAssignableToKind(rightType, 84, true)) { + if (isTypeAssignableToKind(leftType, 168, true) && isTypeAssignableToKind(rightType, 168, true)) { resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 34, true) || isTypeAssignableToKind(rightType, 34, true)) { + else if (isTypeAssignableToKind(leftType, 68, true) || isTypeAssignableToKind(rightType, 68, true)) { resultType = stringType; } else if (isTypeAny(leftType) || isTypeAny(rightType)) { - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + resultType = leftType === errorType || rightType === errorType ? errorType : anyType; } if (resultType && !checkForDisallowedESSymbolOperand(operator)) { return resultType; @@ -37242,6 +37489,8 @@ var ts; error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } return rightType; + default: + return ts.Debug.fail(); } function checkSpecialAssignment(left, right) { var special = ts.getSpecialPropertyAssignmentKind(left.parent); @@ -37253,7 +37502,7 @@ var ts; if (propType.symbol && propType.symbol.flags & 32) { var name = prop.escapedName; var symbol = resolveName(prop.valueDeclaration, name, 67901928, undefined, name, false); - if (symbol) { + if (symbol && symbol.declarations.some(function (d) { return d.kind === 297; })) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); } @@ -37265,8 +37514,8 @@ var ts; return node.kind === 71 && node.escapedText === "eval"; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKind(leftType, 1536) ? left : - maybeTypeOfKind(rightType, 1536) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 3072) ? left : + maybeTypeOfKind(rightType, 3072) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -37326,7 +37575,9 @@ var ts; } } var func = ts.getContainingFunction(node); - var functionFlags = func ? ts.getFunctionFlags(func) : 0; + if (!func) + return anyType; + var functionFlags = ts.getFunctionFlags(func); if (!(functionFlags & 1)) { return anyType; } @@ -37357,14 +37608,14 @@ var ts; } function checkTemplateExpression(node) { ts.forEach(node.templateSpans, function (templateSpan) { - if (maybeTypeOfKind(checkExpression(templateSpan.expression), 1536)) { + if (maybeTypeOfKind(checkExpression(templateSpan.expression), 3072)) { error(templateSpan.expression, ts.Diagnostics.Type_0_cannot_be_converted_to_type_1, typeToString(esSymbolType), typeToString(stringType)); } }); return stringType; } function getContextNode(node) { - if (node.kind === 262) { + if (node.kind === 263) { return node.parent.parent; } return node; @@ -37397,17 +37648,16 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 189 || node.kind === 207; + return node.kind === 190 || node.kind === 208; } function checkDeclarationInitializer(declaration) { - var inJs = ts.isInJavaScriptFile(declaration); - var initializer = inJs && ts.getDeclaredJavascriptInitializer(declaration) || declaration.initializer; + var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, true); var widened = ts.getCombinedNodeFlags(declaration) & 2 || (ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration)) || isTypeAssertion(initializer) ? type : getWidenedLiteralType(type); - if (inJs) { - if (widened.flags & 12288) { + if (ts.isInJavaScriptFile(declaration)) { + if (widened.flags & 24576) { if (noImplicitAny) { reportImplicitAnyError(declaration, anyType); } @@ -37422,33 +37672,23 @@ var ts; } return widened; } - function isTypeParameterWithKeyofConstraint(type) { - if (type.flags & 32768) { - var constraintDeclaration = getConstraintDeclaration(type); - return constraintDeclaration && constraintDeclaration.kind === 174 && - constraintDeclaration.operator === 128; - } - return false; - } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 393216) { + if (contextualType.flags & 786432) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 7372800) { + if (contextualType.flags & 14745600) { var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; - return isTypeParameterWithKeyofConstraint(contextualType) && maybeTypeOfKind(candidateType, 32 | 64 | 1024) || - constraint.flags & 2 && maybeTypeOfKind(candidateType, 32) || - constraint.flags & 4 && maybeTypeOfKind(candidateType, 64) || - constraint.flags & 8 && maybeTypeOfKind(candidateType, 128) || - constraint.flags & 512 && maybeTypeOfKind(candidateType, 1024) || + return maybeTypeOfKind(constraint, 4) && maybeTypeOfKind(candidateType, 64) || + maybeTypeOfKind(constraint, 8) && maybeTypeOfKind(candidateType, 128) || + maybeTypeOfKind(constraint, 1024) && maybeTypeOfKind(candidateType, 2048) || isLiteralOfContextualType(candidateType, constraint); } - return contextualType.flags & (32 | 524288) && maybeTypeOfKind(candidateType, 32) || - contextualType.flags & 64 && maybeTypeOfKind(candidateType, 64) || + return !!(contextualType.flags & (64 | 1048576) && maybeTypeOfKind(candidateType, 64) || contextualType.flags & 128 && maybeTypeOfKind(candidateType, 128) || - contextualType.flags & 1024 && maybeTypeOfKind(candidateType, 1024); + contextualType.flags & 256 && maybeTypeOfKind(candidateType, 256) || + contextualType.flags & 2048 && maybeTypeOfKind(candidateType, 2048)); } return false; } @@ -37461,14 +37701,14 @@ var ts; getWidenedLiteralLikeTypeForContextualType(type, contextualType); } function checkPropertyAssignment(node, checkMode) { - if (node.name.kind === 146) { + if (node.name.kind === 147) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); } function checkObjectLiteralMethod(node, checkMode) { checkGrammarMethod(node); - if (node.name.kind === 146) { + if (node.name.kind === 147) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -37490,7 +37730,7 @@ var ts; return type; } function getTypeOfExpression(node, cache) { - if (node.kind === 186 && node.expression.kind !== 97 && !ts.isRequireCall(node, true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 187 && node.expression.kind !== 97 && !ts.isRequireCall(node, true) && !isSymbolOrSymbolForCall(node)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -37508,7 +37748,7 @@ var ts; } function checkExpression(node, checkMode) { var type; - if (node.kind === 145) { + if (node.kind === 146) { type = checkQualifiedName(node); } else { @@ -37516,10 +37756,10 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 184 && node.parent.expression === node) || - (node.parent.kind === 185 && node.parent.expression === node) || - ((node.kind === 71 || node.kind === 145) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 164 && node.parent.exprName === node)); + var ok = (node.parent.kind === 185 && node.parent.expression === node) || + (node.parent.kind === 186 && node.parent.expression === node) || + ((node.kind === 71 || node.kind === 146) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 165 && node.parent.exprName === node)); 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); } @@ -37553,76 +37793,76 @@ var ts; return trueType; case 86: return falseType; - case 201: + case 202: return checkTemplateExpression(node); case 12: return globalRegExpType; - case 182: - return checkArrayLiteral(node, checkMode); case 183: - return checkObjectLiteral(node, checkMode); + return checkArrayLiteral(node, checkMode); case 184: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, checkMode); case 185: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 186: + return checkIndexedAccess(node); + case 187: if (node.expression.kind === 91) { return checkImportCallExpression(node); } - case 187: - return checkCallExpression(node); case 188: - return checkTaggedTemplateExpression(node); - case 190: - return checkParenthesizedExpression(node, checkMode); - case 204: - return checkClassExpression(node); - case 191: - case 192: - return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 194: - return checkTypeOfExpression(node); + return checkCallExpression(node); case 189: - case 207: - return checkAssertion(node); - case 208: - return checkNonNullAssertion(node); - case 209: - return checkMetaProperty(node); - case 193: - return checkDeleteExpression(node); - case 195: - return checkVoidExpression(node); - case 196: - return checkAwaitExpression(node); - case 197: - return checkPrefixUnaryExpression(node); - case 198: - return checkPostfixUnaryExpression(node); - case 199: - return checkBinaryExpression(node, checkMode); - case 200: - return checkConditionalExpression(node, checkMode); - case 203: - return checkSpreadExpression(node, checkMode); + return checkTaggedTemplateExpression(node); + case 191: + return checkParenthesizedExpression(node, checkMode); case 205: + return checkClassExpression(node); + case 192: + case 193: + return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + case 195: + return checkTypeOfExpression(node); + case 190: + case 208: + return checkAssertion(node); + case 209: + return checkNonNullAssertion(node); + case 210: + return checkMetaProperty(node); + case 194: + return checkDeleteExpression(node); + case 196: + return checkVoidExpression(node); + case 197: + return checkAwaitExpression(node); + case 198: + return checkPrefixUnaryExpression(node); + case 199: + return checkPostfixUnaryExpression(node); + case 200: + return checkBinaryExpression(node, checkMode); + case 201: + return checkConditionalExpression(node, checkMode); + case 204: + return checkSpreadExpression(node, checkMode); + case 206: return undefinedWideningType; - case 202: + case 203: return checkYieldExpression(node); - case 264: + case 265: return checkJsxExpression(node, checkMode); - case 254: - return checkJsxElement(node, checkMode); case 255: - return checkJsxSelfClosingElement(node, checkMode); - case 258: - return checkJsxFragment(node, checkMode); - case 262: - return checkJsxAttributes(node, checkMode); + return checkJsxElement(node, checkMode); case 256: + return checkJsxSelfClosingElement(node, checkMode); + case 259: + return checkJsxFragment(node, checkMode); + case 263: + return checkJsxAttributes(node, checkMode); + case 257: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } - return unknownType; + return errorType; } function checkTypeParameter(node) { if (node.expression) { @@ -37651,7 +37891,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92)) { - if (!(func.kind === 154 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 155 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -37662,7 +37902,7 @@ 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 === 154 || func.kind === 158 || func.kind === 163) { + if (func.kind === 155 || func.kind === 159 || func.kind === 164) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -37724,13 +37964,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 193: + case 158: + case 234: case 192: - case 157: - case 233: - case 191: - case 162: + case 163: + case 154: case 153: - case 152: var parent = node.parent; if (node === parent.type) { return parent; @@ -37748,7 +37988,7 @@ var ts; error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 180 || name.kind === 179) { + else if (name.kind === 181 || name.kind === 180) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -37756,12 +37996,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 159) { + if (node.kind === 160) { checkGrammarIndexSignature(node); } - else if (node.kind === 162 || node.kind === 233 || node.kind === 163 || - node.kind === 157 || node.kind === 154 || - node.kind === 158) { + else if (node.kind === 163 || node.kind === 234 || node.kind === 164 || + node.kind === 158 || node.kind === 155 || + node.kind === 159) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -37786,10 +38026,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 158: + case 159: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 157: + case 158: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -37813,7 +38053,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 159 && node.kind !== 283) { + if (node.kind !== 160 && node.kind !== 284) { registerForUnusedIdentifiersCheck(node); } } @@ -37823,7 +38063,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154) { + if (member.kind === 155) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { @@ -37834,20 +38074,21 @@ var ts; else { var isStatic = ts.hasModifier(member, 32); var names = isStatic ? staticNames : instanceNames; - var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); - if (memberName) { + var name = member.name; + var memberName = name && ts.getPropertyNameForPropertyNameNode(name); + if (name && memberName) { switch (member.kind) { - case 155: - addName(names, member.name, memberName, 1); - break; case 156: - addName(names, member.name, memberName, 2); + addName(names, name, memberName, 1); break; - case 151: - addName(names, member.name, memberName, 3); + case 157: + addName(names, name, memberName, 2); break; - case 153: - addName(names, member.name, memberName, 4); + case 152: + addName(names, name, memberName, 3); + break; + case 154: + addName(names, name, memberName, 4); break; } } @@ -37898,15 +38139,16 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150) { + if (member.kind === 151) { var memberName = void 0; - switch (member.name.kind) { + var name = member.name; + switch (name.kind) { case 9: case 8: - memberName = member.name.text; + memberName = name.text; break; case 71: - memberName = ts.idText(member.name); + memberName = ts.idText(name); break; default: continue; @@ -37922,7 +38164,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 235) { + if (node.kind === 236) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -37967,7 +38209,7 @@ var ts; if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); checkFunctionOrMethodDeclaration(node); - if (ts.hasModifier(node, 128) && node.kind === 153 && node.body) { + if (ts.hasModifier(node, 128) && node.kind === 154 && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -37988,7 +38230,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 151 && + return n.kind === 152 && !ts.hasModifier(n, 32) && !!n.initializer; } @@ -38008,7 +38250,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 215 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 216 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -38032,18 +38274,18 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 155) { + if (node.kind === 156) { if (!(node.flags & 4194304) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 146) { + if (node.name.kind === 147) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { - var otherKind = node.kind === 155 ? 156 : 155; + var otherKind = node.kind === 156 ? 157 : 156; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -38059,7 +38301,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 155) { + if (node.kind === 156) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -38096,7 +38338,7 @@ var ts; } function getTypeParametersForTypeReference(node) { var type = getTypeFromTypeReference(node); - if (type !== unknownType) { + if (type !== errorType) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { return symbol.flags & 524288 && getSymbolLinks(symbol).typeParameters || @@ -38107,11 +38349,11 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 161 && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 162 && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } var type = getTypeFromTypeReference(node); - if (type !== unknownType) { + if (type !== errorType) { if (node.typeArguments) { ts.forEach(node.typeArguments, checkSourceElement); if (produceDiagnostics) { @@ -38121,7 +38363,7 @@ var ts; } } } - if (type.flags & 16 && getNodeLinks(node).resolvedSymbol.flags & 8) { + if (type.flags & 32 && getNodeLinks(node).resolvedSymbol.flags & 8) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -38160,19 +38402,19 @@ var ts; ts.forEach(node.types, checkSourceElement); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 1048576)) { + if (!(type.flags & 2097152)) { return type; } var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) { - if (accessNode.kind === 185 && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 186 && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } return type; } - if (getIndexInfoOfType(getApparentType(objectType), 1) && isTypeAssignableToKind(indexType, 84)) { + if (getIndexInfoOfType(getApparentType(objectType), 1) && isTypeAssignableToKind(indexType, 168)) { return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); @@ -38201,7 +38443,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 170 && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -38215,9 +38457,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 235 && - n.parent.kind !== 234 && - n.parent.kind !== 204 && + if (n.parent.kind !== 236 && + n.parent.kind !== 235 && + n.parent.kind !== 205 && n.flags & 4194304) { if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { flags |= 1; @@ -38297,7 +38539,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 153 || node.kind === 152) && + var reportError = (node.kind === 154 || node.kind === 153) && ts.hasModifier(node, 32) !== ts.hasModifier(subsequentNode, 32); if (reportError) { var diagnostic = ts.hasModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -38330,11 +38572,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304; - var inAmbientContextOrInterface = node.parent.kind === 235 || node.parent.kind === 165 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 236 || node.parent.kind === 166 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 233 || node.kind === 153 || node.kind === 152 || node.kind === 154) { + if (node.kind === 234 || node.kind === 154 || node.kind === 153 || node.kind === 155) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -38447,39 +38689,39 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 235: case 236: - case 296: - case 291: + case 237: + case 297: + case 292: return 2; - case 238: + case 239: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4 | 1 : 4; - case 234: - case 237: + case 235: + case 238: return 2 | 1; - case 273: + case 274: return 2 | 1 | 4; - case 248: + case 249: if (!ts.isEntityNameExpression(d.expression)) { return 1; } d = d.expression; - case 242: + case 243: + case 246: case 245: - case 244: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); return result_3; - case 231: - case 181: - case 233: - case 247: + case 232: + case 182: + case 234: + case 248: return 1; default: - ts.Debug.fail(ts.Debug.showSyntaxKind(d)); + return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); } } } @@ -38523,7 +38765,7 @@ var ts; return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2); } function checkAwaitedType(type, errorNode, diagnosticMessage) { - return getAwaitedType(type, errorNode, diagnosticMessage) || unknownType; + return getAwaitedType(type, errorNode, diagnosticMessage) || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage) { var typeAsAwaitable = type; @@ -38533,7 +38775,7 @@ var ts; if (isTypeAny(type)) { return typeAsAwaitable.awaitedTypeOfType = type; } - if (type.flags & 131072) { + if (type.flags & 262144) { var types = void 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -38563,7 +38805,8 @@ var ts; var thenFunction = getTypeOfPropertyOfType(type, "then"); if (thenFunction && getSignaturesOfType(thenFunction, 0).length > 0) { if (errorNode) { - ts.Debug.assert(!!diagnosticMessage); + if (!diagnosticMessage) + return ts.Debug.fail(); error(errorNode, diagnosticMessage); } return undefined; @@ -38574,49 +38817,49 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); var returnType = getTypeFromTypeNode(returnTypeNode); if (languageVersion >= 2) { - if (returnType === unknownType) { - return unknownType; + if (returnType === errorType) { + return errorType; } var globalPromiseType = getGlobalPromiseType(true); if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); - return unknownType; + return errorType; } } else { markTypeNodeAsReferenced(returnTypeNode); - if (returnType === unknownType) { - return unknownType; + if (returnType === errorType) { + return errorType; } var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode); if (promiseConstructorName === undefined) { error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); - return unknownType; + return errorType; } var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67216319, true); - var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; - if (promiseConstructorType === unknownType) { + var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; + if (promiseConstructorType === errorType) { if (promiseConstructorName.kind === 71 && 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 { error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); } - return unknownType; + return errorType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(true); if (globalPromiseConstructorLikeType === emptyObjectType) { error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); - return unknownType; + return errorType; } if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value)) { - return unknownType; + return errorType; } var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67216319); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); - return unknownType; + return errorType; } } return checkAwaitedType(returnType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -38631,26 +38874,28 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 234: + case 235: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 148: + case 149: expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); + errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 151: + case 152: expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); + errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 153: - case 155: + case 154: case 156: + case 157: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); break; + default: + return ts.Debug.fail(); } checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; }); } @@ -38679,12 +38924,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { + case 170: case 169: - case 168: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 172) { + while (typeNode.kind === 173) { typeNode = typeNode.type; } if (typeNode.kind === 131) { @@ -38709,9 +38954,9 @@ var ts; } } return commonEntityName; - case 172: + case 173: return getEntityNameForDecoratorMetadata(node.type); - case 161: + case 162: return node.typeName; } } @@ -38732,13 +38977,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 148) { + if (node.kind === 149) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 234: + case 235: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -38747,19 +38992,19 @@ var ts; } } break; - case 153: - case 155: + case 154: case 156: + case 157: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 151: + case 152: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 148: + case 149: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -38798,12 +39043,12 @@ var ts; return; } if (!containsArgumentsReference(decl)) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 145 ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 146 ? node.name.right : node.name)); } 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 === 145 ? 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 === 146 ? node.name.right : node.name)); } } } @@ -38832,7 +39077,7 @@ var ts; switch (node.kind) { case 71: return node; - case 184: + case 185: return node.name; default: return undefined; @@ -38842,7 +39087,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); - if (node.name && node.name.kind === 146) { + if (node.name && node.name.kind === 147) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { @@ -38858,7 +39103,7 @@ var ts; } } } - var body = node.kind === 152 ? undefined : node.body; + var body = node.kind === 153 ? undefined : node.body; checkSourceElement(body); var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if ((functionFlags & 1) === 0) { @@ -38891,41 +39136,41 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 234: - case 204: + case 235: + case 205: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 235: + case 236: checkUnusedTypeParameters(node, addDiagnostic); break; - case 273: - case 238: - case 212: - case 240: - case 219: + case 274: + case 239: + case 213: + case 241: case 220: case 221: + case 222: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 154: - case 191: - case 233: - case 192: - case 153: case 155: + case 192: + case 234: + case 193: + case 154: case 156: + case 157: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 152: - case 157: + case 153: case 158: - case 162: + case 159: case 163: - case 236: + case 164: + case 237: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -38935,15 +39180,8 @@ var ts; } function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; - if (isIdentifierThatStartsWithUnderScore(node)) { - var declaration_2 = ts.getRootDeclaration(node.parent); - if ((declaration_2.kind === 231 && ts.isForInOrOfStatement(declaration_2.parent.parent)) || - declaration_2.kind === 147) { - return; - } - } var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(0, ts.createDiagnosticForNodeSpan(ts.getSourceFileOfNode(declaration), declaration, node, message, name)); + addDiagnostic(0, ts.createDiagnosticForNode(node, message, name)); } function parameterNameStartsWithUnderscore(parameterName) { return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); @@ -38956,11 +39194,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 153: - case 151: - case 155: + case 154: + case 152: case 156: - if (member.kind === 156 && member.symbol.flags & 32768) { + case 157: + if (member.kind === 157 && member.symbol.flags & 32768) { break; } var symbol = getSymbolOfNode(member); @@ -38968,7 +39206,7 @@ var ts; addDiagnostic(0, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 154: + case 155: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) { @@ -38976,8 +39214,8 @@ var ts; } } break; - case 159: - case 211: + case 160: + case 212: break; default: ts.Debug.fail(); @@ -39014,6 +39252,7 @@ var ts; return; var unusedImports = ts.createMap(); var unusedDestructures = ts.createMap(); + var unusedVariables = ts.createMap(); nodeWithLocals.locals.forEach(function (local) { if (local.flags & 262144 ? !(local.flags & 3 && !(local.isReferenced & 3)) : local.isReferenced || local.exportSymbol) { return; @@ -39031,6 +39270,11 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } } + else if (ts.isVariableDeclaration(declaration)) { + if (!isIdentifierThatStartsWithUnderScore(declaration.name) || !ts.isForInOrOfStatement(declaration.parent.parent)) { + addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); + } + } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); if (parameter) { @@ -39048,49 +39292,76 @@ var ts; unusedImports.forEach(function (_a) { var importClause = _a[0], unuseds = _a[1]; var importDecl = importClause.parent; - if (forEachImportedDeclaration(importClause, function (d) { return !ts.contains(unuseds, d); })) { + var nDeclarations = (importClause.name ? 1 : 0) + + (importClause.namedBindings ? + (importClause.namedBindings.kind === 246 ? 1 : importClause.namedBindings.elements.length) + : 0); + if (nDeclarations === unuseds.length) { + addDiagnostic(0, unuseds.length === 1 + ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) + : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); + } + else { for (var _i = 0, unuseds_1 = unuseds; _i < unuseds_1.length; _i++) { var unused = unuseds_1[_i]; errorUnusedLocal(unused, ts.idText(unused.name), addDiagnostic); } } - else if (unuseds.length === 1) { - addDiagnostic(0, ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name))); - } - else { - addDiagnostic(0, ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); - } }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0; - if (!bindingPattern.elements.every(function (e) { return ts.contains(bindingElements, e); })) { + if (bindingPattern.elements.length === bindingElements.length) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 && bindingPattern.parent.parent.kind === 233) { + addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); + } + else { + addDiagnostic(kind, bindingElements.length === 1 + ? ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(ts.first(bindingElements).name, ts.isIdentifier))) + : ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused)); + } + } + else { for (var _i = 0, bindingElements_1 = bindingElements; _i < bindingElements_1.length; _i++) { var e = bindingElements_1[_i]; addDiagnostic(kind, ts.createDiagnosticForNode(e, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(e.name, ts.isIdentifier)))); } } - else if (bindingElements.length === 1) { - addDiagnostic(kind, ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(ts.first(bindingElements).name, ts.isIdentifier)))); + }); + unusedVariables.forEach(function (_a) { + var declarationList = _a[0], declarations = _a[1]; + if (declarationList.declarations.length === declarations.length) { + addDiagnostic(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 === 214 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { - addDiagnostic(kind, ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused)); + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var decl = declarations_5[_i]; + addDiagnostic(0, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(decl.name, ts.isIdentifier)))); + } } }); } + function bindingNameText(name) { + switch (name.kind) { + case 71: + return ts.idText(name); + case 181: + case 180: + return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); + default: + return ts.Debug.assertNever(name); + } + } function isImportedDeclaration(node) { - return node.kind === 244 || node.kind === 247 || node.kind === 245; + return node.kind === 245 || node.kind === 248 || node.kind === 246; } function importClauseFromImported(decl) { - return decl.kind === 244 ? decl : decl.kind === 245 ? decl.parent : decl.parent.parent; - } - function forEachImportedDeclaration(importClause, cb) { - var defaultName = importClause.name, namedBindings = importClause.namedBindings; - return (defaultName && cb(importClause)) || - namedBindings && (namedBindings.kind === 245 ? cb(namedBindings) : ts.forEach(namedBindings.elements, cb)); + return decl.kind === 245 ? decl : decl.kind === 246 ? decl.parent : decl.parent.parent; } function checkBlock(node) { - if (node.kind === 212) { + if (node.kind === 213) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -39119,19 +39390,19 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 151 || - node.kind === 150 || + if (node.kind === 152 || + node.kind === 151 || + node.kind === 154 || node.kind === 153 || - node.kind === 152 || - node.kind === 155 || - node.kind === 156) { + node.kind === 156 || + node.kind === 157) { return false; } if (node.flags & 4194304) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 148 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 149 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -39148,6 +39419,7 @@ var ts; } return true; } + return false; }); } function checkIfNewTargetIsCapturedInEnclosingScope(node) { @@ -39162,6 +39434,7 @@ var ts; } return true; } + return false; }); } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { @@ -39175,7 +39448,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 273 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 274 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -39187,7 +39460,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 273 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 274 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(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)); } } @@ -39195,7 +39468,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 231 && !node.initializer) { + if (node.kind === 232 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -39207,15 +39480,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 232); - var container = varDeclList.parent.kind === 213 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233); + var container = varDeclList.parent.kind === 214 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 212 && ts.isFunctionLike(container.parent) || + (container.kind === 213 && ts.isFunctionLike(container.parent) || + container.kind === 240 || container.kind === 239 || - container.kind === 238 || - container.kind === 273); + container.kind === 274); 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); @@ -39225,7 +39498,7 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 148) { + if (ts.getRootDeclaration(node).kind !== 149) { return; } var func = ts.getContainingFunction(node); @@ -39234,7 +39507,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 184) { + if (n.kind === 185) { return visit(n.expression); } else if (n.kind === 71) { @@ -39248,8 +39521,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 148 || - symbol.valueDeclaration.kind === 181) { + if (symbol.valueDeclaration.kind === 149 || + symbol.valueDeclaration.kind === 182) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -39258,7 +39531,7 @@ var ts; return "quit"; } return ts.isFunctionLike(current.parent) || - (current.parent.kind === 151 && + (current.parent.kind === 152 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)); })) { @@ -39284,17 +39557,17 @@ var ts; if (!node.name) { return; } - if (node.name.kind === 146) { + if (node.name.kind === 147) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 181) { - if (node.parent.kind === 179 && languageVersion < 6) { + if (node.kind === 182) { + if (node.parent.kind === 180 && languageVersion < 6) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 146) { + if (node.propertyName && node.propertyName.kind === 147) { checkComputedPropertyName(node.propertyName); } var parent = node.parent.parent; @@ -39309,17 +39582,17 @@ var ts; } } if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 180 && languageVersion < 2 && compilerOptions.downlevelIteration) { + if (node.name.kind === 181 && languageVersion < 2 && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512); } ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 148 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 149 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 220) { + if (node.initializer && node.parent.parent.kind !== 221) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); @@ -39334,15 +39607,15 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfSymbol(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 220) { - var initializer = ts.isInJavaScriptFile(node) && ts.getDeclaredJavascriptInitializer(node) || node.initializer; + var initializer = ts.getEffectiveInitializer(node); + if (initializer && node.parent.parent.kind !== 221) { checkTypeAssignableTo(checkExpressionCached(initializer), type, node, undefined); checkParameterInitializer(node); } } else { var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); - if (type !== unknownType && declarationType !== unknownType && + if (type !== errorType && declarationType !== errorType && !isTypeIdenticalTo(type, declarationType) && !(symbol.flags & 67108864)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); @@ -39355,9 +39628,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 151 && node.kind !== 150) { + if (node.kind !== 152 && node.kind !== 151) { checkExportsOnMergedDeclarations(node); - if (node.kind === 231 || node.kind === 181) { + if (node.kind === 232 || node.kind === 182) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -39366,14 +39639,14 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 151 || nextDeclaration.kind === 150 + var message = nextDeclaration.kind === 152 || nextDeclaration.kind === 151 ? 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; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 148 && right.kind === 231) || - (left.kind === 231 && right.kind === 148)) { + if ((left.kind === 149 && right.kind === 232) || + (left.kind === 232 && right.kind === 149)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -39408,7 +39681,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 214) { + if (node.thenStatement.kind === 215) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -39425,12 +39698,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 232) { + if (node.initializer && node.initializer.kind === 233) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 232) { + if (node.initializer.kind === 233) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -39457,14 +39730,14 @@ var ts; else if (compilerOptions.downlevelIteration && languageVersion < 2) { checkExternalEmitHelpers(node, 256); } - if (node.initializer.kind === 232) { + if (node.initializer.kind === 233) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); - if (varExpr.kind === 182 || varExpr.kind === 183) { - checkDestructuringAssignment(varExpr, iteratedType || unknownType); + if (varExpr.kind === 183 || varExpr.kind === 184) { + checkDestructuringAssignment(varExpr, iteratedType || errorType); } else { var leftType = checkExpression(varExpr); @@ -39482,7 +39755,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 232) { + if (node.initializer.kind === 233) { 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); @@ -39492,7 +39765,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 182 || varExpr.kind === 183) { + if (varExpr.kind === 183 || varExpr.kind === 184) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -39502,7 +39775,7 @@ var ts; checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } - if (rightType === neverType || !isTypeAssignableToKind(rightType, 134217728 | 7372800)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 16777216 | 14745600)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -39544,14 +39817,14 @@ var ts; var reportedError = false; var hasStringConstituent = false; if (allowStringInput) { - if (arrayType.flags & 131072) { + if (arrayType.flags & 262144) { var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 34); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 68); }); if (filteredTypes !== arrayTypes) { arrayType = getUnionType(filteredTypes, 2); } } - else if (arrayType.flags & 34) { + else if (arrayType.flags & 68) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; @@ -39562,7 +39835,7 @@ var ts; reportedError = true; } } - if (arrayType.flags & 16384) { + if (arrayType.flags & 32768) { return stringType; } } @@ -39587,7 +39860,7 @@ var ts; } var arrayElementType = getIndexTypeOfType(arrayType, 1); if (hasStringConstituent && arrayElementType) { - if (arrayElementType.flags & 34) { + if (arrayElementType.flags & 68) { return stringType; } return getUnionType([arrayElementType, stringType], 2); @@ -39620,11 +39893,11 @@ var ts; } } var asyncMethodType = allowAsyncIterables && getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); - var methodType = asyncMethodType || (allowSyncIterables && getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator"))); + var methodType = asyncMethodType || (allowSyncIterables ? getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")) : undefined); if (isTypeAny(methodType)) { return undefined; } - var signatures = methodType && getSignaturesOfType(methodType, 0); + var signatures = methodType ? getSignaturesOfType(methodType, 0) : undefined; if (!ts.some(signatures)) { if (errorNode) { reportTypeNotIterableError(errorNode, type, allowAsyncIterables); @@ -39711,14 +39984,14 @@ var ts; checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return node.kind === 155 - && ts.getEffectiveSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 156)) !== undefined; + return node.kind === 156 + && ts.getEffectiveSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 157)) !== undefined; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = (ts.getFunctionFlags(func) & 3) === 2 ? getPromisedTypeOfPromise(returnType) : returnType; - return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 2048 | 1); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 4096 | 3); } function checkReturnStatement(node) { if (checkGrammarStatementInAmbientContext(node)) { @@ -39733,17 +40006,17 @@ var ts; var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(func); var isGenerator = functionFlags & 1; - if (strictNullChecks || node.expression || returnType.flags & 16384) { + if (strictNullChecks || node.expression || returnType.flags & 32768) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; if (isGenerator) { return; } - else if (func.kind === 156) { + else if (func.kind === 157) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 154) { + else if (func.kind === 155) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -39761,7 +40034,7 @@ var ts; } } } - else if (func.kind !== 154 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { + else if (func.kind !== 155 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -39786,7 +40059,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 266 && !hasDuplicateDefaultClause) { + if (clause.kind === 267 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -39798,7 +40071,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 265) { + if (produceDiagnostics && clause.kind === 266) { var caseType = checkExpression(clause.expression); var caseIsLiteral = isLiteralType(caseType); var comparedExpressionType = expressionType; @@ -39822,10 +40095,11 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 227 && current.label.escapedText === node.label.escapedText) { + if (current.kind === 228 && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } + return false; }); } checkSourceElement(node.statement); @@ -39881,8 +40155,8 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (ts.getObjectFlags(type) & 1 && ts.isClassLike(type.symbol.valueDeclaration)) { - var classDeclaration = type.symbol.valueDeclaration; + 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.hasModifier(member, 32) && hasNonBindableDynamicName(member)) { @@ -39915,8 +40189,8 @@ var ts; } var errorNode; if (propDeclaration && - (propDeclaration.kind === 199 || - ts.getNameOfDeclaration(propDeclaration).kind === 146 || + (propDeclaration.kind === 200 || + ts.getNameOfDeclaration(propDeclaration).kind === 147 || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -39938,6 +40212,7 @@ var ts; function checkTypeNameIsReserved(name, message) { switch (name.escapedText) { case "any": + case "unknown": case "number": case "boolean": case "string": @@ -39947,6 +40222,12 @@ var ts; error(name, message, name.escapedText); } } + function checkClassNameCollisionWithObject(name) { + if (languageVersion === 1 && name.escapedText === "Object" + && moduleKind !== ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.ESNext) { + error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); + } + } function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { var seenDefault = false; @@ -39983,8 +40264,8 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { var name = symbolToString(symbol); - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } @@ -39993,8 +40274,8 @@ var ts; function areTypeParametersIdentical(declarations, targetParameters) { var maxTypeArgumentCount = ts.length(targetParameters); var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters); - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration); var numTypeParameters = sourceParameters.length; if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { @@ -40046,6 +40327,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + if (!(node.flags & 4194304)) { + checkClassNameCollisionWithObject(node.name); + } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); checkExportsOnMergedDeclarations(node); @@ -40084,10 +40368,10 @@ var ts; issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); } checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseConstructorType.flags & 1081344 && !isMixinConstructorType(staticType)) { + if (baseConstructorType.flags & 2162688 && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 1081344)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 2162688)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType_1; })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); @@ -40106,7 +40390,7 @@ var ts; checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); - if (t !== unknownType) { + if (t !== errorType) { if (isValidBaseType(t)) { var genericDiag = t.symbol && t.symbol.flags & 32 ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : @@ -40172,7 +40456,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 234 || d.kind === 235; + return d.kind === 235 || d.kind === 236; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -40190,7 +40474,7 @@ var ts; if (derived === base) { var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) { - if (derivedClassDecl.kind === 204) { + if (derivedClassDecl.kind === 205) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -40203,7 +40487,7 @@ var ts; if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) { continue; } - if (isPrototypeProperty(base) && isPrototypeProperty(derived) || base.flags & 98308 && derived.flags & 98308) { + if (isPrototypeProperty(base) || base.flags & 98308 && derived.flags & 98308) { continue; } var errorMessage = void 0; @@ -40269,7 +40553,7 @@ var ts; var propName = member.name; if (ts.isIdentifier(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 1 || getFalsyFlags(type) & 4096)) { + if (!(type.flags & 3 || getFalsyFlags(type) & 8192)) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -40279,7 +40563,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 151 && + return node.kind === 152 && !ts.hasModifier(node, 32 | 128) && !node.exclamationToken && !node.initializer; @@ -40288,7 +40572,7 @@ var ts; var reference = ts.createPropertyAccess(ts.createThis(), propName); reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 4096); + return !(getFalsyFlags(flowType) & 8192); } function checkInterfaceDeclaration(node) { if (!checkGrammarDecoratorsAndModifiers(node)) @@ -40299,7 +40583,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 235); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -40395,7 +40679,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 197: + case 198: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -40405,7 +40689,7 @@ var ts; } } break; - case 199: + case 200: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -40433,18 +40717,22 @@ var ts; case 8: checkGrammarNumericLiteral(expr); return +expr.text; - case 190: + case 191: return evaluate(expr.expression); case 71: - return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), expr.escapedText); + var identifier = expr; + if (isInfinityOrNaNString(identifier.escapedText)) { + return +(identifier.escapedText); + } + return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); + case 186: case 185: - case 184: 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 === 184) { + if (ex.kind === 185) { name = ex.name.escapedText; } else { @@ -40476,8 +40764,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 || - node.kind === 184 && isConstantMemberAccess(node.expression) || - node.kind === 185 && isConstantMemberAccess(node.expression) && + node.kind === 185 && isConstantMemberAccess(node.expression) || + node.kind === 186 && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9; } function checkEnumDeclaration(node) { @@ -40506,7 +40794,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 237) { + if (declaration.kind !== 238) { return false; } var enumDeclaration = declaration; @@ -40527,10 +40815,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; - if ((declaration.kind === 234 || - (declaration.kind === 233 && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 235 || + (declaration.kind === 234 && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304)) { return declaration; } @@ -40578,7 +40866,7 @@ var ts; if (symbol.flags & 512 && symbol.declarations.length > 1 && !inAmbientContext - && isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { + && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -40588,7 +40876,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, 234); + var mergedClass = ts.getDeclarationOfKind(symbol, 235); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -40631,22 +40919,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 213: + case 214: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 248: case 249: + case 250: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 242: case 243: + case 244: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 181: - case 231: + case 182: + case 232: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -40655,12 +40943,12 @@ var ts; } break; } - case 234: - case 237: - case 233: case 235: case 238: + case 234: case 236: + case 239: + case 237: if (isGlobalAugmentation) { return; } @@ -40678,12 +40966,12 @@ var ts; switch (node.kind) { case 71: return node; - case 145: + case 146: do { node = node.left; } while (node.kind !== 71); return node; - case 184: + case 185: do { node = node.expression; } while (node.kind !== 71); @@ -40692,16 +40980,16 @@ var ts; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (ts.nodeIsMissing(moduleName)) { + if (!moduleName || ts.nodeIsMissing(moduleName)) { return false; } if (!ts.isStringLiteral(moduleName)) { error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 239 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 273 && !inAmbientExternalModule) { - error(moduleName, node.kind === 249 ? + var inAmbientExternalModule = node.parent.kind === 240 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 274 && !inAmbientExternalModule) { + error(moduleName, node.kind === 250 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -40722,13 +41010,13 @@ var ts; (symbol.flags & 67901928 ? 67901928 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 251 ? + var message = node.kind === 252 ? 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 === 251 + && node.kind === 252 && !(target.flags & 67216319) && !(node.flags & 4194304)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -40754,7 +41042,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 245) { + if (importClause.namedBindings.kind === 246) { checkImportBinding(importClause.namedBindings); } else { @@ -40777,7 +41065,7 @@ var ts; if (ts.hasModifier(node, 1)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 253) { + if (node.moduleReference.kind !== 254) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319) { @@ -40808,10 +41096,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 239 && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 239 && + var inAmbientExternalModule = node.parent.kind === 240 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 && !node.moduleSpecifier && node.flags & 4194304; - if (node.parent.kind !== 273 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 274 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -40827,7 +41115,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 273 || node.parent.kind === 239 || node.parent.kind === 238; + var isInAppropriateContext = node.parent.kind === 274 || node.parent.kind === 240 || node.parent.kind === 239; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -40853,8 +41141,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 273 ? node.parent : node.parent.parent; - if (container.kind === 238 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 274 ? node.parent : node.parent.parent; + if (container.kind === 239 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -40917,8 +41205,8 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; + 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))); } @@ -40933,165 +41221,165 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 233 && declaration.kind !== 153) || + return (declaration.kind !== 234 && declaration.kind !== 154) || !!declaration.body; } function checkSourceElement(node) { if (!node) { return; } - if (ts.isInJavaScriptFile(node) && node.jsDoc) { - for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { - var tags = _a[_i].tags; - ts.forEach(tags, checkSourceElement); - } + if (ts.isInJavaScriptFile(node)) { + ts.forEach(node.jsDoc, function (_a) { + var tags = _a.tags; + return ts.forEach(tags, checkSourceElement); + }); } var kind = node.kind; if (cancellationToken) { switch (kind) { - case 238: - case 234: + case 239: case 235: - case 233: + case 236: + case 234: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 147: - return checkTypeParameter(node); case 148: + return checkTypeParameter(node); + case 149: return checkParameter(node); + case 152: case 151: - case 150: return checkPropertyDeclaration(node); - case 162: case 163: - case 157: + case 164: case 158: case 159: - return checkSignatureDeclaration(node); - case 153: - case 152: - return checkMethodDeclaration(node); - case 154: - return checkConstructorDeclaration(node); - case 155: - case 156: - return checkAccessorDeclaration(node); - case 161: - return checkTypeReferenceNode(node); case 160: + return checkSignatureDeclaration(node); + case 154: + case 153: + return checkMethodDeclaration(node); + case 155: + return checkConstructorDeclaration(node); + case 156: + case 157: + return checkAccessorDeclaration(node); + case 162: + return checkTypeReferenceNode(node); + case 161: return checkTypePredicate(node); - case 164: - return checkTypeQuery(node); case 165: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 166: - return checkArrayType(node); + return checkTypeLiteral(node); case 167: - return checkTupleType(node); + return checkArrayType(node); case 168: + return checkTupleType(node); case 169: - return checkUnionOrIntersectionType(node); - case 172: - return checkSourceElement(node.type); - case 174: - return checkTypeOperator(node); case 170: - return checkConditionalType(node); + return checkUnionOrIntersectionType(node); + case 173: + return checkSourceElement(node.type); + case 175: + return checkTypeOperator(node); case 171: + return checkConditionalType(node); + case 172: return checkInferType(node); - case 178: + case 179: return checkImportType(node); - case 289: + case 290: return checkJSDocAugmentsTag(node); - case 296: - case 291: - return checkJSDocTypeAliasTag(node); + case 297: case 292: + return checkJSDocTypeAliasTag(node); + case 293: return checkJSDocParameterTag(node); - case 283: + case 284: checkSignatureDeclaration(node); + case 282: case 281: - case 280: - case 278: case 279: - case 286: + case 280: + case 287: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 284: + case 285: checkJSDocVariadicType(node); return; - case 277: + case 278: return checkSourceElement(node.type); - case 175: - return checkIndexedAccessType(node); case 176: + return checkIndexedAccessType(node); + case 177: return checkMappedType(node); - case 233: - return checkFunctionDeclaration(node); - case 212: - case 239: - return checkBlock(node); - case 213: - return checkVariableStatement(node); - case 215: - return checkExpressionStatement(node); - case 216: - return checkIfStatement(node); - case 217: - return checkDoStatement(node); - case 218: - return checkWhileStatement(node); - case 219: - return checkForStatement(node); - case 220: - return checkForInStatement(node); - case 221: - return checkForOfStatement(node); - case 222: - case 223: - return checkBreakOrContinueStatement(node); - case 224: - return checkReturnStatement(node); - case 225: - return checkWithStatement(node); - case 226: - return checkSwitchStatement(node); - case 227: - return checkLabeledStatement(node); - case 228: - return checkThrowStatement(node); - case 229: - return checkTryStatement(node); - case 231: - return checkVariableDeclaration(node); - case 181: - return checkBindingElement(node); case 234: - return checkClassDeclaration(node); - case 235: - return checkInterfaceDeclaration(node); - case 236: - return checkTypeAliasDeclaration(node); - case 237: - return checkEnumDeclaration(node); - case 238: - return checkModuleDeclaration(node); - case 243: - return checkImportDeclaration(node); - case 242: - return checkImportEqualsDeclaration(node); - case 249: - return checkExportDeclaration(node); - case 248: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 213: + case 240: + return checkBlock(node); case 214: + return checkVariableStatement(node); + case 216: + return checkExpressionStatement(node); + case 217: + return checkIfStatement(node); + case 218: + return checkDoStatement(node); + case 219: + return checkWhileStatement(node); + case 220: + return checkForStatement(node); + case 221: + return checkForInStatement(node); + case 222: + return checkForOfStatement(node); + case 223: + case 224: + return checkBreakOrContinueStatement(node); + case 225: + return checkReturnStatement(node); + case 226: + return checkWithStatement(node); + case 227: + return checkSwitchStatement(node); + case 228: + return checkLabeledStatement(node); + case 229: + return checkThrowStatement(node); case 230: + return checkTryStatement(node); + case 232: + return checkVariableDeclaration(node); + case 182: + return checkBindingElement(node); + case 235: + return checkClassDeclaration(node); + case 236: + return checkInterfaceDeclaration(node); + case 237: + return checkTypeAliasDeclaration(node); + case 238: + return checkEnumDeclaration(node); + case 239: + return checkModuleDeclaration(node); + case 244: + return checkImportDeclaration(node); + case 243: + return checkImportEqualsDeclaration(node); + case 250: + return checkExportDeclaration(node); + case 249: + return checkExportAssignment(node); + case 215: + case 231: checkGrammarStatementInAmbientContext(node); return; - case 252: + case 253: return checkMissingDeclaration(node); } } @@ -41113,7 +41401,7 @@ var ts; if (!ts.isJSDocTypeExpression(parent)) { error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature); } - var paramTag = parent.parent; + var paramTag = node.parent.parent; if (!ts.isJSDocParameterTag(paramTag)) { error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature); return; @@ -41130,8 +41418,8 @@ var ts; function getTypeFromJSDocVariadicType(node) { var type = getTypeFromTypeNode(node.type); var parent = node.parent; - var paramTag = parent.parent; - if (ts.isJSDocTypeExpression(parent) && ts.isJSDocParameterTag(paramTag)) { + 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); @@ -41153,20 +41441,20 @@ var ts; } } function checkDeferredNodes() { - for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { - var node = deferredNodes_1[_i]; + for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { + var node = _a[_i]; switch (node.kind) { - case 191: case 192: + case 193: + case 154: case 153: - case 152: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 155: case 156: + case 157: checkAccessorDeclaration(node); break; - case 204: + case 205: checkClassExpressionDeferred(node); break; } @@ -41181,9 +41469,9 @@ var ts; function unusedIsError(kind) { switch (kind) { case 0: - return compilerOptions.noUnusedLocals; + return !!compilerOptions.noUnusedLocals; case 1: - return compilerOptions.noUnusedParameters; + return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); } @@ -41280,24 +41568,24 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 238: + case 239: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475); break; - case 237: + case 238: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 204: + case 205: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 234: case 235: + case 236: if (!isStatic) { copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928); } break; - case 191: + case 192: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -41335,27 +41623,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 147: - case 234: + case 148: case 235: case 236: case 237: + case 238: return true; + default: + return false; } } - function isTypeReferenceIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 145) { + function isTypeReferenceIdentifier(node) { + while (node.parent.kind === 146) { node = node.parent; } - return node.parent && node.parent.kind === 161; + return node.parent.kind === 162; } - function isHeritageClauseElementIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 184) { + function isHeritageClauseElementIdentifier(node) { + while (node.parent.kind === 185) { node = node.parent; } - return node.parent && node.parent.kind === 206; + return node.parent.kind === 207; } function forEachEnclosingClass(node, callback) { var result; @@ -41383,14 +41671,14 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 145) { + while (nodeOnRightSide.parent.kind === 146) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 242) { - return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; + if (nodeOnRightSide.parent.kind === 243) { + return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 248) { - return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; + if (nodeOnRightSide.parent.kind === 249) { + return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; } @@ -41415,7 +41703,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 178 && parent.qualifier === node) { + if (parent && parent.kind === 179 && parent.qualifier === node) { return parent; } return undefined; @@ -41425,21 +41713,21 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 184 && + entityName.parent.kind === 185 && entityName.parent === entityName.parent.parent.left) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 248 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 249 && ts.isEntityNameExpression(entityName)) { var success = resolveEntityName(entityName, 67216319 | 67901928 | 1920 | 2097152, true); if (success && success !== unknownSymbol) { return success; } } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 242); + var importEqualsDeclaration = ts.getAncestor(entityName, 243); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -41456,7 +41744,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 206) { + if (entityName.parent.kind === 207) { meaning = 67901928; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 67216319; @@ -41471,10 +41759,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 292) { + if (entityName.parent.kind === 293) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 147 && entityName.parent.parent.kind === 295) { + if (entityName.parent.kind === 148 && entityName.parent.parent.kind === 296) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -41490,12 +41778,12 @@ var ts; } return resolveEntityName(entityName, 67216319, false, true); } - else if (entityName.kind === 184 || entityName.kind === 145) { + else if (entityName.kind === 185 || entityName.kind === 146) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 184) { + if (entityName.kind === 185) { checkPropertyAccessExpression(entityName); } else { @@ -41505,38 +41793,40 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 161 ? 67901928 : 1920; + var meaning = entityName.parent.kind === 162 ? 67901928 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 261) { + else if (entityName.parent.kind === 262) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 160) { + if (entityName.parent.kind === 161) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 273) { + if (node.kind === 274) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } + var parent = node.parent; + var grandParent = parent.parent; if (node.flags & 8388608) { return undefined; } if (isDeclarationNameOrImportPropertyName(node)) { - return getSymbolOfNode(node.parent); + return getSymbolOfNode(parent); } else if (ts.isLiteralComputedPropertyDeclarationName(node)) { - return getSymbolOfNode(node.parent.parent); + return getSymbolOfNode(parent.parent); } if (node.kind === 71) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 181 && - node.parent.parent.kind === 179 && - node === node.parent.propertyName) { - var typeOfPattern = getTypeOfNode(node.parent.parent); + else if (parent.kind === 182 && + grandParent.kind === 180 && + node === parent.propertyName) { + var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); if (propertyDeclaration) { return propertyDeclaration; @@ -41545,8 +41835,8 @@ var ts; } switch (node.kind) { case 71: - case 184: - case 145: + case 185: + case 146: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99: var container = ts.getThisContainer(node, false); @@ -41559,43 +41849,43 @@ var ts; if (ts.isInExpressionContext(node)) { return checkExpression(node).symbol; } - case 173: + case 174: return getTypeFromThisTypeNode(node).symbol; case 97: return checkExpression(node).symbol; case 123: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 154) { + if (constructorDeclaration && constructorDeclaration.kind === 155) { return constructorDeclaration.parent.symbol; } return undefined; case 9: case 13: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 243 || node.parent.kind === 249) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 244 || node.parent.kind === 250) && node.parent.moduleSpecifier === node) || ((ts.isInJavaScriptFile(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); } case 8: - var objectType = ts.isElementAccessExpression(node.parent) - ? node.parent.argumentExpression === node ? getTypeOfExpression(node.parent.expression) : undefined - : ts.isLiteralTypeNode(node.parent) && ts.isIndexedAccessTypeNode(node.parent.parent) - ? getTypeFromTypeNode(node.parent.parent.objectType) + var objectType = ts.isElementAccessExpression(parent) + ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined + : ts.isLiteralTypeNode(parent) && ts.isIndexedAccessTypeNode(grandParent) + ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); case 79: case 89: case 36: return getSymbolOfNode(node.parent); - case 178: + case 179: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 270) { + if (location && location.kind === 271) { return resolveEntityName(location.name, 67216319 | 2097152); } return undefined; @@ -41607,7 +41897,7 @@ var ts; } function getTypeOfNode(node) { if (node.flags & 8388608) { - return unknownType; + return errorType; } if (ts.isPartOfTypeNode(node)) { var typeFromTypeNode = getTypeFromTypeNode(node); @@ -41650,29 +41940,29 @@ var ts; var symbol = getSymbolAtLocation(node); if (symbol) { var declaredType = getDeclaredTypeOfSymbol(symbol); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); + return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol); } } - return unknownType; + return errorType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 183 || expr.kind === 182); - if (expr.parent.kind === 221) { + ts.Debug.assert(expr.kind === 184 || expr.kind === 183); + if (expr.parent.kind === 222) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); - return checkDestructuringAssignment(expr, iteratedType || unknownType); + return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 199) { + if (expr.parent.kind === 200) { var iteratedType = getTypeOfExpression(expr.parent.right); - return checkDestructuringAssignment(expr, iteratedType || unknownType); + return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 269) { + if (expr.parent.kind === 270) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); - return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 182); + ts.Debug.assert(expr.parent.kind === 183); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); - var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false, false) || unknownType; - return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || unknownType); + var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, false, false) || errorType; + return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || errorType); } function getPropertySymbolOfDestructuringAssignment(location) { var typeOfObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(location.parent.parent); @@ -41729,11 +42019,11 @@ var ts; } return target; } - function isArgumentsLocalBinding(node) { - if (!ts.isGeneratedIdentifier(node)) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function isArgumentsLocalBinding(nodeIn) { + if (!ts.isGeneratedIdentifier(nodeIn)) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 184 && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 185 && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -41759,11 +42049,10 @@ var ts; } } function isNameOfModuleOrEnumDeclaration(node) { - var parent = node.parent; - return parent && ts.isModuleOrEnumDeclaration(parent) && node === parent.name; + return ts.isModuleOrEnumDeclaration(node.parent) && node === node.parent.name; } - function getReferencedExportContainer(node, prefixLocals) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedExportContainer(nodeIn, prefixLocals) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node, isNameOfModuleOrEnumDeclaration(node)); if (symbol) { @@ -41776,7 +42065,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 273) { + if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 274) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -41787,8 +42076,8 @@ var ts; } } } - function getReferencedImportDeclaration(node) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedImportDeclaration(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node); if (isNonLocalAlias(symbol, 67216319)) { @@ -41810,7 +42099,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 212 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 213 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -41822,9 +42111,9 @@ var ts; } return false; } - function getReferencedDeclarationWithCollidingName(node) { - if (!ts.isGeneratedIdentifier(node)) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedDeclarationWithCollidingName(nodeIn) { + if (!ts.isGeneratedIdentifier(nodeIn)) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node); if (symbol && isSymbolOfDeclarationWithCollidingName(symbol)) { @@ -41834,8 +42123,8 @@ var ts; } return undefined; } - function isDeclarationWithCollidingName(node) { - node = ts.getParseTreeNode(node, ts.isDeclaration); + function isDeclarationWithCollidingName(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); if (node) { var symbol = getSymbolOfNode(node); if (symbol) { @@ -41846,16 +42135,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 242: - case 244: + case 243: case 245: - case 247: - case 251: - return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 249: - var exportClause = node.exportClause; - return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); + case 246: case 248: + case 252: + return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); + case 250: + var exportClause = node.exportClause; + return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); + case 249: return node.expression && node.expression.kind === 71 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -41863,9 +42152,9 @@ var ts; } return false; } - function isTopLevelValueImportEqualsWithEntityName(node) { - node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 273 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + function isTopLevelValueImportEqualsWithEntityName(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); + if (node === undefined || node.parent.kind !== 274 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -41876,11 +42165,11 @@ var ts; if (target === unknownSymbol) { return true; } - return target.flags & 67216319 && + return !!(target.flags & 67216319) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { - return isConstEnumSymbol(s) || s.constEnumOnlyModule; + return isConstEnumSymbol(s) || !!s.constEnumOnlyModule; } function isReferencedAliasDeclaration(node, checkChildren) { if (ts.isAliasSymbolDeclaration(node)) { @@ -41894,7 +42183,7 @@ var ts; } } if (checkChildren) { - return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); + return !!ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); } return false; } @@ -41910,10 +42199,10 @@ var ts; return false; } function isRequiredInitializedParameter(parameter) { - return strictNullChecks && + return !!strictNullChecks && !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && - parameter.initializer && + !!parameter.initializer && !ts.hasModifier(parameter, 92); } function isOptionalUninitializedParameterProperty(parameter) { @@ -41923,7 +42212,7 @@ var ts; ts.hasModifier(parameter, 92); } function getNodeCheckFlags(node) { - return getNodeLinks(node).flags; + return getNodeLinks(node).flags || 0; } function getEnumMemberValue(node) { computeEnumMemberValues(node.parent); @@ -41931,15 +42220,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 272: - case 184: + case 273: case 185: + case 186: return true; } return false; } function getConstantValue(node) { - if (node.kind === 272) { + if (node.kind === 273) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -41951,10 +42240,10 @@ var ts; return undefined; } function isFunctionType(type) { - return type.flags & 65536 && getSignaturesOfType(type, 0).length > 0; + return !!(type.flags & 131072) && getSignaturesOfType(type, 0).length > 0; } - function getTypeReferenceSerializationKind(typeName, location) { - typeName = ts.getParseTreeNode(typeName, ts.isEntityName); + function getTypeReferenceSerializationKind(typeNameIn, location) { + var typeName = ts.getParseTreeNode(typeNameIn, ts.isEntityName); if (!typeName) return ts.TypeReferenceSerializationKind.Unknown; if (location) { @@ -41975,31 +42264,31 @@ var ts; } } if (!typeSymbol) { - return ts.TypeReferenceSerializationKind.ObjectType; - } - var type = getDeclaredTypeOfSymbol(typeSymbol); - if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 1) { + var type = getDeclaredTypeOfSymbol(typeSymbol); + if (type === errorType) { + return ts.TypeReferenceSerializationKind.Unknown; + } + else if (type.flags & 3) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 2048 | 12288 | 16384)) { + else if (isTypeAssignableToKind(type, 4096 | 24576 | 32768)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 136)) { + else if (isTypeAssignableToKind(type, 272)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 84)) { + else if (isTypeAssignableToKind(type, 168)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 34)) { + else if (isTypeAssignableToKind(type, 68)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 1536)) { + else if (isTypeAssignableToKind(type, 3072)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -42012,16 +42301,16 @@ var ts; return ts.TypeReferenceSerializationKind.ObjectType; } } - function createTypeOfDeclaration(declaration, enclosingDeclaration, flags, tracker, addUndefined) { - declaration = ts.getParseTreeNode(declaration, ts.isVariableLikeOrAccessor); + function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { + var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { return ts.createToken(119); } var symbol = getSymbolOfNode(declaration); var type = symbol && !(symbol.flags & (2048 | 131072)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) - : unknownType; - if (type.flags & 1024 && + : errorType; + if (type.flags & 2048 && type.symbol === symbol) { flags |= 1048576; } @@ -42030,16 +42319,16 @@ var ts; } return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker); } - function createReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, tracker) { - signatureDeclaration = ts.getParseTreeNode(signatureDeclaration, ts.isFunctionLike); + function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { + var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { return ts.createToken(119); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024, tracker); } - function createTypeOfExpression(expr, enclosingDeclaration, flags, tracker) { - expr = ts.getParseTreeNode(expr, ts.isExpression); + function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { + var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { return ts.createToken(119); } @@ -42063,9 +42352,9 @@ var ts; } return resolveName(location, reference.escapedText, 67216319 | 1048576 | 2097152, undefined, undefined, true); } - function getReferencedValueDeclaration(reference) { - if (!ts.isGeneratedIdentifier(reference)) { - reference = ts.getParseTreeNode(reference, ts.isIdentifier); + function getReferencedValueDeclaration(referenceIn) { + if (!ts.isGeneratedIdentifier(referenceIn)) { + var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier); if (reference) { var symbol = getReferencedValueSymbol(reference); if (symbol) { @@ -42078,7 +42367,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 && type.flags & 8388608); + return !!(type.flags & 192 && type.flags & 33554432); } return false; } @@ -42118,7 +42407,7 @@ var ts; }, getNodeCheckFlags: function (node) { node = ts.getParseTreeNode(node); - return node ? getNodeCheckFlags(node) : undefined; + return node ? getNodeCheckFlags(node) : 0; }, isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, @@ -42131,8 +42420,8 @@ var ts; createLiteralConstValue: createLiteralConstValue, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, - getConstantValue: function (node) { - node = ts.getParseTreeNode(node, canHaveConstantValue); + getConstantValue: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue); return node ? getConstantValue(node) : undefined; }, collectLinkedAliases: collectLinkedAliases, @@ -42145,20 +42434,20 @@ var ts; getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName, getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol, isLiteralConstDeclaration: isLiteralConstDeclaration, - isLateBound: function (node) { - node = ts.getParseTreeNode(node, ts.isDeclaration); + isLateBound: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); return !!(symbol && ts.getCheckFlags(symbol) & 1024); }, getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); - var otherKind = accessor.kind === 156 ? 155 : 156; + var otherKind = accessor.kind === 157 ? 156 : 157; 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 === 156 ? accessor : otherAccessor; - var getAccessor = accessor.kind === 155 ? accessor : otherAccessor; + var setAccessor = accessor.kind === 157 ? accessor : otherAccessor; + var getAccessor = accessor.kind === 156 ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -42168,14 +42457,14 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 206 && node.parent.parent && node.parent.parent.kind === 267; + return node.parent && node.parent.kind === 207 && node.parent.parent && node.parent.parent.kind === 268; } function getTypeReferenceDirectivesForEntityName(node) { if (!fileToDirective) { return undefined; } var meaning = 67901928 | 1920; - if ((node.kind === 71 && isInTypeQuery(node)) || (node.kind === 184 && !isInHeritageClause(node))) { + if ((node.kind === 71 && isInTypeQuery(node)) || (node.kind === 185 && !isInHeritageClause(node))) { meaning = 67216319 | 1048576; } var symbol = resolveEntityName(node, meaning, true); @@ -42218,7 +42507,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 273 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 274 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -42232,12 +42521,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 238 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 239 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined); if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 273); + return ts.getDeclarationOfKind(moduleSymbol, 274); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -42279,7 +42568,7 @@ var ts; addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", 0, true); - getSymbolLinks(unknownSymbol).type = unknownType; + getSymbolLinks(unknownSymbol).type = errorType; globalArrayType = getGlobalType("Array", 1, true); globalObjectType = getGlobalType("Object", 0, true); globalFunctionType = getGlobalType("Function", 0, true); @@ -42347,7 +42636,7 @@ var ts; case 16384: return "__asyncValues"; case 32768: return "__exportStar"; case 65536: return "__makeTemplateObject"; - default: ts.Debug.fail("Unrecognized helper"); + default: return ts.Debug.fail("Unrecognized helper"); } } function resolveHelpersModule(node, errorNode) { @@ -42364,14 +42653,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 153 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 154 && !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 === 155 || node.kind === 156) { + else if (node.kind === 156 || node.kind === 157) { 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); @@ -42389,16 +42678,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 132) { - if (node.kind === 150 || node.kind === 152) { + if (node.kind === 151 || node.kind === 153) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 159) { + if (node.kind === 160) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 76: - if (node.kind !== 237 && node.parent.kind === 234) { + if (node.kind !== 238 && node.parent.kind === 235) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76)); } break; @@ -42418,7 +42707,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 239 || node.parent.kind === 273) { + else if (node.parent.kind === 240 || node.parent.kind === 274) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -42441,10 +42730,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 239 || node.parent.kind === 273) { + else if (node.parent.kind === 240 || node.parent.kind === 274) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 148) { + else if (node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -42457,7 +42746,7 @@ var ts; if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 151 && node.kind !== 150 && node.kind !== 159 && node.kind !== 148) { + else if (node.kind !== 152 && node.kind !== 151 && node.kind !== 160 && node.kind !== 149) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; @@ -42476,17 +42765,17 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 234) { + else if (node.parent.kind === 235) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 148) { + else if (node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; case 79: - var container = node.parent.kind === 273 ? node.parent : node.parent.parent; - if (container.kind === 238 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 274 ? node.parent : node.parent.parent; + if (container.kind === 239 && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512; @@ -42498,13 +42787,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 234) { + else if (node.parent.kind === 235) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 148) { + else if (node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304) && node.parent.kind === 239) { + else if ((node.parent.flags & 4194304) && node.parent.kind === 240) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -42514,14 +42803,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 234) { - if (node.kind !== 153 && - node.kind !== 151 && - node.kind !== 155 && - node.kind !== 156) { + if (node.kind !== 235) { + if (node.kind !== 154 && + node.kind !== 152 && + node.kind !== 156 && + node.kind !== 157) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 234 && ts.hasModifier(node.parent, 128))) { + if (!(node.parent.kind === 235 && ts.hasModifier(node.parent, 128))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -42540,7 +42829,7 @@ var ts; else if (flags & 2 || node.parent.flags & 4194304) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 148) { + else if (node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -42548,7 +42837,7 @@ var ts; break; } } - if (node.kind === 154) { + if (node.kind === 155) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -42561,20 +42850,21 @@ var ts; else if (flags & 64) { return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly"); } - return; + return false; } - else if ((node.kind === 243 || node.kind === 242) && flags & 2) { + else if ((node.kind === 244 || node.kind === 243) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 148 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 149 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 148 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 149 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { return checkGrammarAsyncModifier(node, lastAsync); } + return false; } function reportObviousModifierErrors(node) { return !node.modifiers @@ -42585,37 +42875,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 155: case 156: - case 154: - case 151: - case 150: - case 153: + case 157: + case 155: case 152: - case 159: - case 238: + case 151: + case 154: + case 153: + case 160: + case 239: + case 244: case 243: - case 242: + case 250: case 249: - case 248: - case 191: case 192: - case 148: + case 193: + case 149: return false; default: - if (node.parent.kind === 239 || node.parent.kind === 273) { + if (node.parent.kind === 240 || node.parent.kind === 274) { return false; } switch (node.kind) { - case 233: - return nodeHasAnyModifiersExcept(node, 120); case 234: - return nodeHasAnyModifiersExcept(node, 117); + return nodeHasAnyModifiersExcept(node, 120); case 235: - case 213: + return nodeHasAnyModifiersExcept(node, 117); case 236: - return true; + case 214: case 237: + return true; + case 238: return nodeHasAnyModifiersExcept(node, 76); default: ts.Debug.fail(); @@ -42628,10 +42918,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 153: - case 233: - case 191: + case 154: + case 234: case 192: + case 193: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -42641,6 +42931,7 @@ var ts; if (list && list.hasTrailingComma) { return grammarErrorAtPos(list[0], list.end - ",".length, ",".length, diag); } + return false; } function checkGrammarTypeParameterList(typeParameters, file) { if (typeParameters && typeParameters.length === 0) { @@ -42648,6 +42939,7 @@ var ts; var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); } + return false; } function checkGrammarParameterList(parameters) { var seenOptionalParameter = false; @@ -42727,10 +43019,10 @@ var ts; } if (parameter.type.kind !== 137 && parameter.type.kind !== 134) { var type = getTypeFromTypeNode(parameter.type); - if (type.flags & 2 || type.flags & 4) { + 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(getTypeFromTypeNode(node.type))); } - if (type.flags & 131072 && allTypesAssignableToKind(type, 32, true)) { + if (type.flags & 262144 && allTypesAssignableToKind(type, 64, true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); @@ -42738,6 +43030,7 @@ var ts; if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); } + return false; } function checkGrammarIndexSignature(node) { return checkGrammarDecoratorsAndModifiers(node) || checkGrammarIndexSignatureParameters(node); @@ -42749,6 +43042,7 @@ var ts; var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); } + return false; } function checkGrammarTypeArguments(node, typeArguments) { return checkGrammarForDisallowedTrailingComma(typeArguments) || @@ -42758,11 +43052,12 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 205) { + if (arg.kind === 206) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } + return false; } function checkGrammarArguments(args) { return checkGrammarForOmittedArgument(args); @@ -42776,7 +43071,7 @@ var ts; var listType = ts.tokenToString(node.token); return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); } - return ts.forEach(types, checkGrammarExpressionWithTypeArguments); + return ts.some(types, checkGrammarExpressionWithTypeArguments); } function checkGrammarExpressionWithTypeArguments(node) { return checkGrammarTypeArguments(node, node.typeArguments); @@ -42831,19 +43126,20 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 146) { + if (node.kind !== 147) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 199 && computedPropertyName.expression.operatorToken.kind === 26) { + if (computedPropertyName.expression.kind === 200 && computedPropertyName.expression.operatorToken.kind === 26) { 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 === 233 || - node.kind === 191 || - node.kind === 153); + ts.Debug.assert(node.kind === 234 || + node.kind === 192 || + node.kind === 154); if (node.flags & 4194304) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -42853,51 +43149,49 @@ var ts; } } function checkGrammarForInvalidQuestionMark(questionToken, message) { - if (questionToken) { - return grammarErrorOnNode(questionToken, message); - } + return !!questionToken && grammarErrorOnNode(questionToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 271) { + if (prop.kind === 272) { continue; } var name = prop.name; - if (name.kind === 146) { + if (name.kind === 147) { checkGrammarComputedPropertyName(name); } - if (prop.kind === 270 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 271 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 120 || prop.kind !== 153) { + if (mod.kind !== 120 || prop.kind !== 154) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; switch (prop.kind) { - case 269: case 270: + case 271: checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8) { checkGrammarNumericLiteral(name); } - case 153: + case 154: currentKind = 1; break; - case 155: + case 156: currentKind = 2; break; - case 156: + case 157: currentKind = 4; break; default: - ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); + throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); } var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { @@ -42930,7 +43224,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 263) { + if (attr.kind === 264) { continue; } var name = attr.name, initializer = attr.initializer; @@ -42940,7 +43234,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 264 && !initializer.expression) { + if (initializer && initializer.kind === 265 && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -42949,12 +43243,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 221 && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 222 && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384) === 0) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 232) { + if (forInOrOfStatement.initializer.kind === 233) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -42962,20 +43256,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 220 + var diagnostic = forInOrOfStatement.kind === 221 ? 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 === 220 + var diagnostic = forInOrOfStatement.kind === 221 ? 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 === 220 + var diagnostic = forInOrOfStatement.kind === 221 ? 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); @@ -43002,11 +43296,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 155 ? + return grammarErrorOnNode(accessor.name, kind === 156 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 156) { + else if (kind === 157) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -43023,12 +43317,13 @@ var ts; } } } + return false; } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 155 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 156 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 155 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 156 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -43039,7 +43334,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 231: + case 232: var decl = parent; if (decl.name.kind !== 71) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -43051,13 +43346,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 151: + case 152: if (!ts.hasModifier(parent, 32) || !ts.hasModifier(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 150: + case 151: if (!ts.hasModifier(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); } @@ -43076,8 +43371,8 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 153) { - if (node.parent.kind === 183) { + if (node.kind === 154) { + if (node.parent.kind === 184) { if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 120)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } @@ -43096,14 +43391,14 @@ var ts; if (node.flags & 4194304) { 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 === 153 && !node.body) { + else if (node.kind === 154 && !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 === 235) { + else if (node.parent.kind === 236) { 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 === 165) { + else if (node.parent.kind === 166) { 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); } } @@ -43114,9 +43409,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 227: + case 228: if (node.label && current.label.escapedText === node.label.escapedText) { - var isMisplacedContinueLabel = node.kind === 222 + var isMisplacedContinueLabel = node.kind === 223 && !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); @@ -43124,8 +43419,8 @@ var ts; return false; } break; - case 226: - if (node.kind === 223 && !node.label) { + case 227: + if (node.kind === 224 && !node.label) { return false; } break; @@ -43138,13 +43433,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 223 + var message = node.kind === 224 ? 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 === 223 + var message = node.kind === 224 ? 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); @@ -43157,7 +43452,7 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - if (node.name.kind === 180 || node.name.kind === 179) { + if (node.name.kind === 181 || node.name.kind === 180) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -43170,11 +43465,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 197 && expr.operator === 38 && + expr.kind === 198 && expr.operator === 38 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 220 && node.parent.parent.kind !== 221) { + if (node.parent.parent.kind !== 221 && node.parent.parent.kind !== 222) { if (node.flags & 4194304) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -43201,7 +43496,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 213 || !node.type || node.initializer || node.flags & 4194304)) { + if (node.exclamationToken && (node.parent.parent.kind !== 214 || !node.type || node.initializer || node.flags & 4194304)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -43226,6 +43521,7 @@ var ts; } } } + return false; } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 71) { @@ -43242,6 +43538,7 @@ var ts; } } } + return false; } function checkGrammarVariableDeclarationList(declarationList) { var declarations = declarationList.declarations; @@ -43251,18 +43548,19 @@ var ts; if (!declarationList.declarations.length) { return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); } + return false; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 216: case 217: case 218: - case 225: case 219: + case 226: case 220: case 221: + case 222: return false; - case 227: + case 228: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -43302,6 +43600,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2)); return true; } + return false; } function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile); @@ -43309,6 +43608,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); return true; } + return false; } function grammarErrorOnNode(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); @@ -43316,11 +43616,12 @@ var ts; diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2)); return true; } + return false; } function checkGrammarConstructorTypeParameters(node) { - var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - if (ts.isNodeArray(typeParameters)) { - var pos = typeParameters.pos, end = typeParameters.end; + var jsdocTypeParameters = ts.isInJavaScriptFile(node) && ts.getJSDocTypeParameterDeclarations(node); + if (node.typeParameters || jsdocTypeParameters && jsdocTypeParameters.length) { + var _a = node.typeParameters || jsdocTypeParameters && jsdocTypeParameters[0] || node, pos = _a.pos, end = _a.end; return grammarErrorAtPos(node, pos, end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); } } @@ -43336,7 +43637,7 @@ var ts; return true; } } - else if (node.parent.kind === 235) { + else if (node.parent.kind === 236) { 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; } @@ -43344,7 +43645,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 165) { + else if (node.parent.kind === 166) { 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; } @@ -43361,13 +43662,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 235 || - node.kind === 236 || + if (node.kind === 236 || + node.kind === 237 || + node.kind === 244 || node.kind === 243 || - node.kind === 242 || + node.kind === 250 || node.kind === 249 || - node.kind === 248 || - node.kind === 241 || + node.kind === 242 || ts.hasModifier(node, 2 | 1 | 512)) { return false; } @@ -43376,12 +43677,13 @@ 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 === 213) { + if (ts.isDeclaration(decl) || decl.kind === 214) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } } } + return false; } function checkGrammarSourceFile(node) { return !!(node.flags & 4194304) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); @@ -43395,7 +43697,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 212 || node.parent.kind === 239 || node.parent.kind === 273) { + if (node.parent.kind === 213 || node.parent.kind === 240 || node.parent.kind === 274) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -43404,6 +43706,7 @@ var ts; else { } } + return false; } function checkGrammarNumericLiteral(node) { if (node.numericLiteralFlags & 32) { @@ -43411,10 +43714,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, 177)) { + else if (ts.isChildOfNodeWithKind(node, 178)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 272)) { + else if (ts.isChildOfNodeWithKind(node, 273)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -43423,6 +43726,7 @@ var ts; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + return false; } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); @@ -43431,6 +43735,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2)); return true; } + return false; } function getAmbientModules() { if (!ambientModulesCache) { @@ -43457,13 +43762,14 @@ var ts; if (ts.isSpreadElement(nodeArguments[0])) { return grammarErrorOnNode(nodeArguments[0], ts.Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element); } + return false; } } ts.createTypeChecker = createTypeChecker; function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 247: - case 251: + case 248: + case 252: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -43471,13 +43777,13 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 244: - case 242: case 245: - case 247: + case 243: + case 246: + case 248: return true; case 71: - return decl.parent.kind === 247; + return decl.parent.kind === 248; default: return false; } @@ -43526,7 +43832,7 @@ var ts; ts.createNodeArray = createNodeArray; function getSynthesizedClone(node) { if (node === undefined) { - return undefined; + return node; } var clone = createSynthesizedNode(node.kind); clone.flags |= node.flags; @@ -43719,7 +44025,7 @@ var ts; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; function createQualifiedName(left, right) { - var node = createSynthesizedNode(145); + var node = createSynthesizedNode(146); node.left = left; node.right = asName(right); return node; @@ -43734,12 +44040,12 @@ var ts; ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26) || - expression.kind === 301 ? + expression.kind === 302 ? createParen(expression) : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(146); + var node = createSynthesizedNode(147); node.expression = parenthesizeForComputedName(expression); return node; } @@ -43751,7 +44057,7 @@ var ts; } ts.updateComputedPropertyName = updateComputedPropertyName; function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(147); + var node = createSynthesizedNode(148); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -43767,7 +44073,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(148); + var node = createSynthesizedNode(149); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -43791,7 +44097,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(149); + var node = createSynthesizedNode(150); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -43803,7 +44109,7 @@ var ts; } ts.updateDecorator = updateDecorator; function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(150); + var node = createSynthesizedNode(151); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -43823,7 +44129,7 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(151); + var node = createSynthesizedNode(152); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -43847,7 +44153,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(152, typeParameters, parameters, type); + var node = createSignatureDeclaration(153, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -43864,7 +44170,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(153); + var node = createSynthesizedNode(154); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -43892,7 +44198,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(154); + var node = createSynthesizedNode(155); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -43912,7 +44218,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(155); + var node = createSynthesizedNode(156); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -43935,7 +44241,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(156); + var node = createSynthesizedNode(157); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -43956,7 +44262,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(157, typeParameters, parameters, type); + return createSignatureDeclaration(158, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -43964,7 +44270,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(158, typeParameters, parameters, type); + return createSignatureDeclaration(159, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -43972,7 +44278,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(159); + var node = createSynthesizedNode(160); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -44010,7 +44316,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(160); + var node = createSynthesizedNode(161); node.parameterName = asName(parameterName); node.type = type; return node; @@ -44024,7 +44330,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(161); + var node = createSynthesizedNode(162); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -44038,7 +44344,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(162, typeParameters, parameters, type); + return createSignatureDeclaration(163, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -44046,7 +44352,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(163, typeParameters, parameters, type); + return createSignatureDeclaration(164, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -44054,7 +44360,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(164); + var node = createSynthesizedNode(165); node.exprName = exprName; return node; } @@ -44066,7 +44372,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(165); + var node = createSynthesizedNode(166); node.members = createNodeArray(members); return node; } @@ -44078,7 +44384,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(166); + var node = createSynthesizedNode(167); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -44090,7 +44396,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(167); + var node = createSynthesizedNode(168); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -44102,7 +44408,7 @@ var ts; } ts.updateTypleTypeNode = updateTypleTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(168, types); + return createUnionOrIntersectionTypeNode(169, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -44110,7 +44416,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169, types); + return createUnionOrIntersectionTypeNode(170, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -44129,7 +44435,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(170); + var node = createSynthesizedNode(171); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -44147,7 +44453,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(171); + var node = createSynthesizedNode(172); node.typeParameter = typeParameter; return node; } @@ -44159,7 +44465,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(178); + var node = createSynthesizedNode(179); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -44177,7 +44483,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(172); + var node = createSynthesizedNode(173); node.type = type; return node; } @@ -44189,11 +44495,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(173); + return createSynthesizedNode(174); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(174); + var node = createSynthesizedNode(175); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -44204,7 +44510,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(175); + var node = createSynthesizedNode(176); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -44218,7 +44524,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(176); + var node = createSynthesizedNode(177); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -44236,7 +44542,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(177); + var node = createSynthesizedNode(178); node.literal = literal; return node; } @@ -44248,7 +44554,7 @@ var ts; } ts.updateLiteralTypeNode = updateLiteralTypeNode; function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(179); + var node = createSynthesizedNode(180); node.elements = createNodeArray(elements); return node; } @@ -44260,7 +44566,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(180); + var node = createSynthesizedNode(181); node.elements = createNodeArray(elements); return node; } @@ -44272,7 +44578,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(181); + var node = createSynthesizedNode(182); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -44290,7 +44596,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(182); + var node = createSynthesizedNode(183); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -44304,7 +44610,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(183); + var node = createSynthesizedNode(184); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -44318,7 +44624,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(184); + var node = createSynthesizedNode(185); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072); @@ -44333,7 +44639,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(185); + var node = createSynthesizedNode(186); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -44347,7 +44653,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(186); + var node = createSynthesizedNode(187); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -44363,7 +44669,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187); + var node = createSynthesizedNode(188); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -44379,7 +44685,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(188); + var node = createSynthesizedNode(189); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -44402,7 +44708,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(189); + var node = createSynthesizedNode(190); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -44416,7 +44722,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(190); + var node = createSynthesizedNode(191); node.expression = expression; return node; } @@ -44428,7 +44734,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(191); + var node = createSynthesizedNode(192); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -44452,7 +44758,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(192); + var node = createSynthesizedNode(193); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -44486,7 +44792,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(193); + var node = createSynthesizedNode(194); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -44498,7 +44804,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(194); + var node = createSynthesizedNode(195); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -44510,7 +44816,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(195); + var node = createSynthesizedNode(196); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -44522,7 +44828,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(196); + var node = createSynthesizedNode(197); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -44534,7 +44840,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(197); + var node = createSynthesizedNode(198); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -44547,7 +44853,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(198); + var node = createSynthesizedNode(199); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -44560,7 +44866,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(199); + var node = createSynthesizedNode(200); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); @@ -44577,7 +44883,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(200); + var node = createSynthesizedNode(201); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -44607,7 +44913,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(201); + var node = createSynthesizedNode(202); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -44645,7 +44951,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(202); + var node = createSynthesizedNode(203); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 ? asteriskTokenOrExpression : expression; return node; @@ -44659,7 +44965,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(203); + var node = createSynthesizedNode(204); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -44671,7 +44977,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(204); + var node = createSynthesizedNode(205); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -44692,11 +44998,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(205); + return createSynthesizedNode(206); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(206); + var node = createSynthesizedNode(207); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -44710,7 +45016,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(207); + var node = createSynthesizedNode(208); node.expression = expression; node.type = type; return node; @@ -44724,7 +45030,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(208); + var node = createSynthesizedNode(209); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -44736,7 +45042,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(209); + var node = createSynthesizedNode(210); node.keywordToken = keywordToken; node.name = name; return node; @@ -44749,7 +45055,7 @@ var ts; } ts.updateMetaProperty = updateMetaProperty; function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(210); + var node = createSynthesizedNode(211); node.expression = expression; node.literal = literal; return node; @@ -44763,11 +45069,11 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(211); + return createSynthesizedNode(212); } ts.createSemicolonClassElement = createSemicolonClassElement; function createBlock(statements, multiLine) { - var block = createSynthesizedNode(212); + var block = createSynthesizedNode(213); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -44775,7 +45081,7 @@ var ts; } ts.createBlock = createBlock; function createExpressionStatement(expression) { - var node = createSynthesizedNode(215); + var node = createSynthesizedNode(216); node.expression = expression; return node; } @@ -44787,7 +45093,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(213); + var node = createSynthesizedNode(214); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -44802,7 +45108,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(214); + return createSynthesizedNode(215); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression) { @@ -44816,7 +45122,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(216); + var node = createSynthesizedNode(217); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -44832,7 +45138,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(217); + var node = createSynthesizedNode(218); node.statement = statement; node.expression = expression; return node; @@ -44846,7 +45152,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(218); + var node = createSynthesizedNode(219); node.expression = expression; node.statement = statement; return node; @@ -44860,7 +45166,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(219); + var node = createSynthesizedNode(220); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -44878,7 +45184,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(220); + var node = createSynthesizedNode(221); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -44894,7 +45200,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(221); + var node = createSynthesizedNode(222); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -44912,7 +45218,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(222); + var node = createSynthesizedNode(223); node.label = asName(label); return node; } @@ -44924,7 +45230,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(223); + var node = createSynthesizedNode(224); node.label = asName(label); return node; } @@ -44936,7 +45242,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(224); + var node = createSynthesizedNode(225); node.expression = expression; return node; } @@ -44948,7 +45254,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(225); + var node = createSynthesizedNode(226); node.expression = expression; node.statement = statement; return node; @@ -44962,7 +45268,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(226); + var node = createSynthesizedNode(227); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -44976,7 +45282,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(227); + var node = createSynthesizedNode(228); node.label = asName(label); node.statement = statement; return node; @@ -44990,7 +45296,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(228); + var node = createSynthesizedNode(229); node.expression = expression; return node; } @@ -45002,7 +45308,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(229); + var node = createSynthesizedNode(230); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -45018,11 +45324,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(230); + return createSynthesizedNode(231); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(231); + var node = createSynthesizedNode(232); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -45038,7 +45344,8 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { - var node = createSynthesizedNode(232); + if (flags === void 0) { flags = 0; } + var node = createSynthesizedNode(233); node.flags |= flags & 3; node.declarations = createNodeArray(declarations); return node; @@ -45051,7 +45358,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(233); + var node = createSynthesizedNode(234); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -45077,7 +45384,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(234); + var node = createSynthesizedNode(235); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -45099,7 +45406,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235); + var node = createSynthesizedNode(236); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -45121,7 +45428,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(236); + var node = createSynthesizedNode(237); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -45141,7 +45448,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(237); + var node = createSynthesizedNode(238); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -45159,7 +45466,8 @@ var ts; } ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { - var node = createSynthesizedNode(238); + if (flags === void 0) { flags = 0; } + var node = createSynthesizedNode(239); node.flags |= flags & (16 | 4 | 512); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -45178,7 +45486,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(239); + var node = createSynthesizedNode(240); node.statements = createNodeArray(statements); return node; } @@ -45190,7 +45498,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(240); + var node = createSynthesizedNode(241); node.clauses = createNodeArray(clauses); return node; } @@ -45202,7 +45510,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(241); + var node = createSynthesizedNode(242); node.name = asName(name); return node; } @@ -45214,7 +45522,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(242); + var node = createSynthesizedNode(243); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -45232,7 +45540,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(243); + var node = createSynthesizedNode(244); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -45250,7 +45558,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(244); + var node = createSynthesizedNode(245); node.name = name; node.namedBindings = namedBindings; return node; @@ -45264,7 +45572,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(245); + var node = createSynthesizedNode(246); node.name = name; return node; } @@ -45276,7 +45584,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(246); + var node = createSynthesizedNode(247); node.elements = createNodeArray(elements); return node; } @@ -45288,7 +45596,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(247); + var node = createSynthesizedNode(248); node.propertyName = propertyName; node.name = name; return node; @@ -45302,7 +45610,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(248); + var node = createSynthesizedNode(249); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -45319,7 +45627,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(249); + var node = createSynthesizedNode(250); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -45337,7 +45645,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(250); + var node = createSynthesizedNode(251); node.elements = createNodeArray(elements); return node; } @@ -45349,7 +45657,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(251); + var node = createSynthesizedNode(252); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -45363,7 +45671,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createExternalModuleReference(expression) { - var node = createSynthesizedNode(253); + var node = createSynthesizedNode(254); node.expression = expression; return node; } @@ -45375,7 +45683,7 @@ var ts; } ts.updateExternalModuleReference = updateExternalModuleReference; function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(254); + var node = createSynthesizedNode(255); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -45391,7 +45699,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(255); + var node = createSynthesizedNode(256); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -45407,7 +45715,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256); + var node = createSynthesizedNode(257); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -45423,7 +45731,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(257); + var node = createSynthesizedNode(258); node.tagName = tagName; return node; } @@ -45435,7 +45743,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(258); + var node = createSynthesizedNode(259); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -45451,7 +45759,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(261); + var node = createSynthesizedNode(262); node.name = name; node.initializer = initializer; return node; @@ -45465,7 +45773,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(262); + var node = createSynthesizedNode(263); node.properties = createNodeArray(properties); return node; } @@ -45477,7 +45785,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(263); + var node = createSynthesizedNode(264); node.expression = expression; return node; } @@ -45489,7 +45797,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(264); + var node = createSynthesizedNode(265); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -45502,7 +45810,7 @@ var ts; } ts.updateJsxExpression = updateJsxExpression; function createCaseClause(expression, statements) { - var node = createSynthesizedNode(265); + var node = createSynthesizedNode(266); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -45516,7 +45824,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(266); + var node = createSynthesizedNode(267); node.statements = createNodeArray(statements); return node; } @@ -45528,7 +45836,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(267); + var node = createSynthesizedNode(268); node.token = token; node.types = createNodeArray(types); return node; @@ -45541,7 +45849,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(268); + var node = createSynthesizedNode(269); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -45555,7 +45863,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(269); + var node = createSynthesizedNode(270); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -45570,7 +45878,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(270); + var node = createSynthesizedNode(271); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -45584,7 +45892,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(271); + var node = createSynthesizedNode(272); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } @@ -45596,7 +45904,7 @@ var ts; } ts.updateSpreadAssignment = updateSpreadAssignment; function createEnumMember(name, initializer) { - var node = createSynthesizedNode(272); + var node = createSynthesizedNode(273); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -45615,7 +45923,7 @@ var ts; (referencedFiles !== undefined && node.referencedFiles !== referencedFiles) || (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(273); + var updated = createSynthesizedNode(274); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -45654,6 +45962,8 @@ var ts; updated.parseDiagnostics = node.parseDiagnostics; if (node.bindDiagnostics !== undefined) updated.bindDiagnostics = node.bindDiagnostics; + if (node.bindSuggestionDiagnostics !== undefined) + updated.bindSuggestionDiagnostics = node.bindSuggestionDiagnostics; if (node.lineMap !== undefined) updated.lineMap = node.lineMap; if (node.classifiableNames !== undefined) @@ -45686,28 +45996,28 @@ var ts; } ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createSynthesizedNode(299); + var node = createSynthesizedNode(300); node.original = original; setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(303); + var node = createSynthesizedNode(304); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(302); + var node = createSynthesizedNode(303); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(300); + var node = createSynthesizedNode(301); node.expression = expression; node.original = original; setTextRange(node, original); @@ -45723,7 +46033,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 301) { + if (node.kind === 302) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26) { @@ -45733,7 +46043,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(301); + var node = createSynthesizedNode(302); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -45746,20 +46056,20 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(274); + var node = ts.createNode(275); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text) { - var node = ts.createNode(275); + var node = ts.createNode(276); node.text = text; return node; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration) { - var node = ts.createNode(276); + var node = ts.createNode(277); node.javascriptText = javascript; node.declarationText = declaration; return node; @@ -45864,7 +46174,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 273) { + if (node.kind === 274) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -46272,7 +46582,7 @@ var ts; ts.createSpreadHelper = createSpreadHelper; function createForOfBindingStatement(node, boundValue) { if (ts.isVariableDeclarationList(node)) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); + var firstDeclaration = ts.first(node.declarations); var updatedDeclaration = ts.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, undefined, boundValue); return ts.setTextRange(ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(node, [updatedDeclaration])), node); } @@ -46295,7 +46605,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 227 + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -46313,19 +46623,20 @@ var ts; case 8: case 9: return false; - case 182: + case 183: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 183: + case 184: return target.properties.length > 0; default: return true; } } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { + if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } var callee = skipOuterExpressions(expression, 7); var thisArg; var target; @@ -46345,7 +46656,7 @@ var ts; } else { switch (callee.kind) { - case 184: { + case 185: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); @@ -46357,7 +46668,7 @@ var ts; } break; } - case 185: { + case 186: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); @@ -46410,14 +46721,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 155: case 156: - return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 269: - return createExpressionForPropertyAssignment(property, receiver); + case 157: + return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); case 270: + return createExpressionForPropertyAssignment(property, receiver); + case 271: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 153: + case 154: return createExpressionForMethodDeclaration(property, receiver); } } @@ -46489,6 +46800,7 @@ var ts; } ts.getDeclarationName = getDeclarationName; function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (emitFlags === void 0) { emitFlags = 0; } var nodeName = ts.getNameOfDeclaration(node); if (nodeName && ts.isIdentifier(nodeName) && !ts.isGeneratedIdentifier(nodeName)) { var name = ts.getMutableClone(nodeName); @@ -46513,7 +46825,7 @@ var ts; function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); ts.setTextRange(qualifiedName, name); - var emitFlags; + var emitFlags = 0; if (!allowSourceMaps) emitFlags |= 48; if (!allowComments) @@ -46528,7 +46840,8 @@ var ts; } ts.convertToFunctionBody = convertToFunctionBody; function convertFunctionDeclarationToExpression(node) { - ts.Debug.assert(!!node.body); + if (!node.body) + return ts.Debug.fail(); var updated = ts.createFunctionExpression(node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body); ts.setOriginalNode(updated, node); ts.setTextRange(updated, node); @@ -46573,7 +46886,7 @@ var ts; ts.addStandardPrologue = addStandardPrologue; function addCustomPrologue(target, source, statementOffset, visitor) { var numStatements = source.length; - while (statementOffset < numStatements) { + while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; if (ts.getEmitFlags(statement) & 1048576) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); @@ -46617,7 +46930,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 190) { + if (skipped.kind === 191) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -46626,15 +46939,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(199, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(199, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(200, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(200, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 202) { + && operand.kind === 203) { return false; } return true; @@ -46673,7 +46986,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 199 && node.operatorToken.kind === 37) { + if (node.kind === 200 && node.operatorToken.kind === 37) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -46688,7 +47001,7 @@ var ts; return 0; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(200, 55); + var conditionalPrecedence = ts.getOperatorPrecedence(201, 55); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { @@ -46699,17 +47012,17 @@ var ts; ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; function parenthesizeSubexpressionOfConditionalExpression(e) { var emittedExpression = ts.skipPartiallyEmittedExpressions(e); - return emittedExpression.kind === 199 && emittedExpression.operatorToken.kind === 26 || - emittedExpression.kind === 301 + return emittedExpression.kind === 200 && emittedExpression.operatorToken.kind === 26 || + emittedExpression.kind === 302 ? ts.createParen(e) : e; } ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression; function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 204 || - check.kind === 191 || - check.kind === 301 || + return (check.kind === 205 || + check.kind === 192 || + check.kind === 302 || ts.isBinaryExpression(check) && check.operatorToken.kind === 26) ? ts.createParen(e) : e; @@ -46718,9 +47031,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, true); switch (leftmostExpr.kind) { - case 186: - return ts.createParen(expression); case 187: + return ts.createParen(expression); + case 188: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -46731,7 +47044,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 187 || emittedExpression.arguments)) { + && (emittedExpression.kind !== 188 || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -46769,7 +47082,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(199, 26); + var commaPrecedence = ts.getOperatorPrecedence(200, 26); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -46780,29 +47093,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 191 || kind === 192) { + if (kind === 192 || kind === 193) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, false).kind; - if (leftmostExpressionKind === 183 || leftmostExpressionKind === 191) { + if (leftmostExpressionKind === 184 || leftmostExpressionKind === 192) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 170 ? ts.createParenthesizedType(member) : member; + return member.kind === 171 ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 168: case 169: - case 162: + case 170: case 163: + case 164: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -46810,9 +47123,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 164: - case 174: - case 171: + case 165: + case 175: + case 172: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -46838,24 +47151,24 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 198: + case 199: node = node.operand; continue; - case 199: + case 200: node = node.left; continue; - case 200: + case 201: node = node.condition; continue; - case 186: + case 187: if (stopAtCallExpressions) { return node; } + case 186: case 185: - case 184: node = node.expression; continue; - case 300: + case 301: node = node.expression; continue; } @@ -46863,7 +47176,7 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, false).kind === 183) { + if (!ts.isBlock(body) && getLeftmostExpression(body, false).kind === 184) { return ts.setTextRange(ts.createParen(body), body); } return body; @@ -46872,13 +47185,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7; } switch (node.kind) { - case 190: + case 191: return (kinds & 1) !== 0; - case 189: - case 207: + case 190: case 208: + case 209: return (kinds & 2) !== 0; - case 300: + case 301: return (kinds & 4) !== 0; } return false; @@ -46903,7 +47216,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 208) { + while (ts.isAssertionExpression(node) || node.kind === 209) { node = node.expression; } return node; @@ -46911,15 +47224,15 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 190: return ts.updateParen(outerExpression, expression); - case 189: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 207: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 208: return ts.updateNonNullExpression(outerExpression, expression); - case 300: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 191: return ts.updateParen(outerExpression, expression); + case 190: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 208: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 209: return ts.updateNonNullExpression(outerExpression, expression); + case 301: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } function isIgnorableParen(node) { - return node.kind === 190 + return node.kind === 191 && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -46981,10 +47294,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 243 && node.importClause) { + if (node.kind === 244 && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 249 && node.moduleSpecifier) { + if (node.kind === 250 && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -47025,8 +47338,9 @@ var ts; return bindingElement.initializer; } if (ts.isPropertyAssignment(bindingElement)) { - return ts.isAssignmentExpression(bindingElement.initializer, true) - ? bindingElement.initializer.right + var initializer = bindingElement.initializer; + return ts.isAssignmentExpression(initializer, true) + ? initializer.right : undefined; } if (ts.isShorthandPropertyAssignment(bindingElement)) { @@ -47046,11 +47360,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 269: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 270: - return bindingElement.name; + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 271: + return bindingElement.name; + case 272: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -47066,11 +47380,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 148: - case 181: + case 149: + case 182: return bindingElement.dotDotDotToken; - case 203: - case 271: + case 204: + case 272: return bindingElement; } return undefined; @@ -47078,7 +47392,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 181: + case 182: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -47086,7 +47400,7 @@ var ts; : propertyName; } break; - case 269: + case 270: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -47094,7 +47408,7 @@ var ts; : propertyName; } break; - case 271: + case 272: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -47108,11 +47422,11 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 179: case 180: - case 182: - return name.elements; + case 181: case 183: + return name.elements; + case 184: return name.properties; } } @@ -47151,11 +47465,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 180: - case 182: - return convertToArrayAssignmentPattern(node); - case 179: + case 181: case 183: + return convertToArrayAssignmentPattern(node); + case 180: + case 184: return convertToObjectAssignmentPattern(node); } } @@ -47292,257 +47606,257 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 144) || kind === 173) { + if ((kind > 0 && kind <= 145) || kind === 174) { return node; } switch (kind) { case 71: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 145: - return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); case 146: - return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); case 147: - return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); + return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); case 148: - return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); case 149: - return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 150: - return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); case 151: - return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 152: - return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); + return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 153: - return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); case 154: - return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 155: - return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); case 156: - return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 157: - return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); case 158: - return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 159: - return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 160: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 161: - return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); + return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); case 162: - return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); case 163: - return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 164: - return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); + return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 165: - return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); + return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); case 166: - return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); + return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); case 167: - return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); case 168: - return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); case 169: - return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); case 170: - return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); + return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); case 171: - return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 178: - return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); + return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); case 172: - return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174: - return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 175: - return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 176: - return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 177: - return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); + return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); case 179: - return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); + return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); + case 173: + return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 175: + return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 176: + return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); + case 177: + return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); + case 178: + return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); case 180: - return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); + return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); case 181: - return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); case 182: - return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); + return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); case 183: - return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); + return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); case 184: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); case 185: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); case 186: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); case 187: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); case 188: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); case 189: - return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 190: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 191: - return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 192: - return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); + return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 193: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); case 194: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 195: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); case 196: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); case 197: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); case 198: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); case 199: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); case 200: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); case 201: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); case 202: - return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); case 203: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); case 204: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 205: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 206: - return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 207: - return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 208: - return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); case 209: - return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 210: + return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); + case 211: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 212: - return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 213: + return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 214: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 215: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 216: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 217: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); case 218: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 219: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 220: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 221: - return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 222: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); + return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 223: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); case 224: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); case 225: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); case 226: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 227: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 228: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 229: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 230: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 231: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 232: - return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 233: - return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); case 234: - return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 235: - return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); + return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); case 236: - return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); case 237: - return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); + return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 238: - return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); case 239: - return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); case 240: - return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); + return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 241: - return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 242: - return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); + return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); case 243: - return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); case 244: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); + return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 245: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); case 246: - return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 247: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); case 248: - return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); case 249: - return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 250: - return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 251: + return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); + case 252: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 253: - return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); case 254: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); case 255: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 256: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); case 257: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); case 258: + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + case 259: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 261: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 262: - return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 263: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); case 264: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 265: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 266: - return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); case 267: - return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 268: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); case 269: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 270: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); case 271: - return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); case 272: - return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); case 273: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 274: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 300: - return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 301: + return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + case 302: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: return node; @@ -47568,52 +47882,52 @@ var ts; var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; - if ((kind > 0 && kind <= 144)) { + if ((kind > 0 && kind <= 145)) { return initial; } - if ((kind >= 160 && kind <= 177)) { + if ((kind >= 161 && kind <= 178)) { return initial; } var result = initial; switch (node.kind) { - case 211: - case 214: - case 205: - case 230: - case 299: + case 212: + case 215: + case 206: + case 231: + case 300: break; - case 145: + case 146: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 146: + case 147: result = reduceNode(node.expression, cbNode, result); break; - case 148: + case 149: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149: + case 150: result = reduceNode(node.expression, cbNode, result); break; - case 150: + case 151: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 151: + case 152: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153: + case 154: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -47622,53 +47936,48 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 154: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; case 155: - result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; case 156: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 157: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 179: case 180: + case 181: result = reduceNodes(node.elements, cbNodes, result); break; - case 181: + case 182: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 182: + case 183: result = reduceNodes(node.elements, cbNodes, result); break; - case 183: - result = reduceNodes(node.properties, cbNodes, result); - break; case 184: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.properties, cbNodes, result); break; case 185: result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); + result = reduceNode(node.name, cbNode, result); break; case 186: result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); + result = reduceNode(node.argumentExpression, cbNode, result); break; case 187: result = reduceNode(node.expression, cbNode, result); @@ -47676,14 +47985,19 @@ var ts; result = reduceNodes(node.arguments, cbNodes, result); break; case 188: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 189: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 189: + case 190: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 191: + case 192: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -47691,262 +48005,262 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 192: + case 193: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 190: - case 193: + case 191: case 194: case 195: case 196: - case 202: + case 197: case 203: - case 208: + case 204: + case 209: result = reduceNode(node.expression, cbNode, result); break; - case 197: case 198: + case 199: result = reduceNode(node.operand, cbNode, result); break; - case 199: + case 200: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 200: + case 201: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 201: + case 202: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 204: + case 205: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 206: + case 207: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 207: + case 208: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; - case 210: + case 211: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 212: + case 213: result = reduceNodes(node.statements, cbNodes, result); break; - case 213: + case 214: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 215: + case 216: result = reduceNode(node.expression, cbNode, result); break; - case 216: + case 217: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 217: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; case 218: - case 225: - result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); break; case 219: + case 226: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 220: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220: case 221: + case 222: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 224: - case 228: + case 225: + case 229: result = reduceNode(node.expression, cbNode, result); break; - case 226: + case 227: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 227: + case 228: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 229: + case 230: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 231: + case 232: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 232: - result = reduceNodes(node.declarations, cbNodes, result); - break; case 233: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); + result = reduceNodes(node.declarations, cbNodes, result); break; case 234: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.heritageClauses, cbNodes, result); - result = reduceNodes(node.members, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); break; - case 237: + case 235: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; case 238: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.body, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); break; case 239: - result = reduceNodes(node.statements, cbNodes, result); + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); break; case 240: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 241: result = reduceNodes(node.clauses, cbNodes, result); break; - case 242: + case 243: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 243: + case 244: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 244: + case 245: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 245: - result = reduceNode(node.name, cbNode, result); - break; case 246: - case 250: - result = reduceNodes(node.elements, cbNodes, result); + result = reduceNode(node.name, cbNode, result); break; case 247: case 251: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 248: + case 252: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 248: + case 249: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 249: + case 250: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 253: + case 254: result = reduceNode(node.expression, cbNode, result); break; - case 254: + case 255: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 258: + case 259: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 255: case 256: + case 257: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 262: + case 263: result = reduceNodes(node.properties, cbNodes, result); break; - case 257: + case 258: result = reduceNode(node.tagName, cbNode, result); break; - case 261: + case 262: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 263: - result = reduceNode(node.expression, cbNode, result); - break; case 264: result = reduceNode(node.expression, cbNode, result); break; case 265: result = reduceNode(node.expression, cbNode, result); + break; case 266: + result = reduceNode(node.expression, cbNode, result); + case 267: result = reduceNodes(node.statements, cbNodes, result); break; - case 267: + case 268: result = reduceNodes(node.types, cbNodes, result); break; - case 268: + case 269: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 269: + case 270: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270: + case 271: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 271: + case 272: result = reduceNode(node.expression, cbNode, result); break; - case 272: + case 273: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 273: + case 274: result = reduceNodes(node.statements, cbNodes, result); break; - case 300: + case 301: result = reduceNode(node.expression, cbNode, result); break; - case 301: + case 302: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -47960,8 +48274,8 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements) - : ts.prependRange(statements, declarations); + ? ts.setTextRange(ts.createNodeArray(ts.prependStatements(statements.slice(), declarations)), statements) + : ts.prependStatements(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; function liftToBlock(nodes) { @@ -47999,7 +48313,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 206)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 207)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -48040,7 +48354,7 @@ var ts; }); Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, { __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 65536 ? ts.formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 131072 ? ts.formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { return this.checker.typeToString(this); } }, }); var nodeConstructors = [ @@ -48089,12 +48403,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName && e.propertyName.escapedText === "default"; + return e.propertyName !== undefined && e.propertyName.escapedText === "default"; } function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 273 ? transformSourceFile(node) : transformBundle(node); + return node.kind === 274 ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -48122,7 +48436,7 @@ var ts; } ts.getImportNeedsImportStarHelper = getImportNeedsImportStarHelper; function getImportNeedsImportDefaultHelper(node) { - return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings))); + return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (!!node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings))); } ts.getImportNeedsImportDefaultHelper = getImportNeedsImportDefaultHelper; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { @@ -48138,16 +48452,16 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 243: + case 244: externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 242: - if (node.moduleReference.kind === 253) { + case 243: + if (node.moduleReference.kind === 254) { externalImports.push(node); } break; - case 249: + case 250: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -48174,12 +48488,12 @@ var ts; } } break; - case 248: + case 249: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 213: + case 214: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -48187,7 +48501,7 @@ var ts; } } break; - case 233: + case 234: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -48205,7 +48519,7 @@ var ts; } } break; - case 234: + case 235: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -48307,7 +48621,7 @@ var ts; var flattenContext = { context: context, level: level, - downlevelIteration: context.getCompilerOptions().downlevelIteration, + downlevelIteration: !!context.getCompilerOptions().downlevelIteration, hoistTempVariables: true, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -48372,13 +48686,14 @@ var ts; return false; } function flattenDestructuringBinding(node, visitor, context, level, rval, hoistTempVariables, skipInitializer) { + if (hoistTempVariables === void 0) { hoistTempVariables = false; } var pendingExpressions; var pendingDeclarations = []; var declarations = []; var flattenContext = { context: context, level: level, - downlevelIteration: context.getCompilerOptions().downlevelIteration, + downlevelIteration: !!context.getCompilerOptions().downlevelIteration, hoistTempVariables: hoistTempVariables, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -48404,7 +48719,7 @@ var ts; } else { context.hoistVariableDeclaration(temp); - var pendingDeclaration = ts.lastOrUndefined(pendingDeclarations); + var pendingDeclaration = ts.last(pendingDeclarations); pendingDeclaration.pendingExpressions = ts.append(pendingDeclaration.pendingExpressions, ts.createAssignment(temp, pendingDeclaration.value)); ts.addRange(pendingDeclaration.pendingExpressions, pendingExpressions); pendingDeclaration.value = temp; @@ -48649,8 +48964,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(184); context.enableSubstitution(185); + context.enableSubstitution(186); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -48662,14 +48977,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 274) { + if (node.kind === 275) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 276) { + if (prepend.kind === 277) { return ts.createUnparsedSourceFile(prepend.javascriptText); } return prepend; @@ -48698,15 +49013,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 273: + case 274: + case 241: case 240: - case 239: - case 212: + case 213: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 235: case 234: - case 233: if (ts.hasModifier(node, 2)) { break; } @@ -48714,7 +49029,7 @@ var ts; recordEmittedDeclarationInScope(node); } else { - ts.Debug.assert(node.kind === 234 || ts.hasModifier(node, 512)); + ts.Debug.assert(node.kind === 235 || ts.hasModifier(node, 512)); } break; } @@ -48736,10 +49051,10 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { + case 244: case 243: - case 242: - case 248: case 249: + case 250: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -48754,13 +49069,13 @@ var ts; return node; } switch (node.kind) { - case 243: + case 244: return visitImportDeclaration(node); - case 242: + case 243: return visitImportEqualsDeclaration(node); - case 248: - return visitExportAssignment(node); case 249: + return visitExportAssignment(node); + case 250: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -48770,11 +49085,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 249 || - node.kind === 243 || + if (node.kind === 250 || node.kind === 244 || - (node.kind === 242 && - node.moduleReference.kind === 253)) { + node.kind === 245 || + (node.kind === 243 && + node.moduleReference.kind === 254)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -48790,15 +49105,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 154: - return undefined; - case 151: - case 159: case 155: + return undefined; + case 152: + case 160: case 156: - case 153: + case 157: + case 154: return visitorWorker(node); - case 211: + case 212: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -48828,87 +49143,88 @@ var ts; case 76: case 124: case 132: - case 166: case 167: - case 165: - case 160: - case 147: + case 168: + case 166: + case 161: + case 148: case 119: + case 142: case 122: case 137: case 134: case 131: case 105: case 138: - case 163: - case 162: case 164: - case 161: - case 168: + case 163: + case 165: + case 162: case 169: case 170: - case 172: + case 171: case 173: case 174: case 175: case 176: case 177: - case 159: - case 149: - case 236: - return undefined; - case 151: - return visitPropertyDeclaration(node); - case 241: - return undefined; - case 154: - return visitConstructor(node); - case 235: - return ts.createNotEmittedStatement(node); - case 234: - return visitClassDeclaration(node); - case 204: - return visitClassExpression(node); - case 267: - return visitHeritageClause(node); - case 206: - return visitExpressionWithTypeArguments(node); - case 153: - return visitMethodDeclaration(node); - case 155: - return visitGetAccessor(node); - case 156: - return visitSetAccessor(node); - case 233: - return visitFunctionDeclaration(node); - case 191: - return visitFunctionExpression(node); - case 192: - return visitArrowFunction(node); - case 148: - return visitParameter(node); - case 190: - return visitParenthesizedExpression(node); - case 189: - case 207: - return visitAssertionExpression(node); - case 186: - return visitCallExpression(node); - case 187: - return visitNewExpression(node); - case 188: - return visitTaggedTemplateExpression(node); - case 208: - return visitNonNullExpression(node); + case 178: + case 160: + case 150: case 237: - return visitEnumDeclaration(node); - case 213: - return visitVariableStatement(node); - case 231: - return visitVariableDeclaration(node); - case 238: - return visitModuleDeclaration(node); + return undefined; + case 152: + return visitPropertyDeclaration(node); case 242: + return undefined; + case 155: + return visitConstructor(node); + case 236: + return ts.createNotEmittedStatement(node); + case 235: + return visitClassDeclaration(node); + case 205: + return visitClassExpression(node); + case 268: + return visitHeritageClause(node); + case 207: + return visitExpressionWithTypeArguments(node); + case 154: + return visitMethodDeclaration(node); + case 156: + return visitGetAccessor(node); + case 157: + return visitSetAccessor(node); + case 234: + return visitFunctionDeclaration(node); + case 192: + return visitFunctionExpression(node); + case 193: + return visitArrowFunction(node); + case 149: + return visitParameter(node); + case 191: + return visitParenthesizedExpression(node); + case 190: + case 208: + return visitAssertionExpression(node); + case 187: + return visitCallExpression(node); + case 188: + return visitNewExpression(node); + case 189: + return visitTaggedTemplateExpression(node); + case 209: + return visitNonNullExpression(node); + case 238: + return visitEnumDeclaration(node); + case 214: + return visitVariableStatement(node); + case 232: + return visitVariableDeclaration(node); + case 239: + return visitModuleDeclaration(node); + case 243: return visitImportEqualsDeclaration(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -48916,7 +49232,8 @@ var ts; } function visitSourceFile(node) { var alwaysStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") && - !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015); + !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015) && + !ts.isJsonSourceFile(node); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict)); } function shouldEmitDecorateCallForClass(node) { @@ -48986,7 +49303,7 @@ var ts; statement.pos = closingBraceLocation.pos; ts.setEmitFlags(statement, 1536 | 384); statements.push(statement); - ts.prependRange(statements, context.endLexicalEnvironment()); + ts.prependStatements(statements, context.endLexicalEnvironment()); var iife = ts.createImmediatelyInvokedArrowFunction(statements); ts.setEmitFlags(iife, 33554432); var varStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ @@ -49128,7 +49445,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 215 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 216 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -49162,7 +49479,7 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 151 + return member.kind === 152 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } @@ -49237,12 +49554,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 155: case 156: + case 157: return getAllDecoratorsOfAccessors(node, member); - case 153: + case 154: return getAllDecoratorsOfMethod(member); - case 151: + case 152: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -49321,7 +49638,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 151 + ? member.kind === 152 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -49405,37 +49722,37 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 153 - || kind === 155 + return kind === 154 || kind === 156 - || kind === 151; + || kind === 157 + || kind === 152; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 153; + return node.kind === 154; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 234: - case 204: + case 235: + case 205: return ts.getFirstConstructorWithBody(node) !== undefined; - case 153: - case 155: + case 154: case 156: + case 157: return true; } return false; } function serializeTypeOfNode(node) { switch (node.kind) { - case 151: - case 148: - case 155: - return serializeTypeNode(node.type); + case 152: + case 149: case 156: + return serializeTypeNode(node.type); + case 157: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 234: - case 204: - case 153: + case 235: + case 205: + case 154: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -49467,7 +49784,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 155) { + if (container && node.kind === 156) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -49494,22 +49811,22 @@ var ts; case 95: case 131: return ts.createVoidZero(); - case 172: + case 173: return serializeTypeNode(node.type); - case 162: case 163: + case 164: return ts.createIdentifier("Function"); - case 166: case 167: + case 168: return ts.createIdentifier("Array"); - case 160: + case 161: case 122: return ts.createIdentifier("Boolean"); case 137: return ts.createIdentifier("String"); case 135: return ts.createIdentifier("Object"); - case 177: + case 178: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -49527,18 +49844,19 @@ var ts; return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 161: + case 162: return serializeTypeReferenceNode(node); + case 170: case 169: - case 168: return serializeUnionOrIntersectionType(node); - case 164: - case 174: + case 165: case 175: case 176: - case 165: + case 177: + case 166: case 119: - case 173: + case 142: + case 174: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -49549,7 +49867,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 172) { + while (typeNode.kind === 173) { typeNode = typeNode.type; } if (typeNode.kind === 131) { @@ -49576,7 +49894,8 @@ var ts; return serializedUnion || ts.createVoidZero(); } function serializeTypeReferenceNode(node) { - switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) { + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, true); var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -49602,8 +49921,9 @@ var ts; case ts.TypeReferenceSerializationKind.Promise: return ts.createIdentifier("Promise"); case ts.TypeReferenceSerializationKind.ObjectType: - default: return ts.createIdentifier("Object"); + default: + return ts.Debug.assertNever(kind); } } function serializeEntityNameAsExpression(node, useFallback) { @@ -49617,7 +49937,7 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } return name; - case 145: + case 146: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -49872,7 +50192,7 @@ var ts; var statements = []; startLexicalEnvironment(); var members = ts.map(node.members, transformEnumMember); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); ts.addRange(statements, members); currentNamespaceContainerName = savedCurrentNamespaceLocalName; return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); @@ -49902,7 +50222,7 @@ var ts; } } function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules); } function hasNamespaceQualifiedExportName(node) { return isExportOfNamespace(node) @@ -49934,11 +50254,11 @@ var ts; function addVarForEnumOrModuleDeclaration(statements, node) { var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, false, true)) - ], currentScope.kind === 273 ? 0 : 1)); + ], currentScope.kind === 274 ? 0 : 1)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 237) { + if (node.kind === 238) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -49999,7 +50319,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 239) { + if (body.kind === 240) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -50017,19 +50337,19 @@ var ts; var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; statementsLocation = ts.moveRangePos(moduleBlock.statements, -1); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); ts.setTextRange(block, blockLocation); - if (body.kind !== 239) { + if (body.kind !== 240) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 238) { + if (moduleDeclaration.body.kind === 239) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -50049,7 +50369,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 245) { + if (node.kind === 246) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -50184,15 +50504,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(71); - context.enableSubstitution(270); - context.enableEmitNotification(238); + context.enableSubstitution(271); + context.enableEmitNotification(239); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 238; + return ts.getOriginalNode(node).kind === 239; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 237; + return ts.getOriginalNode(node).kind === 238; } function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -50238,9 +50558,9 @@ var ts; switch (node.kind) { case 71: return substituteExpressionIdentifier(node); - case 184: - return substitutePropertyAccessExpression(node); case 185: + return substitutePropertyAccessExpression(node); + case 186: return substituteElementAccessExpression(node); } return node; @@ -50270,9 +50590,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 !== 273) { - var substitute = (applicableSubstitutions & 2 && container.kind === 238) || - (applicableSubstitutions & 8 && container.kind === 237); + if (container && container.kind !== 274) { + var substitute = (applicableSubstitutions & 2 && container.kind === 239) || + (applicableSubstitutions & 8 && container.kind === 238); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } @@ -50385,15 +50705,15 @@ var ts; switch (node.kind) { case 120: return undefined; - case 196: + case 197: return visitAwaitExpression(node); - case 153: + case 154: return visitMethodDeclaration(node); - case 233: + case 234: return visitFunctionDeclaration(node); - case 191: - return visitFunctionExpression(node); case 192: + return visitFunctionExpression(node); + case 193: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -50402,27 +50722,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 213: + case 214: return visitVariableStatementInAsyncBody(node); - case 219: - return visitForStatementInAsyncBody(node); case 220: - return visitForInStatementInAsyncBody(node); + return visitForStatementInAsyncBody(node); case 221: + return visitForInStatementInAsyncBody(node); + case 222: return visitForOfStatementInAsyncBody(node); - case 268: + case 269: return visitCatchClauseInAsyncBody(node); - case 212: - case 226: - case 240: - case 265: - case 266: - case 229: - case 217: - case 218: - case 216: - case 225: + case 213: case 227: + case 241: + case 266: + case 267: + case 230: + case 218: + case 219: + case 217: + case 226: + case 228: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -50471,8 +50791,9 @@ var ts; : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, ts.liftToBlock)); } function visitForStatementInAsyncBody(node) { - return ts.updateFor(node, isVariableDeclarationListWithCollidingName(node.initializer) - ? visitVariableDeclarationListWithCollidingNames(node.initializer, false) + var initializer = node.initializer; + return ts.updateFor(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, ts.liftToBlock)); } function visitAwaitExpression(node) { @@ -50513,10 +50834,10 @@ var ts; } } function isVariableDeclarationListWithCollidingName(node) { - return node + return !!node && ts.isVariableDeclarationList(node) && !(node.flags & 3) - && ts.forEach(node.declarations, collidesWithParameterName); + && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { hoistVariableDeclarationList(node); @@ -50570,7 +50891,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 === 192; + var isArrowFunction = node.kind === 193; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames; enclosingFunctionParameterNames = ts.createUnderscoreEscapedMap(); @@ -50583,7 +50904,7 @@ var ts; var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.createBlock(statements, true); ts.setTextRange(block, node.body); if (languageVersion >= 2) { @@ -50634,14 +50955,14 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(186); - context.enableSubstitution(184); + context.enableSubstitution(187); context.enableSubstitution(185); - context.enableEmitNotification(234); - context.enableEmitNotification(153); - context.enableEmitNotification(155); - context.enableEmitNotification(156); + context.enableSubstitution(186); + context.enableEmitNotification(235); context.enableEmitNotification(154); + context.enableEmitNotification(156); + context.enableEmitNotification(157); + context.enableEmitNotification(155); } } function onEmitNode(hint, node, emitCallback) { @@ -50666,11 +50987,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 184: - return substitutePropertyAccessExpression(node); case 185: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 186: + return substituteElementAccessExpression(node); + case 187: return substituteCallExpression(node); } return node; @@ -50701,11 +51022,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 234 - || kind === 154 - || kind === 153 + return kind === 235 || kind === 155 - || kind === 156; + || kind === 154 + || kind === 156 + || kind === 157; } function createSuperAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096) { @@ -50785,45 +51106,47 @@ var ts; return node; } switch (node.kind) { - case 196: + case 197: return visitAwaitExpression(node); - case 202: + case 203: return visitYieldExpression(node); - case 227: + case 225: + return visitReturnStatement(node); + case 228: return visitLabeledStatement(node); - case 183: + case 184: return visitObjectLiteralExpression(node); - case 199: + case 200: return visitBinaryExpression(node, noDestructuringValue); - case 231: + case 232: return visitVariableDeclaration(node); - case 221: + case 222: return visitForOfStatement(node, undefined); - case 219: + case 220: return visitForStatement(node); - case 195: + case 196: return visitVoidExpression(node); - case 154: - return visitConstructorDeclaration(node); - case 153: - return visitMethodDeclaration(node); case 155: - return visitGetAccessorDeclaration(node); + return visitConstructorDeclaration(node); + case 154: + return visitMethodDeclaration(node); case 156: + return visitGetAccessorDeclaration(node); + case 157: return visitSetAccessorDeclaration(node); - case 233: + case 234: return visitFunctionDeclaration(node); - case 191: - return visitFunctionExpression(node); case 192: + return visitFunctionExpression(node); + case 193: return visitArrowFunction(node); - case 148: + case 149: return visitParameter(node); - case 215: + case 216: return visitExpressionStatement(node); - case 190: + case 191: return visitParenthesizedExpression(node, noDestructuringValue); - case 268: + case 269: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -50847,10 +51170,16 @@ var ts; } return ts.visitEachChild(node, visitor, context); } + function visitReturnStatement(node) { + if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) { + return ts.updateReturn(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : ts.createVoidZero())); + } + return ts.visitEachChild(node, visitor, context); + } function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 221 && statement.awaitModifier) { + if (statement.kind === 222 && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -50862,7 +51191,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 === 271) { + if (e.kind === 272) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -50871,7 +51200,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 269 + chunkObject = ts.append(chunkObject, e.kind === 270 ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -50884,7 +51213,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 1048576) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 183) { + if (objects.length && objects[0].kind !== 184) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -50996,7 +51325,7 @@ var ts; var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, callValues), node.expression), ts.createVariableDeclaration(result) - ]), node.expression), 2097152), ts.createComma(ts.createAssignment(result, createDownlevelAwait(callNext)), ts.createLogicalNot(getDone)), undefined, convertForOfStatementHead(node, createDownlevelAwait(getValue))), node), 256); + ]), node.expression), 2097152), ts.createComma(ts.createAssignment(result, createDownlevelAwait(callNext)), ts.createLogicalNot(getDone)), undefined, convertForOfStatementHead(node, getValue)), node), 256); return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ @@ -51090,7 +51419,7 @@ var ts; var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor); appendObjectRestAssignmentsIfNeeded(statements, node); statements.push(ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression(undefined, ts.createToken(39), node.name && ts.getGeneratedNameForNode(node.name), undefined, [], undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset)))))); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.updateBlock(node.body, statements); if (languageVersion >= 2) { if (resolver.getNodeCheckFlags(node) & 4096) { @@ -51116,7 +51445,7 @@ var ts; var leadingStatements = endLexicalEnvironment(); if (statementOffset > 0 || ts.some(statements) || ts.some(leadingStatements)) { var block = ts.convertToFunctionBody(body, true); - ts.prependRange(statements, leadingStatements); + ts.prependStatements(statements, leadingStatements); ts.addRange(statements, block.statements.slice(statementOffset)); return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(statements), block.statements)); } @@ -51140,14 +51469,14 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(186); - context.enableSubstitution(184); + context.enableSubstitution(187); context.enableSubstitution(185); - context.enableEmitNotification(234); - context.enableEmitNotification(153); - context.enableEmitNotification(155); - context.enableEmitNotification(156); + context.enableSubstitution(186); + context.enableEmitNotification(235); context.enableEmitNotification(154); + context.enableEmitNotification(156); + context.enableEmitNotification(157); + context.enableEmitNotification(155); } } function onEmitNode(hint, node, emitCallback) { @@ -51172,11 +51501,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 184: - return substitutePropertyAccessExpression(node); case 185: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 186: + return substituteElementAccessExpression(node); + case 187: return substituteCallExpression(node); } return node; @@ -51207,11 +51536,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 234 - || kind === 154 - || kind === 153 + return kind === 235 || kind === 155 - || kind === 156; + || kind === 154 + || kind === 156 + || kind === 157; } function createSuperAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096) { @@ -51306,13 +51635,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 254: - return visitJsxElement(node, false); case 255: + return visitJsxElement(node, false); + case 256: return visitJsxSelfClosingElement(node, false); - case 258: + case 259: return visitJsxFragment(node, false); - case 264: + case 265: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -51322,13 +51651,13 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 264: + case 265: return visitJsxExpression(node); - case 254: - return visitJsxElement(node, true); case 255: + return visitJsxElement(node, true); + case 256: return visitJsxSelfClosingElement(node, true); - case 258: + case 259: return visitJsxFragment(node, true); default: return ts.Debug.failBadSyntaxKind(node); @@ -51392,7 +51721,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 264) { + else if (node.kind === 265) { if (node.expression === undefined) { return ts.createTrue(); } @@ -51452,7 +51781,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 254) { + if (node.kind === 255) { return getTagName(node.openingElement); } else { @@ -51752,7 +52081,7 @@ var ts; return node; } switch (node.kind) { - case 199: + case 200: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -51841,14 +52170,14 @@ var ts; hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return hierarchyFacts & 4096 - && node.kind === 224 + return (hierarchyFacts & 4096) !== 0 + && node.kind === 225 && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 212))) + || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 213))) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432) !== 0; } @@ -51876,63 +52205,63 @@ var ts; switch (node.kind) { case 115: return undefined; - case 234: + case 235: return visitClassDeclaration(node); - case 204: + case 205: return visitClassExpression(node); - case 148: + case 149: return visitParameter(node); - case 233: + case 234: return visitFunctionDeclaration(node); - case 192: + case 193: return visitArrowFunction(node); - case 191: + case 192: return visitFunctionExpression(node); - case 231: + case 232: return visitVariableDeclaration(node); case 71: return visitIdentifier(node); - case 232: + case 233: return visitVariableDeclarationList(node); - case 226: - return visitSwitchStatement(node); - case 240: - return visitCaseBlock(node); - case 212: - return visitBlock(node, false); - case 223: - case 222: - return visitBreakOrContinueStatement(node); case 227: + return visitSwitchStatement(node); + case 241: + return visitCaseBlock(node); + case 213: + return visitBlock(node, false); + case 224: + case 223: + return visitBreakOrContinueStatement(node); + case 228: return visitLabeledStatement(node); - case 217: case 218: - return visitDoOrWhileStatement(node, undefined); case 219: - return visitForStatement(node, undefined); + return visitDoOrWhileStatement(node, undefined); case 220: - return visitForInStatement(node, undefined); + return visitForStatement(node, undefined); case 221: + return visitForInStatement(node, undefined); + case 222: return visitForOfStatement(node, undefined); - case 215: + case 216: return visitExpressionStatement(node); - case 183: + case 184: return visitObjectLiteralExpression(node); - case 268: + case 269: return visitCatchClause(node); - case 270: + case 271: return visitShorthandPropertyAssignment(node); - case 146: + case 147: return visitComputedPropertyName(node); - case 182: + case 183: return visitArrayLiteralExpression(node); - case 186: - return visitCallExpression(node); case 187: + return visitCallExpression(node); + case 188: return visitNewExpression(node); - case 190: + case 191: return visitParenthesizedExpression(node, true); - case 199: + case 200: return visitBinaryExpression(node, true); case 13: case 14: @@ -51943,28 +52272,28 @@ var ts; return visitStringLiteral(node); case 8: return visitNumericLiteral(node); - case 188: + case 189: return visitTaggedTemplateExpression(node); - case 201: - return visitTemplateExpression(node); case 202: - return visitYieldExpression(node); + return visitTemplateExpression(node); case 203: + return visitYieldExpression(node); + case 204: return visitSpreadElement(node); case 97: return visitSuperKeyword(false); case 99: return visitThisKeyword(node); - case 209: + case 210: return visitMetaProperty(node); - case 153: + case 154: return visitMethodDeclaration(node); - case 155: case 156: + case 157: return visitAccessorDeclaration(node); - case 213: + case 214: return visitVariableStatement(node); - case 224: + case 225: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -51981,7 +52310,7 @@ var ts; if (taggedTemplateStringDeclarations) { statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(taggedTemplateStringDeclarations))); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0, 0); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -52045,13 +52374,14 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 223 ? 2 : 4; + var jump = node.kind === 224 ? 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; - if (!node.label) { - if (node.kind === 223) { + var label = node.label; + if (!label) { + if (node.kind === 224) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -52061,13 +52391,13 @@ var ts; } } else { - if (node.kind === 223) { - labelMarker = "break-" + node.label.escapedText; - setLabeledJump(convertedLoopState, true, ts.idText(node.label), labelMarker); + if (node.kind === 224) { + labelMarker = "break-" + label.escapedText; + setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + node.label.escapedText; - setLabeledJump(convertedLoopState, false, ts.idText(node.label), labelMarker); + labelMarker = "continue-" + label.escapedText; + setLabeledJump(convertedLoopState, false, ts.idText(label), labelMarker); } } var returnExpression = ts.createLiteral(labelMarker); @@ -52150,7 +52480,7 @@ var ts; statement.pos = closingBraceLocation.pos; ts.setEmitFlags(statement, 1536 | 384); statements.push(statement); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); ts.setEmitFlags(block, 1536); return block; @@ -52176,7 +52506,7 @@ var ts; convertedLoopState = savedConvertedLoopState; } function transformConstructorParameters(constructor, hasSynthesizedSuper) { - return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) + return ts.visitParameterList(constructor && !hasSynthesizedSuper ? constructor.parameters : undefined, visitor, context) || []; } function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { @@ -52197,7 +52527,7 @@ var ts; } ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; @@ -52213,7 +52543,7 @@ var ts; && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createFileLevelUniqueName("_this"))); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); if (constructor) { prependCaptureNewTargetIfNeeded(statements, constructor, false); } @@ -52225,17 +52555,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 224) { + if (statement.kind === 225) { return true; } - else if (statement.kind === 216) { + else if (statement.kind === 217) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 212) { + else if (statement.kind === 213) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -52264,7 +52594,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 215 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 216 && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -52272,8 +52602,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 | 32768))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 199 - || superCallExpression.left.kind !== 186) { + if (superCallExpression.kind !== 200 + || superCallExpression.left.kind !== 187) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); @@ -52374,7 +52704,7 @@ var ts; statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 && node.kind !== 192) { + if (node.transformFlags & 32768 && node.kind !== 193) { captureThisForNode(statements, node, ts.createThis()); } } @@ -52392,18 +52722,18 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 192: + case 193: return statements; - case 153: - case 155: + case 154: case 156: + case 157: newTarget = ts.createVoidZero(); break; - case 154: + case 155: newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); break; - case 233: - case 191: + case 234: + case 192: newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 93, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); break; default: @@ -52423,20 +52753,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 211: + case 212: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 153: + case 154: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 155: case 156: + case 157: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 154: + case 155: break; default: ts.Debug.failBadSyntaxKind(node); @@ -52561,7 +52891,7 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 233 || node.kind === 191)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 234 || node.kind === 192)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); @@ -52595,7 +52925,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 192); + ts.Debug.assert(node.kind === 193); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -52615,7 +52945,7 @@ var ts; closeBraceLocation = body; } var lexicalEnvironment = context.endLexicalEnvironment(); - ts.prependRange(statements, lexicalEnvironment); + ts.prependStatements(statements, lexicalEnvironment); prependCaptureNewTargetIfNeeded(statements, node, false); if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; @@ -52648,9 +52978,9 @@ var ts; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 190: + case 191: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 199: + case 200: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -52658,9 +52988,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 190: + case 191: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 199: + case 200: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -52718,11 +53048,10 @@ var ts; ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 - && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); if (firstDeclaration) { - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, ts.last(declarations).end)); } } return declarationList; @@ -52786,14 +53115,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 217: case 218: - return visitDoOrWhileStatement(node, outermostLabeledStatement); case 219: - return visitForStatement(node, outermostLabeledStatement); + return visitDoOrWhileStatement(node, outermostLabeledStatement); case 220: - return visitForInStatement(node, outermostLabeledStatement); + return visitForStatement(node, outermostLabeledStatement); case 221: + return visitForInStatement(node, outermostLabeledStatement); + case 222: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -52817,35 +53146,34 @@ var ts; } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; - if (ts.isVariableDeclarationList(node.initializer)) { + var initializer = node.initializer; + if (ts.isVariableDeclarationList(initializer)) { if (node.initializer.flags & 3) { enableSubstitutionsForBlockScopedBindings(); } - var firstOriginalDeclaration = ts.firstOrUndefined(node.initializer.declarations); + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, boundValue); var declarationList = ts.setTextRange(ts.createVariableDeclarationList(declarations), node.initializer); ts.setOriginalNode(declarationList, node.initializer); - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(declarations[0].pos, ts.last(declarations).end)); statements.push(ts.createVariableStatement(undefined, declarationList)); } else { statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, boundValue) - ]), ts.moveRangePos(node.initializer, -1)), node.initializer)), ts.moveRangeEnd(node.initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { - var assignment = ts.createAssignment(node.initializer, boundValue); + var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); statements.push(ts.createStatement(visitBinaryExpression(assignment, false))); } else { - assignment.end = node.initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(node.initializer, -1))); + assignment.end = initializer.end; + statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -52918,7 +53246,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 146) { + if (property.name.kind === 147) { numInitialProperties = i; break; } @@ -52980,11 +53308,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 219: case 220: case 221: + case 222: var initializer = node.initializer; - if (initializer && initializer.kind === 232) { + if (initializer && initializer.kind === 233) { loopInitializer = initializer; } break; @@ -53020,7 +53348,7 @@ var ts; if (loopOutParameters.length) { copyOutParameters(loopOutParameters, 1, statements_4); } - ts.prependRange(statements_4, lexicalEnvironment); + ts.prependStatements(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, true); } if (ts.isBlock(loopBody)) { @@ -53210,20 +53538,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 155: case 156: + case 157: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 153: + case 154: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 269: + case 270: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 270: + case 271: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -53298,7 +53626,7 @@ var ts; var body = node.transformFlags & (32768 | 128) ? transformFunctionBody(node) : visitFunctionBodyDownLevel(node); - if (node.kind === 155) { + if (node.kind === 156) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -53322,7 +53650,7 @@ var ts; } function visitArrayLiteralExpression(node) { if (node.transformFlags & 64) { - return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + return transformAndSpreadElements(node.elements, true, !!node.multiLine, !!node.elements.hasTrailingComma); } return ts.visitEachChild(node, visitor, context); } @@ -53337,11 +53665,11 @@ var ts; } function visitTypeScriptClassWrapper(node) { var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock); - var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.firstOrUndefined(stmt.declarationList.declarations).initializer; }; + var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.first(stmt.declarationList.declarations).initializer; }; var bodyStatements = ts.visitNodes(body.statements, visitor, ts.isStatement); var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer); var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); }); - var varStatement = ts.cast(ts.firstOrUndefined(classStatements), ts.isVariableStatement); + var varStatement = ts.cast(ts.first(classStatements), ts.isVariableStatement); var variable = varStatement.declarationList.declarations[0]; var initializer = ts.skipOuterExpressions(variable.initializer); var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression); @@ -53429,7 +53757,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 182 + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -53575,13 +53903,13 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(99); - context.enableEmitNotification(154); - context.enableEmitNotification(153); context.enableEmitNotification(155); + context.enableEmitNotification(154); context.enableEmitNotification(156); + context.enableEmitNotification(157); + context.enableEmitNotification(193); context.enableEmitNotification(192); - context.enableEmitNotification(191); - context.enableEmitNotification(233); + context.enableEmitNotification(234); } } function onSubstituteNode(hint, node) { @@ -53604,14 +53932,13 @@ var ts; return node; } function isNameOfDeclarationWithCollidingName(node) { - var parent = node.parent; - switch (parent.kind) { - case 181: - case 234: - case 237: - case 231: - return parent.name === node - && resolver.isDeclarationWithCollidingName(parent); + switch (node.parent.kind) { + case 182: + case 235: + case 238: + case 232: + return node.parent.name === node + && resolver.isDeclarationWithCollidingName(node.parent); } return false; } @@ -53670,11 +53997,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 215) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 186) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187) { return false; } var callTarget = statementExpression.expression; @@ -53682,7 +54009,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 203) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204) { return false; } var expression = callArgument.expression; @@ -53726,24 +54053,24 @@ var ts; if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(256); context.enableEmitNotification(257); - context.enableEmitNotification(255); + context.enableEmitNotification(258); + context.enableEmitNotification(256); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(184); - context.enableSubstitution(269); + context.enableSubstitution(185); + context.enableSubstitution(270); return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { return node; } function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 256: case 257: - case 255: + case 258: + case 256: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -53779,7 +54106,7 @@ var ts; } function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token >= 72 && token <= 107) { + if (token !== undefined && token >= 72 && token <= 107) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -53796,6 +54123,7 @@ var ts; case 4: return "yield"; case 5: return "yield*"; case 7: return "endfinally"; + default: return undefined; } } function transformGenerators(context) { @@ -53859,13 +54187,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 217: - return visitDoStatement(node); case 218: + return visitDoStatement(node); + case 219: return visitWhileStatement(node); - case 226: - return visitSwitchStatement(node); case 227: + return visitSwitchStatement(node); + case 228: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -53873,24 +54201,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 233: + case 234: return visitFunctionDeclaration(node); - case 191: + case 192: return visitFunctionExpression(node); - case 155: case 156: + case 157: return visitAccessorDeclaration(node); - case 213: + case 214: return visitVariableStatement(node); - case 219: - return visitForStatement(node); case 220: + return visitForStatement(node); + case 221: return visitForInStatement(node); - case 223: - return visitBreakStatement(node); - case 222: - return visitContinueStatement(node); case 224: + return visitBreakStatement(node); + case 223: + return visitContinueStatement(node); + case 225: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -53906,21 +54234,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 199: - return visitBinaryExpression(node); case 200: + return visitBinaryExpression(node); + case 201: return visitConditionalExpression(node); - case 202: + case 203: return visitYieldExpression(node); - case 182: - return visitArrayLiteralExpression(node); case 183: + return visitArrayLiteralExpression(node); + case 184: return visitObjectLiteralExpression(node); - case 185: - return visitElementAccessExpression(node); case 186: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 187: + return visitCallExpression(node); + case 188: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -53928,9 +54256,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 233: + case 234: return visitFunctionDeclaration(node); - case 191: + case 192: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -54014,7 +54342,7 @@ var ts; var statementOffset = ts.addPrologue(statements, body.statements, false, visitor); transformAndEmitStatements(body.statements, statementOffset); var buildResult = build(); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); statements.push(ts.createReturn(buildResult)); inGeneratorFunctionBody = savedInGeneratorFunctionBody; inStatementContainingYield = savedInStatementContainingYield; @@ -54052,13 +54380,14 @@ var ts; } } function visitBinaryExpression(node) { - switch (ts.getExpressionAssociativity(node)) { + var assoc = ts.getExpressionAssociativity(node); + switch (assoc) { case 0: return visitLeftAssociativeBinaryExpression(node); case 1: return visitRightAssociativeBinaryExpression(node); default: - ts.Debug.fail("Unknown associativity."); + return ts.Debug.assertNever(assoc); } } function isCompoundAssignment(kind) { @@ -54086,10 +54415,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 184: + case 185: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 185: + case 186: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -54290,35 +54619,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 212: + case 213: return transformAndEmitBlock(node); - case 215: - return transformAndEmitExpressionStatement(node); case 216: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 217: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 218: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 219: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 220: + return transformAndEmitForStatement(node); + case 221: return transformAndEmitForInStatement(node); - case 222: - return transformAndEmitContinueStatement(node); case 223: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 224: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 225: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 226: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 227: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 228: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 229: + return transformAndEmitThrowStatement(node); + case 230: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -54612,7 +54941,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 266 && defaultClauseIndex === -1) { + if (clause.kind === 267 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -54622,7 +54951,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 265) { + if (clause.kind === 266) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -54712,7 +55041,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 16777216) !== 0; + return !!node && (node.transformFlags & 16777216) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -54799,7 +55128,8 @@ var ts; } function endBlock() { var block = peekBlock(); - ts.Debug.assert(block !== undefined, "beginBlock was never called."); + if (block === undefined) + return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; blockActions[index] = 1; blockOffsets[index] = operations ? operations.length : 0; @@ -55042,7 +55372,7 @@ var ts; return 0; } function createLabel(label) { - if (label > 0) { + if (label !== undefined && label > 0) { if (labelExpressions === undefined) { labelExpressions = []; } @@ -55413,7 +55743,7 @@ var ts; name: "typescript:generator", scoped: false, priority: 6, - text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" + text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; })(ts || (ts = {})); var ts; @@ -55437,11 +55767,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71); - context.enableSubstitution(199); - context.enableSubstitution(197); + context.enableSubstitution(200); context.enableSubstitution(198); - context.enableSubstitution(270); - context.enableEmitNotification(273); + context.enableSubstitution(199); + context.enableSubstitution(271); + context.enableEmitNotification(274); var moduleInfoMap = []; var deferredExports = []; var currentSourceFile; @@ -55480,7 +55810,7 @@ var ts; ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); addExportEqualsIfNeeded(statements, false); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { ts.addEmitHelper(updated, exportStarHelper); @@ -55595,7 +55925,7 @@ var ts; } ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); addExportEqualsIfNeeded(statements, true); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var body = ts.createBlock(statements, true); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { ts.addEmitHelper(body, exportStarHelper); @@ -55626,23 +55956,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 243: + case 244: return visitImportDeclaration(node); - case 242: + case 243: return visitImportEqualsDeclaration(node); - case 249: + case 250: return visitExportDeclaration(node); - case 248: + case 249: return visitExportAssignment(node); - case 213: + case 214: return visitVariableStatement(node); - case 233: - return visitFunctionDeclaration(node); case 234: + return visitFunctionDeclaration(node); + case 235: return visitClassDeclaration(node); - case 302: - return visitMergeDeclarationMarker(node); case 303: + return visitMergeDeclarationMarker(node); + case 304: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -55667,24 +55997,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 269: + case 270: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 270: + case 271: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 271: + case 272: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 153: - case 155: + case 154: case 156: + case 157: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -55999,7 +56329,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 213) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -56031,10 +56361,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 245: + case 246: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 246: + case 247: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -56142,7 +56472,7 @@ var ts; return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 273) { + if (node.kind === 274) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -56184,10 +56514,10 @@ var ts; switch (node.kind) { case 71: return substituteExpressionIdentifier(node); - case 199: + case 200: return substituteBinaryExpression(node); + case 199: case 198: - case 197: return substituteUnaryExpression(node); } return node; @@ -56202,7 +56532,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 273) { + if (exportContainer && exportContainer.kind === 274) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -56245,7 +56575,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 198 + var expression = node.kind === 199 ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 ? 59 : 60), ts.createLiteral(1)), node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -56309,11 +56639,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71); - context.enableSubstitution(270); - context.enableSubstitution(199); - context.enableSubstitution(197); + context.enableSubstitution(271); + context.enableSubstitution(200); context.enableSubstitution(198); - context.enableEmitNotification(273); + context.enableSubstitution(199); + context.enableEmitNotification(274); var moduleInfoMap = []; var deferredExports = []; var exportFunctionsMap = []; @@ -56399,7 +56729,7 @@ var ts; ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement); var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset); ts.addRange(statements, hoistedStatements); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -56417,7 +56747,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 249 && externalImport.exportClause) { + if (externalImport.kind === 250 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -56440,7 +56770,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 249) { + if (externalImport.kind !== 250) { continue; } if (!externalImport.exportClause) { @@ -56491,15 +56821,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 243: + case 244: if (!entry.importClause) { break; } - case 242: + case 243: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 249: + case 250: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -56521,13 +56851,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 243: + case 244: return visitImportDeclaration(node); - case 242: + case 243: return visitImportEqualsDeclaration(node); - case 249: + case 250: return undefined; - case 248: + case 249: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -56648,7 +56978,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 2097152) === 0 - && (enclosingBlockScopedContainer.kind === 273 + && (enclosingBlockScopedContainer.kind === 274 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -56670,7 +57000,7 @@ var ts; : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 213) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -56709,10 +57039,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 245: + case 246: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 246: + case 247: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -56812,43 +57142,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 213: + case 214: return visitVariableStatement(node); - case 233: - return visitFunctionDeclaration(node); case 234: + return visitFunctionDeclaration(node); + case 235: return visitClassDeclaration(node); - case 219: - return visitForStatement(node); case 220: - return visitForInStatement(node); + return visitForStatement(node); case 221: + return visitForInStatement(node); + case 222: return visitForOfStatement(node); - case 217: - return visitDoStatement(node); case 218: + return visitDoStatement(node); + case 219: return visitWhileStatement(node); - case 227: + case 228: return visitLabeledStatement(node); - case 225: - return visitWithStatement(node); case 226: + return visitWithStatement(node); + case 227: return visitSwitchStatement(node); - case 240: + case 241: return visitCaseBlock(node); - case 265: - return visitCaseClause(node); case 266: + return visitCaseClause(node); + case 267: return visitDefaultClause(node); - case 229: + case 230: return visitTryStatement(node); - case 268: + case 269: return visitCatchClause(node); - case 212: + case 213: return visitBlock(node); - case 302: - return visitMergeDeclarationMarker(node); case 303: + return visitMergeDeclarationMarker(node); + case 304: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -56857,7 +57187,7 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateFor(node, 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 = ts.updateFor(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)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -56880,9 +57210,6 @@ var ts; && shouldHoistVariableDeclarationList(node); } function visitForInitializer(node) { - if (!node) { - return node; - } if (shouldHoistForInitializer(node)) { var expressions = void 0; for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { @@ -56945,7 +57272,7 @@ var ts; } function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 - && node.kind === 199) { + && node.kind === 200) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -56988,7 +57315,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 273; + return container !== undefined && container.kind === 274; } else { return false; @@ -57003,7 +57330,7 @@ var ts; return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 273) { + if (node.kind === 274) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -57037,7 +57364,7 @@ var ts; } function substituteUnspecified(node) { switch (node.kind) { - case 270: + case 271: return substituteShorthandPropertyAssignment(node); } return node; @@ -57061,10 +57388,10 @@ var ts; switch (node.kind) { case 71: return substituteExpressionIdentifier(node); - case 199: + case 200: return substituteBinaryExpression(node); - case 197: case 198: + case 199: return substituteUnaryExpression(node); } return node; @@ -57116,14 +57443,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 198 + var expression = node.kind === 199 ? ts.setTextRange(ts.createPrefix(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 === 198) { + if (node.kind === 199) { expression = node.operator === 43 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -57140,7 +57467,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 273) { + if (exportContainer && exportContainer.kind === 274) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -57168,7 +57495,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(273); + context.enableEmitNotification(274); context.enableSubstitution(71); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -57195,9 +57522,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 242: + case 243: return undefined; - case 248: + case 249: return visitExportAssignment(node); } return node; @@ -57283,7 +57610,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 === 234) { + else if (node.parent.kind === 235) { 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 : @@ -57312,7 +57639,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 === 234) { + else if (node.parent.kind === 235) { 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 : @@ -57356,18 +57683,18 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); + 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 === 231 || node.kind === 181) { + if (node.kind === 232 || node.kind === 182) { 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 === 151 || node.kind === 150 || - (node.kind === 148 && ts.hasModifier(node.parent, 8))) { + else if (node.kind === 152 || node.kind === 151 || + (node.kind === 149 && ts.hasModifier(node.parent, 8))) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -57375,7 +57702,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 === 234 || node.kind === 148) { + else if (node.parent.kind === 235 || node.kind === 149) { 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 : @@ -57399,7 +57726,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 156) { + if (node.kind === 157) { if (ts.hasModifier(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 : @@ -57436,23 +57763,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 158: + case 159: 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 157: + case 158: 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 159: + case 160: 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 154: case 153: - case 152: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -57460,7 +57787,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 === 234) { + else if (node.parent.kind === 235) { 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 : @@ -57473,7 +57800,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 233: + case 234: 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 : @@ -57481,7 +57808,7 @@ var ts; ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; break; default: - ts.Debug.fail("This is unknown kind for signature: " + node.kind); + return ts.Debug.fail("This is unknown kind for signature: " + node.kind); } return { diagnosticMessage: diagnosticMessage, @@ -57498,27 +57825,27 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 154: + case 155: 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 158: - case 163: + case 159: + case 164: 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 157: + case 158: 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 159: + case 160: 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 154: case 153: - case 152: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -57526,7 +57853,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 === 234) { + else if (node.parent.parent.kind === 235) { 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 : @@ -57538,52 +57865,52 @@ 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 233: - case 162: + case 234: + case 163: 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; default: - ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } } function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 234: + case 235: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 235: + case 236: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 158: + case 159: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157: + case 158: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 154: case 153: - case 152: if (ts.hasModifier(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 === 234) { + else if (node.parent.parent.kind === 235) { 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 233: + case 234: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 236: + case 237: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: - ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); + return ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); } return { diagnosticMessage: diagnosticMessage, @@ -57593,7 +57920,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 234) { + if (node.parent.parent.kind === 235) { diagnosticMessage = node.parent.token === 108 ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -57733,16 +58060,16 @@ var ts; } } function transformRoot(node) { - if (node.kind === 273 && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 274 && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 274) { + if (node.kind === 275) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { if (sourceFile.isDeclarationFile || ts.isSourceFileJavaScript(sourceFile)) - return; + return undefined; hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; enclosingDeclaration = sourceFile; @@ -57764,7 +58091,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 276) { + if (prepend.kind === 277) { return ts.createUnparsedSourceFile(prepend.declarationText); } })); @@ -57859,7 +58186,7 @@ var ts; return name; } else { - if (name.kind === 180) { + if (name.kind === 181) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -57867,7 +58194,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 205) { + if (elem.kind === 206) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -57901,7 +58228,7 @@ var ts; if (shouldPrintWithInitializer(node)) { return; } - var shouldUseResolverType = node.kind === 148 && + var shouldUseResolverType = node.kind === 149 && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { @@ -57910,7 +58237,7 @@ var ts; if (!ts.getParseTreeNode(node)) { return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(119); } - if (node.kind === 156) { + if (node.kind === 157) { return ts.createKeywordTypeNode(119); } errorNameNode = node.name; @@ -57919,12 +58246,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 231 || node.kind === 181) { + if (node.kind === 232 || node.kind === 182) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 148 - || node.kind === 151 - || node.kind === 150) { + if (node.kind === 149 + || node.kind === 152 + || node.kind === 151) { 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)); @@ -57941,19 +58268,19 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 233: - case 238: - case 235: case 234: + case 239: case 236: + case 235: case 237: + case 238: return !resolver.isDeclarationVisible(node); - case 231: + case 232: return !getBindingNameVisible(node); - case 242: case 243: + case 244: + case 250: case 249: - case 248: return false; } return false; @@ -57963,7 +58290,7 @@ var ts; return false; } if (ts.isBindingPattern(elem.name)) { - return ts.forEach(elem.name.elements, getBindingNameVisible); + return ts.some(elem.name.elements, getBindingNameVisible); } else { return resolver.isDeclarationVisible(elem); @@ -58005,8 +58332,8 @@ var ts; } function rewriteModuleSpecifier(parent, input) { if (!input) - return; - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 238 && parent.kind !== 178); + return undefined; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 && parent.kind !== 179); if (input.kind === 9 && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -58018,7 +58345,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 253) { + if (decl.moduleReference.kind === 254) { var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.name, ts.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); } @@ -58038,7 +58365,7 @@ var ts; if (!decl.importClause.namedBindings) { return visibleDefaultBinding && ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 245) { + if (decl.importClause.namedBindings.kind === 246) { var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; } @@ -58118,61 +58445,61 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 165 || input.kind === 176) && input.parent.kind !== 236); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 || input.kind === 177) && input.parent.kind !== 237); if (shouldEnterSuppressNewDiagnosticsContextContext) { suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 206: { + case 207: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 161: { + case 162: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 158: + case 159: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 154: { + case 155: { var isPrivate = ts.hasModifier(input, 8); - var ctor = ts.createSignatureDeclaration(154, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0), undefined); + var ctor = ts.createSignatureDeclaration(155, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0), undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 153: { - var sig = ts.createSignatureDeclaration(152, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 154: { + var sig = ts.createSignatureDeclaration(153, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 155: { - var newNode = ensureAccessor(input); - return cleanup(newNode); - } case 156: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 151: + case 157: { + var newNode = ensureAccessor(input); + return cleanup(newNode); + } + case 152: return cleanup(ts.updateProperty(input, undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 150: + case 151: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 152: { + case 153: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 157: { + case 158: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 159: { + case 160: { return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119))); } - case 231: { + case 232: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -58180,13 +58507,13 @@ var ts; suppressNewDiagnosticContexts = true; return cleanup(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 147: { + case 148: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, undefined, undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 170: { + case 171: { var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree); var oldEnclosingDecl = enclosingDeclaration; @@ -58196,13 +58523,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 162: { + case 163: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 163: { + case 164: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 178: { + case 179: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -58231,7 +58558,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 153 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 154 && ts.hasModifier(node.parent, 8); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -58240,14 +58567,14 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249: { + case 250: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; } return ts.updateExportDeclaration(input, undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 248: { + case 249: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -58275,10 +58602,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 242: { + case 243: { return transformImportEqualsDeclaration(input); } - case 243: { + case 244: { return transformImportDeclaration(input); } } @@ -58298,18 +58625,18 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 236: + case 237: return cleanup(ts.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 235: { + case 236: { return cleanup(ts.updateInterfaceDeclaration(input, undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 233: { + case 234: { return cleanup(ts.updateFunctionDeclaration(input, undefined, ensureModifiers(input, isPrivate), undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined)); } - case 238: { + case 239: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 239) { + if (inner && inner.kind === 240) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -58327,7 +58654,7 @@ var ts; return cleanup(ts.updateModuleDeclaration(input, undefined, mods, input.name, body)); } } - case 234: { + case 235: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -58389,10 +58716,10 @@ var ts; return cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 213: { + case 214: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 237: { + case 238: { return cleanup(ts.updateEnumDeclaration(input, undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -58409,7 +58736,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 238) { + if (input.kind === 239) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -58430,7 +58757,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 205) { + if (e.kind === 206) { return; } if (e.name) { @@ -58484,7 +58811,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 ^ (4 | 256); var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0; - var parentIsFile = node.parent.kind === 273; + var parentIsFile = node.parent.kind === 274; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1) | 512 | 2); additions = 0; @@ -58531,7 +58858,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 235) { + if (node.kind === 236) { return true; } return false; @@ -58550,7 +58877,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 155 + return accessor.kind === 156 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -58559,51 +58886,51 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 231: + case 232: + case 152: case 151: - case 150: - case 148: + case 149: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 233: - case 238: - case 242: - case 235: case 234: - case 236: - case 237: - case 213: + case 239: case 243: + case 236: + case 235: + case 237: + case 238: + case 214: + case 244: + case 250: case 249: - case 248: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 158: - case 154: - case 153: - case 155: - case 156: - case 151: - case 150: - case 152: - case 157: case 159: - case 231: - case 147: - case 206: - case 161: - case 170: + case 155: + case 154: + case 156: + case 157: + case 152: + case 151: + case 153: + case 158: + case 160: + case 232: + case 148: + case 207: case 162: + case 171: case 163: - case 178: + case 164: + case 179: return true; } return false; @@ -58654,7 +58981,7 @@ var ts; } ts.getTransformers = getTransformers; function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(304); + var enabledSyntaxKindFeatures = new Array(305); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -58889,7 +59216,7 @@ var ts; return currentSource.skipTrivia ? currentSource.skipTrivia(pos) : ts.skipTrivia(currentSourceText, pos); } function initialize(filePath, sourceMapFilePath, sourceFileOrBundle, outputSourceMapDataList) { - if (disabled) { + if (disabled || ts.fileExtensionIs(filePath, ".json")) { return; } if (sourceMapData) { @@ -58920,7 +59247,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 273) { + if (sourceFileOrBundle.kind === 274) { sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { @@ -58980,7 +59307,7 @@ var ts; sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } function emitPos(pos) { - if (disabled || ts.positionIsSynthesized(pos)) { + if (disabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(currentSource)) { return; } if (extendedDiagnostics) { @@ -59017,12 +59344,12 @@ var ts; } } function emitNodeWithSourceMap(hint, node, emitCallback) { - if (disabled) { + if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0; var range = emitNode && emitNode.sourceMapRange; var _a = range || node, pos = _a.pos, end = _a.end; var source = range && range.source; @@ -59031,7 +59358,7 @@ var ts; source = undefined; if (source) setSourceFile(source); - if (node.kind !== 299 + if (node.kind !== 300 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -59048,7 +59375,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 299 + if (node.kind !== 300 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -59058,11 +59385,11 @@ var ts; } } function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { - if (disabled) { + if (disabled || ts.isInJsonFile(node)) { return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; tokenPos = skipSourceTrivia(range ? range.pos : tokenPos); if ((emitFlags & 128) === 0 && tokenPos >= 0) { @@ -59076,12 +59403,18 @@ var ts; } return tokenPos; } + function isJsonSourceMapSource(sourceFile) { + return ts.fileExtensionIs(sourceFile.fileName, ".json"); + } function setSourceFile(sourceFile) { if (disabled) { return; } currentSource = sourceFile; currentSourceText = currentSource.text; + if (isJsonSourceMapSource(sourceFile)) { + return; + } var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, currentSource.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true); sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); @@ -59095,8 +59428,8 @@ var ts; } } function getText() { - if (disabled) { - return; + if (disabled || isJsonSourceMapSource(currentSource)) { + return undefined; } encodeLastRecordedSourceMapSpan(); return JSON.stringify({ @@ -59110,8 +59443,8 @@ var ts; }); } function getSourceMappingURL() { - if (disabled) { - return; + if (disabled || isJsonSourceMapSource(currentSource)) { + return undefined; } if (compilerOptions.inlineSourceMap) { var base64SourceMapText = ts.base64encode(ts.sys, getText()); @@ -59163,7 +59496,7 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = printerOptions.removeComments; + var disabled = !!printerOptions.removeComments; return { reset: reset, setWriter: setWriter, @@ -59181,7 +59514,7 @@ var ts; if (node) { hasWrittenComment = false; var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0; var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; if ((pos < 0 && end < 0) || (pos === end)) { emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); @@ -59190,7 +59523,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 299; + var isEmittedNode = node.kind !== 300; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 10; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 10; if (!skipLeadingComments) { @@ -59204,7 +59537,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 232) { + if (node.kind === 233) { declarationListContainerEnd = end; } } @@ -59445,10 +59778,10 @@ var ts; detachedCommentsInfo = undefined; } function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; } function forEachLeadingCommentWithoutDetachedComments(cb) { - var pos = ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos; + var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); } @@ -59488,6 +59821,7 @@ var ts; var infoExtension = ".tsbundleinfo"; var brackets = createBracketsMap(); function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { @@ -59512,17 +59846,17 @@ var ts; ts.forEachEmittedFile = forEachEmittedFile; function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 274) { + if (sourceFile.kind === 275) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; var declarationMapPath = ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var bundleInfoPath = options.references && jsFilePath && (ts.removeFileExtension(jsFilePath) + infoExtension); + var bundleInfoPath = options.references && jsFilePath ? (ts.removeFileExtension(jsFilePath) + infoExtension) : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: bundleInfoPath }; } else { var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var sourceMapFilePath = ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); var isJs = ts.isSourceFileJavaScript(sourceFile); var declarationFilePath = ((forceDtsPaths || options.declaration) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; var declarationMapPath = ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; @@ -59579,7 +59913,7 @@ var ts; emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), emittedFiles: emittedFilesList, - sourceMaps: sourceMapDataList + sourceMaps: sourceMapDataList, }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, bundleInfoPath = _a.bundleInfoPath; @@ -59654,8 +59988,8 @@ var ts; declarationTransform.dispose(); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 274 ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 273 ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 275 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 274 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -59672,7 +60006,7 @@ var ts; if (sourceMapFilePath) { ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, mapRecorder.getText(), false, sourceFiles); } - ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); + ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); if (bundleInfoPath) { bundleInfo.totalLength = writer.getTextPos(); ts.writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), false); @@ -59742,9 +60076,9 @@ var ts; break; } switch (node.kind) { - case 273: return printFile(node); - case 274: return printBundle(node); - case 275: return printUnparsedSource(node); + case 274: return printFile(node); + case 275: return printBundle(node); + case 276: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -59901,8 +60235,7 @@ var ts; return getPipelinePhase(currentPhase + 1, hint); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assertDefined(onEmitNode); - onEmitNode(hint, node, getNextPipelinePhase(0, hint)); + ts.Debug.assertDefined(onEmitNode)(hint, node, getNextPipelinePhase(0, hint)); } function pipelineEmitWithComments(hint, node) { ts.Debug.assertDefined(emitNodeWithComments); @@ -59914,9 +60247,8 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assertDefined(onEmitSourceMapOfNode); ts.Debug.assert(hint !== 0 && hint !== 2); - onEmitSourceMapOfNode(hint, node, pipelineEmitWithHint); + ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { if (hint === 0) @@ -59933,220 +60265,220 @@ var ts; case 15: case 16: return emitLiteral(node); - case 275: + case 276: return emitUnparsedSource(node); case 71: return emitIdentifier(node); - case 145: - return emitQualifiedName(node); case 146: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 147: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 148: - return emitParameter(node); + return emitTypeParameter(node); case 149: - return emitDecorator(node); + return emitParameter(node); case 150: - return emitPropertySignature(node); + return emitDecorator(node); case 151: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 152: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 153: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 154: - return emitConstructor(node); + return emitMethodDeclaration(node); case 155: + return emitConstructor(node); case 156: - return emitAccessorDeclaration(node); case 157: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 158: - return emitConstructSignature(node); + return emitCallSignature(node); case 159: - return emitIndexSignature(node); + return emitConstructSignature(node); case 160: - return emitTypePredicate(node); + return emitIndexSignature(node); case 161: - return emitTypeReference(node); + return emitTypePredicate(node); case 162: - return emitFunctionType(node); - case 283: - return emitJSDocFunctionType(node); + return emitTypeReference(node); case 163: - return emitConstructorType(node); + return emitFunctionType(node); + case 284: + return emitJSDocFunctionType(node); case 164: - return emitTypeQuery(node); + return emitConstructorType(node); case 165: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 166: - return emitArrayType(node); + return emitTypeLiteral(node); case 167: - return emitTupleType(node); + return emitArrayType(node); case 168: - return emitUnionType(node); + return emitTupleType(node); case 169: - return emitIntersectionType(node); + return emitUnionType(node); case 170: - return emitConditionalType(node); + return emitIntersectionType(node); case 171: - return emitInferType(node); + return emitConditionalType(node); case 172: - return emitParenthesizedType(node); - case 206: - return emitExpressionWithTypeArguments(node); + return emitInferType(node); case 173: - return emitThisType(); + return emitParenthesizedType(node); + case 207: + return emitExpressionWithTypeArguments(node); case 174: - return emitTypeOperator(node); + return emitThisType(); case 175: - return emitIndexedAccessType(node); + return emitTypeOperator(node); case 176: - return emitMappedType(node); + return emitIndexedAccessType(node); case 177: - return emitLiteralType(node); + return emitMappedType(node); case 178: + return emitLiteralType(node); + case 179: return emitImportTypeNode(node); - case 278: + case 279: write("*"); return; - case 279: + case 280: write("?"); return; - case 280: - return emitJSDocNullableType(node); case 281: - return emitJSDocNonNullableType(node); + return emitJSDocNullableType(node); case 282: + return emitJSDocNonNullableType(node); + case 283: return emitJSDocOptionalType(node); - case 284: + case 285: return emitJSDocVariadicType(node); - case 179: - return emitObjectBindingPattern(node); case 180: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 181: + return emitArrayBindingPattern(node); + case 182: return emitBindingElement(node); - case 210: - return emitTemplateSpan(node); case 211: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 212: - return emitBlock(node); + return emitSemicolonClassElement(); case 213: - return emitVariableStatement(node); + return emitBlock(node); case 214: - return emitEmptyStatement(); + return emitVariableStatement(node); case 215: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 216: - return emitIfStatement(node); + return emitExpressionStatement(node); case 217: - return emitDoStatement(node); + return emitIfStatement(node); case 218: - return emitWhileStatement(node); + return emitDoStatement(node); case 219: - return emitForStatement(node); + return emitWhileStatement(node); case 220: - return emitForInStatement(node); + return emitForStatement(node); case 221: - return emitForOfStatement(node); + return emitForInStatement(node); case 222: - return emitContinueStatement(node); + return emitForOfStatement(node); case 223: - return emitBreakStatement(node); + return emitContinueStatement(node); case 224: - return emitReturnStatement(node); + return emitBreakStatement(node); case 225: - return emitWithStatement(node); + return emitReturnStatement(node); case 226: - return emitSwitchStatement(node); + return emitWithStatement(node); case 227: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 228: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 229: - return emitTryStatement(node); + return emitThrowStatement(node); case 230: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 231: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 232: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 233: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 234: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 235: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 236: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 237: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 238: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 239: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 240: - return emitCaseBlock(node); + return emitModuleBlock(node); case 241: - return emitNamespaceExportDeclaration(node); + return emitCaseBlock(node); case 242: - return emitImportEqualsDeclaration(node); + return emitNamespaceExportDeclaration(node); case 243: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 244: - return emitImportClause(node); + return emitImportDeclaration(node); case 245: - return emitNamespaceImport(node); + return emitImportClause(node); case 246: - return emitNamedImports(node); + return emitNamespaceImport(node); case 247: - return emitImportSpecifier(node); + return emitNamedImports(node); case 248: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 249: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 250: - return emitNamedExports(node); + return emitExportDeclaration(node); case 251: - return emitExportSpecifier(node); + return emitNamedExports(node); case 252: - return; + return emitExportSpecifier(node); case 253: + return; + case 254: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 256: - case 259: - return emitJsxOpeningElementOrFragment(node); case 257: case 260: - return emitJsxClosingElementOrFragment(node); + return emitJsxOpeningElementOrFragment(node); + case 258: case 261: - return emitJsxAttribute(node); + return emitJsxClosingElementOrFragment(node); case 262: - return emitJsxAttributes(node); + return emitJsxAttribute(node); case 263: - return emitJsxSpreadAttribute(node); + return emitJsxAttributes(node); case 264: - return emitJsxExpression(node); + return emitJsxSpreadAttribute(node); case 265: - return emitCaseClause(node); + return emitJsxExpression(node); case 266: - return emitDefaultClause(node); + return emitCaseClause(node); case 267: - return emitHeritageClause(node); + return emitDefaultClause(node); case 268: - return emitCatchClause(node); + return emitHeritageClause(node); case 269: - return emitPropertyAssignment(node); + return emitCatchClause(node); case 270: - return emitShorthandPropertyAssignment(node); + return emitPropertyAssignment(node); case 271: - return emitSpreadAssignment(node); + return emitShorthandPropertyAssignment(node); case 272: + return emitSpreadAssignment(node); + case 273: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -60175,69 +60507,69 @@ var ts; case 91: writeTokenNode(node, writeKeyword); return; - case 182: - return emitArrayLiteralExpression(node); case 183: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 184: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 185: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 186: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 187: - return emitNewExpression(node); + return emitCallExpression(node); case 188: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 189: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 190: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 191: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 192: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 193: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 194: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 195: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 196: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 197: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 198: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 199: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 200: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 201: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 202: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 203: - return emitSpreadExpression(node); + return emitYieldExpression(node); case 204: - return emitClassExpression(node); + return emitSpreadExpression(node); case 205: + return emitClassExpression(node); + case 206: return; - case 207: - return emitAsExpression(node); case 208: - return emitNonNullExpression(node); + return emitAsExpression(node); case 209: + return emitNonNullExpression(node); + case 210: return emitMetaProperty(node); - case 254: - return emitJsxElement(node); case 255: + return emitJsxElement(node); + case 256: return emitJsxSelfClosingElement(node); - case 258: + case 259: return emitJsxFragment(node); - case 300: - return emitPartiallyEmittedExpression(node); case 301: + return emitPartiallyEmittedExpression(node); + case 302: return emitCommaList(node); } } @@ -60254,7 +60586,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 274 ? node : undefined; + var bundle = node.kind === 275 ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -60353,7 +60685,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 283 && !node.name) { + if (node.parent && node.parent.kind === 284 && !node.name) { emit(node.type); } else { @@ -60411,7 +60743,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 155 ? "get" : "set"); + writeKeyword(node.kind === 156 ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -60659,7 +60991,7 @@ var ts; increaseIndent(); } var preferNewLine = node.multiLine ? 32768 : 0; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 ? 32 : 0; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 32 : 0; emitList(node, node.properties, 263122 | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); @@ -60782,7 +61114,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 197 + return operand.kind === 198 && ((node.operator === 37 && (operand.operator === 37 || operand.operator === 43)) || (node.operator === 38 && (operand.operator === 38 || operand.operator === 44))); } @@ -60896,7 +61228,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 216) { + if (node.elseStatement.kind === 217) { writeSpace(); emit(node.elseStatement); } @@ -60959,7 +61291,7 @@ var ts; emitTokenWithComment(19, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(144, node.initializer.end, writeKeyword, node); + emitTokenWithComment(145, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(20, node.expression.end, writePunctuation, node); @@ -60967,7 +61299,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 232) { + if (node.kind === 233) { emit(node); } else { @@ -61252,7 +61584,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 238) { + while (body.kind === 239) { writePunctuation("."); emit(body.name); body = body.body; @@ -61297,7 +61629,7 @@ var ts; if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(142, node.importClause.end, writeKeyword, node); + emitTokenWithComment(143, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -61349,7 +61681,7 @@ var ts; if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(142, fromPos, writeKeyword, node); + emitTokenWithComment(143, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -61546,7 +61878,7 @@ var ts; emitSourceFileWorker(node); } function emitSyntheticTripleSlashReferencesIfNeeded(node) { - emitTripleSlashDirectives(node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || []); + emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || []); } function emitTripleSlashDirectivesIfNeeded(node) { if (node.isDeclarationFile) @@ -61790,7 +62122,7 @@ var ts; if (isUndefined && format & 8192) { return; } - var isEmpty = isUndefined || start >= children.length || count === 0; + var isEmpty = children === undefined || start >= children.length || count === 0; if (isEmpty && format & 16384) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); @@ -61831,7 +62163,7 @@ var ts; increaseIndent(); } var previousSibling = void 0; - var shouldDecreaseIndentAfterEmit = void 0; + var shouldDecreaseIndentAfterEmit = false; for (var i = 0; i < count; i++) { var child = children[start + i]; if (previousSibling) { @@ -62107,7 +62439,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 190 && ts.nodeIsSynthesized(node)) { + while (node.kind === 191 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -62166,81 +62498,81 @@ var ts; if (!node) return; switch (node.kind) { - case 212: + case 213: ts.forEach(node.statements, generateNames); break; - case 227: - case 225: - case 217: + case 228: + case 226: case 218: + case 219: generateNames(node.statement); break; - case 216: + case 217: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 219: - case 221: case 220: + case 222: + case 221: generateNames(node.initializer); generateNames(node.statement); break; - case 226: + case 227: generateNames(node.caseBlock); break; - case 240: + case 241: ts.forEach(node.clauses, generateNames); break; - case 265: case 266: + case 267: ts.forEach(node.statements, generateNames); break; - case 229: + case 230: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 268: + case 269: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 213: + case 214: generateNames(node.declarationList); break; - case 232: + case 233: ts.forEach(node.declarations, generateNames); break; - case 231: - case 148: - case 181: - case 234: + case 232: + case 149: + case 182: + case 235: generateNameIfNeeded(node.name); break; - case 233: + case 234: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 179: case 180: + case 181: ts.forEach(node.elements, generateNames); break; - case 243: - generateNames(node.importClause); - break; case 244: - generateNameIfNeeded(node.name); - generateNames(node.namedBindings); + generateNames(node.importClause); break; case 245: generateNameIfNeeded(node.name); + generateNames(node.namedBindings); break; case 246: - ts.forEach(node.elements, generateNames); + generateNameIfNeeded(node.name); break; case 247: + ts.forEach(node.elements, generateNames); + break; + case 248: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -62249,12 +62581,12 @@ var ts; if (!node) return; switch (node.kind) { - case 269: case 270: - case 151: - case 153: - case 155: + case 271: + case 152: + case 154: case 156: + case 157: generateNameIfNeeded(node.name); break; } @@ -62388,21 +62720,21 @@ var ts; switch (node.kind) { case 71: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8)); + case 239: case 238: - case 237: return generateNameForModuleOrEnum(node); - case 243: - case 249: + case 244: + case 250: return generateNameForImportOrExportDeclaration(node); - case 233: case 234: - case 248: + case 235: + case 249: return generateNameForExportDefault(); - case 204: + case 205: return generateNameForClassExpression(); - case 153: - case 155: + case 154: case 156: + case 157: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); @@ -62417,7 +62749,7 @@ var ts; case 3: return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16), !!(name.autoGenerateFlags & 8)); } - ts.Debug.fail("Unsupported GeneratedIdentifierKind."); + return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } function getNodeForGeneratedName(name) { var autoGenerateId = name.autoGenerateId; @@ -63078,8 +63410,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? - configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -63107,7 +63438,7 @@ var ts; function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) { var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; - var host = createProgramOptions.host, oldProgram = createProgramOptions.oldProgram; + var oldProgram = createProgramOptions.oldProgram; var program; var files = []; var commonSourceDirectory; @@ -63124,7 +63455,7 @@ var ts; var modulesWithElidedImports = ts.createMap(); var sourceFilesFoundSearchingNodeModules = ts.createMap(); ts.performance.mark("beforeProgram"); - host = host || createCompilerHost(options); + var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHost(host); var skipDefaultLib = options.noLib; var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); }); @@ -63231,6 +63562,7 @@ var ts; getOptionsDiagnostics: getOptionsDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getSemanticDiagnostics: getSemanticDiagnostics, + getSuggestionDiagnostics: getSuggestionDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, getTypeChecker: getTypeChecker, getClassifiableNames: getClassifiableNames, @@ -63601,7 +63933,7 @@ var ts; return nodes; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules.get(file.path); + return !!sourceFilesFoundSearchingNodeModules.get(file.path); } function isSourceFileDefaultLibrary(file) { if (file.hasNoDefaultLib) { @@ -63615,7 +63947,7 @@ var ts; return equalityComparer(file.fileName, getDefaultLibraryFileName()); } else { - return ts.forEach(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); }); + return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); }); } } function getDiagnosticsProducingTypeChecker() { @@ -63732,11 +64064,24 @@ var ts; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); - if (isCheckJs) { - diagnostics = ts.concatenate(diagnostics, sourceFile.jsDocDiagnostics); + var diagnostics; + for (var _i = 0, _a = [bindDiagnostics, checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile, isCheckJs ? sourceFile.jsDocDiagnostics : undefined]; _i < _a.length; _i++) { + var diags = _a[_i]; + if (diags) { + for (var _b = 0, diags_1 = diags; _b < diags_1.length; _b++) { + var diag = diags_1[_b]; + if (shouldReportDiagnostic(diag)) { + diagnostics = ts.append(diagnostics, diag); + } + } + } } - return ts.filter(diagnostics, shouldReportDiagnostic); + return diagnostics; + }); + } + function getSuggestionDiagnostics(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken); }); } function shouldReportDiagnostic(diagnostic) { @@ -63766,62 +64111,62 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 148: - case 151: + case 149: + case 152: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - case 153: - case 152: case 154: + case 153: case 155: case 156: - case 191: - case 233: + case 157: case 192: - case 231: + case 234: + case 193: + case 232: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 242: + case 243: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 248: + case 249: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 267: + case 268: var heritageClause = node; if (heritageClause.token === 108) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 235: + case 236: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 238: + case 239: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 236: + case 237: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 237: + case 238: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 208: + case 209: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 207: + case 208: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 189: + case 190: ts.Debug.fail(); } var prevParent = parent; @@ -63834,25 +64179,25 @@ 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_to_remove_this_warning)); } switch (parent.kind) { - case 234: - case 153: - case 152: + case 235: case 154: + case 153: case 155: case 156: - case 191: - case 233: + case 157: case 192: + case 234: + case 193: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 213: + case 214: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 213); + return checkModifiers(nodes, parent.kind === 214); } break; - case 151: + case 152: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; @@ -63863,17 +64208,17 @@ var ts; return; } break; - case 148: + case 149: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 186: case 187: - case 206: - case 255: + case 188: + case 207: case 256: + case 257: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; @@ -64624,9 +64969,9 @@ var ts; if (ts.isObjectLiteralExpression(pathProp.initializer)) { for (var _a = 0, _b = ts.getPropertyAssignment(pathProp.initializer, key); _a < _b.length; _a++) { var keyProps = _b[_a]; - if (ts.isArrayLiteralExpression(keyProps.initializer) && - keyProps.initializer.elements.length > valueIndex) { - programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, keyProps.initializer.elements[valueIndex], message, arg0, arg1, arg2)); + var initializer = keyProps.initializer; + if (ts.isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) { + programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, arg0, arg1, arg2)); needCompilerDiagnostic = false; } } @@ -64728,6 +65073,7 @@ var ts; return false; } programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, arrayLiteral.elements[index], message, arg0, arg1, arg2)); + return false; } function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(toPath(emitFileName), true); @@ -64745,13 +65091,16 @@ var ts; if (out) { return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts"); } + if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { + return true; + } if (options.outDir) { return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); } if (ts.fileExtensionIsOneOf(filePath, ts.supportedJavascriptExtensions) || ts.fileExtensionIs(filePath, ".d.ts")) { var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath(ts.combinePaths(filePathWithoutExtension, ".ts")) || - !!getSourceFileByPath(ts.combinePaths(filePathWithoutExtension, ".tsx")); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts")) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx")); } return false; } @@ -64879,7 +65228,7 @@ var ts; for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var version_1 = sourceFile.version; - var oldInfo = useOldState && oldState.fileInfos.get(sourceFile.path); + var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.path) : undefined; if (referencedMap) { var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName); if (newReferences) { @@ -64926,7 +65275,8 @@ var ts; return false; } var info = state.fileInfos.get(sourceFile.path); - ts.Debug.assert(!!info); + if (!info) + return ts.Debug.fail(); var prevSignature = info.signature; var latestSignature; if (sourceFile.isDeclarationFile) { @@ -65051,7 +65401,7 @@ var ts; var ts; (function (ts) { function hasSameKeys(map1, map2) { - return map1 === map2 || map1 && map2 && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); + 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); @@ -65073,7 +65423,7 @@ var ts; ts.copyEntries(oldState.changedFilesSet, state.changedFilesSet); } var referencedMap = state.referencedMap; - var oldReferencedMap = useOldState && oldState.referencedMap; + var oldReferencedMap = useOldState ? oldState.referencedMap : undefined; state.fileInfos.forEach(function (info, sourceFilePath) { var oldInfo; var newReferences; @@ -65239,7 +65589,7 @@ var ts; assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile); if (!targetSourceFile) { var sourceMaps = []; - var emitSkipped = void 0; + var emitSkipped = false; var diagnostics = void 0; var emittedFiles = []; var affectedEmitResult = void 0; @@ -65350,7 +65700,7 @@ var ts; var customFailedLookupPaths = ts.createMap(); var directoryWatchesOfFailedLookups = ts.createMap(); var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory())); - var rootPath = rootDir && resolutionHost.toPath(rootDir); + var rootPath = (rootDir && resolutionHost.toPath(rootDir)); var typeRootsWatches = ts.createMap(); return { startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions, @@ -65402,7 +65752,7 @@ var ts; return false; } var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path); - return value && !!value.length; + return !!value && !!value.length; } function createHasInvalidatedResolution(forceAllFilesAsInvalidated) { if (allFilesHaveInvalidatedResolution || forceAllFilesAsInvalidated) { @@ -65411,7 +65761,7 @@ var ts; } var collected = filesWithInvalidatedResolutions; filesWithInvalidatedResolutions = undefined; - return function (path) { return (collected && collected.has(path)) || + return function (path) { return (!!collected && collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } function clearPerDirectoryResolutions() { @@ -65559,19 +65909,20 @@ var ts; if (isNodeModulesDirectory(dirPath)) { return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath }, ts.getDirectoryPath(dirPath)); } - var subDirectory; + var subDirectoryPath, subDirectory; if (rootPath !== undefined) { while (!isInDirectoryPath(dirPath, rootPath)) { var parentPath = ts.getDirectoryPath(dirPath); if (parentPath === dirPath) { break; } - subDirectory = dirPath.slice(parentPath.length + ts.directorySeparator.length); + subDirectoryPath = dirPath; + subDirectory = dir; dirPath = parentPath; dir = ts.getDirectoryPath(dir); } } - return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath, subDirectory: subDirectory }, dirPath); + return filterFSRootDirectoriesToWatch({ dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath }, dirPath); } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -65590,7 +65941,7 @@ var ts; for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) { var failedLookupLocation = failedLookupLocations_1[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, ignore = _a.ignore, subDirectory = _a.subDirectory; + var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, ignore = _a.ignore; if (!ignore) { if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) { var refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0; @@ -65600,7 +65951,7 @@ var ts; setAtRoot = true; } else { - setDirectoryWatcher(dir, dirPath, subDirectory); + setDirectoryWatcher(dir, dirPath); } } } @@ -65608,19 +65959,13 @@ var ts; setDirectoryWatcher(rootDir, rootPath); } } - function setDirectoryWatcher(dir, dirPath, subDirectory) { + function setDirectoryWatcher(dir, dirPath) { var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); if (dirWatcher) { dirWatcher.refCount++; } else { - dirWatcher = { watcher: createDirectoryWatcher(dir, dirPath), refCount: 1 }; - directoryWatchesOfFailedLookups.set(dirPath, dirWatcher); - } - if (subDirectory) { - var subDirectoryMap = dirWatcher.subDirectoryMap || (dirWatcher.subDirectoryMap = ts.createMap()); - var existing = subDirectoryMap.get(subDirectory) || 0; - subDirectoryMap.set(subDirectory, existing + 1); + directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath), refCount: 1 }); } } function stopWatchFailedLookupLocationOfResolution(resolution) { @@ -65636,7 +65981,7 @@ var ts; for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) { var failedLookupLocation = failedLookupLocations_2[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore, subDirectory = _a.subDirectory; + var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore; if (!ignore) { var refCount = customFailedLookupPaths.get(failedLookupLocationPath); if (refCount) { @@ -65652,7 +65997,7 @@ var ts; removeAtRoot = true; } else { - removeDirectoryWatcher(dirPath, subDirectory); + removeDirectoryWatcher(dirPath); } } } @@ -65660,39 +66005,18 @@ var ts; removeDirectoryWatcher(rootPath); } } - function removeDirectoryWatcher(dirPath, subDirectory) { + function removeDirectoryWatcher(dirPath) { var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); - if (subDirectory) { - var existing = dirWatcher.subDirectoryMap.get(subDirectory); - if (existing === 1) { - dirWatcher.subDirectoryMap.delete(subDirectory); - } - else { - dirWatcher.subDirectoryMap.set(subDirectory, existing - 1); - } - } dirWatcher.refCount--; } - function inWatchedSubdirectory(dirPath, fileOrDirectoryPath) { - var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); - if (!dirWatcher || !dirWatcher.subDirectoryMap) - return false; - return ts.forEachKey(dirWatcher.subDirectoryMap, function (subDirectory) { - var fullSubDirectory = dirPath + "/" + subDirectory; - return fullSubDirectory === fileOrDirectoryPath || isInDirectoryPath(fullSubDirectory, fileOrDirectoryPath); - }); - } function createDirectoryWatcher(directory, dirPath) { return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) { var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory); if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } - if (!allFilesHaveInvalidatedResolution && - (dirPath === rootPath || isNodeModulesDirectory(dirPath) || ts.getDirectoryPath(fileOrDirectoryPath) === dirPath || inWatchedSubdirectory(dirPath, fileOrDirectoryPath))) { - if (invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) { - resolutionHost.onInvalidatedResolution(); - } + if (!allFilesHaveInvalidatedResolution && invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) { + resolutionHost.onInvalidatedResolution(); } }, 1); } @@ -65744,7 +66068,7 @@ var ts; removeResolutionsOfFile(filePath); invalidateResolutions(function (resolution, getResolutionWithResolvedFileName) { var result = getResolutionWithResolvedFileName(resolution); - return result && resolutionHost.toPath(result.resolvedFileName) === filePath; + return !!result && resolutionHost.toPath(result.resolvedFileName) === filePath; }); } function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) { @@ -65791,7 +66115,7 @@ var ts; return rootPath; } var _a = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath), dirPath = _a.dirPath, ignore = _a.ignore; - return !ignore && directoryWatchesOfFailedLookups.has(dirPath) && dirPath; + return !ignore && directoryWatchesOfFailedLookups.has(dirPath) ? dirPath : undefined; } function createTypeRootsWatch(typeRootPath, typeRoot) { return resolutionHost.watchTypeRootsDirectory(typeRoot, function (fileOrDirectory) { @@ -66013,9 +66337,9 @@ var ts; system.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } function createWatchCompilerHostOfConfigFile(configFileName, optionsToExtend, system, createProgram, reportDiagnostic, reportWatchStatus) { - reportDiagnostic = reportDiagnostic || createDiagnosticReporter(system); - var host = createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus); - host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; + var diagnosticReporter = reportDiagnostic || createDiagnosticReporter(system); + var host = createWatchCompilerHost(system, createProgram, diagnosticReporter, reportWatchStatus); + host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, diagnosticReporter, diagnostic); }; host.configFileName = configFileName; host.optionsToExtend = optionsToExtend; return host; @@ -66059,7 +66383,7 @@ var ts; var configFileSpecs; var configFileParsingDiagnostics; var hasChangedConfigFileParsingErrors = false; - var cachedDirectoryStructureHost = configFileName && ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames); + var cachedDirectoryStructureHost = configFileName === undefined ? undefined : ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames); if (cachedDirectoryStructureHost && host.onCachedDirectoryStructureHostCreate) { host.onCachedDirectoryStructureHostCreate(cachedDirectoryStructureHost); } @@ -66109,7 +66433,7 @@ var ts; readFile: readFile, trace: trace, directoryExists: directoryStructureHost.directoryExists && (function (path) { return directoryStructureHost.directoryExists(path); }), - getDirectories: directoryStructureHost.getDirectories && (function (path) { return directoryStructureHost.getDirectories(path); }), + getDirectories: (directoryStructureHost.getDirectories && (function (path) { return directoryStructureHost.getDirectories(path); })), realpath: host.realpath && (function (s) { return host.realpath(s); }), getEnvironmentVariable: host.getEnvironmentVariable ? (function (name) { return host.getEnvironmentVariable(name); }) : (function () { return ""; }), onReleaseOldSourceFile: onReleaseOldSourceFile, @@ -66596,6 +66920,7 @@ var ts; "es2018.promise": "lib.es2018.promise.d.ts", "es2018.regexp": "lib.es2018.regexp.d.ts", "esnext.array": "lib.esnext.array.d.ts", + "esnext.symbol": "lib.esnext.symbol.d.ts", "esnext.asynciterable": "lib.esnext.asynciterable.d.ts", }), }, @@ -67219,7 +67544,7 @@ var ts; case "string": return ts.map(values, function (v) { return v || ""; }); default: - return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + return ts.mapDefined(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }); } } ts.parseListTypeOption = parseListTypeOption; @@ -67340,6 +67665,7 @@ var ts; } return optionNameMap.get(optionName); } + ts.getOptionFromName = getOptionFromName; function getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host) { var configFileText; try { @@ -67474,7 +67800,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 269) { + if (element.kind !== 270) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -67545,13 +67871,13 @@ var ts; case 8: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 197: + case 198: if (valueExpression.operator !== 38 || valueExpression.operand.kind !== 8) { break; } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 183: + case 184: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; if (option) { @@ -67561,7 +67887,7 @@ var ts; else { return convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined); } - case 182: + case 183: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -67598,6 +67924,7 @@ var ts; var expectedType = ts.isString(option.type) ? option.type : "string"; return typeof value === expectedType; } + return false; } function generateTSConfig(options, fileNames, newLine) { var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); @@ -68019,13 +68346,10 @@ var ts; } function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { - return undefined; + return false; } var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption.compileOnSave, basePath, errors); - if (typeof result === "boolean" && result) { - return result; - } - return false; + return typeof result === "boolean" && result; } function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var errors = []; @@ -68054,7 +68378,7 @@ var ts; return options; } function getDefaultTypeAcquisition(configFileName) { - return { enable: configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; + return { enable: !!configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; } function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) { var options = getDefaultTypeAcquisition(configFileName); @@ -68382,7 +68706,7 @@ var ts; } if (commandLine.options.help || commandLine.options.all) { printVersion(); - printHelp(commandLine.options.all); + printHelp(!!commandLine.options.all); return ts.sys.exit(ts.ExitStatus.Success); } if (commandLine.options.project) { @@ -68412,7 +68736,7 @@ var ts; } if (commandLine.fileNames.length === 0 && !configFileName) { printVersion(); - printHelp(commandLine.options.all); + printHelp(!!commandLine.options.all); return ts.sys.exit(ts.ExitStatus.Success); } var commandLineOptions = commandLine.options; @@ -68575,7 +68899,7 @@ var ts; output.push(getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine); var optsList = showAllOptions ? ts.sort(ts.optionDeclarations, function (a, b) { return ts.compareStringsCaseInsensitive(a.name, b.name); }) : - ts.filter(ts.optionDeclarations.slice(), function (v) { return v.showInSimplifiedHelpView; }); + ts.filter(ts.optionDeclarations.slice(), function (v) { return !!v.showInSimplifiedHelpView; }); marginLength = 0; var usageColumn = []; var descriptionColumn = []; diff --git a/lib/tsserver.js b/lib/tsserver.js index dc5875cc4b9..035ba5afaf9 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -188,169 +188,170 @@ var ts; SyntaxKind[SyntaxKind["TypeKeyword"] = 139] = "TypeKeyword"; SyntaxKind[SyntaxKind["UndefinedKeyword"] = 140] = "UndefinedKeyword"; SyntaxKind[SyntaxKind["UniqueKeyword"] = 141] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 142] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 143] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 144] = "OfKeyword"; - SyntaxKind[SyntaxKind["QualifiedName"] = 145] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 146] = "ComputedPropertyName"; - SyntaxKind[SyntaxKind["TypeParameter"] = 147] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 148] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 149] = "Decorator"; - SyntaxKind[SyntaxKind["PropertySignature"] = 150] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 151] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 152] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 153] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 154] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 155] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 156] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 157] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 158] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 159] = "IndexSignature"; - SyntaxKind[SyntaxKind["TypePredicate"] = 160] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 161] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 162] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 163] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 164] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 165] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 166] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 167] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 168] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 169] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 170] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 171] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 172] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 173] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 174] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 175] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 176] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 177] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 178] = "ImportType"; - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 179] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 180] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 181] = "BindingElement"; - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 182] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 183] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 184] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 185] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 186] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 187] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 188] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 189] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 190] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 191] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 192] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 193] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 194] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 195] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 196] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 197] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 198] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 199] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 200] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 201] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 202] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 203] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 204] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 205] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 206] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 207] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 208] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 209] = "MetaProperty"; - SyntaxKind[SyntaxKind["TemplateSpan"] = 210] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 211] = "SemicolonClassElement"; - SyntaxKind[SyntaxKind["Block"] = 212] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 213] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 214] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 215] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 216] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 217] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 218] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 219] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 220] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 221] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 222] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 223] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 224] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 225] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 226] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 227] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 228] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 229] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 230] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 231] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 232] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 233] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 234] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 235] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 236] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 237] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 238] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 239] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 240] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 241] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 242] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 243] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 244] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 245] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 246] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 247] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 248] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 249] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 250] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 251] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 252] = "MissingDeclaration"; - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 253] = "ExternalModuleReference"; - SyntaxKind[SyntaxKind["JsxElement"] = 254] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 255] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 256] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 257] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 258] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 259] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 260] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 261] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 262] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 263] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 264] = "JsxExpression"; - SyntaxKind[SyntaxKind["CaseClause"] = 265] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 266] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 267] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 268] = "CatchClause"; - SyntaxKind[SyntaxKind["PropertyAssignment"] = 269] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 270] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 271] = "SpreadAssignment"; - SyntaxKind[SyntaxKind["EnumMember"] = 272] = "EnumMember"; - SyntaxKind[SyntaxKind["SourceFile"] = 273] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 274] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 275] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 276] = "InputFiles"; - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 277] = "JSDocTypeExpression"; - SyntaxKind[SyntaxKind["JSDocAllType"] = 278] = "JSDocAllType"; - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 279] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 280] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 281] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 282] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 283] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 284] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 285] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 286] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 287] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 288] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 289] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 290] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 291] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 292] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 293] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 294] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 295] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 296] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 297] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["SyntaxList"] = 298] = "SyntaxList"; - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 299] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 300] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 301] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 302] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 303] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["Count"] = 304] = "Count"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 142] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 143] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 144] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 145] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 146] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 147] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 148] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 149] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 150] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 151] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 152] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 153] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 154] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 155] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 156] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 157] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 158] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 159] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 160] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 161] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 162] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 163] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 164] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 165] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 166] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 167] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 168] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 169] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 170] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 171] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 172] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 173] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 174] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 175] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 176] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 177] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 178] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 179] = "ImportType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 180] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 181] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 182] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 183] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 184] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 185] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 186] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 187] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 188] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 189] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 190] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 191] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 192] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 193] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 194] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 195] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 196] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 197] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 198] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 199] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 200] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 201] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 202] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 203] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 204] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 205] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 206] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 207] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 208] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 209] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 210] = "MetaProperty"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 211] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 212] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 213] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 214] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 215] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 216] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 217] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 218] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 219] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 220] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 221] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 222] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 223] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 224] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 225] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 226] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 227] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 228] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 229] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 230] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 231] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 232] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 233] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 234] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 235] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 236] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 237] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 238] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 239] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 240] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 241] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 242] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 243] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 244] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 245] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 246] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 247] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 248] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 249] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 250] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 251] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 252] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 253] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 254] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 255] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 256] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 257] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 258] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 259] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 260] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 261] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 262] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 263] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 264] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 265] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 266] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 267] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 268] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 269] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 270] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 271] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 272] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 273] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 274] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 275] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 276] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 277] = "InputFiles"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 278] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 279] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 280] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 281] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 282] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 283] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 284] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 285] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 286] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 288] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 289] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 290] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 291] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 292] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 293] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 294] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 295] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 296] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 297] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 298] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["SyntaxList"] = 299] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 300] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 301] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 302] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 303] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 304] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["Count"] = 305] = "Count"; SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 59] = "FirstCompoundAssignment"; @@ -358,15 +359,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 144] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 145] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 160] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 178] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 179] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 144] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 145] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -375,13 +376,13 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 145] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 277] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 297] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 288] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 297] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 278] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 298] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 289] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 298] = "LastJSDocTagNode"; SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; - SyntaxKind[SyntaxKind["LastContextualKeyword"] = 144] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -749,67 +750,69 @@ var ts; var TypeFlags; (function (TypeFlags) { TypeFlags[TypeFlags["Any"] = 1] = "Any"; - TypeFlags[TypeFlags["String"] = 2] = "String"; - TypeFlags[TypeFlags["Number"] = 4] = "Number"; - TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; - TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; - TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; - TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; - TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; - TypeFlags[TypeFlags["UniqueESSymbol"] = 1024] = "UniqueESSymbol"; - TypeFlags[TypeFlags["Void"] = 2048] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 4096] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 8192] = "Null"; - TypeFlags[TypeFlags["Never"] = 16384] = "Never"; - TypeFlags[TypeFlags["TypeParameter"] = 32768] = "TypeParameter"; - TypeFlags[TypeFlags["Object"] = 65536] = "Object"; - TypeFlags[TypeFlags["Union"] = 131072] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 262144] = "Intersection"; - TypeFlags[TypeFlags["Index"] = 524288] = "Index"; - TypeFlags[TypeFlags["IndexedAccess"] = 1048576] = "IndexedAccess"; - TypeFlags[TypeFlags["Conditional"] = 2097152] = "Conditional"; - TypeFlags[TypeFlags["Substitution"] = 4194304] = "Substitution"; - TypeFlags[TypeFlags["FreshLiteral"] = 8388608] = "FreshLiteral"; - TypeFlags[TypeFlags["ContainsWideningType"] = 16777216] = "ContainsWideningType"; - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 33554432] = "ContainsObjectLiteral"; - TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 67108864] = "ContainsAnyFunctionType"; - TypeFlags[TypeFlags["NonPrimitive"] = 134217728] = "NonPrimitive"; - TypeFlags[TypeFlags["UnionOfUnitTypes"] = 268435456] = "UnionOfUnitTypes"; - TypeFlags[TypeFlags["GenericMappedType"] = 536870912] = "GenericMappedType"; - TypeFlags[TypeFlags["Nullable"] = 12288] = "Nullable"; - TypeFlags[TypeFlags["Literal"] = 224] = "Literal"; - TypeFlags[TypeFlags["Unit"] = 13536] = "Unit"; - TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; - TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 1120] = "StringOrNumberLiteralOrUnique"; - TypeFlags[TypeFlags["DefinitelyFalsy"] = 14560] = "DefinitelyFalsy"; - TypeFlags[TypeFlags["PossiblyFalsy"] = 14574] = "PossiblyFalsy"; - TypeFlags[TypeFlags["Intrinsic"] = 134249103] = "Intrinsic"; - TypeFlags[TypeFlags["Primitive"] = 16382] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 84] = "NumberLike"; - TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; - TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; - TypeFlags[TypeFlags["ESSymbolLike"] = 1536] = "ESSymbolLike"; - TypeFlags[TypeFlags["VoidLike"] = 6144] = "VoidLike"; - TypeFlags[TypeFlags["DisjointDomains"] = 134233854] = "DisjointDomains"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 393216] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 458752] = "StructuredType"; - TypeFlags[TypeFlags["TypeVariable"] = 1081344] = "TypeVariable"; - TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 7372800] = "InstantiableNonPrimitive"; - TypeFlags[TypeFlags["InstantiablePrimitive"] = 524288] = "InstantiablePrimitive"; - TypeFlags[TypeFlags["Instantiable"] = 7897088] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 8355840] = "StructuredOrInstantiable"; - TypeFlags[TypeFlags["Narrowable"] = 142575359] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 134283777] = "NotUnionOrUnit"; - TypeFlags[TypeFlags["NotUnit"] = 8374815] = "NotUnit"; - TypeFlags[TypeFlags["RequiresWidening"] = 50331648] = "RequiresWidening"; - TypeFlags[TypeFlags["PropagatingFlags"] = 117440512] = "PropagatingFlags"; - TypeFlags[TypeFlags["NonWideningType"] = 16777216] = "NonWideningType"; - TypeFlags[TypeFlags["Wildcard"] = 33554432] = "Wildcard"; - TypeFlags[TypeFlags["EmptyObject"] = 67108864] = "EmptyObject"; - TypeFlags[TypeFlags["ConstructionFlags"] = 117440512] = "ConstructionFlags"; + TypeFlags[TypeFlags["Unknown"] = 2] = "Unknown"; + TypeFlags[TypeFlags["String"] = 4] = "String"; + TypeFlags[TypeFlags["Number"] = 8] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 16] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 32] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 64] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 128] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 256] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 512] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 1024] = "ESSymbol"; + TypeFlags[TypeFlags["UniqueESSymbol"] = 2048] = "UniqueESSymbol"; + TypeFlags[TypeFlags["Void"] = 4096] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 8192] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 16384] = "Null"; + TypeFlags[TypeFlags["Never"] = 32768] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 65536] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 131072] = "Object"; + TypeFlags[TypeFlags["Union"] = 262144] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 524288] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 1048576] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 2097152] = "IndexedAccess"; + TypeFlags[TypeFlags["Conditional"] = 4194304] = "Conditional"; + TypeFlags[TypeFlags["Substitution"] = 8388608] = "Substitution"; + TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; + TypeFlags[TypeFlags["FreshLiteral"] = 33554432] = "FreshLiteral"; + TypeFlags[TypeFlags["UnionOfUnitTypes"] = 67108864] = "UnionOfUnitTypes"; + TypeFlags[TypeFlags["ContainsWideningType"] = 134217728] = "ContainsWideningType"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 268435456] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 536870912] = "ContainsAnyFunctionType"; + TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; + TypeFlags[TypeFlags["Nullable"] = 24576] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 448] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 27072] = "Unit"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 192] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 2240] = "StringOrNumberLiteralOrUnique"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 29120] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 29148] = "PossiblyFalsy"; + TypeFlags[TypeFlags["Intrinsic"] = 16839967] = "Intrinsic"; + TypeFlags[TypeFlags["Primitive"] = 32764] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 68] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 168] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 272] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 544] = "EnumLike"; + TypeFlags[TypeFlags["ESSymbolLike"] = 3072] = "ESSymbolLike"; + TypeFlags[TypeFlags["VoidLike"] = 12288] = "VoidLike"; + TypeFlags[TypeFlags["DisjointDomains"] = 16809468] = "DisjointDomains"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 786432] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 917504] = "StructuredType"; + TypeFlags[TypeFlags["TypeVariable"] = 2162688] = "TypeVariable"; + TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 14745600] = "InstantiableNonPrimitive"; + TypeFlags[TypeFlags["InstantiablePrimitive"] = 1048576] = "InstantiablePrimitive"; + TypeFlags[TypeFlags["Instantiable"] = 15794176] = "Instantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 16711680] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["Narrowable"] = 33492479] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 16909315] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["NotUnit"] = 16749629] = "NotUnit"; + TypeFlags[TypeFlags["RequiresWidening"] = 402653184] = "RequiresWidening"; + TypeFlags[TypeFlags["PropagatingFlags"] = 939524096] = "PropagatingFlags"; + TypeFlags[TypeFlags["NonWideningType"] = 134217728] = "NonWideningType"; + TypeFlags[TypeFlags["Wildcard"] = 268435456] = "Wildcard"; + TypeFlags[TypeFlags["EmptyObject"] = 536870912] = "EmptyObject"; + TypeFlags[TypeFlags["ConstructionFlags"] = 939524096] = "ConstructionFlags"; + TypeFlags[TypeFlags["GenericMappedType"] = 134217728] = "GenericMappedType"; })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); var ObjectFlags; (function (ObjectFlags) { @@ -1154,6 +1157,7 @@ var ts; })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); var EmitFlags; (function (EmitFlags) { + EmitFlags[EmitFlags["None"] = 0] = "None"; EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine"; EmitFlags[EmitFlags["AdviseOnEmitNode"] = 2] = "AdviseOnEmitNode"; EmitFlags[EmitFlags["NoSubstitution"] = 4] = "NoSubstitution"; @@ -1386,7 +1390,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.versionMajorMinor = "2.9"; + ts.versionMajorMinor = "3.0"; ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); (function (ts) { @@ -1517,6 +1521,10 @@ var ts; return array ? array.length : 0; } ts.length = length; + function hasEntries(map) { + return !!map && !!map.size; + } + ts.hasEntries = hasEntries; function forEach(array, callback) { if (array) { for (var i = 0; i < array.length; i++) { @@ -1657,7 +1665,7 @@ var ts; return result; } } - Debug.fail(); + return Debug.fail(); } ts.findMap = findMap; function contains(array, value, equalityComparer) { @@ -2187,15 +2195,6 @@ var ts; return to; } ts.addRange = addRange; - function prependRange(to, from) { - if (from === undefined || from.length === 0) - return to; - if (to === undefined) - return from.slice(); - to.unshift.apply(to, from); - return to; - } - ts.prependRange = prependRange; function pushIfUnique(array, toAdd, equalityComparer) { if (contains(array, toAdd, equalityComparer)) { return false; @@ -2588,10 +2587,10 @@ var ts; if (value !== undefined && test(value)) return value; if (value && typeof value.kind === "number") { - Debug.fail("Invalid cast. The supplied " + Debug.showSyntaxKind(value) + " did not pass the test '" + Debug.getFunctionName(test) + "'."); + return Debug.fail("Invalid cast. The supplied " + Debug.showSyntaxKind(value) + " did not pass the test '" + Debug.getFunctionName(test) + "'."); } else { - Debug.fail("Invalid cast. The supplied value did not pass the test '" + Debug.getFunctionName(test) + "'."); + return Debug.fail("Invalid cast. The supplied value did not pass the test '" + Debug.getFunctionName(test) + "'."); } } ts.cast = cast; @@ -2671,7 +2670,7 @@ var ts; } ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { - baseIndex = baseIndex || 0; + if (baseIndex === void 0) { baseIndex = 0; } return text.replace(/{(\d+)}/g, function (_match, index) { return Debug.assertDefined(args[+index + baseIndex]); }); } ts.formatStringFromArgs = formatStringFromArgs; @@ -2908,7 +2907,9 @@ var ts; return compareValues(a ? 1 : 0, b ? 1 : 0); } ts.compareBooleans = compareBooleans; - function compareMessageText(text1, text2) { + function compareMessageText(t1, t2) { + var text1 = t1; + var text2 = t2; while (text1 && text2) { var string1 = isString(text1) ? text1 : text1.messageText; var string2 = isString(text2) ? text2 : text2.messageText; @@ -2942,6 +2943,14 @@ var ts; return moduleResolution; } ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; + function unreachableCodeIsError(options) { + return options.allowUnreachableCode === false; + } + ts.unreachableCodeIsError = unreachableCodeIsError; + function unusedLabelIsError(options) { + return options.allowUnusedLabels === false; + } + ts.unusedLabelIsError = unusedLabelIsError; function getAreDeclarationMapsEnabled(options) { return !!(options.declaration && options.declarationMap); } @@ -2960,7 +2969,7 @@ var ts; } ts.getEmitDeclarations = getEmitDeclarations; function getStrictOptionValue(compilerOptions, flag) { - return compilerOptions[flag] === undefined ? compilerOptions.strict : compilerOptions[flag]; + return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; } ts.getStrictOptionValue = getStrictOptionValue; function hasZeroOrOneAsteriskCharacter(str) { @@ -3338,6 +3347,23 @@ var ts; return startsWith(str, prefix) ? str.substr(prefix.length) : str; } ts.removePrefix = removePrefix; + function tryRemovePrefix(str, prefix) { + return startsWith(str, prefix) ? str.substring(prefix.length) : undefined; + } + ts.tryRemovePrefix = tryRemovePrefix; + function tryRemoveDirectoryPrefix(path, dirPath) { + var a = tryRemovePrefix(path, dirPath); + if (a === undefined) + return undefined; + switch (a.charCodeAt(0)) { + case 47: + case 92: + return a.slice(1); + default: + return undefined; + } + } + ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; function endsWith(str, suffix) { var expectedPos = str.length - suffix.length; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; @@ -3347,6 +3373,10 @@ var ts; return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str; } ts.removeSuffix = removeSuffix; + function tryRemoveSuffix(str, suffix) { + return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : undefined; + } + ts.tryRemoveSuffix = tryRemoveSuffix; function stringContains(str, substring) { return str.indexOf(substring) !== -1; } @@ -3420,7 +3450,7 @@ var ts; var subpattern = ""; var hasWrittenComponent = false; var components = getNormalizedPathComponents(spec, basePath); - var lastComponent = lastOrUndefined(components); + var lastComponent = last(components); if (usage !== "exclude" && lastComponent === "**") { return undefined; } @@ -3486,14 +3516,17 @@ var ts; }; } ts.getFileMatcherPatterns = getFileMatcherPatterns; + function getRegexFromPattern(pattern, useCaseSensitiveFileNames) { + return new RegExp(pattern, useCaseSensitiveFileNames ? "" : "i"); + } + ts.getRegexFromPattern = getRegexFromPattern; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); - var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); - var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); - var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return getRegexFromPattern(pattern, useCaseSensitiveFileNames); }); + var includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames); + var excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames); var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; @@ -3611,11 +3644,11 @@ var ts; return scriptKind === 1 || scriptKind === 2; } function hasJavaScriptFileExtension(fileName) { - return forEach(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + return some(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); } ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; function hasTypeScriptFileExtension(fileName) { - return forEach(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + return some(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); } ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) { @@ -3803,7 +3836,8 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { - assert(value !== undefined && value !== null, message); + if (value === undefined || value === null) + return fail(message); return value; } Debug.assertDefined = assertDefined; @@ -3961,10 +3995,7 @@ var ts; ts.resolutionExtensionIsTypeScriptOrJson = resolutionExtensionIsTypeScriptOrJson; function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - if (ext !== undefined) { - return ext; - } - Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : Debug.fail("File " + path + " has unknown extension."); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -4518,6 +4549,7 @@ var ts; return watchDirectoryRecursively(directoryName, callback); } watchDirectory(directoryName, callback); + return undefined; }; } function createNonPollingWatchFile() { @@ -4748,6 +4780,7 @@ var ts; switch (entryKind) { case 0: return stat.isFile(); case 1: return stat.isDirectory(); + default: return false; } } catch (e) { @@ -4926,6 +4959,7 @@ var ts; The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), + Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), @@ -5377,6 +5411,7 @@ var ts; Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2568, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators_2568", "Type '{0}' is not an array type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: diag(2570, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await_2570", "Property '{0}' does not exist on type '{1}'. Did you forget to use 'await'?"), + Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."), JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -5430,7 +5465,7 @@ var ts; _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: diag(2692, ts.DiagnosticCategory.Error, "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible."), _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: diag(2693, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", "'{0}' only refers to a type, but is being used as a value here."), 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."), + 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."), 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."), @@ -5460,6 +5495,7 @@ var ts; Cannot_invoke_an_object_which_is_possibly_undefined: diag(2722, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_undefined_2722", "Cannot invoke an object which is possibly 'undefined'."), Cannot_invoke_an_object_which_is_possibly_null_or_undefined: diag(2723, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_null_or_undefined_2723", "Cannot invoke an object which is possibly 'null' or 'undefined'."), Module_0_has_no_exported_member_1_Did_you_mean_2: diag(2724, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_2_2724", "Module '{0}' has no exported member '{1}'. Did you mean '{2}'?"), + Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."), 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}'."), @@ -5758,6 +5794,7 @@ var ts; _0_is_declared_but_never_used: diag(6196, ts.DiagnosticCategory.Error, "_0_is_declared_but_never_used_6196", "'{0}' is declared but never used.", true), Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"), All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", true), + All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", true), 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"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -5785,7 +5822,7 @@ var ts; Function_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: diag(7024, ts.DiagnosticCategory.Error, "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", "Function 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."), Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: diag(7025, ts.DiagnosticCategory.Error, "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type."), JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: diag(7026, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists."), - Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected."), + Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected.", true), Unused_label: diag(7028, ts.DiagnosticCategory.Error, "Unused_label_7028", "Unused label.", true), Fallthrough_case_in_switch: diag(7029, ts.DiagnosticCategory.Error, "Fallthrough_case_in_switch_7029", "Fallthrough case in switch."), Not_all_code_paths_return_a_value: diag(7030, ts.DiagnosticCategory.Error, "Not_all_code_paths_return_a_value_7030", "Not all code paths return a value."), @@ -5866,6 +5903,7 @@ var ts; Implement_inherited_abstract_class: diag(90007, ts.DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"), Add_0_to_unresolved_variable: diag(90008, ts.DiagnosticCategory.Message, "Add_0_to_unresolved_variable_90008", "Add '{0}.' to unresolved variable"), Remove_destructuring: diag(90009, ts.DiagnosticCategory.Message, "Remove_destructuring_90009", "Remove destructuring"), + Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"), Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""), Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"), Add_0_to_existing_import_declaration_from_1: diag(90015, ts.DiagnosticCategory.Message, "Add_0_to_existing_import_declaration_from_1_90015", "Add '{0}' to existing import declaration from \"{1}\""), @@ -5935,6 +5973,9 @@ var ts; Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing 'typeof'"), Remove_unused_label: diag(95053, ts.DiagnosticCategory.Message, "Remove_unused_label_95053", "Remove unused label"), Remove_all_unused_labels: diag(95054, ts.DiagnosticCategory.Message, "Remove_all_unused_labels_95054", "Remove all unused labels"), + Convert_0_to_mapped_object_type: diag(95055, ts.DiagnosticCategory.Message, "Convert_0_to_mapped_object_type_95055", "Convert '{0}' to mapped object type"), + Convert_namespace_import_to_named_imports: diag(95056, ts.DiagnosticCategory.Message, "Convert_namespace_import_to_named_imports_95056", "Convert namespace import to named imports"), + Convert_named_imports_to_namespace_import: diag(95057, ts.DiagnosticCategory.Message, "Convert_named_imports_to_namespace_import_95057", "Convert named imports to namespace import"), }; })(ts || (ts = {})); var ts; @@ -5971,7 +6012,7 @@ var ts; "false": 86, "finally": 87, "for": 88, - "from": 142, + "from": 143, "function": 89, "get": 125, "if": 90, @@ -5997,7 +6038,7 @@ var ts; "public": 114, "readonly": 132, "require": 133, - "global": 143, + "global": 144, "return": 96, "set": 136, "static": 115, @@ -6013,6 +6054,7 @@ var ts; "typeof": 103, "undefined": 140, "unique": 141, + "unknown": 142, "var": 104, "void": 105, "while": 106, @@ -6020,7 +6062,7 @@ var ts; "yield": 116, "async": 120, "await": 121, - "of": 144, + "of": 145, "{": 17, "}": 18, "(": 19, @@ -6526,8 +6568,9 @@ var ts; return true; } ts.isIdentifierText = isIdentifierText; - function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { if (languageVariant === void 0) { languageVariant = 0; } + var text = textInitial; var pos; var end; var startPos; @@ -7725,7 +7768,7 @@ var ts; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function packageIdIsEqual(a, b) { - return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; + return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; } function packageIdToString(_a) { var name = _a.name, subModuleName = _a.subModuleName, version = _a.version; @@ -7768,7 +7811,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 273) { + while (node && node.kind !== 274) { node = node.parent; } return node; @@ -7776,11 +7819,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 212: - case 240: - case 219: + case 213: + case 241: case 220: case 221: + case 222: return true; } return false; @@ -7816,9 +7859,8 @@ var ts; } } ts.getEndLinePosition = getEndLinePosition; - function isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) { - return !(hasGlobalName && hasGlobalName(name)) - && !currentSourceFile.identifiers.has(name); + function isFileLevelUniqueName(sourceFile, name, hasGlobalName) { + return !(hasGlobalName && hasGlobalName(name)) && !sourceFile.identifiers.has(name); } ts.isFileLevelUniqueName = isFileLevelUniqueName; function nodeIsMissing(node) { @@ -7832,6 +7874,19 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + function prependStatements(to, from) { + if (from === undefined || from.length === 0) + return to; + if (to === undefined) + return from.slice(); + var prologue = to.length && isPrologueDirective(to[0]) && to.shift(); + to.unshift.apply(to, from); + if (prologue) { + to.unshift(prologue); + } + return to; + } + ts.prependStatements = prependStatements; function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { if (text.charCodeAt(commentPos + 1) === 47 && commentPos + 2 < commentEnd && @@ -7861,7 +7916,7 @@ var ts; if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 298 && node._children.length > 0) { + if (node.kind === 299 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -7901,7 +7956,7 @@ var ts; ts.indexOfNode = indexOfNode; function getEmitFlags(node) { var emitNode = node.emitNode; - return emitNode && emitNode.flags; + return emitNode && emitNode.flags || 0; } ts.getEmitFlags = getEmitFlags; function getLiteralText(node, sourceFile) { @@ -7929,7 +7984,7 @@ var ts; case 12: return node.text; } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); } ts.getLiteralText = getLiteralText; function getTextOfConstantValue(value) { @@ -7955,7 +8010,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 231 && node.parent.kind === 268; + return node.kind === 232 && node.parent.kind === 269; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -7975,11 +8030,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node && node.kind === 238 && (!node.body); + return node && node.kind === 239 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 273 || - node.kind === 238 || + return node.kind === 274 || + node.kind === 239 || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -7993,9 +8048,9 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isModuleAugmentationExternal(node) { switch (node.parent.kind) { - case 273: + case 274: return ts.isExternalModule(node.parent); - case 239: + case 240: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8007,51 +8062,51 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 273: - case 240: - case 268: - case 238: - case 219: + case 274: + case 241: + case 269: + case 239: case 220: case 221: - case 154: - case 153: + case 222: case 155: + case 154: case 156: - case 233: - case 191: + case 157: + case 234: case 192: + case 193: return true; - case 212: - return parentNode && !ts.isFunctionLike(parentNode); + case 213: + return !ts.isFunctionLike(parentNode); } return false; } ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 157: case 158: - case 152: case 159: - case 162: - case 163: - case 283: - case 234: - case 204: - case 235: - case 236: - case 295: - case 233: case 153: + case 160: + case 163: + case 164: + case 284: + case 235: + case 205: + case 236: + case 237: + case 296: + case 234: case 154: case 155: case 156: - case 191: + case 157: case 192: - case 291: - case 296: - case 287: + case 193: + case 292: + case 297: + case 288: return true; default: ts.assertTypeIsNever(node); @@ -8061,8 +8116,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { + case 244: case 243: - case 242: return true; default: return false; @@ -8071,15 +8126,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { + case 244: case 243: - case 242: - case 213: - case 234: - case 233: - case 238: - case 236: + case 214: case 235: + case 234: + case 239: case 237: + case 236: + case 238: return true; default: return false; @@ -8109,7 +8164,7 @@ var ts; case 9: case 8: return escapeLeadingUnderscores(name.text); - case 146: + case 147: return isStringOrNumericLiteral(name.expression) ? escapeLeadingUnderscores(name.expression.text) : undefined; default: ts.Debug.assertNever(name); @@ -8120,10 +8175,12 @@ var ts; switch (name.kind) { case 71: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 145: + case 146: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 184: + case 185: return entityNameToString(name.expression) + "." + entityNameToString(name.name); + default: + throw ts.Debug.assertNever(name); } } ts.entityNameToString = entityNameToString; @@ -8142,11 +8199,6 @@ var ts; return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3); } ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; - function createDiagnosticForNodeSpan(sourceFile, startNode, endNode, message, arg0, arg1, arg2, arg3) { - var start = ts.skipTrivia(sourceFile.text, startNode.pos); - return ts.createFileDiagnostic(sourceFile, start, endNode.end - start, message, arg0, arg1, arg2, arg3); - } - ts.createDiagnosticForNodeSpan = createDiagnosticForNodeSpan; function createDiagnosticForNodeFromMessageChain(node, messageChain) { var sourceFile = getSourceFileOfNode(node); var span = getErrorSpanForNode(sourceFile, node); @@ -8169,7 +8221,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 212) { + if (node.body && node.body.kind === 213) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8181,31 +8233,31 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 273: + case 274: 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 231: - case 181: - case 234: - case 204: + case 232: + case 182: case 235: - case 238: - case 237: - case 272: - case 233: - case 191: - case 153: - case 155: - case 156: + case 205: case 236: + case 239: + case 238: + case 273: + case 234: + case 192: + case 154: + case 156: + case 157: + case 237: + case 152: case 151: - case 150: errorNode = node.name; break; - case 192: + case 193: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8235,7 +8287,7 @@ var ts; } ts.isJsonSourceFile = isJsonSourceFile; function isConstEnumDeclaration(node) { - return node.kind === 237 && isConst(node); + return node.kind === 238 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -8248,21 +8300,21 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 186 && n.expression.kind === 97; + return n.kind === 187 && n.expression.kind === 97; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 186 && n.expression.kind === 91; + return n.kind === 187 && n.expression.kind === 91; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 178 && - n.argument.kind === 177 && + return n.kind === 179 && + n.argument.kind === 178 && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 215 + return node.kind === 216 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -8271,11 +8323,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 148 || - node.kind === 147 || - node.kind === 191 || + var commentRanges = (node.kind === 149 || + node.kind === 148 || node.kind === 192 || - node.kind === 190) ? + node.kind === 193 || + node.kind === 191) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); return ts.filter(commentRanges, function (comment) { @@ -8290,11 +8342,12 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (160 <= node.kind && node.kind <= 178) { + if (161 <= node.kind && node.kind <= 179) { return true; } switch (node.kind) { case 119: + case 142: case 134: case 137: case 122: @@ -8303,63 +8356,64 @@ var ts; case 131: return true; case 105: - return node.parent.kind !== 195; - case 206: + return node.parent.kind !== 196; + case 207: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 147: - return node.parent.kind === 176 || node.parent.kind === 171; + case 148: + return node.parent.kind === 177 || node.parent.kind === 172; case 71: - if (node.parent.kind === 145 && node.parent.right === node) { + if (node.parent.kind === 146 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 184 && node.parent.name === node) { + else if (node.parent.kind === 185 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 71 || node.kind === 145 || node.kind === 184, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 145: - case 184: - case 99: + ts.Debug.assert(node.kind === 71 || node.kind === 146 || node.kind === 185, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 146: + case 185: + case 99: { var parent = node.parent; - if (parent.kind === 164) { + if (parent.kind === 165) { return false; } - if (parent.kind === 178) { + if (parent.kind === 179) { return !parent.isTypeOf; } - if (160 <= parent.kind && parent.kind <= 178) { + if (161 <= parent.kind && parent.kind <= 179) { return true; } switch (parent.kind) { - case 206: + case 207: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 147: - return node === parent.constraint; - case 151: - case 150: case 148: - case 231: + return node === parent.constraint; + case 152: + case 151: + case 149: + case 232: return node === parent.type; - case 233: - case 191: + case 234: case 192: + case 193: + case 155: case 154: case 153: - case 152: - case 155: case 156: - return node === parent.type; case 157: + return node === parent.type; case 158: case 159: + case 160: return node === parent.type; - case 189: + case 190: return node === parent.type; - case 186: case 187: - return ts.contains(parent.typeArguments, node); case 188: + return ts.contains(parent.typeArguments, node); + case 189: return false; } + } } return false; } @@ -8378,23 +8432,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224: + case 225: return visitor(node); - case 240: - case 212: - case 216: + case 241: + case 213: case 217: case 218: case 219: case 220: case 221: - case 225: + case 222: case 226: - case 265: - case 266: case 227: - case 229: - case 268: + case 266: + case 267: + case 228: + case 230: + case 269: return ts.forEachChild(node, traverse); } } @@ -8404,23 +8458,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202: + case 203: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 237: - case 235: case 238: case 236: - case 234: - case 204: + case 239: + case 237: + case 235: + case 205: return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 146) { + if (node.name && node.name.kind === 147) { traverse(node.name.expression); return; } @@ -8433,10 +8487,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 166) { + if (node && node.kind === 167) { return node.elementType; } - else if (node && node.kind === 161) { + else if (node && node.kind === 162) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -8446,12 +8500,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { + case 236: case 235: - case 234: - case 204: - case 165: + case 205: + case 166: return node.members; - case 183: + case 184: return node.properties; } } @@ -8459,14 +8513,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 181: - case 272: - case 148: - case 269: - case 151: - case 150: + case 182: + case 273: + case 149: case 270: - case 231: + case 152: + case 151: + case 271: + case 232: return true; } } @@ -8478,8 +8532,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 232 - && node.parent.parent.kind === 213; + return node.parent.kind === 233 + && node.parent.parent.kind === 214; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -8490,13 +8544,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 153: - case 152: case 154: + case 153: case 155: case 156: - case 233: - case 191: + case 157: + case 234: + case 192: return true; } return false; @@ -8507,7 +8561,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 227) { + if (node.statement.kind !== 228) { return node.statement; } node = node.statement; @@ -8515,17 +8569,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 212 && ts.isFunctionLike(node.parent); + return node && node.kind === 213 && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 153 && node.parent.kind === 183; + return node && node.kind === 154 && node.parent.kind === 184; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 153 && - (node.parent.kind === 183 || - node.parent.kind === 204); + return node.kind === 154 && + (node.parent.kind === 184 || + node.parent.kind === 205); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -8537,31 +8591,35 @@ var ts; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { - return ts.filter(objectLiteral.properties, function (property) { - if (property.kind === 269) { + return objectLiteral.properties.filter(function (property) { + if (property.kind === 270) { var propName = getTextOfPropertyName(property.name); - return key === propName || (key2 && key2 === propName); + return key === propName || (!!key2 && key2 === propName); } + return false; }); } ts.getPropertyAssignment = getPropertyAssignment; function getTsConfigObjectLiteralExpression(tsConfigSourceFile) { if (tsConfigSourceFile && tsConfigSourceFile.statements.length) { var expression = tsConfigSourceFile.statements[0].expression; - return ts.isObjectLiteralExpression(expression) && expression; + return ts.tryCast(expression, ts.isObjectLiteralExpression); } } ts.getTsConfigObjectLiteralExpression = getTsConfigObjectLiteralExpression; function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) { - var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile); - return jsonObjectLiteral && - ts.firstDefined(getPropertyAssignment(jsonObjectLiteral, propKey), function (property) { - return ts.isArrayLiteralExpression(property.initializer) ? - ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) : - undefined; - }); + return ts.firstDefined(getTsConfigPropArray(tsConfigSourceFile, propKey), function (property) { + return ts.isArrayLiteralExpression(property.initializer) ? + ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) : + undefined; + }); } ts.getTsConfigPropArrayElementValue = getTsConfigPropArrayElementValue; + function getTsConfigPropArray(tsConfigSourceFile, propKey) { + var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile); + return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : ts.emptyArray; + } + ts.getTsConfigPropArray = getTsConfigPropArray; function getContainingFunction(node) { return ts.findAncestor(node.parent, ts.isFunctionLike); } @@ -8571,45 +8629,46 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { + ts.Debug.assert(node.kind !== 274); while (true) { node = node.parent; if (!node) { - return undefined; + return ts.Debug.fail(); } switch (node.kind) { - case 146: + case 147: if (ts.isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 149: - if (node.parent.kind === 148 && ts.isClassElement(node.parent.parent)) { + case 150: + if (node.parent.kind === 149 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { node = node.parent; } break; - case 192: + case 193: if (!includeArrowFunctions) { continue; } - case 233: - case 191: - case 238: - case 151: - case 150: - case 153: + case 234: + case 192: + case 239: case 152: + case 151: case 154: + case 153: case 155: case 156: case 157: case 158: case 159: - case 237: - case 273: + case 160: + case 238: + case 274: return node; } } @@ -8619,9 +8678,9 @@ var ts; var container = getThisContainer(node, false); if (container) { switch (container.kind) { - case 154: - case 233: - case 191: + case 155: + case 234: + case 192: return container; } } @@ -8635,25 +8694,25 @@ var ts; return node; } switch (node.kind) { - case 146: + case 147: node = node.parent; break; - case 233: - case 191: + case 234: case 192: + case 193: if (!stopOnFunctions) { continue; } - case 151: - case 150: - case 153: case 152: + case 151: case 154: + case 153: case 155: case 156: + case 157: return node; - case 149: - if (node.parent.kind === 148 && ts.isClassElement(node.parent.parent)) { + case 150: + if (node.parent.kind === 149 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { @@ -8665,14 +8724,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 191 || func.kind === 192) { + if (func.kind === 192 || func.kind === 193) { var prev = func; var parent = func.parent; - while (parent.kind === 190) { + while (parent.kind === 191) { prev = parent; parent = parent.parent; } - if (parent.kind === 186 && parent.expression === prev) { + if (parent.kind === 187 && parent.expression === prev) { return parent; } } @@ -8680,26 +8739,26 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 184 || kind === 185) + return (kind === 185 || kind === 186) && node.expression.kind === 97; } ts.isSuperProperty = isSuperProperty; function isThisProperty(node) { var kind = node.kind; - return (kind === 184 || kind === 185) + return (kind === 185 || kind === 186) && node.expression.kind === 99; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 161: + case 162: return node.typeName; - case 206: + case 207: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 71: - case 145: + case 146: return node; } return undefined; @@ -8707,10 +8766,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 188: + case 189: return node.tag; + case 257: case 256: - case 255: return node.tagName; default: return node.expression; @@ -8719,21 +8778,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 234: + case 235: return true; - case 151: - return parent.kind === 234; - case 155: + case 152: + return parent.kind === 235; case 156: - case 153: + case 157: + case 154: return node.body !== undefined - && parent.kind === 234; - case 148: + && parent.kind === 235; + case 149: return parent.body !== undefined - && (parent.kind === 154 - || parent.kind === 153 - || parent.kind === 156) - && grandparent.kind === 234; + && (parent.kind === 155 + || parent.kind === 154 + || parent.kind === 157) + && grandparent.kind === 235; } return false; } @@ -8749,19 +8808,21 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 234: - return ts.forEach(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); - case 153: - case 156: - return ts.forEach(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); + case 235: + return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); + case 154: + case 157: + return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); + default: + return false; } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 256 || - parent.kind === 255 || - parent.kind === 257) { + if (parent.kind === 257 || + parent.kind === 256 || + parent.kind === 258) { return parent.tagName === node; } return false; @@ -8774,45 +8835,45 @@ var ts; case 101: case 86: case 12: - case 182: case 183: case 184: case 185: case 186: case 187: case 188: - case 207: case 189: case 208: case 190: + case 209: case 191: - case 204: case 192: - case 195: + case 205: case 193: + case 196: case 194: - case 197: + case 195: case 198: case 199: case 200: - case 203: case 201: - case 13: - case 205: - case 254: - case 255: - case 258: + case 204: case 202: - case 196: - case 209: + case 13: + case 206: + case 255: + case 256: + case 259: + case 203: + case 197: + case 210: return true; - case 145: - while (node.parent.kind === 145) { + case 146: + while (node.parent.kind === 146) { node = node.parent; } - return node.parent.kind === 164 || isJSXTagName(node); + return node.parent.kind === 165 || isJSXTagName(node); case 71: - if (node.parent.kind === 164 || isJSXTagName(node)) { + if (node.parent.kind === 165 || isJSXTagName(node)) { return true; } case 8: @@ -8827,47 +8888,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 231: - case 148: + case 232: + case 149: + case 152: case 151: - case 150: - case 272: - case 269: - case 181: + case 273: + case 270: + case 182: return parent.initializer === node; - case 215: case 216: case 217: case 218: - case 224: + case 219: case 225: case 226: - case 265: - case 228: + case 227: + case 266: + case 229: return parent.expression === node; - case 219: + case 220: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 232) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 233) || forStatement.condition === node || forStatement.incrementor === node; - case 220: case 221: + case 222: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 232) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233) || forInStatement.expression === node; - case 189: - case 207: + case 190: + case 208: return node === parent.expression; - case 210: + case 211: return node === parent.expression; - case 146: + case 147: return node === parent.expression; - case 149: + case 150: + case 265: case 264: - case 263: - case 271: + case 272: return true; - case 206: + case 207: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -8875,7 +8936,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 242 && node.moduleReference.kind === 253; + return node.kind === 243 && node.moduleReference.kind === 254; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -8884,7 +8945,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 242 && node.moduleReference.kind !== 253; + return node.kind === 243 && node.moduleReference.kind !== 254; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -8896,15 +8957,15 @@ var ts; } ts.isSourceFileNotJavaScript = isSourceFileNotJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 65536); + return !!node && !!(node.flags & 65536); } ts.isInJavaScriptFile = isInJavaScriptFile; function isInJsonFile(node) { - return node && !!(node.flags & 16777216); + return !!node && !!(node.flags & 16777216); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return node && !!(node.flags & 2097152); + return !!node && !!(node.flags & 2097152); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -8916,7 +8977,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 186) { + if (callExpression.kind !== 187) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -8938,22 +8999,48 @@ var ts; return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34; } ts.isStringDoubleQuoted = isStringDoubleQuoted; - function getJSInitializerSymbol(symbol) { - if (!symbol || !symbol.valueDeclaration) { - return symbol; + function getDeclarationOfJSInitializer(node) { + if (!isInJavaScriptFile(node) || !node.parent) { + return undefined; } - var declaration = symbol.valueDeclaration; - var e = getDeclaredJavascriptInitializer(declaration) || getAssignedJavascriptInitializer(declaration); - return e && e.symbol ? e.symbol : symbol; - } - ts.getJSInitializerSymbol = getJSInitializerSymbol; - function getDeclaredJavascriptInitializer(node) { - if (node && ts.isVariableDeclaration(node) && node.initializer) { - return getJavascriptInitializer(node.initializer, false) || - ts.isIdentifier(node.name) && getDefaultedJavascriptInitializer(node.name, node.initializer, false); + var name; + var decl; + if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) { + name = node.parent.name; + decl = node.parent; } + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 && node.parent.right === node) { + name = node.parent.left; + decl = name; + } + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 54) { + if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { + name = node.parent.parent.name; + decl = node.parent.parent; + } + else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 58 && node.parent.parent.right === node.parent) { + name = node.parent.parent.left; + decl = name; + } + if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { + return undefined; + } + } + if (!name || !getJavascriptInitializer(node, isPrototypeAccess(name))) { + return undefined; + } + return decl; } - ts.getDeclaredJavascriptInitializer = getDeclaredJavascriptInitializer; + ts.getDeclarationOfJSInitializer = getDeclarationOfJSInitializer; + function getEffectiveInitializer(node) { + if (isInJavaScriptFile(node) && node.initializer && + ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 54 && + node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { + return node.initializer.right; + } + return node.initializer; + } + ts.getEffectiveInitializer = getEffectiveInitializer; function getAssignedJavascriptInitializer(node) { if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); @@ -8965,11 +9052,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 191 || e.kind === 192 ? initializer : undefined; + return e.kind === 192 || e.kind === 193 ? initializer : undefined; } - if (initializer.kind === 191 || - initializer.kind === 204 || - initializer.kind === 192) { + if (initializer.kind === 192 || + initializer.kind === 205 || + initializer.kind === 193) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -8983,6 +9070,13 @@ var ts; return e; } } + function isDefaultedJavascriptInitializer(node) { + var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 ? node.parent.left : + undefined; + return name && getJavascriptInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); + } + ts.isDefaultedJavascriptInitializer = isDefaultedJavascriptInitializer; function getOuterNameOfJsInitializer(node) { if (ts.isBinaryExpression(node.parent)) { var parent = (node.parent.operatorToken.kind === 54 && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; @@ -9075,7 +9169,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 215 && + expr.parent && expr.parent.kind === 216 && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -9085,14 +9179,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 243: - case 249: + case 244: + case 250: return node.parent; - case 253: + case 254: return node.parent.parent; - case 186: + case 187: return node.parent; - case 177: + case 178: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -9102,12 +9196,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 243: - case 249: + case 244: + case 250: return node.moduleSpecifier; - case 242: - return node.moduleReference.kind === 253 ? node.moduleReference.expression : undefined; - case 178: + case 243: + return node.moduleReference.kind === 254 ? node.moduleReference.expression : undefined; + case 179: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -9116,11 +9210,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 243: + case 244: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 242: + case 243: return node; - case 249: + case 250: return undefined; default: return ts.Debug.assertNever(node); @@ -9128,19 +9222,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 243 && node.importClause && !!node.importClause.name; + return node.kind === 244 && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 148: + case 149: + case 154: case 153: - case 152: + case 271: case 270: - case 269: + case 152: case 151: - case 150: return node.questionToken !== undefined; } } @@ -9148,14 +9242,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 283 && + return node.kind === 284 && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 296 || node.kind === 291; + return node.kind === 297 || node.kind === 292; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -9165,38 +9259,39 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 58 && - node.expression.right; + node.expression.operatorToken.kind === 58 + ? node.expression.right + : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && getSpecialPropertyAssignmentKind(node.expression) !== 0 && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 54 && - node.expression.right.right; + node.expression.right.operatorToken.kind === 54 + ? node.expression.right.right + : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 213: + case 214: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 151: + case 152: return node.initializer; - case 269: + case 270: return node.initializer; } } function getSingleVariableOfVariableStatement(node) { - return ts.isVariableStatement(node) && - node.declarationList.declarations.length > 0 && - node.declarationList.declarations[0]; + return ts.isVariableStatement(node) ? ts.firstOrUndefined(node.declarationList.declarations) : undefined; } function getNestedModuleDeclaration(node) { - return node.kind === 238 && + return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 238 && - node.body; + node.body.kind === 239 + ? node.body + : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; @@ -9206,7 +9301,7 @@ var ts; var parent = node.parent; if (!parent) return; - if (parent.kind === 269 || parent.kind === 151 || getNestedModuleDeclaration(parent)) { + if (parent.kind === 270 || parent.kind === 152 || getNestedModuleDeclaration(parent)) { getJSDocCommentsAndTagsWorker(parent); } if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) { @@ -9220,10 +9315,10 @@ var ts; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 || ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 || - node.kind === 184 && node.parent && node.parent.kind === 215) { + node.kind === 185 && node.parent && node.parent.kind === 216) { getJSDocCommentsAndTagsWorker(parent); } - if (node.kind === 148) { + if (node.kind === 149) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); } if (isVariableLike(node) && ts.hasInitializer(node) && node.initializer !== hostNode && ts.hasJSDocNodes(node.initializer)) { @@ -9277,12 +9372,12 @@ var ts; ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { var last = ts.lastOrUndefined(s.parameters); - return last && isRestParameter(last); + return !!last && isRestParameter(last); } 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 === 284; + return node.dotDotDotToken !== undefined || !!type && type.kind === 285; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -9295,31 +9390,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 199: + case 200: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 ? 1 : 2 : 0; - case 197: case 198: + case 199: var unaryOperator = parent.operator; return unaryOperator === 43 || unaryOperator === 44 ? 2 : 0; - case 220: case 221: + case 222: return parent.initializer === node ? 1 : 0; - case 190: - case 182: - case 203: - case 208: + case 191: + case 183: + case 204: + case 209: node = parent; break; - case 270: + case 271: if (parent.name !== node) { return 0; } node = parent.parent; break; - case 269: + case 270: if (parent.name === node) { return 0; } @@ -9338,22 +9433,22 @@ var ts; ts.isAssignmentTarget = isAssignmentTarget; function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 212: case 213: - case 225: - case 216: + case 214: case 226: - case 240: - case 265: - case 266: + case 217: case 227: - case 219: + case 241: + case 266: + case 267: + case 228: case 220: case 221: - case 217: + case 222: case 218: - case 229: - case 268: + case 219: + case 230: + case 269: return true; } return false; @@ -9370,26 +9465,26 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 172); + return walkUp(node, 173); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 190); + return walkUp(node, 191); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 190) { + while (node.kind === 191) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function isDeleteTarget(node) { - if (node.kind !== 184 && node.kind !== 185) { + if (node.kind !== 185 && node.kind !== 186) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 193; + return node && node.kind === 194; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -9409,9 +9504,10 @@ var ts; switch (name.kind) { case 71: case 9: - case 8: - if (ts.isDeclaration(name.parent)) { - return name.parent.name === name; + case 8: { + var parent = name.parent; + if (ts.isDeclaration(parent)) { + return parent.name === name; } else if (ts.isQualifiedName(name.parent)) { var tag = name.parent.parent; @@ -9421,6 +9517,7 @@ var ts; var binExp = name.parent.parent; return ts.isBinaryExpression(binExp) && getSpecialPropertyAssignmentKind(binExp) !== 0 && ts.getNameOfDeclaration(binExp) === name; } + } default: return false; } @@ -9428,49 +9525,49 @@ var ts; ts.isAnyDeclarationName = isAnyDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 146 && + node.parent.kind === 147 && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 151: - case 150: - case 153: case 152: - case 155: + case 151: + case 154: + case 153: case 156: - case 272: - case 269: - case 184: + case 157: + case 273: + case 270: + case 185: return parent.name === node; - case 145: + case 146: if (parent.right === node) { - while (parent.kind === 145) { + while (parent.kind === 146) { parent = parent.parent; } - return parent.kind === 164 || parent.kind === 161; + return parent.kind === 165 || parent.kind === 162; } return false; - case 181: - case 247: + case 182: + case 248: return parent.propertyName === node; - case 251: - case 261: + case 252: + case 262: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 242 || - node.kind === 241 || - node.kind === 244 && !!node.name || - node.kind === 245 || - node.kind === 247 || - node.kind === 251 || - node.kind === 248 && exportAssignmentIsAlias(node) || + return node.kind === 243 || + node.kind === 242 || + node.kind === 245 && !!node.name || + node.kind === 246 || + node.kind === 248 || + node.kind === 252 || + node.kind === 249 && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -9530,11 +9627,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 72 <= token && token <= 144; + return 72 <= token && token <= 145; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 117 <= token && token <= 144; + return 117 <= token && token <= 145; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -9564,13 +9661,13 @@ var ts; } var flags = 0; switch (node.kind) { - case 233: - case 191: - case 153: + case 234: + case 192: + case 154: if (node.asteriskToken) { flags |= 1; } - case 192: + case 193: if (hasModifier(node, 256)) { flags |= 2; } @@ -9584,10 +9681,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 233: - case 191: + case 234: case 192: - case 153: + case 193: + case 154: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256); @@ -9603,11 +9700,11 @@ var ts; ts.isStringOrNumericLiteral = isStringOrNumericLiteral; function hasDynamicName(declaration) { var name = ts.getNameOfDeclaration(declaration); - return name && isDynamicName(name); + return !!name && isDynamicName(name); } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 146 && + return name.kind === 147 && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -9623,7 +9720,7 @@ var ts; if (name.kind === 9 || name.kind === 8) { return escapeLeadingUnderscores(name.text); } - if (name.kind === 146) { + if (name.kind === 147) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -9673,11 +9770,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 148; + return root.kind === 149; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 181) { + while (node.kind === 182) { node = node.parent.parent; } return node; @@ -9685,15 +9782,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 154 - || kind === 191 - || kind === 233 + return kind === 155 || kind === 192 - || kind === 153 - || kind === 155 + || kind === 234 + || kind === 193 + || kind === 154 || kind === 156 - || kind === 238 - || kind === 273; + || kind === 157 + || kind === 239 + || kind === 274; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -9712,23 +9809,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 187 && expression.arguments !== undefined; + var hasArguments = expression.kind === 188 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 187: + case 188: return hasArguments ? 0 : 1; - case 197: - case 194: + case 198: case 195: - case 193: case 196: - case 200: - case 202: + case 194: + case 197: + case 201: + case 203: return 1; - case 199: + case 200: switch (operator) { case 40: case 58: @@ -9752,15 +9849,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 187 && expression.arguments !== undefined; + var hasArguments = expression.kind === 188 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 199) { + if (expression.kind === 200) { return expression.operatorToken.kind; } - else if (expression.kind === 197 || expression.kind === 198) { + else if (expression.kind === 198 || expression.kind === 199) { return expression.operator; } else { @@ -9770,15 +9867,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 301: + case 302: return 0; - case 203: + case 204: return 1; - case 202: + case 203: return 2; - case 200: + case 201: return 4; - case 199: + case 200: switch (operatorKind) { case 26: return 0; @@ -9799,21 +9896,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 197: - case 194: - case 195: - case 193: - case 196: - return 16; case 198: + case 195: + case 196: + case 194: + case 197: + return 16; + case 199: return 17; - case 186: - return 18; case 187: - return hasArguments ? 19 : 18; + return 18; case 188: - case 184: + return hasArguments ? 19 : 18; + case 189: case 185: + case 186: return 19; case 99: case 97: @@ -9823,19 +9920,19 @@ var ts; case 86: case 8: case 9: - case 182: case 183: - case 191: + case 184: case 192: - case 204: - case 254: + case 193: + case 205: case 255: - case 258: + case 256: + case 259: case 12: case 13: - case 201: - case 190: - case 205: + case 202: + case 191: + case 206: return 20; default: return -1; @@ -10035,7 +10132,7 @@ var ts; var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + linePos = output.length - s.length + ts.last(lineStartsOfS); } } } @@ -10194,7 +10291,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 71 && identifierIsThisKeyword(node); + return !!node && node.kind === 71 && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { @@ -10208,10 +10305,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 155) { + if (accessor.kind === 156) { getAccessor = accessor; } - else if (accessor.kind === 156) { + else if (accessor.kind === 157) { setAccessor = accessor; } else { @@ -10220,7 +10317,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 155 || member.kind === 156) + if ((member.kind === 156 || member.kind === 157) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -10231,10 +10328,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 155 && !getAccessor) { + if (member.kind === 156 && !getAccessor) { getAccessor = member; } - if (member.kind === 156 && !setAccessor) { + if (member.kind === 157 && !setAccessor) { setAccessor = member; } } @@ -10269,24 +10366,19 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 285); - var templateTags = ts.flatMap(ts.filter(node.parent.tags, ts.isJSDocTemplateTag), function (tag) { return tag.typeParameters; }); - var templateTagNodes = templateTags; - templateTagNodes.pos = templateTagNodes.length > 0 ? ts.first(templateTagNodes).pos : node.pos; - templateTagNodes.end = templateTagNodes.length > 0 ? ts.last(templateTagNodes).end : node.end; - templateTagNodes.hasTrailingComma = false; - return templateTagNodes; + ts.Debug.assert(node.parent.kind === 286); + return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray); } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getJSDocTypeParameterDeclarations(node) { - var tag = ts.find(ts.getJSDocTags(node), function (tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 285 && tag.parent.tags.some(isJSDocTypeAlias)); - }); - return (tag && tag.typeParameters) || ts.emptyArray; + return ts.flatMap(ts.getJSDocTags(node), function (tag) { return isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined; }); } ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; + function isNonTypeAliasTemplate(tag) { + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 286 && tag.parent.tags.some(isJSDocTypeAlias)); + } function getEffectiveSetAccessorTypeAnnotationNode(node) { var parameter = getSetAccessorValueParameter(node); return parameter && getEffectiveTypeAnnotationNode(parameter); @@ -10363,12 +10455,12 @@ var ts; lastComment = comment; } if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.last(detachedComments).end); var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); if (nodeLine >= lastCommentLine + 2) { emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); - currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.last(detachedComments).end }; } } } @@ -10511,7 +10603,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 206 && + if (ts.isExpressionWithTypeArguments(node) && node.parent.token === 85 && ts.isClassLike(node.parent.parent)) { return node.parent.parent; @@ -10529,8 +10621,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 183 - || kind === 182; + return kind === 184 + || kind === 183; } return false; } @@ -10540,7 +10632,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 206 + return node.kind === 207 && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 @@ -10561,17 +10653,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 145 && node.parent.right === node) || - (node.parent.kind === 184 && node.parent.name === node); + return (node.parent.kind === 146 && node.parent.right === node) || + (node.parent.kind === 185 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 183 && + return expression.kind === 184 && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 182 && + return expression.kind === 183 && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -10668,14 +10760,14 @@ var ts; return output; } function base64encode(host, input) { - if (host.base64encode) { + if (host && host.base64encode) { return host.base64encode(input); } return convertToBase64(input); } ts.base64encode = base64encode; function base64decode(host, input) { - if (host.base64decode) { + if (host && host.base64decode) { return host.base64decode(input); } var length = input.length; @@ -10851,8 +10943,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 237: case 238: + case 239: return parseNode === parseNode.parent.name; } } @@ -10920,20 +11012,20 @@ var ts; if (!parent) return 0; switch (parent.kind) { + case 199: case 198: - case 197: var operator = parent.operator; return operator === 43 || operator === 44 ? writeOrReadWrite() : 0; - case 199: + case 200: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0; - case 184: + case 185: return parent.name !== node ? 0 : accessKind(parent); default: return 0; } function writeOrReadWrite() { - return parent.parent && parent.parent.kind === 215 ? 1 : 2; + return parent.parent && parent.parent.kind === 216 ? 1 : 2; } } function compareDataObjects(dst, src) { @@ -11010,7 +11102,7 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 65536 ? type.objectFlags : 0; + return type.flags & 131072 ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { @@ -11189,9 +11281,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 147) { + if (d && d.kind === 148) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 235) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236) { return current; } } @@ -11199,7 +11291,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 154; + return ts.hasModifier(node, 92) && node.parent.kind === 155; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -11217,7 +11309,7 @@ var ts; } ts.isEmptyBindingElement = isEmptyBindingElement; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 181 || ts.isBindingPattern(node))) { + while (node && (node.kind === 182 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -11225,14 +11317,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 231) { + if (node.kind === 232) { node = node.parent; } - if (node && node.kind === 232) { + if (node && node.kind === 233) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 213) { + if (node && node.kind === 214) { flags |= ts.getModifierFlags(node); } return flags; @@ -11241,14 +11333,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 231) { + if (node.kind === 232) { node = node.parent; } - if (node && node.kind === 232) { + if (node && node.kind === 233) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 213) { + if (node && node.kind === 214) { flags |= node.flags; } return flags; @@ -11292,7 +11384,7 @@ var ts; try { ts.localizedDiagnosticMessages = JSON.parse(fileContents); } - catch (e) { + catch (_a) { if (errors) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath)); } @@ -11352,17 +11444,17 @@ var ts; return getDeclarationIdentifier(hostNode); } switch (hostNode.kind) { - case 213: + case 214: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 215: + case 216: var expr = hostNode.expression; switch (expr.kind) { - case 184: - return expr.name; case 185: + return expr.name; + case 186: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -11371,10 +11463,10 @@ var ts; return undefined; case 1: return undefined; - case 190: { + case 191: { return getDeclarationIdentifier(hostNode.expression); } - case 227: { + case 228: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -11401,23 +11493,23 @@ var ts; return undefined; } switch (declaration.kind) { - case 204: - case 191: + case 205: + case 192: if (!declaration.name) { return getAssignedName(declaration); } break; case 71: return declaration; - case 297: - case 292: { + case 298: + case 293: { var name = declaration.name; - if (name.kind === 145) { + if (name.kind === 146) { return name.right; } break; } - case 199: { + case 200: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1: @@ -11429,11 +11521,11 @@ var ts; return undefined; } } - case 291: + case 292: return declaration.name; - case 296: + case 297: return getNameOfJSDocTypedef(declaration); - case 248: { + case 249: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -11572,628 +11664,628 @@ var ts; } ts.isIdentifier = isIdentifier; function isQualifiedName(node) { - return node.kind === 145; + return node.kind === 146; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 146; + return node.kind === 147; } ts.isComputedPropertyName = isComputedPropertyName; function isTypeParameterDeclaration(node) { - return node.kind === 147; + return node.kind === 148; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 148; + return node.kind === 149; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 149; + return node.kind === 150; } ts.isDecorator = isDecorator; function isPropertySignature(node) { - return node.kind === 150; + return node.kind === 151; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 151; + return node.kind === 152; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 152; + return node.kind === 153; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 153; + return node.kind === 154; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 154; + return node.kind === 155; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 155; + return node.kind === 156; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 156; + return node.kind === 157; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 157; + return node.kind === 158; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 158; + return node.kind === 159; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 159; + return node.kind === 160; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; function isGetOrSetAccessorDeclaration(node) { - return node.kind === 156 || node.kind === 155; + return node.kind === 157 || node.kind === 156; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isTypePredicateNode(node) { - return node.kind === 160; + return node.kind === 161; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 161; + return node.kind === 162; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 162; + return node.kind === 163; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 163; + return node.kind === 164; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 164; + return node.kind === 165; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 165; + return node.kind === 166; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 166; + return node.kind === 167; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 167; + return node.kind === 168; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 168; + return node.kind === 169; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 169; + return node.kind === 170; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 170; + return node.kind === 171; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 171; + return node.kind === 172; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 172; + return node.kind === 173; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 173; + return node.kind === 174; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 174; + return node.kind === 175; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 175; + return node.kind === 176; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 176; + return node.kind === 177; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 177; + return node.kind === 178; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 178; + return node.kind === 179; } ts.isImportTypeNode = isImportTypeNode; function isObjectBindingPattern(node) { - return node.kind === 179; + return node.kind === 180; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 180; + return node.kind === 181; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 181; + return node.kind === 182; } ts.isBindingElement = isBindingElement; function isArrayLiteralExpression(node) { - return node.kind === 182; + return node.kind === 183; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 183; + return node.kind === 184; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 184; + return node.kind === 185; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 185; + return node.kind === 186; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 186; + return node.kind === 187; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 187; + return node.kind === 188; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 188; + return node.kind === 189; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 189; + return node.kind === 190; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 190; + return node.kind === 191; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 300) { + while (node.kind === 301) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 191; + return node.kind === 192; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 192; + return node.kind === 193; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 194; + return node.kind === 195; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 195; + return node.kind === 196; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 196; + return node.kind === 197; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 197; + return node.kind === 198; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 198; + return node.kind === 199; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 199; + return node.kind === 200; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 200; + return node.kind === 201; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 201; + return node.kind === 202; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 202; + return node.kind === 203; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 203; + return node.kind === 204; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 204; + return node.kind === 205; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 205; + return node.kind === 206; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 206; + return node.kind === 207; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 207; + return node.kind === 208; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 208; + return node.kind === 209; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 209; + return node.kind === 210; } ts.isMetaProperty = isMetaProperty; function isTemplateSpan(node) { - return node.kind === 210; + return node.kind === 211; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 211; + return node.kind === 212; } ts.isSemicolonClassElement = isSemicolonClassElement; function isBlock(node) { - return node.kind === 212; + return node.kind === 213; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 213; + return node.kind === 214; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 214; + return node.kind === 215; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 215; + return node.kind === 216; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 216; + return node.kind === 217; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 217; + return node.kind === 218; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 218; + return node.kind === 219; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 219; + return node.kind === 220; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 220; + return node.kind === 221; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 221; + return node.kind === 222; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 222; + return node.kind === 223; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 223; + return node.kind === 224; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 223 || node.kind === 222; + return node.kind === 224 || node.kind === 223; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 224; + return node.kind === 225; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 225; + return node.kind === 226; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 226; + return node.kind === 227; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 227; + return node.kind === 228; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 228; + return node.kind === 229; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 229; + return node.kind === 230; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 230; + return node.kind === 231; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 231; + return node.kind === 232; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 232; + return node.kind === 233; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 233; + return node.kind === 234; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 234; + return node.kind === 235; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 235; + return node.kind === 236; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 236; + return node.kind === 237; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 237; + return node.kind === 238; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 238; + return node.kind === 239; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 239; + return node.kind === 240; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 240; + return node.kind === 241; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 241; + return node.kind === 242; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 242; + return node.kind === 243; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 243; + return node.kind === 244; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 244; + return node.kind === 245; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 245; + return node.kind === 246; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 246; + return node.kind === 247; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 247; + return node.kind === 248; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 248; + return node.kind === 249; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 249; + return node.kind === 250; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 250; + return node.kind === 251; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 251; + return node.kind === 252; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 252; + return node.kind === 253; } ts.isMissingDeclaration = isMissingDeclaration; function isExternalModuleReference(node) { - return node.kind === 253; + return node.kind === 254; } ts.isExternalModuleReference = isExternalModuleReference; function isJsxElement(node) { - return node.kind === 254; + return node.kind === 255; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 255; + return node.kind === 256; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 256; + return node.kind === 257; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 257; + return node.kind === 258; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 258; + return node.kind === 259; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 259; + return node.kind === 260; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 260; + return node.kind === 261; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 261; + return node.kind === 262; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 262; + return node.kind === 263; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 263; + return node.kind === 264; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 264; + return node.kind === 265; } ts.isJsxExpression = isJsxExpression; function isCaseClause(node) { - return node.kind === 265; + return node.kind === 266; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 266; + return node.kind === 267; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 267; + return node.kind === 268; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 268; + return node.kind === 269; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 269; + return node.kind === 270; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 270; + return node.kind === 271; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 271; + return node.kind === 272; } ts.isSpreadAssignment = isSpreadAssignment; function isEnumMember(node) { - return node.kind === 272; + return node.kind === 273; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 273; + return node.kind === 274; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 274; + return node.kind === 275; } ts.isBundle = isBundle; function isJSDocTypeExpression(node) { - return node.kind === 277; + return node.kind === 278; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 278; + return node.kind === 279; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 279; + return node.kind === 280; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 280; + return node.kind === 281; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 281; + return node.kind === 282; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 282; + return node.kind === 283; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 283; + return node.kind === 284; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 284; + return node.kind === 285; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 285; + return node.kind === 286; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 289; + return node.kind === 290; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 290; + return node.kind === 291; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocParameterTag(node) { - return node.kind === 292; + return node.kind === 293; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 293; + return node.kind === 294; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 294; + return node.kind === 295; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 295; + return node.kind === 296; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 296; + return node.kind === 297; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 297; + return node.kind === 298; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 297 || node.kind === 292; + return node.kind === 298 || node.kind === 293; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 286; + return node.kind === 287; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 291; + return node.kind === 292; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 287; + return node.kind === 288; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); (function (ts) { function isSyntaxList(n) { - return n.kind === 298; + return n.kind === 299; } ts.isSyntaxList = isSyntaxList; function isNode(node) { @@ -12201,11 +12293,11 @@ var ts; } ts.isNode = isNode; function isNodeKind(kind) { - return kind >= 145; + return kind >= 146; } ts.isNodeKind = isNodeKind; function isToken(n) { - return n.kind >= 0 && n.kind <= 144; + return n.kind >= 0 && n.kind <= 145; } ts.isToken = isToken; function isNodeArray(array) { @@ -12224,6 +12316,10 @@ var ts; return 13 <= kind && kind <= 16; } ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isTemplateLiteralToken(node) { + return isTemplateLiteralKind(node.kind); + } + ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; return kind === 15 @@ -12270,7 +12366,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 145 + return kind === 146 || kind === 71; } ts.isEntityName = isEntityName; @@ -12279,14 +12375,14 @@ var ts; return kind === 71 || kind === 9 || kind === 8 - || kind === 146; + || kind === 147; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 71 - || kind === 179 - || kind === 180; + || kind === 180 + || kind === 181; } ts.isBindingName = isBindingName; function isFunctionLike(node) { @@ -12299,13 +12395,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 233: - case 153: + case 234: case 154: case 155: case 156: - case 191: + case 157: case 192: + case 193: return true; default: return false; @@ -12313,14 +12409,14 @@ var ts; } function isFunctionLikeKind(kind) { switch (kind) { - case 152: - case 157: - case 287: + case 153: case 158: + case 288: case 159: - case 162: - case 283: + case 160: case 163: + case 284: + case 164: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -12333,28 +12429,28 @@ var ts; ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock; function isClassElement(node) { var kind = node.kind; - return kind === 154 - || kind === 151 - || kind === 153 - || kind === 155 + return kind === 155 + || kind === 152 + || kind === 154 || kind === 156 - || kind === 159 - || kind === 211; + || kind === 157 + || kind === 160 + || kind === 212; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 234 || node.kind === 204); + return node && (node.kind === 235 || node.kind === 205); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 155 || node.kind === 156); + return node && (node.kind === 156 || node.kind === 157); } ts.isAccessor = isAccessor; function isMethodOrAccessor(node) { switch (node.kind) { - case 153: - case 155: + case 154: case 156: + case 157: return true; default: return false; @@ -12363,11 +12459,11 @@ var ts; ts.isMethodOrAccessor = isMethodOrAccessor; function isTypeElement(node) { var kind = node.kind; - return kind === 158 - || kind === 157 - || kind === 150 - || kind === 152 - || kind === 159; + return kind === 159 + || kind === 158 + || kind === 151 + || kind === 153 + || kind === 160; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -12376,17 +12472,18 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 269 - || kind === 270 + return kind === 270 || kind === 271 - || kind === 153 - || kind === 155 - || kind === 156; + || kind === 272 + || kind === 154 + || kind === 156 + || kind === 157; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 160 && kind <= 178) + return (kind >= 161 && kind <= 179) || kind === 119 + || kind === 142 || kind === 134 || kind === 135 || kind === 122 @@ -12397,14 +12494,14 @@ var ts; || kind === 140 || kind === 95 || kind === 131 - || kind === 206 - || kind === 278 + || kind === 207 || kind === 279 || kind === 280 || kind === 281 || kind === 282 || kind === 283 - || kind === 284; + || kind === 284 + || kind === 285; } function isTypeNode(node) { return isTypeNodeKind(node.kind); @@ -12412,8 +12509,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 162: case 163: + case 164: return true; } return false; @@ -12422,29 +12519,29 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 180 - || kind === 179; + return kind === 181 + || kind === 180; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 182 - || kind === 183; + return kind === 183 + || kind === 184; } ts.isAssignmentPattern = isAssignmentPattern; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 181 - || kind === 205; + return kind === 182 + || kind === 206; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 231: - case 148: - case 181: + case 232: + case 149: + case 182: return true; } return false; @@ -12457,8 +12554,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 179: - case 183: + case 180: + case 184: return true; } return false; @@ -12466,8 +12563,8 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180: - case 182: + case 181: + case 183: return true; } return false; @@ -12475,25 +12572,25 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 184 - || kind === 145 - || kind === 178; + return kind === 185 + || kind === 146 + || kind === 179; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 184 - || kind === 145; + return kind === 185 + || kind === 146; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { + case 257: case 256: - case 255: - case 186: case 187: case 188: - case 149: + case 189: + case 150: return true; default: return false; @@ -12501,12 +12598,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 186 || node.kind === 187; + return node.kind === 187 || node.kind === 188; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 201 + return kind === 202 || kind === 13; } ts.isTemplateLiteral = isTemplateLiteral; @@ -12516,32 +12613,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 184: case 185: - case 187: case 186: - case 254: - case 255: - case 258: case 188: - case 182: - case 190: + case 187: + case 255: + case 256: + case 259: + case 189: case 183: - case 204: case 191: + case 184: + case 205: + case 192: case 71: case 12: case 8: case 9: case 13: - case 201: + case 202: case 86: case 95: case 99: case 101: case 97: - case 208: case 209: + case 210: case 91: return true; default: @@ -12554,13 +12651,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 197: case 198: - case 193: + case 199: case 194: case 195: case 196: - case 189: + case 197: + case 190: return true; default: return isLeftHandSideExpressionKind(kind); @@ -12568,9 +12665,9 @@ var ts; } function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 198: + case 199: return true; - case 197: + case 198: return expr.operator === 43 || expr.operator === 44; default: @@ -12584,15 +12681,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 200: - case 202: - case 192: - case 199: + case 201: case 203: - case 207: - case 205: + case 193: + case 200: + case 204: + case 208: + case 206: + case 302: case 301: - case 300: return true; default: return isUnaryExpressionKind(kind); @@ -12600,16 +12697,16 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 189 - || kind === 207; + return kind === 190 + || kind === 208; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 300; + return node.kind === 301; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 299; + return node.kind === 300; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -12619,20 +12716,20 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 219: case 220: case 221: - case 217: + case 222: case 218: + case 219: return true; - case 227: + case 228: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isForInOrOfStatement(node) { - return node.kind === 220 || node.kind === 221; + return node.kind === 221 || node.kind === 222; } ts.isForInOrOfStatement = isForInOrOfStatement; function isConciseBody(node) { @@ -12651,108 +12748,108 @@ var ts; ts.isForInitializer = isForInitializer; function isModuleBody(node) { var kind = node.kind; - return kind === 239 - || kind === 238 + return kind === 240 + || kind === 239 || kind === 71; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 239 - || kind === 238; + return kind === 240 + || kind === 239; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 - || kind === 238; + || kind === 239; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 246 - || kind === 245; + return kind === 247 + || kind === 246; } ts.isNamedImportBindings = isNamedImportBindings; function isModuleOrEnumDeclaration(node) { - return node.kind === 238 || node.kind === 237; + return node.kind === 239 || node.kind === 238; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 192 - || kind === 181 - || kind === 234 - || kind === 204 - || kind === 154 - || kind === 237 - || kind === 272 - || kind === 251 - || kind === 233 - || kind === 191 - || kind === 155 - || kind === 244 - || kind === 242 - || kind === 247 + return kind === 193 + || kind === 182 || kind === 235 - || kind === 261 - || kind === 153 - || kind === 152 + || kind === 205 + || kind === 155 || kind === 238 - || kind === 241 - || kind === 245 - || kind === 148 - || kind === 269 - || kind === 151 - || kind === 150 - || kind === 156 - || kind === 270 - || kind === 236 - || kind === 147 - || kind === 231 - || kind === 296 - || kind === 291 - || kind === 297; - } - function isDeclarationStatementKind(kind) { - return kind === 233 + || kind === 273 || kind === 252 || kind === 234 + || kind === 192 + || kind === 156 + || kind === 245 + || kind === 243 + || kind === 248 + || kind === 236 + || kind === 262 + || kind === 154 + || kind === 153 + || kind === 239 + || kind === 242 + || kind === 246 + || kind === 149 + || kind === 270 + || kind === 152 + || kind === 151 + || kind === 157 + || kind === 271 + || kind === 237 + || kind === 148 + || kind === 232 + || kind === 297 + || kind === 292 + || kind === 298; + } + function isDeclarationStatementKind(kind) { + return kind === 234 + || kind === 253 || kind === 235 || kind === 236 || kind === 237 || kind === 238 + || kind === 239 + || kind === 244 || kind === 243 - || kind === 242 + || kind === 250 || kind === 249 - || kind === 248 - || kind === 241; + || kind === 242; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 223 - || kind === 222 - || kind === 230 - || kind === 217 - || kind === 215 - || kind === 214 - || kind === 220 - || kind === 221 - || kind === 219 - || kind === 216 - || kind === 227 - || kind === 224 - || kind === 226 - || kind === 228 - || kind === 229 - || kind === 213 + return kind === 224 + || kind === 223 + || kind === 231 || kind === 218 + || kind === 216 + || kind === 215 + || kind === 221 + || kind === 222 + || kind === 220 + || kind === 217 + || kind === 228 || kind === 225 - || kind === 299 - || kind === 303 - || kind === 302; + || kind === 227 + || kind === 229 + || kind === 230 + || kind === 214 + || kind === 219 + || kind === 226 + || kind === 300 + || kind === 304 + || kind === 303; } function isDeclaration(node) { - if (node.kind === 147) { - return node.parent.kind !== 295 || ts.isInJavaScriptFile(node); + if (node.kind === 148) { + return node.parent.kind !== 296 || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -12773,10 +12870,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 212) + if (node.kind !== 213) return false; if (node.parent !== undefined) { - if (node.parent.kind === 229 || node.parent.kind === 268) { + if (node.parent.kind === 230 || node.parent.kind === 269) { return false; } } @@ -12784,8 +12881,8 @@ var ts; } function isModuleReference(node) { var kind = node.kind; - return kind === 253 - || kind === 145 + return kind === 254 + || kind === 146 || kind === 71; } ts.isModuleReference = isModuleReference; @@ -12793,64 +12890,65 @@ var ts; var kind = node.kind; return kind === 99 || kind === 71 - || kind === 184; + || kind === 185; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 254 - || kind === 264 - || kind === 255 + return kind === 255 + || kind === 265 + || kind === 256 || kind === 10 - || kind === 258; + || kind === 259; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 261 - || kind === 263; + return kind === 262 + || kind === 264; } ts.isJsxAttributeLike = isJsxAttributeLike; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 264; + || kind === 265; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 256 - || kind === 255; + return kind === 257 + || kind === 256; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 265 - || kind === 266; + return kind === 266 + || kind === 267; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isJSDocNode(node) { - return node.kind >= 277 && node.kind <= 297; + return node.kind >= 278 && node.kind <= 298; } ts.isJSDocNode = isJSDocNode; function isJSDocCommentContainingNode(node) { - return node.kind === 285 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 286 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; function isJSDocTag(node) { - return node.kind >= 288 && node.kind <= 297; + return node.kind >= 289 && node.kind <= 298; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 156; + return node.kind === 157; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 155; + return node.kind === 156; } ts.isGetAccessor = isGetAccessor; function hasJSDocNodes(node) { - return !!node.jsDoc && node.jsDoc.length > 0; + var jsDoc = node.jsDoc; + return !!jsDoc && jsDoc.length > 0; } ts.hasJSDocNodes = hasJSDocNodes; function hasType(node) { @@ -12859,8 +12957,7 @@ var ts; ts.hasType = hasType; function couldHaveType(node) { switch (node.kind) { - case 148: - case 150: + case 149: case 151: case 152: case 153: @@ -12871,24 +12968,25 @@ var ts; case 158: case 159: case 160: - case 162: + case 161: case 163: - case 172: - case 174: - case 176: - case 189: - case 191: + case 164: + case 173: + case 175: + case 177: + case 190: case 192: - case 207: - case 231: - case 233: - case 236: - case 277: - case 280: + case 193: + case 208: + case 232: + case 234: + case 237: + case 278: case 281: case 282: case 283: case 284: + case 285: return true; } return false; @@ -12904,13 +13002,13 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 261: - case 263: - case 269: + case 262: + case 264: case 270: - case 153: - case 155: + case 271: + case 154: case 156: + case 157: return true; default: return false; @@ -12918,7 +13016,7 @@ var ts; } ts.isObjectLiteralElement = isObjectLiteralElement; function isTypeReferenceType(node) { - return node.kind === 161 || node.kind === 206; + return node.kind === 162 || node.kind === 207; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -12950,7 +13048,7 @@ var ts; } ts.isStringLiteralLike = isStringLiteralLike; function isNamedImportsOrExports(node) { - return node.kind === 246 || node.kind === 250; + return node.kind === 247 || node.kind === 251; } ts.isNamedImportsOrExports = isNamedImportsOrExports; })(ts || (ts = {})); @@ -12971,7 +13069,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 273) { + if (kind === 274) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71) { @@ -13009,28 +13107,28 @@ var ts; } ts.isJSDocLikeText = isJSDocLikeText; function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 144) { + if (!node || node.kind <= 145) { return; } switch (node.kind) { - case 145: + case 146: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 147: + case 148: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 270: + case 271: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 271: + case 272: return visitNode(cbNode, node.expression); - case 148: + case 149: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -13038,59 +13136,59 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); + case 152: + return visitNodes(cbNode, cbNodes, node.decorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.exclamationToken) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.initializer); case 151: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150: - 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 269: + case 270: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 231: + case 232: 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 181: + case 182: 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 162: case 163: - case 157: + case 164: case 158: case 159: + case 160: 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 153: - case 152: case 154: + case 153: case 155: case 156: - case 191: - case 233: + case 157: case 192: + case 234: + case 193: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13101,187 +13199,180 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 161: + case 162: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 160: + case 161: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 164: - return visitNode(cbNode, node.exprName); case 165: - return visitNodes(cbNode, cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 166: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNode, cbNodes, node.members); case 167: - return visitNodes(cbNode, cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 168: + return visitNodes(cbNode, cbNodes, node.elementTypes); case 169: - return visitNodes(cbNode, cbNodes, node.types); case 170: + return visitNodes(cbNode, cbNodes, node.types); + case 171: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 171: + case 172: return visitNode(cbNode, node.typeParameter); - case 178: + case 179: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 172: - case 174: - return visitNode(cbNode, node.type); + case 173: case 175: + return visitNode(cbNode, node.type); + case 176: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 176: + case 177: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 177: + case 178: return visitNode(cbNode, node.literal); - case 179: case 180: - return visitNodes(cbNode, cbNodes, node.elements); - case 182: + case 181: return visitNodes(cbNode, cbNodes, node.elements); case 183: - return visitNodes(cbNode, cbNodes, node.properties); + return visitNodes(cbNode, cbNodes, node.elements); case 184: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNode, cbNodes, node.properties); case 185: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 186: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 187: + case 188: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 188: + case 189: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 189: + case 190: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 190: - return visitNode(cbNode, node.expression); - case 193: + case 191: return visitNode(cbNode, node.expression); case 194: return visitNode(cbNode, node.expression); case 195: return visitNode(cbNode, node.expression); - case 197: - return visitNode(cbNode, node.operand); - case 202: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 196: return visitNode(cbNode, node.expression); case 198: return visitNode(cbNode, node.operand); + case 203: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 197: + return visitNode(cbNode, node.expression); case 199: + return visitNode(cbNode, node.operand); + case 200: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 207: + case 208: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 208: - return visitNode(cbNode, node.expression); case 209: + return visitNode(cbNode, node.expression); + case 210: return visitNode(cbNode, node.name); - case 200: + case 201: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 203: + case 204: return visitNode(cbNode, node.expression); - case 212: - case 239: + case 213: + case 240: return visitNodes(cbNode, cbNodes, node.statements); - case 273: + case 274: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 213: + case 214: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 232: + case 233: return visitNodes(cbNode, cbNodes, node.declarations); - case 215: - return visitNode(cbNode, node.expression); case 216: + return visitNode(cbNode, node.expression); + case 217: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 217: + case 218: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 218: + case 219: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 219: + case 220: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 220: + case 221: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 221: + case 222: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222: case 223: - return visitNode(cbNode, node.label); case 224: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.label); case 225: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); + return visitNode(cbNode, node.expression); case 226: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 227: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 240: + case 241: return visitNodes(cbNode, cbNodes, node.clauses); - case 265: + case 266: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 266: + case 267: return visitNodes(cbNode, cbNodes, node.statements); - case 227: + case 228: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 228: - return visitNode(cbNode, node.expression); case 229: + return visitNode(cbNode, node.expression); + case 230: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 268: + case 269: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 149: + case 150: return visitNode(cbNode, node.expression); - case 234: - case 204: - 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 235: + case 205: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13293,112 +13384,119 @@ var ts; visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNode, cbNodes, node.heritageClauses) || + visitNodes(cbNode, cbNodes, node.members); case 237: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNode, cbNodes, node.members); - case 272: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNode, cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 238: + return visitNodes(cbNode, cbNodes, node.decorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNode, cbNodes, node.members); + case 273: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 239: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 242: + case 243: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 243: + case 244: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 244: + case 245: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 241: - return visitNode(cbNode, node.name); - case 245: + case 242: return visitNode(cbNode, node.name); case 246: - case 250: + return visitNode(cbNode, node.name); + case 247: + case 251: return visitNodes(cbNode, cbNodes, node.elements); - case 249: + case 250: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 247: - case 251: + case 248: + case 252: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 248: + case 249: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 201: + case 202: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 210: + case 211: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 146: + case 147: return visitNode(cbNode, node.expression); - case 267: + case 268: return visitNodes(cbNode, cbNodes, node.types); - case 206: + case 207: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 253: - return visitNode(cbNode, node.expression); - case 252: - return visitNodes(cbNode, cbNodes, node.decorators); - case 301: - return visitNodes(cbNode, cbNodes, node.elements); case 254: + return visitNode(cbNode, node.expression); + case 253: + return visitNodes(cbNode, cbNodes, node.decorators); + case 302: + return visitNodes(cbNode, cbNodes, node.elements); + case 255: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 258: + case 259: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 255: case 256: + case 257: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 262: + case 263: return visitNodes(cbNode, cbNodes, node.properties); - case 261: + case 262: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 263: - return visitNode(cbNode, node.expression); case 264: + return visitNode(cbNode, node.expression); + case 265: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 257: + case 258: return visitNode(cbNode, node.tagName); - case 277: - return visitNode(cbNode, node.type); - case 281: - return visitNode(cbNode, node.type); - case 280: + case 278: return visitNode(cbNode, node.type); case 282: return visitNode(cbNode, node.type); + case 281: + return visitNode(cbNode, node.type); case 283: + return visitNode(cbNode, node.type); + case 284: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 284: - return visitNode(cbNode, node.type); case 285: + return visitNode(cbNode, node.type); + case 286: return visitNodes(cbNode, cbNodes, node.tags); - case 292: - case 297: + case 293: + case 298: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -13407,17 +13505,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 293: - return visitNode(cbNode, node.typeExpression); case 294: return visitNode(cbNode, node.typeExpression); - case 289: - return visitNode(cbNode, node.class); case 295: - return visitNodes(cbNode, cbNodes, node.typeParameters); + return visitNode(cbNode, node.typeExpression); + case 290: + return visitNode(cbNode, node.class); case 296: + return visitNodes(cbNode, cbNodes, node.typeParameters); + case 297: if (node.typeExpression && - node.typeExpression.kind === 277) { + node.typeExpression.kind === 278) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -13425,16 +13523,16 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 291: + case 292: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 287: + case 288: 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 286: + case 287: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -13442,7 +13540,7 @@ var ts; } } return; - case 300: + case 301: return visitNode(cbNode, node.expression); } } @@ -13475,6 +13573,7 @@ var ts; } ts.isExternalModule = isExternalModule; function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + if (aggressiveChecks === void 0) { aggressiveChecks = false; } var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); newSourceFile.flags |= (sourceFile.flags & 1572864); return newSourceFile; @@ -13512,6 +13611,7 @@ var ts; var contextFlags; var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { + if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); if (scriptKind === 6) { var result_1 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); @@ -13539,6 +13639,7 @@ var ts; if (languageVersion === void 0) { languageVersion = 2; } initializeState(sourceText, languageVersion, syntaxCursor, 6); sourceFile = createSourceFile(fileName, 2, 6, false); + sourceFile.flags = contextFlags; nextToken(); var pos = getNodePos(); if (token() === 1) { @@ -13546,7 +13647,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(215); + var statement = createNode(216); switch (token()) { case 21: statement.expression = parseArrayLiteralExpression(); @@ -13689,10 +13790,11 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { - var sourceFile = new SourceFileConstructor(273, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(274, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; + sourceFile.bindSuggestionDiagnostics = undefined; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); sourceFile.languageVariant = getLanguageVariant(scriptKind); @@ -14006,7 +14108,7 @@ var ts; return parsePropertyNameWorker(true); } function parseComputedPropertyName() { - var node = createNode(146); + var node = createNode(147); parseExpected(21); node.expression = allowInAnd(parseExpression); parseExpected(22); @@ -14120,7 +14222,7 @@ var ts; case 14: return true; } - ts.Debug.fail("Non-exhaustive case in 'isListElement'."); + return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { ts.Debug.assert(token() === 17); @@ -14196,6 +14298,8 @@ var ts; return token() === 29 || token() === 41; case 14: return token() === 27 && lookAhead(nextTokenIsSlash); + default: + return false; } } function isVariableDeclaratorListTerminator() { @@ -14314,14 +14418,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 154: - case 159: case 155: + case 160: case 156: - case 151: - case 211: + case 157: + case 152: + case 212: return true; - case 153: + case 154: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 71 && methodDeclaration.name.originalKeywordKind === 123; @@ -14333,8 +14437,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 265: case 266: + case 267: return true; } } @@ -14343,65 +14447,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 233: + case 234: + case 214: case 213: - case 212: + case 217: case 216: - case 215: - case 228: + case 229: + case 225: + case 227: case 224: - case 226: case 223: + case 221: case 222: case 220: - case 221: case 219: - case 218: - case 225: - case 214: - case 229: - case 227: - case 217: + case 226: + case 215: case 230: + case 228: + case 218: + case 231: + case 244: case 243: - case 242: + case 250: case 249: - case 248: - case 238: - case 234: + case 239: case 235: - case 237: case 236: + case 238: + case 237: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 272; + return node.kind === 273; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 158: - case 152: case 159: - case 150: - case 157: + case 153: + case 160: + case 151: + case 158: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 231) { + if (node.kind !== 232) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 148) { + if (node.kind !== 149) { return false; } var parameter = node; @@ -14440,6 +14544,7 @@ var ts; case 22: return ts.Diagnostics.Identifier_expected; case 13: return ts.Diagnostics.Identifier_expected; case 14: return ts.Diagnostics.Identifier_expected; + default: return undefined; } } function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { @@ -14508,7 +14613,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(145, entity.pos); + var node = createNode(146, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -14523,19 +14628,19 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(201); + var template = createNode(202); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14, "Template head has wrong token kind"); var list = []; var listPos = getNodePos(); do { list.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(list).literal.kind === 15); + } while (ts.last(list).literal.kind === 15); template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { - var span = createNode(210); + var span = createNode(211); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18) { @@ -14579,7 +14684,7 @@ var ts; return node; } function parseTypeReference() { - var node = createNode(161); + var node = createNode(162); node.typeName = parseEntityName(true, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token() === 27) { node.typeArguments = parseBracketedList(19, parseType, 27, 29); @@ -14588,20 +14693,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(160, lhs.pos); + var node = createNode(161, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(173); + var node = createNode(174); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(278); + var result = createNode(279); if (postFixEquals) { - return createJSDocPostfixType(282, result); + return createJSDocPostfixType(283, result); } else { nextToken(); @@ -14609,7 +14714,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(281); + var result = createNode(282); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -14623,28 +14728,28 @@ var ts; token() === 29 || token() === 58 || token() === 49) { - var result = createNode(279, pos); + var result = createNode(280, pos); return finishNode(result); } else { - var result = createNode(280, pos); + var result = createNode(281, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(283); + var result = createNodeWithJSDoc(284); nextToken(); fillSignature(56, 4 | 32, result); return finishNode(result); } - var node = createNode(161); + var node = createNode(162); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(148); + var parameter = createNode(149); if (token() === 99 || token() === 94) { parameter.name = parseIdentifierName(); parseExpected(56); @@ -14656,23 +14761,23 @@ var ts; var dotdotdot = parseOptionalToken(24); var type = parseType(); if (dotdotdot) { - var variadic = createNode(284, dotdotdot.pos); + var variadic = createNode(285, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58) { - return createJSDocPostfixType(282, type); + return createJSDocPostfixType(283, type); } return type; } function parseTypeQuery() { - var node = createNode(164); + var node = createNode(165); parseExpected(103); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(147); + var node = createNode(148); node.name = parseIdentifier(); if (parseOptional(85)) { if (isStartOfType() || !isStartOfExpression()) { @@ -14706,7 +14811,7 @@ var ts; isStartOfType(true); } function parseParameter() { - var node = createNodeWithJSDoc(148); + var node = createNodeWithJSDoc(149); if (token() === 99) { node.name = createIdentifier(true); node.type = parseParameterType(); @@ -14774,7 +14879,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 158) { + if (kind === 159) { parseExpected(94); } fillSignature(56, 4, node); @@ -14811,7 +14916,7 @@ var ts; return token() === 56 || token() === 26 || token() === 22; } function parseIndexSignatureDeclaration(node) { - node.kind = 159; + node.kind = 160; node.parameters = parseBracketedList(16, parseParameter, 21, 22); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -14821,11 +14926,11 @@ var ts; node.name = parsePropertyName(); node.questionToken = parseOptionalToken(55); if (token() === 19 || token() === 27) { - node.kind = 152; + node.kind = 153; fillSignature(56, 4, node); } else { - node.kind = 150; + node.kind = 151; node.type = parseTypeAnnotation(); if (token() === 58) { node.initializer = parseInitializer(); @@ -14838,7 +14943,7 @@ var ts; if (token() === 19 || token() === 27) { return true; } - var idToken; + var idToken = false; while (ts.isModifierKind(token())) { idToken = true; nextToken(); @@ -14862,10 +14967,10 @@ var ts; } function parseTypeMember() { if (token() === 19 || token() === 27) { - return parseSignatureMember(157); + return parseSignatureMember(158); } if (token() === 94 && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(158); + return parseSignatureMember(159); } var node = createNodeWithJSDoc(0); node.modifiers = parseModifiers(); @@ -14891,7 +14996,7 @@ var ts; return false; } function parseTypeLiteral() { - var node = createNode(165); + var node = createNode(166); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -14917,14 +15022,14 @@ var ts; return token() === 21 && nextTokenIsIdentifier() && nextToken() === 92; } function parseMappedTypeParameter() { - var node = createNode(147); + var node = createNode(148); node.name = parseIdentifier(); parseExpected(92); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(176); + var node = createNode(177); parseExpected(17); if (token() === 132 || token() === 37 || token() === 38) { node.readonlyToken = parseTokenNode(); @@ -14947,12 +15052,12 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(167); + var node = createNode(168); node.elementTypes = parseBracketedList(20, parseType, 21, 22); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(172); + var node = createNode(173); parseExpected(19); node.type = parseType(); if (!node.type) { @@ -14963,7 +15068,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 163) { + if (kind === 164) { parseExpected(94); } if (!fillSignature(36, 4 | (sourceFile.languageVariant === 1 ? 8 : 0), node)) { @@ -14979,10 +15084,10 @@ var ts; return token() === 23 ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(177); + var node = createNode(178); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(197); + unaryMinusExpression = createNode(198); unaryMinusExpression.operator = 38; nextToken(); } @@ -15003,7 +15108,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288; - var node = createNode(178); + var node = createNode(179); if (parseOptional(103)) { node.isTypeOf = true; } @@ -15023,6 +15128,7 @@ var ts; function parseNonArrayType() { switch (token()) { case 119: + case 142: case 137: case 134: case 138: @@ -15078,6 +15184,7 @@ var ts; function isStartOfType(inStartOfParameter) { switch (token()) { case 119: + case 142: case 137: case 134: case 122: @@ -15124,25 +15231,25 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51: - type = createJSDocPostfixType(281, type); + type = createJSDocPostfixType(282, type); break; case 55: if (!(contextFlags & 2097152) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createJSDocPostfixType(280, type); + type = createJSDocPostfixType(281, type); break; case 21: parseExpected(21); if (isStartOfType()) { - var node = createNode(175, type.pos); + var node = createNode(176, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22); type = finishNode(node); } else { - var node = createNode(166, type.pos); + var node = createNode(167, type.pos); node.elementType = type; parseExpected(22); type = finishNode(node); @@ -15161,16 +15268,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(174); + var node = createNode(175); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(171); + var node = createNode(172); parseExpected(126); - var typeParameter = createNode(147); + var typeParameter = createNode(148); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -15201,10 +15308,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(169, parseTypeOperatorOrHigher, 48); + return parseUnionOrIntersectionType(170, parseTypeOperatorOrHigher, 48); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(168, parseIntersectionTypeOrHigher, 49); + return parseUnionOrIntersectionType(169, parseIntersectionTypeOrHigher, 49); } function isStartOfFunctionType() { if (token() === 27) { @@ -15250,7 +15357,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(160, typePredicateVariable.pos); + var node = createNode(161, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -15271,14 +15378,14 @@ var ts; } function parseTypeWorker(noConditionalTypes) { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(162); + return parseFunctionOrConstructorType(163); } if (token() === 94) { - return parseFunctionOrConstructorType(163); + return parseFunctionOrConstructorType(164); } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85)) { - var node = createNode(170, type.pos); + var node = createNode(171, type.pos); node.checkType = type; node.extendsType = parseTypeWorker(true); parseExpected(55); @@ -15400,7 +15507,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(202); + var node = createNode(203); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 39 || isStartOfExpression())) { @@ -15416,13 +15523,13 @@ var ts; ts.Debug.assert(token() === 36, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(192, asyncModifier.pos); + node = createNode(193, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(192, identifier.pos); + node = createNode(193, identifier.pos); } - var parameter = createNode(148, identifier.pos); + var parameter = createNode(149, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); @@ -15568,7 +15675,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(192); + var node = createNodeWithJSDoc(193); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256) ? 2 : 0; if (!fillSignature(56, isAsync | (allowAmbiguity ? 0 : 8), node)) { @@ -15602,7 +15709,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(200, leftOperand.pos); + var node = createNode(201, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -15617,7 +15724,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 92 || t === 144; + return t === 92 || t === 145; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -15654,43 +15761,43 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(199, left.pos); + var node = createNode(200, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(207, left.pos); + var node = createNode(208, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(197); + var node = createNode(198); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(193); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(194); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(195); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(196); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { if (token() === 121) { if (inAwaitContext()) { @@ -15701,7 +15808,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(196); + var node = createNode(197); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15718,7 +15825,7 @@ var ts; if (token() === 40) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 189) { + if (simpleUnaryExpression.kind === 190) { 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 { @@ -15771,7 +15878,7 @@ var ts; } function parseUpdateExpression() { if (token() === 43 || token() === 44) { - var node = createNode(197); + var node = createNode(198); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -15783,7 +15890,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 || token() === 44) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(198, expression.pos); + var node = createNode(199, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -15802,7 +15909,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); nextToken(); - var node = createNode(209, fullStart); + var node = createNode(210, fullStart); node.keywordToken = 91; node.name = parseIdentifierName(); expression = finishNode(node); @@ -15826,30 +15933,17 @@ var ts; if (token() === 19 || token() === 23 || token() === 21) { return expression; } - var node = createNode(184, expression.pos); + var node = createNode(185, expression.pos); node.expression = expression; parseExpectedToken(23, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } - function tagNamesAreEquivalent(lhs, rhs) { - if (lhs.kind !== rhs.kind) { - return false; - } - if (lhs.kind === 71) { - return lhs.escapedText === rhs.escapedText; - } - if (lhs.kind === 99) { - return true; - } - return lhs.name.escapedText === rhs.name.escapedText && - tagNamesAreEquivalent(lhs.expression, rhs.expression); - } function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 256) { - var node = createNode(254, opening.pos); + if (opening.kind === 257) { + var node = createNode(255, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -15858,22 +15952,22 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 259) { - var node = createNode(258, opening.pos); + else if (opening.kind === 260) { + var node = createNode(259, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 255); + ts.Debug.assert(opening.kind === 256); result = opening; } if (inExpressionContext && token() === 27) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(199, result.pos); + var badNode = createNode(200, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -15929,7 +16023,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(262); + var jsxAttributes = createNode(263); jsxAttributes.properties = parseList(13, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -15937,7 +16031,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(27); if (token() === 29) { - var node_1 = createNode(259, fullStart); + var node_1 = createNode(260, fullStart); scanJsxText(); return finishNode(node_1); } @@ -15946,7 +16040,7 @@ var ts; var attributes = parseJsxAttributes(); var node; if (token() === 29) { - node = createNode(256, fullStart); + node = createNode(257, fullStart); scanJsxText(); } else { @@ -15958,7 +16052,7 @@ var ts; parseExpected(29, undefined, false); scanJsxText(); } - node = createNode(255, fullStart); + node = createNode(256, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -15970,7 +16064,7 @@ var ts; var expression = token() === 99 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23)) { - var propertyAccess = createNode(184, expression.pos); + var propertyAccess = createNode(185, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15978,7 +16072,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(264); + var node = createNode(265); if (!parseExpected(17)) { return undefined; } @@ -16000,7 +16094,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(261); + var node = createNode(262); node.name = parseIdentifierName(); if (token() === 58) { switch (scanJsxAttributeValue()) { @@ -16015,7 +16109,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(263); + var node = createNode(264); parseExpected(17); parseExpected(24); node.expression = parseExpression(); @@ -16023,7 +16117,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(257); + var node = createNode(258); parseExpected(28); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -16036,7 +16130,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(260); + var node = createNode(261); parseExpected(28); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -16051,7 +16145,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(189); + var node = createNode(190); parseExpected(27); node.type = parseType(); parseExpected(29); @@ -16062,7 +16156,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23); if (dotToken) { - var propertyAccess = createNode(184, expression.pos); + var propertyAccess = createNode(185, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -16070,13 +16164,13 @@ var ts; } if (token() === 51 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(208, expression.pos); + var nonNullExpression = createNode(209, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(21)) { - var indexedAccess = createNode(185, expression.pos); + var indexedAccess = createNode(186, expression.pos); indexedAccess.expression = expression; if (token() === 22) { indexedAccess.argumentExpression = createMissingNode(71, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -16103,7 +16197,7 @@ var ts; return token() === 13 || token() === 14; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(188, tag.pos); + var tagExpression = createNode(189, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 @@ -16123,7 +16217,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(186, expression.pos); + var callExpr = createNode(187, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -16131,7 +16225,7 @@ var ts; continue; } else if (token() === 19) { - var callExpr = createNode(186, expression.pos); + var callExpr = createNode(187, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -16228,28 +16322,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(190); + var node = createNodeWithJSDoc(191); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); return finishNode(node); } function parseSpreadElement() { - var node = createNode(203); + var node = createNode(204); parseExpected(24); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 ? parseSpreadElement() : - token() === 26 ? createNode(205) : + token() === 26 ? createNode(206) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(182); + var node = createNode(183); parseExpected(21); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16261,17 +16355,17 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0); if (parseOptionalToken(24)) { - node.kind = 271; + node.kind = 272; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); if (parseContextualModifier(125)) { - return parseAccessorDeclaration(node, 155); + return parseAccessorDeclaration(node, 156); } if (parseContextualModifier(136)) { - return parseAccessorDeclaration(node, 156); + return parseAccessorDeclaration(node, 157); } var asteriskToken = parseOptionalToken(39); var tokenIsIdentifier = isIdentifier(); @@ -16282,7 +16376,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 || token() === 18 || token() === 58); if (isShorthandPropertyAssignment) { - node.kind = 270; + node.kind = 271; var equalsToken = parseOptionalToken(58); if (equalsToken) { node.equalsToken = equalsToken; @@ -16290,14 +16384,14 @@ var ts; } } else { - node.kind = 269; + node.kind = 270; parseExpected(56); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(183); + var node = createNode(184); parseExpected(17); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16311,7 +16405,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNodeWithJSDoc(191); + var node = createNodeWithJSDoc(192); node.modifiers = parseModifiers(); parseExpected(89); node.asteriskToken = parseOptionalToken(39); @@ -16336,7 +16430,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94); if (parseOptional(23)) { - var node_2 = createNode(209, fullStart); + var node_2 = createNode(210, fullStart); node_2.keywordToken = 94; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -16353,7 +16447,7 @@ var ts; } break; } - var node = createNode(187, fullStart); + var node = createNode(188, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19) { @@ -16362,7 +16456,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(212); + var node = createNode(213); if (parseExpected(17, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -16393,12 +16487,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(214); + var node = createNode(215); parseExpected(25); return finishNode(node); } function parseIfStatement() { - var node = createNode(216); + var node = createNode(217); parseExpected(90); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -16408,7 +16502,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(217); + var node = createNode(218); parseExpected(81); node.statement = parseStatement(); parseExpected(106); @@ -16419,7 +16513,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(218); + var node = createNode(219); parseExpected(106); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -16442,8 +16536,8 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(144) : parseOptional(144)) { - var forOfStatement = createNode(221, pos); + if (awaitToken ? parseExpected(145) : parseOptional(145)) { + var forOfStatement = createNode(222, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -16451,14 +16545,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92)) { - var forInStatement = createNode(220, pos); + var forInStatement = createNode(221, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(219, pos); + var forStatement = createNode(220, pos); forStatement.initializer = initializer; parseExpected(25); if (token() !== 25 && token() !== 20) { @@ -16476,7 +16570,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 223 ? 72 : 77); + parseExpected(kind === 224 ? 72 : 77); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16484,7 +16578,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(224); + var node = createNode(225); parseExpected(96); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -16493,7 +16587,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(225); + var node = createNode(226); parseExpected(107); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -16502,7 +16596,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(265); + var node = createNode(266); parseExpected(73); node.expression = allowInAnd(parseExpression); parseExpected(56); @@ -16510,7 +16604,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(266); + var node = createNode(267); parseExpected(79); parseExpected(56); node.statements = parseList(3, parseStatement); @@ -16520,12 +16614,12 @@ var ts; return token() === 73 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(226); + var node = createNode(227); parseExpected(98); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); - var caseBlock = createNode(240); + var caseBlock = createNode(241); parseExpected(17); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(18); @@ -16533,14 +16627,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(228); + var node = createNode(229); parseExpected(100); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(229); + var node = createNode(230); parseExpected(102); node.tryBlock = parseBlock(false); node.catchClause = token() === 74 ? parseCatchClause() : undefined; @@ -16551,7 +16645,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(268); + var result = createNode(269); parseExpected(74); if (parseOptional(19)) { result.variableDeclaration = parseVariableDeclaration(); @@ -16564,7 +16658,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(230); + var node = createNode(231); parseExpected(78); parseSemicolon(); return finishNode(node); @@ -16573,12 +16667,12 @@ var ts; var node = createNodeWithJSDoc(0); var expression = allowInAnd(parseExpression); if (expression.kind === 71 && parseOptional(56)) { - node.kind = 227; + node.kind = 228; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 215; + node.kind = 216; node.expression = expression; parseSemicolon(); } @@ -16628,7 +16722,7 @@ var ts; return false; } continue; - case 143: + case 144: nextToken(); return token() === 17 || token() === 71 || token() === 84; case 91: @@ -16690,7 +16784,7 @@ var ts; case 129: case 130: case 139: - case 143: + case 144: return true; case 114: case 112: @@ -16716,16 +16810,16 @@ var ts; case 17: return parseBlock(false); case 104: - return parseVariableStatement(createNodeWithJSDoc(231)); + return parseVariableStatement(createNodeWithJSDoc(232)); case 110: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(231)); + return parseVariableStatement(createNodeWithJSDoc(232)); } break; case 89: - return parseFunctionDeclaration(createNodeWithJSDoc(233)); + return parseFunctionDeclaration(createNodeWithJSDoc(234)); case 75: - return parseClassDeclaration(createNodeWithJSDoc(234)); + return parseClassDeclaration(createNodeWithJSDoc(235)); case 90: return parseIfStatement(); case 81: @@ -16735,9 +16829,9 @@ var ts; case 88: return parseForOrForInOrForOfStatement(); case 77: - return parseBreakOrContinueStatement(222); - case 72: return parseBreakOrContinueStatement(223); + case 72: + return parseBreakOrContinueStatement(224); case 96: return parseReturnStatement(); case 107: @@ -16770,7 +16864,7 @@ var ts; case 117: case 115: case 132: - case 143: + case 144: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -16812,7 +16906,7 @@ var ts; return parseTypeAliasDeclaration(node); case 83: return parseEnumDeclaration(node); - case 143: + case 144: case 129: case 130: return parseModuleDeclaration(node); @@ -16831,12 +16925,13 @@ var ts; } default: if (node.decorators || node.modifiers) { - var missing = createMissingNode(252, true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(253, true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; return finishNode(missing); } + return undefined; } } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { @@ -16852,16 +16947,16 @@ var ts; } function parseArrayBindingElement() { if (token() === 26) { - return createNode(205); + return createNode(206); } - var node = createNode(181); + var node = createNode(182); node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(181); + var node = createNode(182); node.dotDotDotToken = parseOptionalToken(24); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -16877,14 +16972,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(179); + var node = createNode(180); parseExpected(17); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(18); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(180); + var node = createNode(181); parseExpected(21); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(22); @@ -16906,7 +17001,7 @@ var ts; return parseVariableDeclaration(true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(231); + var node = createNode(232); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 && token() === 51 && !scanner.hasPrecedingLineBreak()) { @@ -16919,7 +17014,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(232); + var node = createNode(233); switch (token()) { case 104: break; @@ -16933,7 +17028,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 144 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 145 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -16948,13 +17043,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20; } function parseVariableStatement(node) { - node.kind = 213; + node.kind = 214; node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 233; + node.kind = 234; parseExpected(89); node.asteriskToken = parseOptionalToken(39); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); @@ -16965,14 +17060,14 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(node) { - node.kind = 154; + node.kind = 155; parseExpected(123); fillSignature(56, 0, node); node.body = parseFunctionBlockOrSemicolon(0, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 153; + node.kind = 154; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 : 0; var isAsync = ts.hasModifier(node, 256) ? 2 : 0; @@ -16981,7 +17076,7 @@ var ts; return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 151; + node.kind = 152; if (!node.questionToken && token() === 51 && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } @@ -17056,7 +17151,7 @@ var ts; if (!parseOptional(57)) { break; } - var decorator = createNode(149, decoratorStart); + var decorator = createNode(150, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -17097,7 +17192,7 @@ var ts; } function parseClassElement() { if (token() === 25) { - var result = createNode(211); + var result = createNode(212); nextToken(); return finishNode(result); } @@ -17105,10 +17200,10 @@ var ts; node.decorators = parseDecorators(); node.modifiers = parseModifiers(true); if (parseContextualModifier(125)) { - return parseAccessorDeclaration(node, 155); + return parseAccessorDeclaration(node, 156); } if (parseContextualModifier(136)) { - return parseAccessorDeclaration(node, 156); + return parseAccessorDeclaration(node, 157); } if (token() === 123) { return parseConstructorDeclaration(node); @@ -17127,13 +17222,13 @@ var ts; node.name = createMissingNode(71, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } - ts.Debug.fail("Should not have attempted to parse class member declaration."); + return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 204); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 205); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 234); + return parseClassDeclarationOrExpression(node, 235); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -17166,17 +17261,15 @@ var ts; } function parseHeritageClause() { var tok = token(); - if (tok === 85 || tok === 108) { - var node = createNode(267); - node.token = tok; - nextToken(); - node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); - return finishNode(node); - } - return undefined; + ts.Debug.assert(tok === 85 || tok === 108); + var node = createNode(268); + node.token = tok; + nextToken(); + node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); + return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(206); + var node = createNode(207); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -17193,7 +17286,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 235; + node.kind = 236; parseExpected(109); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -17202,7 +17295,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 236; + node.kind = 237; parseExpected(139); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -17212,13 +17305,13 @@ var ts; return finishNode(node); } function parseEnumMember() { - var node = createNodeWithJSDoc(272); + var node = createNodeWithJSDoc(273); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 237; + node.kind = 238; parseExpected(83); node.name = parseIdentifier(); if (parseExpected(17)) { @@ -17231,7 +17324,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(239); + var node = createNode(240); if (parseExpected(17)) { node.statements = parseList(1, parseStatement); parseExpected(18); @@ -17242,7 +17335,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 238; + node.kind = 239; var namespaceFlag = flags & 16; node.flags |= flags; node.name = parseIdentifier(); @@ -17252,8 +17345,8 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 238; - if (token() === 143) { + node.kind = 239; + if (token() === 144) { node.name = parseIdentifier(); node.flags |= 512; } @@ -17271,7 +17364,7 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 143) { + if (token() === 144) { return parseAmbientExternalModuleDeclaration(node); } else if (parseOptional(130)) { @@ -17296,7 +17389,7 @@ var ts; return nextToken() === 41; } function parseNamespaceExportDeclaration(node) { - node.kind = 241; + node.kind = 242; parseExpected(118); parseExpected(130); node.name = parseIdentifier(); @@ -17309,23 +17402,23 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 26 && token() !== 142) { + if (token() !== 26 && token() !== 143) { return parseImportEqualsDeclaration(node, identifier); } } - node.kind = 243; + node.kind = 244; if (identifier || token() === 39 || token() === 17) { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(142); + parseExpected(143); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 242; + node.kind = 243; node.name = identifier; parseExpected(58); node.moduleReference = parseModuleReference(); @@ -17333,13 +17426,13 @@ var ts; return finishNode(node); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(244, fullStart); + var importClause = createNode(245, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(26)) { - importClause.namedBindings = token() === 39 ? parseNamespaceImport() : parseNamedImportsOrExports(246); + importClause.namedBindings = token() === 39 ? parseNamespaceImport() : parseNamedImportsOrExports(247); } return finishNode(importClause); } @@ -17349,7 +17442,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(253); + var node = createNode(254); parseExpected(133); parseExpected(19); node.expression = parseModuleSpecifier(); @@ -17367,7 +17460,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(245); + var namespaceImport = createNode(246); parseExpected(39); parseExpected(118); namespaceImport.name = parseIdentifier(); @@ -17375,14 +17468,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 246 ? parseImportSpecifier : parseExportSpecifier, 17, 18); + node.elements = parseBracketedList(22, kind === 247 ? parseImportSpecifier : parseExportSpecifier, 17, 18); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(251); + return parseImportOrExportSpecifier(252); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(247); + return parseImportOrExportSpecifier(248); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17401,21 +17494,21 @@ var ts; else { node.name = identifierName; } - if (kind === 247 && checkIdentifierIsKeyword) { + if (kind === 248 && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 249; + node.kind = 250; if (parseOptional(39)) { - parseExpected(142); + parseExpected(143); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(250); - if (token() === 142 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(142); + node.exportClause = parseNamedImportsOrExports(251); + if (token() === 143 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(143); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -17423,7 +17516,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 248; + node.kind = 249; if (parseOptional(58)) { node.isExportEquals = true; } @@ -17441,10 +17534,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1) - || node.kind === 242 && node.moduleReference.kind === 253 - || node.kind === 243 - || node.kind === 248 + || node.kind === 243 && node.moduleReference.kind === 254 + || node.kind === 244 || node.kind === 249 + || node.kind === 250 ? node : undefined; } @@ -17506,7 +17599,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(277, scanner.getTokenPos()); + var result = createNode(278, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17); result.type = doInsideOfContext(2097152, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -17559,8 +17652,8 @@ var ts; PropertyLikeParse[PropertyLikeParse["CallbackParameter"] = 4] = "CallbackParameter"; })(PropertyLikeParse || (PropertyLikeParse = {})); function parseJSDocCommentWorker(start, length) { + if (start === void 0) { start = 0; } var content = sourceText; - start = start || 0; var end = length === undefined ? content.length : start + length; length = end - start; ts.Debug.assert(start >= 0); @@ -17585,17 +17678,15 @@ var ts; comments.push(text); indent += text.length; } - var t = nextJSDocToken(); - while (t === 5) { - t = nextJSDocToken(); - } - if (t === 4) { + nextJSDocToken(); + while (parseOptionalJsdoc(5)) + ; + if (parseOptionalJsdoc(4)) { state = 0; indent = 0; - t = nextJSDocToken(); } loop: while (true) { - switch (t) { + switch (token()) { case 57: if (state === 0 || state === 1) { removeTrailingNewlines(comments); @@ -17645,7 +17736,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - t = nextJSDocToken(); + nextJSDocToken(); } removeLeadingNewlines(comments); removeTrailingNewlines(comments); @@ -17663,7 +17754,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(285, start); + var result = createNode(286, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -17801,7 +17892,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(288, atToken.pos); + var result = createNode(289, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -17842,7 +17933,7 @@ var ts; switch (node.kind) { case 135: return true; - case 166: + case 167: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -17858,12 +17949,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 ? - createNode(297, atToken.pos) : - createNode(292, atToken.pos); + createNode(298, atToken.pos) : + createNode(293, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); - var nestedTypeLiteral = parseNestedTypeLiteral(typeExpression, name, target); + var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; @@ -17879,20 +17970,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(277, scanner.getTokenPos()); + var typeLiteralExpression = createNode(278, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) { - if (child.kind === 292 || child.kind === 297) { + if (child.kind === 293 || child.kind === 298) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(286, start_2); + jsdocTypeLiteral = createNode(287, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 166) { + if (typeExpression.type.kind === 167) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -17901,27 +17992,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 293; })) { - parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); - } - var result = createNode(293, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result); - } - function parseTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 294; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var result = createNode(294, atToken.pos); result.atToken = atToken; result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result); + } + function parseTypeTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 295; })) { + parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); + } + var result = createNode(295, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(289, atToken.pos); + var result = createNode(290, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -17929,7 +18020,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17); - var node = createNode(206); + var node = createNode(207); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -17941,7 +18032,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(true); while (parseOptional(23)) { - var prop = createNode(184, node.pos); + var prop = createNode(185, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -17949,7 +18040,7 @@ var ts; return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(290, atToken.pos); + var tag = createNode(291, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); @@ -17957,7 +18048,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(296, atToken.pos); + var typedefTag = createNode(297, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -17973,9 +18064,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(286, start_3); + jsdocTypeLiteral = createNode(287, start_3); } - if (child.kind === 294) { + if (child.kind === 295) { if (childTypeTag) { break; } @@ -17988,7 +18079,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 166) { + if (typeExpression && typeExpression.type.kind === 167) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -18003,7 +18094,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(23)) { - var jsDocNamespaceNode = createNode(238, pos); + var jsDocNamespaceNode = createNode(239, pos); if (nested) { jsDocNamespaceNode.flags |= 4; } @@ -18017,7 +18108,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(291, atToken.pos); + var callbackTag = createNode(292, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -18026,16 +18117,15 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(287, start); + var jsdocSignature = createNode(288, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (token() === 57) { - nextJSDocToken(); + if (parseOptionalJsdoc(57)) { var tag = parseTag(indent); - if (tag && tag.kind === 293) { + if (tag && tag.kind === 294) { return tag; } } @@ -18080,7 +18170,7 @@ var ts; case 57: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 292 && + if (child && child.kind === 293 && target !== 4 && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -18141,48 +18231,44 @@ var ts; return tag; } function parseTemplateTag(atToken, tagName) { - if (ts.some(tags, ts.isJSDocTemplateTag)) { - parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); + var constraint; + if (token() === 17) { + constraint = parseJSDocTypeExpression(); } var typeParameters = []; var typeParametersPos = getNodePos(); - while (true) { - var typeParameter = createNode(147); - var name = parseJSDocIdentifierNameWithOptionalBraces(); + do { skipWhitespace(); - if (!name) { - parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); + var typeParameter = createNode(148); + if (!ts.tokenIsIdentifierOrKeyword(token())) { + parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); return undefined; } - typeParameter.name = name; + typeParameter.name = parseJSDocIdentifierName(); + skipWhitespace(); finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 26) { - nextJSDocToken(); - skipWhitespace(); - } - else { - break; - } + } while (parseOptionalJsdoc(26)); + if (constraint) { + ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(295, atToken.pos); + var result = createNode(296, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); finishNode(result); return result; } - function parseJSDocIdentifierNameWithOptionalBraces() { - var parsedBrace = parseOptional(17); - var res = parseJSDocIdentifierName(); - if (parsedBrace) { - parseExpected(18); - } - return res; - } function nextJSDocToken() { return currentToken = scanner.scanJSDocToken(); } + function parseOptionalJsdoc(t) { + if (token() === t) { + nextJSDocToken(); + return true; + } + return false; + } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(true); if (parseOptional(21)) { @@ -18576,10 +18662,7 @@ var ts; break; } case "amd-dependency": { - context.amdDependencies = ts.map(ts.toArray(entryOrList), function (_a) { - var _b = _a.arguments, name = _b.name, path = _b.path; - return ({ name: name, path: path }); - }); + context.amdDependencies = ts.map(ts.toArray(entryOrList), function (x) { return ({ name: x.arguments.name, path: x.arguments.path }); }); break; } case "amd-module": { @@ -18711,6 +18794,20 @@ var ts; } return argMap; } + function tagNamesAreEquivalent(lhs, rhs) { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === 71) { + return lhs.escapedText === rhs.escapedText; + } + if (lhs.kind === 99) { + return true; + } + return lhs.name.escapedText === rhs.name.escapedText && + tagNamesAreEquivalent(lhs.expression, rhs.expression); + } + ts.tagNamesAreEquivalent = tagNamesAreEquivalent; })(ts || (ts = {})); var ts; (function (ts) { @@ -18726,21 +18823,21 @@ var ts; ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateWorker(node) { switch (node.kind) { - case 235: case 236: - return 0; case 237: + return 0; + case 238: if (ts.isConst(node)) { return 2; } break; + case 244: case 243: - case 242: if (!(ts.hasModifier(node, 1))) { return 0; } break; - case 239: { + case 240: { var state_1 = 0; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -18759,7 +18856,7 @@ var ts; }); return state_1; } - case 238: + case 239: return getModuleInstanceState(node); case 71: if (node.isInJSDocNamespace) { @@ -18882,13 +18979,13 @@ var ts; if (symbolFlags & 67216319) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 238)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 239)) { symbol.valueDeclaration = node; } } } function getDeclarationName(node) { - if (node.kind === 248) { + if (node.kind === 249) { return node.isExportEquals ? "export=" : "default"; } var name = ts.getNameOfDeclaration(node); @@ -18897,7 +18994,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 146) { + if (name.kind === 147) { var nameExpression = name.expression; if (ts.isStringOrNumericLiteral(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); @@ -18908,31 +19005,31 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 154: + case 155: return "__constructor"; - case 162: - case 157: - case 287: - return "__call"; case 163: case 158: - return "__new"; + case 288: + return "__call"; + case 164: case 159: + return "__new"; + case 160: return "__index"; - case 249: + case 250: return "__export"; - case 273: + case 274: return "export="; - case 199: + case 200: if (ts.getSpecialPropertyAssignmentKind(node) === 2) { return "export="; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 283: + case 284: return (ts.isJSDocConstructSignature(node) ? "__new" : "__call"); - case 148: - ts.Debug.assert(node.parent.kind === 283, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + case 149: + ts.Debug.assert(node.parent.kind === 284, "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; @@ -18982,7 +19079,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (node.kind === 248 && !node.isExportEquals)) { + (node.kind === 249 && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -19007,7 +19104,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 2097152) { - if (node.kind === 251 || (node.kind === 242 && hasExportModifier)) { + if (node.kind === 252 || (node.kind === 243 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -19037,7 +19134,7 @@ var ts; var saveThisParentContainer = thisParentContainer; var savedBlockScopeContainer = blockScopeContainer; if (containerFlags & 1) { - if (node.kind !== 192) { + if (node.kind !== 193) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -19065,7 +19162,7 @@ var ts; currentFlow.container = node; } } - currentReturnTarget = isIIFE || node.kind === 154 ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 155 ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -19077,13 +19174,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 273) { + if (node.kind === 274) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 154) { + if (node.kind === 155) { node.returnFlowNode = currentFlow; } } @@ -19126,8 +19223,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 233 ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 233 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 234 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 234 ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -19159,76 +19256,76 @@ var ts; return; } switch (node.kind) { - case 218: + case 219: bindWhileStatement(node); break; - case 217: + case 218: bindDoStatement(node); break; - case 219: + case 220: bindForStatement(node); break; - case 220: case 221: + case 222: bindForInOrForOfStatement(node); break; - case 216: + case 217: bindIfStatement(node); break; - case 224: - case 228: + case 225: + case 229: bindReturnOrThrow(node); break; + case 224: case 223: - case 222: bindBreakOrContinueStatement(node); break; - case 229: + case 230: bindTryStatement(node); break; - case 226: + case 227: bindSwitchStatement(node); break; - case 240: + case 241: bindCaseBlock(node); break; - case 265: + case 266: bindCaseClause(node); break; - case 227: + case 228: bindLabeledStatement(node); break; - case 197: + case 198: bindPrefixUnaryExpressionFlow(node); break; - case 198: + case 199: bindPostfixUnaryExpressionFlow(node); break; - case 199: + case 200: bindBinaryExpressionFlow(node); break; - case 193: + case 194: bindDeleteExpressionFlow(node); break; - case 200: + case 201: bindConditionalExpressionFlow(node); break; - case 231: + case 232: bindVariableDeclarationFlow(node); break; - case 186: + case 187: bindCallExpressionFlow(node); break; - case 296: - case 291: + case 297: + case 292: bindJSDocTypeAlias(node); break; - case 273: + case 274: bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 212: - case 239: + case 213: + case 240: bindEachFunctionsFirst(node.statements); break; default: @@ -19241,15 +19338,15 @@ var ts; switch (expr.kind) { case 71: case 99: - case 184: + case 185: return isNarrowableReference(expr); - case 186: + case 187: return hasNarrowableArgument(expr); - case 190: + case 191: return isNarrowingExpression(expr.expression); - case 199: + case 200: return isNarrowingBinaryExpression(expr); - case 197: + case 198: return expr.operator === 51 && isNarrowingExpression(expr.operand); } return false; @@ -19258,7 +19355,7 @@ var ts; return expr.kind === 71 || expr.kind === 99 || expr.kind === 97 || - expr.kind === 184 && isNarrowableReference(expr.expression); + expr.kind === 185 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -19269,7 +19366,7 @@ var ts; } } } - if (expr.expression.kind === 184 && + if (expr.expression.kind === 185 && isNarrowableReference(expr.expression.expression)) { return true; } @@ -19302,9 +19399,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 190: + case 191: return isNarrowableOperand(expr.expression); - case 199: + case 200: switch (expr.operatorToken.kind) { case 58: return isNarrowableOperand(expr.left); @@ -19381,33 +19478,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 216: - case 218: case 217: - return parent.expression === node; case 219: - case 200: + case 218: + return parent.expression === node; + case 220: + case 201: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 190) { + if (node.kind === 191) { node = node.expression; } - else if (node.kind === 197 && node.operator === 51) { + else if (node.kind === 198 && node.operator === 51) { node = node.operand; } else { - return node.kind === 199 && (node.operatorToken.kind === 53 || + return node.kind === 200 && (node.operatorToken.kind === 53 || node.operatorToken.kind === 54); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 190 || - node.parent.kind === 197 && + while (node.parent.kind === 191 || + node.parent.kind === 198 && node.parent.operator === 51) { node = node.parent; } @@ -19449,7 +19546,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 227 + var enclosingLabeledStatement = node.parent.kind === 228 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -19481,13 +19578,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 221) { + if (node.kind === 222) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 232) { + if (node.initializer.kind !== 233) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -19509,7 +19606,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 224) { + if (node.kind === 225) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -19529,7 +19626,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 223 ? breakTarget : continueTarget; + var flowLabel = node.kind === 224 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -19592,7 +19689,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 266; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -19614,6 +19711,7 @@ var ts; } var preCaseLabel = createBranchLabel(); addAntecedent(preCaseLabel, createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1)); + addAntecedent(preCaseLabel, createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1)); addAntecedent(preCaseLabel, fallthroughFlow); currentFlow = finishFlowLabel(preCaseLabel); var clause = clauses[i]; @@ -19655,15 +19753,15 @@ var ts; bind(node.statement); popActiveLabel(); if (!activeLabel.referenced && !options.allowUnusedLabels) { - file.bindDiagnostics.push(createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); + errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 217) { + if (!node.statement || node.statement.kind !== 218) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 199 && node.operatorToken.kind === 58) { + if (node.kind === 200 && node.operatorToken.kind === 58) { bindAssignmentTargetFlow(node.left); } else { @@ -19674,10 +19772,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 182) { + else if (node.kind === 183) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 203) { + if (e.kind === 204) { bindAssignmentTargetFlow(e.expression); } else { @@ -19685,16 +19783,16 @@ var ts; } } } - else if (node.kind === 183) { + else if (node.kind === 184) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 269) { + if (p.kind === 270) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 270) { + else if (p.kind === 271) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 271) { + else if (p.kind === 272) { bindAssignmentTargetFlow(p.expression); } } @@ -19750,7 +19848,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 && node.left.kind === 185) { + if (operator === 58 && node.left.kind === 186) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -19761,7 +19859,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 184) { + if (node.expression.kind === 185) { bindAssignmentTargetFlow(node.expression); } } @@ -19805,10 +19903,10 @@ var ts; } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 190) { + while (expr.kind === 191) { expr = expr.expression; } - if (expr.kind === 191 || expr.kind === 192) { + if (expr.kind === 192 || expr.kind === 193) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -19816,7 +19914,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 184) { + if (node.expression.kind === 185) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -19825,53 +19923,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 204: - case 234: - case 237: - case 183: - case 165: - case 286: - case 262: - return 1; + case 205: case 235: - return 1 | 64; case 238: + case 184: + case 166: + case 287: + case 263: + return 1; case 236: - case 176: + return 1 | 64; + case 239: + case 237: + case 177: return 1 | 32; - case 273: + case 274: return 1 | 4 | 32; - case 153: + case 154: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 154: - case 233: - case 152: case 155: + case 234: + case 153: case 156: case 157: - case 287: - case 283: - case 162: case 158: - case 159: + case 288: + case 284: case 163: + case 159: + case 160: + case 164: return 1 | 4 | 32 | 8; - case 191: case 192: + case 193: return 1 | 4 | 32 | 8 | 16; - case 239: + case 240: return 4; - case 151: + case 152: return node.initializer ? 4 : 0; - case 268: - case 219: + case 269: case 220: case 221: - case 240: + case 222: + case 241: return 2; - case 212: + case 213: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -19884,40 +19982,40 @@ var ts; } function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 238: + case 239: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 273: + case 274: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 204: - case 234: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 237: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 165: - case 286: - case 183: + case 205: case 235: - case 262: - return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 162: - case 163: - case 157: - case 158: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 238: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 166: case 287: + case 184: + case 236: + case 263: + return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + case 163: + case 164: + case 158: case 159: - case 153: - case 152: + case 288: + case 160: case 154: + case 153: case 155: case 156: - case 233: - case 191: + case 157: + case 234: case 192: - case 283: - case 296: - case 291: - case 236: - case 176: + case 193: + case 284: + case 297: + case 292: + case 237: + case 177: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -19932,11 +20030,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 273 ? node : node.body; - if (body && (body.kind === 273 || body.kind === 239)) { + var body = node.kind === 274 ? node : node.body; + if (body && (body.kind === 274 || body.kind === 240)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 249 || stat.kind === 248) { + if (stat.kind === 250 || stat.kind === 249) { return true; } } @@ -20009,11 +20107,11 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 271 || prop.name.kind !== 71) { + if (prop.kind === 272 || prop.name.kind !== 71) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 269 || prop.kind === 270 || prop.kind === 153 + var currentKind = prop.kind === 270 || prop.kind === 271 || prop.kind === 154 ? 1 : 2; var existingKind = seen.get(identifier.escapedText); @@ -20041,13 +20139,14 @@ var ts; symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); + return symbol; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 238: + case 239: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 273: + case 274: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -20167,8 +20266,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 273 && - blockScopeContainer.kind !== 238 && + if (blockScopeContainer.kind !== 274 && + blockScopeContainer.kind !== 239 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -20201,6 +20300,16 @@ var ts; var span = ts.getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } + function errorOrSuggestionOnFirstToken(isError, node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + var diag = ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2); + if (isError) { + file.bindDiagnostics.push(diag); + } + else { + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + } + } function bind(node) { if (!node) { return; @@ -20208,7 +20317,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 144) { + if (node.kind > 145) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -20272,11 +20381,11 @@ var ts; break; } case 99: - if (currentFlow && (ts.isExpression(node) || parent.kind === 270)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 271)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 184: + case 185: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -20284,7 +20393,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 199: + case 200: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1: @@ -20311,127 +20420,127 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 268: + case 269: return checkStrictModeCatchClause(node); - case 193: + case 194: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 198: + case 199: return checkStrictModePostfixUnaryExpression(node); - case 197: + case 198: return checkStrictModePrefixUnaryExpression(node); - case 225: + case 226: return checkStrictModeWithStatement(node); - case 173: + case 174: seenThisKeyword = true; return; - case 160: + case 161: break; - case 147: - return bindTypeParameter(node); case 148: + return bindTypeParameter(node); + case 149: return bindParameter(node); - case 231: + case 232: return bindVariableDeclarationOrBindingElement(node); - case 181: + case 182: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); + case 152: case 151: - case 150: return bindPropertyWorker(node); - case 269: case 270: + case 271: return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 272: + case 273: return bindPropertyOrMethodOrAccessor(node, 8, 68008959); - case 157: case 158: case 159: + case 160: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 153: - case 152: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 67208127); - case 233: - return bindFunctionDeclaration(node); case 154: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 153: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 67208127); + case 234: + return bindFunctionDeclaration(node); case 155: - return bindPropertyOrMethodOrAccessor(node, 32768, 67150783); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 156: + return bindPropertyOrMethodOrAccessor(node, 32768, 67150783); + case 157: return bindPropertyOrMethodOrAccessor(node, 65536, 67183551); - case 162: - case 283: - case 287: case 163: + case 284: + case 288: + case 164: return bindFunctionOrConstructorType(node); - case 165: - case 286: - case 176: + case 166: + case 287: + case 177: return bindAnonymousTypeWorker(node); - case 183: + case 184: return bindObjectLiteralExpression(node); - case 191: case 192: + case 193: return bindFunctionExpression(node); - case 186: + case 187: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 204: - case 234: + case 205: + case 235: inStrictMode = true; return bindClassLikeDeclaration(node); - case 235: - return bindBlockScopedDeclaration(node, 64, 67901832); case 236: - return bindBlockScopedDeclaration(node, 524288, 67901928); + return bindBlockScopedDeclaration(node, 64, 67901832); case 237: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 67901928); case 238: + return bindEnumDeclaration(node); + case 239: return bindModuleDeclaration(node); - case 262: + case 263: return bindJsxAttributes(node); - case 261: + case 262: return bindJsxAttribute(node, 4, 0); - case 242: - case 245: - case 247: - case 251: - return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); - case 241: - return bindNamespaceExportDeclaration(node); - case 244: - return bindImportClause(node); - case 249: - return bindExportDeclaration(node); + case 243: + case 246: case 248: + case 252: + return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); + case 242: + return bindNamespaceExportDeclaration(node); + case 245: + return bindImportClause(node); + case 250: + return bindExportDeclaration(node); + case 249: return bindExportAssignment(node); - case 273: + case 274: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 212: + case 213: if (!ts.isFunctionLike(node.parent)) { return; } - case 239: + case 240: return updateStrictModeStatementList(node.statements); - case 292: - if (node.parent.kind === 287) { + case 293: + if (node.parent.kind === 288) { return bindParameter(node); } - if (node.parent.kind !== 286) { + if (node.parent.kind !== 287) { break; } - case 297: + case 298: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 282 ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 ? 4 | 16777216 : 4; return declareSymbolAndAddToSymbolTable(propTag, flags, 0); - case 296: - case 291: + case 297: + case 292: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -20461,7 +20570,7 @@ var ts; bindAnonymousDeclaration(node, 2097152, getDeclarationName(node)); } else { - var flags = node.kind === 248 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 249 && ts.exportAssignmentIsAlias(node) ? 2097152 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863); @@ -20471,7 +20580,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 273) { + if (node.parent.kind !== 274) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -20513,13 +20622,11 @@ var ts; function bindExportsPropertyAssignment(node) { setCommonJsModuleIndicator(node); var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, function (id, original) { - if (!original) { - return undefined; + var symbol = forEachIdentifierInEntityName(lhs.expression, undefined, function (id, symbol) { + if (symbol) { + addDeclarationToSymbol(symbol, id, 1536 | 67108864); } - var s = ts.getJSInitializerSymbol(original); - addDeclarationToSymbol(s, id, 1536 | 67108864); - return s; + return symbol; }); if (symbol) { var flags = ts.isClassExpression(node.right) ? @@ -20544,13 +20651,13 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, false); switch (thisContainer.kind) { - case 233: - case 191: + case 234: + case 192: var constructorSymbol = thisContainer.symbol; if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 58) { var l = thisContainer.parent.left; if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { - constructorSymbol = getJSInitializerSymbolFromName(l.expression.expression, thisParentContainer); + constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } if (constructorSymbol) { @@ -20558,16 +20665,16 @@ var ts; declareSymbol(constructorSymbol.members, constructorSymbol, node, 4, 0 & ~4); } break; - case 154: - case 151: - case 153: case 155: + case 152: + case 154: case 156: + case 157: var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4, 0, true); break; - case 273: + case 274: break; default: ts.Debug.fail(ts.Debug.showSyntaxKind(thisContainer)); @@ -20577,7 +20684,7 @@ var ts; if (node.expression.kind === 99) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 273) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -20615,39 +20722,52 @@ var ts; node.expression.parent = node; bindPropertyAssignment(node.expression, node, false); } - function getJSInitializerSymbolFromName(name, lookupContainer) { - return ts.getJSInitializerSymbol(lookupSymbolForPropertyAccess(name, lookupContainer)); - } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { - var symbol = getJSInitializerSymbolFromName(name); + var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 273 && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 273; - if (!isPrototypeProperty && (!symbol || !(symbol.flags & 1920)) && isToplevelNamespaceableInitializer) { + : propertyAccess.parent.parent.kind === 274; + if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920)) && isToplevelNamespaceableInitializer) { var flags_1 = 1536 | 67108864; var excludeFlags_1 = 67215503 & ~67108864; - forEachIdentifierInEntityName(propertyAccess.expression, function (id, original) { - if (original) { - addDeclarationToSymbol(original, id, flags_1); - return original; + namespaceSymbol = forEachIdentifierInEntityName(propertyAccess.expression, namespaceSymbol, function (id, symbol, parent) { + if (symbol) { + addDeclarationToSymbol(symbol, id, flags_1); + return symbol; } else { - return symbol = declareSymbol(symbol ? symbol.exports : container.locals, symbol, id, flags_1, excludeFlags_1); + return declareSymbol(parent ? parent.exports : container.locals, parent, id, flags_1, excludeFlags_1); } }); } - if (!symbol || !(symbol.flags & (16 | 32 | 1024 | 4096))) { + if (!namespaceSymbol || !isJavascriptContainer(namespaceSymbol)) { return; } var symbolTable = isPrototypeProperty ? - (symbol.members || (symbol.members = ts.createSymbolTable())) : - (symbol.exports || (symbol.exports = ts.createSymbolTable())); + (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : + (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); var jsContainerFlag = isToplevelNamespaceableInitializer ? 67108864 : 0; var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedJavascriptInitializer(propertyAccess)); var symbolFlags = (isMethod ? 8192 : 4) | jsContainerFlag; var symbolExcludes = (isMethod ? 67208127 : 0) & ~jsContainerFlag; - declareSymbol(symbolTable, symbol, propertyAccess, symbolFlags, symbolExcludes); + declareSymbol(symbolTable, namespaceSymbol, propertyAccess, symbolFlags, symbolExcludes); + } + function isJavascriptContainer(symbol) { + if (symbol.flags & (16 | 32 | 1024)) { + return true; + } + var node = symbol.valueDeclaration; + var init = !node ? undefined : + ts.isVariableDeclaration(node) ? node.initializer : + ts.isBinaryExpression(node) ? node.right : + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) ? node.parent.right : + undefined; + if (init) { + var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); + return !!ts.getJavascriptInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 54 ? init.right : init, isPrototypeAssignment); + } + return false; } function getParentOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.parent)) { @@ -20661,21 +20781,22 @@ var ts; return lookupSymbolForNameWorker(lookupContainer, node.escapedText); } else { - var symbol = ts.getJSInitializerSymbol(lookupSymbolForPropertyAccess(node.expression)); + var symbol = lookupSymbolForPropertyAccess(node.expression); return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); } } - function forEachIdentifierInEntityName(e, action) { + function forEachIdentifierInEntityName(e, parent, action) { if (isExportsOrModuleExportsOrAlias(file, e)) { return file.symbol; } else if (ts.isIdentifier(e)) { - return action(e, lookupSymbolForPropertyAccess(e)); + return action(e, lookupSymbolForPropertyAccess(e), parent); } else { - var s = ts.getJSInitializerSymbol(forEachIdentifierInEntityName(e.expression, action)); - ts.Debug.assert(!!s && !!s.exports); - return action(e.name, s.exports.get(e.name.escapedText)); + var s = forEachIdentifierInEntityName(e.expression, parent, action); + if (!s || !s.exports) + return ts.Debug.fail(); + return action(e.name, s.exports.get(e.name.escapedText), s); } } function bindCallExpression(node) { @@ -20684,7 +20805,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 234) { + if (node.kind === 235) { bindBlockScopedDeclaration(node, 32, 68008383); } else { @@ -20728,7 +20849,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 292 && container.kind !== 287) { + if (node.kind === 293 && container.kind !== 288) { return; } if (inStrictMode && !(node.flags & 4194304)) { @@ -20801,7 +20922,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144, 67639784); } } - else if (node.parent.kind === 171) { + else if (node.parent.kind === 172) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -20819,26 +20940,26 @@ var ts; } function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 || (instanceState === 2 && options.preserveConstEnums); + return instanceState === 1 || (instanceState === 2 && !!options.preserveConstEnums); } function checkUnreachable(node) { if (!(currentFlow.flags & 1)) { return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 214) || - node.kind === 234 || - (node.kind === 238 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 237 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 215) || + node.kind === 235 || + (node.kind === 239 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 238 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; - var reportUnreachableCode = !options.allowUnreachableCode && - !(node.flags & 4194304) && - (node.kind !== 213 || - ts.getCombinedNodeFlags(node.declarationList) & 3 || - ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); - if (reportUnreachableCode) { - errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); + if (!options.allowUnreachableCode) { + var isError = ts.unreachableCodeIsError(options) && + !(node.flags & 4194304) && + (!ts.isVariableStatement(node) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3) || + node.declarationList.declarations.some(function (d) { return !!d.initializer; })); + errorOrSuggestionOnFirstToken(isError, node, ts.Diagnostics.Unreachable_code_detected); } } } @@ -20853,8 +20974,8 @@ var ts; ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias; function isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node) { var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText); - return symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && - symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer); + return !!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && + !!symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer); } function isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node) { return isExportsOrModuleExportsOrAlias(sourceFile, node) || @@ -20870,58 +20991,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 186: - return computeCallExpression(node, subtreeFlags); case 187: + return computeCallExpression(node, subtreeFlags); + case 188: return computeNewExpression(node, subtreeFlags); - case 238: + case 239: return computeModuleDeclaration(node, subtreeFlags); - case 190: - return computeParenthesizedExpression(node, subtreeFlags); - case 199: - return computeBinaryExpression(node, subtreeFlags); - case 215: - return computeExpressionStatement(node, subtreeFlags); - case 148: - return computeParameter(node, subtreeFlags); - case 192: - return computeArrowFunction(node, subtreeFlags); case 191: + return computeParenthesizedExpression(node, subtreeFlags); + case 200: + return computeBinaryExpression(node, subtreeFlags); + case 216: + return computeExpressionStatement(node, subtreeFlags); + case 149: + return computeParameter(node, subtreeFlags); + case 193: + return computeArrowFunction(node, subtreeFlags); + case 192: return computeFunctionExpression(node, subtreeFlags); - case 233: - return computeFunctionDeclaration(node, subtreeFlags); - case 231: - return computeVariableDeclaration(node, subtreeFlags); - case 232: - return computeVariableDeclarationList(node, subtreeFlags); - case 213: - return computeVariableStatement(node, subtreeFlags); - case 227: - return computeLabeledStatement(node, subtreeFlags); case 234: + return computeFunctionDeclaration(node, subtreeFlags); + case 232: + return computeVariableDeclaration(node, subtreeFlags); + case 233: + return computeVariableDeclarationList(node, subtreeFlags); + case 214: + return computeVariableStatement(node, subtreeFlags); + case 228: + return computeLabeledStatement(node, subtreeFlags); + case 235: return computeClassDeclaration(node, subtreeFlags); - case 204: + case 205: return computeClassExpression(node, subtreeFlags); - case 267: - return computeHeritageClause(node, subtreeFlags); case 268: + return computeHeritageClause(node, subtreeFlags); + case 269: return computeCatchClause(node, subtreeFlags); - case 206: + case 207: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 154: - return computeConstructor(node, subtreeFlags); - case 151: - return computePropertyDeclaration(node, subtreeFlags); - case 153: - return computeMethod(node, subtreeFlags); case 155: + return computeConstructor(node, subtreeFlags); + case 152: + return computePropertyDeclaration(node, subtreeFlags); + case 154: + return computeMethod(node, subtreeFlags); case 156: + case 157: return computeAccessor(node, subtreeFlags); - case 242: + case 243: return computeImportEquals(node, subtreeFlags); - case 184: - return computePropertyAccess(node, subtreeFlags); case 185: + return computePropertyAccess(node, subtreeFlags); + case 186: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -20965,10 +21086,10 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 && leftKind === 183) { + if (operatorTokenKind === 58 && leftKind === 184) { transformFlags |= 8 | 192 | 3072; } - else if (operatorTokenKind === 58 && leftKind === 182) { + else if (operatorTokenKind === 58 && leftKind === 183) { transformFlags |= 192 | 3072; } else if (operatorTokenKind === 40 @@ -21006,8 +21127,8 @@ var ts; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 207 - || expressionKind === 189) { + if (expressionKind === 208 + || expressionKind === 190) { transformFlags |= 3; } if (expressionTransformFlags & 1024) { @@ -21306,12 +21427,12 @@ var ts; var excludeFlags = 939525441; switch (kind) { case 120: - case 196: + case 197: transformFlags |= 8 | 16; break; - case 189: - case 207: - case 300: + case 190: + case 208: + case 301: transformFlags |= 3; excludeFlags = 536872257; break; @@ -21321,17 +21442,16 @@ var ts; case 117: case 124: case 76: - case 237: - case 272: - case 208: + case 238: + case 273: + case 209: case 132: transformFlags |= 3; break; - case 254: case 255: case 256: - case 10: case 257: + case 10: case 258: case 259: case 260: @@ -21339,17 +21459,18 @@ var ts; case 262: case 263: case 264: + case 265: transformFlags |= 4; break; case 13: case 14: case 15: case 16: - case 201: - case 188: - case 270: + case 202: + case 189: + case 271: case 115: - case 209: + case 210: transformFlags |= 192; break; case 9: @@ -21362,13 +21483,13 @@ var ts; transformFlags |= 192; } break; - case 221: + case 222: if (node.awaitModifier) { transformFlags |= 8; } transformFlags |= 192; break; - case 202: + case 203: transformFlags |= 8 | 192 | 16777216; break; case 119: @@ -21379,10 +21500,9 @@ var ts; case 122: case 138: case 105: - case 147: - case 150: - case 152: - case 157: + case 148: + case 151: + case 153: case 158: case 159: case 160: @@ -21398,27 +21518,28 @@ var ts; case 170: case 171: case 172: - case 235: - case 236: case 173: + case 236: + case 237: case 174: case 175: case 176: case 177: - case 241: + case 178: + case 242: transformFlags = 3; excludeFlags = -3; break; - case 146: + case 147: transformFlags |= 2097152; if (subtreeFlags & 16384) { transformFlags |= 65536; } break; - case 203: + case 204: transformFlags |= 192 | 524288; break; - case 271: + case 272: transformFlags |= 8 | 1048576; break; case 97: @@ -21428,27 +21549,27 @@ var ts; case 99: transformFlags |= 16384; break; - case 179: + case 180: transformFlags |= 192 | 8388608; if (subtreeFlags & 524288) { transformFlags |= 8 | 1048576; } excludeFlags = 940049729; break; - case 180: + case 181: transformFlags |= 192 | 8388608; excludeFlags = 940049729; break; - case 181: + case 182: transformFlags |= 192; if (node.dotDotDotToken) { transformFlags |= 524288; } break; - case 149: + case 150: transformFlags |= 3 | 4096; break; - case 183: + case 184: excludeFlags = 942740801; if (subtreeFlags & 2097152) { transformFlags |= 192; @@ -21460,29 +21581,31 @@ var ts; transformFlags |= 8; } break; - case 182: - case 187: + case 183: + case 188: excludeFlags = 940049729; if (subtreeFlags & 524288) { transformFlags |= 192; } break; - case 217: case 218: case 219: case 220: + case 221: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 273: + case 274: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 224: - case 222: + case 225: + transformFlags |= 33554432 | 8; + break; case 223: + case 224: transformFlags |= 33554432; break; } @@ -21490,33 +21613,33 @@ var ts; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 160 && kind <= 178) { + if (kind >= 161 && kind <= 179) { return -3; } switch (kind) { - case 186: case 187: - case 182: + case 188: + case 183: return 940049729; - case 238: + case 239: return 977327425; - case 148: + case 149: return 939525441; - case 192: + case 193: return 1003902273; - case 191: - case 233: - return 1003935041; - case 232: - return 948962625; + case 192: case 234: - case 204: + return 1003935041; + case 233: + return 948962625; + case 235: + case 205: return 942011713; - case 154: - return 1003668801; - case 153: case 155: + return 1003668801; + case 154: case 156: + case 157: return 1003668801; case 119: case 134: @@ -21526,30 +21649,30 @@ var ts; case 122: case 138: case 105: - case 147: - case 150: - case 152: - case 157: + case 148: + case 151: + case 153: case 158: case 159: - case 235: + case 160: case 236: + case 237: return -3; - case 183: + case 184: return 942740801; - case 268: + case 269: return 940574017; - case 179: case 180: + case 181: return 940049729; - case 189: - case 207: - case 300: case 190: + case 208: + case 301: + case 191: case 97: return 536872257; - case 184: case 185: + case 186: return 671089985; default: return 939525441; @@ -21602,7 +21725,7 @@ var ts; var shouldBail = visitSymbol(type.symbol); if (shouldBail) return; - if (type.flags & 65536) { + if (type.flags & 131072) { var objectType = type; var objectFlags = objectType.objectFlags; if (objectFlags & 4) { @@ -21618,16 +21741,16 @@ var ts; visitObjectType(objectType); } } - if (type.flags & 32768) { + if (type.flags & 65536) { visitTypeParameter(type); } - if (type.flags & 393216) { + if (type.flags & 786432) { visitUnionOrIntersectionType(type); } - if (type.flags & 524288) { + if (type.flags & 1048576) { visitIndexType(type); } - if (type.flags & 1048576) { + if (type.flags & 2097152) { visitIndexedAccessType(type); } } @@ -21695,11 +21818,11 @@ var ts; } function visitSymbol(symbol) { if (!symbol) { - return; + return false; } var symbolId = ts.getSymbolId(symbol); if (visitedSymbols[symbolId]) { - return; + return false; } visitedSymbols[symbolId] = symbol; if (!accept(symbol)) { @@ -21711,12 +21834,13 @@ var ts; symbol.exports.forEach(visitSymbol); } ts.forEach(symbol.declarations, function (d) { - if (d.type && d.type.kind === 164) { + if (d.type && d.type.kind === 165) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); } }); + return false; } } } @@ -21729,7 +21853,7 @@ var ts; } ts.trace = trace; function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; + return !!compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; function withPackageId(packageId, r) { @@ -21890,14 +22014,13 @@ var ts; } } function secondaryLookup() { - var resolvedFile; var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); if (initialLocationForSecondaryLookup !== undefined) { if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); - resolvedFile = resolvedTypeScriptOnly(result && result.value); + var resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -22049,7 +22172,7 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); break; default: - ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } if (perFolderCache) { perFolderCache.set(moduleName, result); @@ -22227,7 +22350,7 @@ var ts; var originalPath = void 0; if (!compilerOptions.preserveSymlinks && resolvedValue) { originalPath = resolvedValue.path; - var path = realPath(resolved_1.value.path, host, traceEnabled); + var path = realPath(resolvedValue.path, host, traceEnabled); if (path === originalPath) { originalPath = undefined; } @@ -22327,7 +22450,7 @@ var ts; function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (extensions === Extensions.Json) { var extensionLess = ts.tryRemoveExtension(candidate, ".json"); - return extensionLess && tryAddingExtensions(extensionLess, extensions, failedLookupLocations, onlyRecordFailures, state); + return extensionLess === undefined ? undefined : tryAddingExtensions(extensionLess, extensions, failedLookupLocations, onlyRecordFailures, state); } var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); if (resolvedByAddingExtension) { @@ -22361,7 +22484,7 @@ var ts; } function tryExtension(ext) { var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); - return path && { path: path, ext: ext }; + return path === undefined ? undefined : { path: path, ext: ext }; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { @@ -22732,11 +22855,12 @@ var ts; getGlobalDiagnostics: getGlobalDiagnostics, getTypeOfSymbolAtLocation: function (symbol, location) { location = ts.getParseTreeNode(location); - return location ? getTypeOfSymbolAtLocation(symbol, location) : unknownType; + return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType; }, - getSymbolsOfParameterPropertyDeclaration: function (parameter, parameterName) { - parameter = ts.getParseTreeNode(parameter, ts.isParameter); - ts.Debug.assert(parameter !== undefined, "Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); + getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) { + var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter); + if (parameter === undefined) + return ts.Debug.fail("Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); return getSymbolsOfParameterPropertyDeclaration(parameter, ts.escapeLeadingUnderscores(parameterName)); }, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, @@ -22748,9 +22872,9 @@ var ts; getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, getWidenedType: getWidenedType, - getTypeFromTypeNode: function (node) { - node = ts.getParseTreeNode(node, ts.isTypeNode); - return node ? getTypeFromTypeNode(node) : unknownType; + getTypeFromTypeNode: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode); + return node ? getTypeFromTypeNode(node) : errorType; }, getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, @@ -22776,8 +22900,8 @@ var ts; node = ts.getParseTreeNode(node); return node ? getShorthandAssignmentValueSymbol(node) : undefined; }, - getExportSpecifierLocalTargetSymbol: function (node) { - node = ts.getParseTreeNode(node, ts.isExportSpecifier); + getExportSpecifierLocalTargetSymbol: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isExportSpecifier); return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; }, getExportSymbolOfSymbol: function (symbol) { @@ -22785,10 +22909,10 @@ var ts; }, getTypeAtLocation: function (node) { node = ts.getParseTreeNode(node); - return node ? getTypeOfNode(node) : unknownType; + return node ? getTypeOfNode(node) : errorType; }, - getPropertySymbolOfDestructuringAssignment: function (location) { - location = ts.getParseTreeNode(location, ts.isIdentifier); + getPropertySymbolOfDestructuringAssignment: function (locationIn) { + var location = ts.getParseTreeNode(locationIn, ts.isIdentifier); return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined; }, signatureToString: function (signature, enclosingDeclaration, flags, kind) { @@ -22818,41 +22942,41 @@ var ts; getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: function (node) { - node = ts.getParseTreeNode(node, ts.isExpression); + getContextualType: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isExpression); return node ? getContextualType(node) : undefined; }, - getContextualTypeForArgumentAtIndex: function (node, argIndex) { - node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) { + var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); return node && getContextualTypeForArgumentAtIndex(node, argIndex); }, - getContextualTypeForJsxAttribute: function (node) { - node = ts.getParseTreeNode(node, ts.isJsxAttributeLike); + getContextualTypeForJsxAttribute: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike); return node && getContextualTypeForJsxAttribute(node); }, isContextSensitive: isContextSensitive, getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: function (node, candidatesOutArray, theArgumentCount) { - node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + getResolvedSignature: function (nodeIn, candidatesOutArray, theArgumentCount) { + var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); apparentArgumentCount = theArgumentCount; var res = node ? getResolvedSignature(node, candidatesOutArray) : undefined; apparentArgumentCount = undefined; return res; }, - getConstantValue: function (node) { - node = ts.getParseTreeNode(node, canHaveConstantValue); + getConstantValue: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue); return node ? getConstantValue(node) : undefined; }, - isValidPropertyAccess: function (node, propertyName) { - node = ts.getParseTreeNode(node, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode); + isValidPropertyAccess: function (nodeIn, propertyName) { + var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode); return !!node && isValidPropertyAccess(node, ts.escapeLeadingUnderscores(propertyName)); }, - isValidPropertyAccessForCompletions: function (node, type, property) { - node = ts.getParseTreeNode(node, ts.isPropertyAccessExpression); + isValidPropertyAccessForCompletions: function (nodeIn, type, property) { + var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessExpression); return !!node && isValidPropertyAccessForCompletions(node, type, property); }, - getSignatureFromDeclaration: function (declaration) { - declaration = ts.getParseTreeNode(declaration, ts.isFunctionLike); + getSignatureFromDeclaration: function (declarationIn) { + var declaration = ts.getParseTreeNode(declarationIn, ts.isFunctionLike); return declaration ? getSignatureFromDeclaration(declaration) : undefined; }, isImplementationOfOverload: function (node) { @@ -22864,7 +22988,8 @@ var ts; var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); + if (!node) + return ts.Debug.fail(); links.immediateTarget = getTargetOfAliasDeclaration(node, true); } return links.immediateTarget; @@ -22875,13 +23000,13 @@ var ts; getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { - node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); + getAllAttributesTypeFromJsxOpeningLikeElement: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isJsxOpeningLikeElement); return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; }, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, - isOptionalParameter: function (node) { - node = ts.getParseTreeNode(node, ts.isParameter); + isOptionalParameter: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isParameter); return node ? isOptionalParameter(node) : false; }, tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); }, @@ -22913,7 +23038,7 @@ var ts; getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, getSuggestionForNonexistentModule: function (node, target) { return getSuggestionForNonexistentModule(node, target); }, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 32768 ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 65536 ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined, false, excludeGlobals); }, @@ -22925,24 +23050,31 @@ var ts; node = ts.getParseTreeNode(node); return node && tryGetThisTypeAt(node); }, - getTypeArgumentConstraint: function (node) { - node = ts.getParseTreeNode(node, ts.isTypeNode); + getTypeArgumentConstraint: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode); return node && getTypeArgumentConstraint(node); }, - getSuggestionDiagnostics: function (file) { - return (suggestionDiagnostics.get(file.fileName) || ts.emptyArray).concat(getUnusedDiagnostics()); - function getUnusedDiagnostics() { - if (file.isDeclarationFile) - return ts.emptyArray; + getSuggestionDiagnostics: function (file, ct) { + var diagnostics; + try { + cancellationToken = ct; checkSourceFile(file); - var diagnostics = []; ts.Debug.assert(!!(getNodeLinks(file).flags & 1)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + if (!file.isDeclarationFile && (!unusedIsError(0) || !unusedIsError(1))) { + addUnusedDiagnostics(); + } + return diagnostics || ts.emptyArray; + } + finally { + cancellationToken = undefined; + } + function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (kind, diag) { if (!unusedIsError(kind)) { - diagnostics.push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); } }); - return diagnostics; } }, runWithCancellationToken: function (token, callback) { @@ -22967,22 +23099,23 @@ var ts; var anyType = createIntrinsicType(1, "any"); var autoType = createIntrinsicType(1, "any"); var wildcardType = createIntrinsicType(1, "any"); - var unknownType = createIntrinsicType(1, "unknown"); - var undefinedType = createIntrinsicType(4096, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(4096 | 16777216, "undefined"); - var nullType = createIntrinsicType(8192, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(8192 | 16777216, "null"); - var stringType = createIntrinsicType(2, "string"); - var numberType = createIntrinsicType(4, "number"); - var trueType = createIntrinsicType(128, "true"); - var falseType = createIntrinsicType(128, "false"); + var errorType = createIntrinsicType(1, "error"); + var unknownType = createIntrinsicType(2, "unknown"); + var undefinedType = createIntrinsicType(8192, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(8192 | 134217728, "undefined"); + var nullType = createIntrinsicType(16384, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(16384 | 134217728, "null"); + var stringType = createIntrinsicType(4, "string"); + var numberType = createIntrinsicType(8, "number"); + var trueType = createIntrinsicType(256, "true"); + var falseType = createIntrinsicType(256, "false"); var booleanType = createBooleanType([trueType, falseType]); - var esSymbolType = createIntrinsicType(512, "symbol"); - var voidType = createIntrinsicType(2048, "void"); - var neverType = createIntrinsicType(16384, "never"); - var silentNeverType = createIntrinsicType(16384, "never"); - var implicitNeverType = createIntrinsicType(16384, "never"); - var nonPrimitiveType = createIntrinsicType(134217728, "object"); + var esSymbolType = createIntrinsicType(1024, "symbol"); + var voidType = createIntrinsicType(4096, "void"); + var neverType = createIntrinsicType(32768, "never"); + var silentNeverType = createIntrinsicType(32768, "never"); + var implicitNeverType = createIntrinsicType(32768, "never"); + var nonPrimitiveType = createIntrinsicType(16777216, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -22992,17 +23125,17 @@ var ts; var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); emptyGenericType.instantiations = ts.createMap(); var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - anyFunctionType.flags |= 67108864; + anyFunctionType.flags |= 536870912; 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); - var markerSuperType = createType(32768); - var markerSubType = createType(32768); + var markerSuperType = createType(65536); + var markerSubType = createType(65536); markerSubType.constraint = markerSuperType; - var markerOtherType = createType(32768); + var markerOtherType = createType(65536); var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, unknownType, undefined, 0, false, false); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, undefined, 0, false, false); var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, false, false); var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, undefined, 0, false, false); var resolvingSignaturesArray = [resolvingSignature]; @@ -23216,6 +23349,7 @@ var ts; typeToString(type, enclosingDeclaration, flags, emitTextWriterWrapper(writer)); }, buildSymbolDisplay: function (symbol, writer, enclosingDeclaration, meaning, flags) { + if (flags === void 0) { flags = 0; } symbolToString(symbol, enclosingDeclaration, meaning, flags | 4, emitTextWriterWrapper(writer)); }, buildSignatureDisplay: function (signature, writer, enclosing, flags, kind) { @@ -23465,15 +23599,17 @@ var ts; function mergeSymbol(target, source) { if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864) { - var targetValueDeclaration = target.valueDeclaration; - ts.Debug.assert(!!(target.flags & 33554432)); + ts.Debug.assert(source !== target); + if (!(target.flags & 33554432)) { + target = cloneSymbol(target); + } if (source.flags & 512 && target.flags & 512 && target.constEnumOnlyModule && !source.constEnumOnlyModule) { target.constEnumOnlyModule = false; } target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 238 && source.valueDeclaration.kind !== 238))) { + (target.valueDeclaration.kind === 239 && source.valueDeclaration.kind !== 239))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -23487,18 +23623,6 @@ var ts; target.exports = ts.createSymbolTable(); mergeSymbolTable(target.exports, source.exports); } - if ((source.flags | target.flags) & 67108864) { - var sourceInitializer = ts.getJSInitializerSymbol(source); - var init = ts.getDeclaredJavascriptInitializer(targetValueDeclaration) || ts.getAssignedJavascriptInitializer(targetValueDeclaration); - var targetInitializer = init && init.symbol ? init.symbol : target; - if (!(targetInitializer.flags & 33554432)) { - var mergedInitializer = getMergedSymbol(targetInitializer); - targetInitializer = mergedInitializer === targetInitializer ? cloneSymbol(targetInitializer) : mergedInitializer; - } - if (sourceInitializer !== source || targetInitializer !== target) { - mergeSymbol(targetInitializer, sourceInitializer); - } - } recordMergedSymbol(target, source); } else if (target.flags & 1024) { @@ -23519,11 +23643,12 @@ var ts; error(errorNode, message_2, symbolToString(source)); }); } + return target; } function combineSymbolTables(first, second) { - if (!first || first.size === 0) + if (!ts.hasEntries(first)) return second; - if (!second || second.size === 0) + if (!ts.hasEntries(second)) return first; var combined = ts.createSymbolTable(); mergeSymbolTable(combined, first); @@ -23532,17 +23657,7 @@ var ts; } function mergeSymbolTable(target, source) { source.forEach(function (sourceSymbol, id) { - var targetSymbol = target.get(id); - if (!targetSymbol) { - target.set(id, sourceSymbol); - } - else { - if (!(targetSymbol.flags & 33554432)) { - targetSymbol = cloneSymbol(targetSymbol); - target.set(id, targetSymbol); - } - mergeSymbol(targetSymbol, sourceSymbol); - } + target.set(id, target.has(id) ? mergeSymbol(target.get(id), sourceSymbol) : sourceSymbol); }); } function mergeModuleAugmentation(moduleName) { @@ -23564,8 +23679,7 @@ var ts; } mainModule = resolveExternalModuleSymbol(mainModule); if (mainModule.flags & 1920) { - mainModule = mainModule.flags & 33554432 ? mainModule : cloneSymbol(mainModule); - mergeSymbol(mainModule, moduleAugmentation.symbol); + mainModule = mergeSymbol(mainModule, moduleAugmentation.symbol); } else { error(moduleName, ts.Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text); @@ -23597,7 +23711,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 273 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 274 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -23624,7 +23738,7 @@ var ts; if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } - ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration"); + return ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration"); } function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { var declarationFile = ts.getSourceFileOfNode(declaration); @@ -23643,15 +23757,15 @@ var ts; return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } if (declaration.pos <= usage.pos) { - if (declaration.kind === 181) { - var errorBindingElement = ts.getAncestor(usage, 181); + if (declaration.kind === 182) { + var errorBindingElement = ts.getAncestor(usage, 182); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 231), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 232), usage); } - else if (declaration.kind === 231) { + else if (declaration.kind === 232) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } else if (ts.isClassDeclaration(declaration)) { @@ -23659,10 +23773,10 @@ var ts; } return true; } - if (usage.parent.kind === 251 || (usage.parent.kind === 248 && usage.parent.isExportEquals)) { + if (usage.parent.kind === 252 || (usage.parent.kind === 249 && usage.parent.isExportEquals)) { return true; } - if (usage.kind === 248 && usage.isExportEquals) { + if (usage.kind === 249 && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -23670,15 +23784,16 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 213: - case 219: - case 221: + case 214: + case 220: + case 222: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } - return ts.isForInOrOfStatement(declaration.parent.parent) && isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container); + var grandparent = declaration.parent.parent; + return ts.isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, container); } function isUsedInFunctionOrInstanceProperty(usage, declaration, container) { return !!ts.findAncestor(usage, function (current) { @@ -23689,21 +23804,22 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 151 && + current.parent.kind === 152 && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32)) { - if (declaration.kind === 153) { + if (declaration.kind === 154) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 151 && !ts.hasModifier(declaration, 32); + var isDeclarationInstanceProperty = declaration.kind === 152 && !ts.hasModifier(declaration, 32); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } } } + return false; }); } } @@ -23725,21 +23841,21 @@ var ts; if (result = lookup(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 67901928 && lastLocation.kind !== 285) { + if (meaning & result.flags & 67901928 && lastLocation.kind !== 286) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 148 || - lastLocation.kind === 147 + lastLocation.kind === 149 || + lastLocation.kind === 148 : false; } if (meaning & 67216319 && result.flags & 1) { useResult = - lastLocation.kind === 148 || + lastLocation.kind === 149 || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 170) { + else if (location.kind === 171) { useResult = lastLocation === location.trueType; } if (useResult) { @@ -23751,13 +23867,13 @@ var ts; } } switch (location.kind) { - case 273: + case 274: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 238: + case 239: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 273 || ts.isAmbientModule(location)) { + if (location.kind === 274 || ts.isAmbientModule(location)) { if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { @@ -23768,21 +23884,26 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 && - ts.getDeclarationOfKind(moduleExport, 251)) { + ts.getDeclarationOfKind(moduleExport, 252)) { break; } } if (name !== "default" && (result = lookup(moduleExports, name, meaning & 2623475))) { - break loop; + if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) { + result = undefined; + } + else { + break loop; + } } break; - case 237: + case 238: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 152: case 151: - case 150: if (ts.isClassLike(location.parent) && !ts.hasModifier(location, 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -23792,9 +23913,9 @@ var ts; } } break; - case 234: - case 204: case 235: + case 205: + case 236: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { result = undefined; @@ -23806,7 +23927,7 @@ var ts; } break loop; } - if (location.kind === 204 && meaning & 32) { + if (location.kind === 205 && meaning & 32) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -23814,7 +23935,7 @@ var ts; } } break; - case 206: + case 207: if (lastLocation === location.expression && location.parent.token === 85) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 67901928))) { @@ -23825,28 +23946,28 @@ var ts; } } break; - case 146: + case 147: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 235) { + if (ts.isClassLike(grandparent) || grandparent.kind === 236) { if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67901928)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 153: - case 152: case 154: + case 153: case 155: case 156: - case 233: - case 192: + case 157: + case 234: + case 193: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 191: + case 192: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -23859,19 +23980,18 @@ var ts; } } break; - case 149: - if (location.parent && location.parent.kind === 148) { + case 150: + if (location.parent && location.parent.kind === 149) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { location = location.parent; } break; - case 296: - case 291: - lastLocation = location; - location = ts.getJSDocHost(location).parent; - continue; + case 297: + case 292: + location = ts.getJSDocHost(location); + break; } if (isSelfReferenceLocation(location)) { lastSelfReferenceLocation = location; @@ -23884,7 +24004,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 273); + ts.Debug.assert(lastLocation.kind === 274); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -23943,7 +24063,7 @@ var ts; } if (result && isInExternalModule && (meaning & 67216319) === 67216319 && !(originalLocation.flags & 2097152)) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 241) { + if (decls && decls.length === 1 && decls[0].kind === 242) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } @@ -23952,12 +24072,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 233: case 234: case 235: - case 237: case 236: case 238: + case 237: + case 239: return true; default: return false; @@ -23969,7 +24089,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 147) { + if (decl.kind === 148) { 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)); @@ -24009,18 +24129,18 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - var isError = !!(expression && resolveEntityName(expression, 64, true)); - if (isError) { + if (expression && resolveEntityName(expression, 64, true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); + return true; } - return isError; + return false; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71: - case 184: + case 185: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 206: + case 207: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -24082,8 +24202,9 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384)); - var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 237) ? d : undefined; }); - ts.Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined"); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 238) ? d : undefined; }); + if (declaration === undefined) + return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { if (result.flags & 2) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); @@ -24097,17 +24218,17 @@ var ts; } } function isSameScopeDescendentOf(initial, parent, stopAt) { - return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); + return !!parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); } function getAnyImportSyntax(node) { switch (node.kind) { - case 242: + case 243: return node; - case 244: - return node.parent; case 245: + return node.parent; + case 246: return node.parent.parent; - case 247: + case 248: return node.parent.parent.parent; default: return undefined; @@ -24117,7 +24238,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 253) { + if (node.moduleReference.kind === 254) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -24129,7 +24250,7 @@ var ts; : resolveSymbol(moduleSymbol.exports.get(name), dontResolveAlias); } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasModifier(node, 512)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasModifier(node, 512) || ts.isExportSpecifier(node)); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias) { if (!allowSyntheticDefaultImports) { @@ -24207,6 +24328,7 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { + if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); if (targetSymbol) { @@ -24269,33 +24391,35 @@ var ts; return getNodeLinks(expression).resolvedSymbol; } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { + if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 242: + case 243: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 244: - return getTargetOfImportClause(node, dontRecursivelyResolve); case 245: + return getTargetOfImportClause(node, dontRecursivelyResolve); + case 246: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 247: - return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 251: - return getTargetOfExportSpecifier(node, 67216319 | 67901928 | 1920, dontRecursivelyResolve); case 248: - case 199: + return getTargetOfImportSpecifier(node, dontRecursivelyResolve); + case 252: + return getTargetOfExportSpecifier(node, 67216319 | 67901928 | 1920, dontRecursivelyResolve); + case 249: + case 200: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 241: + case 242: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + default: + return ts.Debug.fail(); } } function isNonLocalAlias(symbol, excludes) { if (excludes === void 0) { excludes = 67216319 | 67901928 | 1920; } if (!symbol) return false; - return (symbol.flags & (2097152 | excludes)) === 2097152 || (symbol.flags & 2097152 && symbol.flags & 67108864); + return (symbol.flags & (2097152 | excludes)) === 2097152 || !!(symbol.flags & 2097152 && symbol.flags & 67108864); } function resolveSymbol(symbol, dontResolveAlias) { - var shouldResolve = !dontResolveAlias && isNonLocalAlias(symbol); - return shouldResolve ? resolveAlias(symbol) : symbol; + return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here."); @@ -24303,7 +24427,8 @@ var ts; if (!links.target) { links.target = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); + if (!node) + return ts.Debug.fail(); var target = getTargetOfAliasDeclaration(node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; @@ -24333,11 +24458,12 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); - if (node.kind === 248) { + if (!node) + return ts.Debug.fail(); + if (node.kind === 249) { checkExpressionCached(node.expression); } - else if (node.kind === 251) { + else if (node.kind === 252) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -24349,11 +24475,11 @@ var ts; if (entityName.kind === 71 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 71 || entityName.parent.kind === 145) { + if (entityName.kind === 71 || entityName.parent.kind === 146) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 242); + ts.Debug.assert(entityName.parent.kind === 243); return resolveEntityName(entityName, 67216319 | 67901928 | 1920, false, dontResolveAlias); } } @@ -24374,9 +24500,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 145 || name.kind === 184) { - var left = name.kind === 145 ? name.left : name.expression; - var right = name.kind === 145 ? name.right : name.name; + else if (name.kind === 146 || name.kind === 185) { + var left = name.kind === 146 ? name.left : name.expression; + var right = name.kind === 146 ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -24385,13 +24511,6 @@ var ts; return namespace; } if (ts.isInJavaScriptFile(name)) { - var initializer = ts.getDeclaredJavascriptInitializer(namespace.valueDeclaration) || ts.getAssignedJavascriptInitializer(namespace.valueDeclaration); - if (initializer) { - namespace = getSymbolOfNode(initializer); - } - if (!namespace) { - return undefined; - } if (namespace.valueDeclaration && ts.isVariableDeclaration(namespace.valueDeclaration) && namespace.valueDeclaration.initializer && @@ -24415,7 +24534,7 @@ var ts; } } else { - ts.Debug.assertNever(name, "Unknown entity name kind."); + throw ts.Debug.assertNever(name, "Unknown entity name kind."); } ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -24553,14 +24672,7 @@ var ts; moduleSymbol.exports.forEach(function (s, name) { if (name === "export=") return; - if (!merged.exports.has(name)) { - merged.exports.set(name, s); - } - else { - var ms = cloneSymbol(merged.exports.get(name)); - mergeSymbol(ms, s); - merged.exports.set(name, ms); - } + merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); return merged; } @@ -24634,7 +24746,7 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 16382 ? undefined : getPropertyOfType(type, memberName); + return type.flags & 32764 ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { return symbol.flags & 32 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") : @@ -24715,6 +24827,38 @@ var ts; function getParentOfSymbol(symbol) { return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent)); } + function getContainerOfSymbol(symbol) { + var container = getParentOfSymbol(symbol); + if (container) { + return container; + } + var candidate = ts.forEach(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + if (!candidate) { + return undefined; + } + var alias = getAliasForSymbolInContainer(candidate, symbol); + return alias ? candidate : undefined; + } + function getAliasForSymbolInContainer(container, symbol) { + if (container === getParentOfSymbol(symbol)) { + return symbol; + } + var exports = getExportsOfSymbol(container); + var quick = exports.get(symbol.escapedName); + if (quick && symbolRefersToTarget(quick)) { + return quick; + } + return ts.forEachEntry(exports, function (exported) { + if (symbolRefersToTarget(exported)) { + return exported; + } + }); + function symbolRefersToTarget(s) { + if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { + return s; + } + } + } function getExportSymbolOfValueSymbolIfExported(symbol) { return symbol && (symbol.flags & 1048576) !== 0 ? getMergedSymbol(symbol.exportSymbol) @@ -24727,7 +24871,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 154 && ts.nodeIsPresent(member.body)) { + if (member.kind === 155 && ts.nodeIsPresent(member.body)) { return member; } } @@ -24745,12 +24889,12 @@ var ts; } function createBooleanType(trueFalseTypes) { var type = getUnionType(trueFalseTypes); - type.flags |= 8; + type.flags |= 16; type.intrinsicName = "boolean"; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(65536); + var type = createType(131072); type.objectFlags = objectFlags; type.symbol = symbol; return type; @@ -24800,11 +24944,11 @@ var ts; } } switch (location.kind) { - case 273: + case 274: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 238: + case 239: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -24841,7 +24985,7 @@ var ts; } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && - !ts.some(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); } function trySymbolTable(symbols, ignoreQualification) { @@ -24864,20 +25008,25 @@ var ts; return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); } } + if (symbolFromSymbolTable.escapedName === symbol.escapedName && symbolFromSymbolTable.exportSymbol) { + if (isAccessible(getMergedSymbol(symbolFromSymbolTable.exportSymbol), undefined, ignoreQualification)) { + return [symbol]; + } + } }); } } function needsQualification(symbol, enclosingDeclaration, meaning) { var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { - var symbolFromSymbolTable = symbolTable.get(symbol.escapedName); + var symbolFromSymbolTable = getMergedSymbol(symbolTable.get(symbol.escapedName)); if (!symbolFromSymbolTable) { return false; } if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 251)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 252)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -24891,10 +25040,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 151: - case 153: - case 155: + case 152: + case 154: case 156: + case 157: continue; default: return false; @@ -24930,14 +25079,14 @@ var ts; return hasAccessibleDeclarations; } else { - if (ts.some(symbol.declarations, hasExternalModuleSymbol)) { + if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return { accessibility: 0 }; } } meaningToLook = getQualifiedLeftMeaning(meaning); - symbol = getParentOfSymbol(symbol); + symbol = getContainerOfSymbol(symbol); } var symbolExternalModule = ts.forEach(initialSymbol.declarations, getExternalModuleContainer); if (symbolExternalModule) { @@ -24962,7 +25111,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 273 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 274 && ts.isExternalOrCommonJsModule(declaration)); + } + function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -25002,13 +25154,13 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 164 || + if (entityName.parent.kind === 165 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 146) { + entityName.parent.kind === 147) { meaning = 67216319 | 1048576; } - else if (entityName.kind === 145 || entityName.kind === 184 || - entityName.parent.kind === 242) { + else if (entityName.kind === 146 || entityName.kind === 185 || + entityName.parent.kind === 243) { meaning = 1920; } else { @@ -25045,14 +25197,15 @@ var ts; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { + if (flags === void 0) { flags = 0; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144) { - sigOutput = kind === 1 ? 163 : 162; + sigOutput = kind === 1 ? 164 : 163; } else { - sigOutput = kind === 1 ? 158 : 157; + sigOutput = kind === 1 ? 159 : 158; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 | 512); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); @@ -25062,10 +25215,11 @@ var ts; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576; } + if (flags === void 0) { flags = 1048576 | 16384; } if (writer === void 0) { writer = ts.createTextWriter(""); } var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960, writer); - ts.Debug.assert(typeNode !== undefined, "should always get typenode"); + if (typeNode === undefined) + return ts.Debug.fail("should always get typenode"); var options = { removeComments: true }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); @@ -25078,6 +25232,7 @@ var ts; return result; } function toNodeBuilderFlags(flags) { + if (flags === void 0) { flags = 0; } return flags & 9469291; } function createNodeBuilder() { @@ -25142,7 +25297,7 @@ var ts; function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { return { enclosingDeclaration: enclosingDeclaration, - flags: flags, + flags: flags || 0, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, encounteredError: false, visitedSymbols: undefined, @@ -25163,34 +25318,37 @@ var ts; return ts.createKeywordTypeNode(119); } if (type.flags & 2) { - return ts.createKeywordTypeNode(137); + return ts.createKeywordTypeNode(142); } if (type.flags & 4) { - return ts.createKeywordTypeNode(134); + return ts.createKeywordTypeNode(137); } if (type.flags & 8) { + return ts.createKeywordTypeNode(134); + } + if (type.flags & 16) { return ts.createKeywordTypeNode(122); } - if (type.flags & 256 && !(type.flags & 131072)) { + if (type.flags & 512 && !(type.flags & 262144)) { var parentSymbol = getParentOfSymbol(type.symbol); var parentName = symbolToName(parentSymbol, context, 67901928, false); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : ts.createQualifiedName(parentName, ts.symbolName(type.symbol)); return ts.createTypeReferenceNode(enumLiteralName, undefined); } - if (type.flags & 272) { + if (type.flags & 544) { var name = symbolToName(type.symbol, context, 67901928, false); return ts.createTypeReferenceNode(name, undefined); } - if (type.flags & (32)) { + if (type.flags & (64)) { return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value), 16777216)); } - if (type.flags & (64)) { + if (type.flags & (128)) { return ts.createLiteralTypeNode((ts.createLiteral(type.value))); } - if (type.flags & 128) { + if (type.flags & 256) { return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); } - if (type.flags & 1024) { + if (type.flags & 2048) { if (!(context.flags & 1048576)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return symbolToTypeNode(type.symbol, context, 67216319); @@ -25201,25 +25359,25 @@ var ts; } return ts.createTypeOperatorNode(141, ts.createKeywordTypeNode(138)); } - if (type.flags & 2048) { + if (type.flags & 4096) { return ts.createKeywordTypeNode(105); } - if (type.flags & 4096) { + if (type.flags & 8192) { return ts.createKeywordTypeNode(140); } - if (type.flags & 8192) { + if (type.flags & 16384) { return ts.createKeywordTypeNode(95); } - if (type.flags & 16384) { + if (type.flags & 32768) { return ts.createKeywordTypeNode(131); } - if (type.flags & 512) { + if (type.flags & 1024) { return ts.createKeywordTypeNode(138); } - if (type.flags & 134217728) { + if (type.flags & 16777216) { return ts.createKeywordTypeNode(135); } - if (type.flags & 32768 && type.isThisType) { + if (type.flags & 65536 && type.isThisType) { if (context.flags & 4194304) { if (!context.encounteredError && !(context.flags & 32768)) { context.encounteredError = true; @@ -25232,23 +25390,24 @@ var ts; } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4) { - ts.Debug.assert(!!(type.flags & 65536)); + ts.Debug.assert(!!(type.flags & 131072)); return typeReferenceToTypeNode(type); } - if (type.flags & 32768 || objectFlags & 3) { - if (type.flags & 32768 && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 65536 || objectFlags & 3) { + if (type.flags & 65536 && ts.contains(context.inferTypeParameters, type)) { return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, undefined)); } if (context.flags & 4 && - type.flags & 32768 && + type.flags & 65536 && ts.length(type.symbol.declarations) && ts.isTypeParameterDeclaration(type.symbol.declarations[0]) && typeParameterShadowsNameInScope(type, context) && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return ts.createTypeReferenceNode(ts.getGeneratedNameForNode(type.symbol.declarations[0].name, 16 | 8), undefined); } - var name = type.symbol ? symbolToName(type.symbol, context, 67901928, false) : ts.createIdentifier("?"); - return ts.createTypeReferenceNode(name, undefined); + return type.symbol + ? symbolToTypeNode(type.symbol, context, 67901928) + : ts.createTypeReferenceNode(ts.createIdentifier("?"), undefined); } if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); @@ -25256,11 +25415,11 @@ var ts; return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); return symbolToTypeNode(type.aliasSymbol, context, 67901928, typeArgumentNodes); } - if (type.flags & (131072 | 262144)) { - var types = type.flags & 131072 ? formatUnionTypes(type.types) : type.types; + if (type.flags & (262144 | 524288)) { + var types = type.flags & 262144 ? formatUnionTypes(type.types) : type.types; var typeNodes = mapToTypeNodes(types, context); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 131072 ? 168 : 169, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 ? 169 : 170, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -25271,20 +25430,20 @@ var ts; } } if (objectFlags & (16 | 32)) { - ts.Debug.assert(!!(type.flags & 65536)); + ts.Debug.assert(!!(type.flags & 131072)); return createAnonymousTypeNode(type); } - if (type.flags & 524288) { + if (type.flags & 1048576) { var indexedType = type.type; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); return ts.createTypeOperatorNode(indexTypeNode); } - if (type.flags & 1048576) { + if (type.flags & 2097152) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 2097152) { + if (type.flags & 4194304) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -25294,12 +25453,12 @@ var ts; var falseTypeNode = typeToTypeNodeHelper(getFalseTypeFromConditionalType(type), context); return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } - if (type.flags & 4194304) { + if (type.flags & 8388608) { return typeToTypeNodeHelper(type.typeVariable, context); } - ts.Debug.fail("Should be unreachable."); + return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 65536)); + ts.Debug.assert(!!(type.flags & 131072)); var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -25324,7 +25483,7 @@ var ts; var isInstanceType = type === getInferredClassType(symbol) ? 67901928 : 67216319; return symbolToTypeNode(symbol, context, isInstanceType); } - else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 204 && context.flags & 2048) || + else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 205 && context.flags & 2048) || symbol.flags & (384 | 512) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319); @@ -25357,7 +25516,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 273 || declaration.parent.kind === 239; + return declaration.parent.kind === 274 || declaration.parent.kind === 240; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return (!!(context.flags & 4096) || (context.visitedSymbols && context.visitedSymbols.has(id))) && @@ -25376,12 +25535,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 162, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 163, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 163, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 164, context); return signatureNode; } } @@ -25495,11 +25654,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 157, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 158, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 158, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 159, context)); } if (resolvedType.stringIndexInfo) { var indexInfo = resolvedType.objectFlags & 2048 ? @@ -25529,7 +25688,7 @@ var ts; var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; if (ts.getCheckFlags(propertySymbol) & 1024) { - var decl = ts.firstOrUndefined(propertySymbol.declarations); + var decl = ts.first(propertySymbol.declarations); var name = hasLateBindableName(decl) && resolveEntityName(decl.name.expression, 67216319); if (name && context.tracker.trackSymbol) { context.tracker.trackSymbol(name, saveEnclosingDeclaration, 67216319); @@ -25542,7 +25701,7 @@ var ts; var signatures = getSignaturesOfType(propertyType, 0); for (var _e = 0, signatures_1 = signatures; _e < signatures_1.length; _e++) { var signature = signatures_1[_e]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 152, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 153, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -25584,7 +25743,7 @@ var ts; var name = ts.getNameFromIndexInfo(indexInfo) || "x"; var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 137 : 134); var indexingParameter = ts.createParameter(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined); - var typeNode = indexInfo.type ? typeToTypeNodeHelper(indexInfo.type, context) : typeToTypeNodeHelper(anyType, context); + var typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); if (!indexInfo.type && !(context.flags & 2097152)) { context.encounteredError = true; } @@ -25599,7 +25758,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 154); }); + var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -25651,22 +25810,22 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 148); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 292); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); - var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(ts.getSynthesizedClone); + var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration ? ts.isRestParameter(parameterDeclaration) : parameterSymbol.isRestParameter; var dotDotDotToken = isRest ? ts.createToken(24) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? parameterDeclaration.name.kind === 71 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) : - parameterDeclaration.name.kind === 145 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) : + parameterDeclaration.name.kind === 146 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -25678,7 +25837,7 @@ var ts; function elideInitializerAndSetEmitFlags(node) { var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 181) { + if (clone.kind === 182) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 | 16777216); @@ -25690,7 +25849,7 @@ var ts; var chain; var isTypeParameter = symbol.flags & 262144; if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64)) { - chain = getSymbolChain(symbol, meaning, true); + chain = ts.Debug.assertDefined(getSymbolChain(symbol, meaning, true)); ts.Debug.assert(chain && chain.length > 0); } else { @@ -25702,12 +25861,12 @@ var ts; var parentSymbol; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + var parent = getContainerOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); if (parent) { var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false); if (parentChain) { parentSymbol = parent; - accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); } } } @@ -25715,7 +25874,7 @@ var ts; return accessibleSymbolChain; } if (endOfChain || - (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol))) && + (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol))) && !(symbol.flags & (2048 | 4096))) { return [symbol]; } @@ -25886,6 +26045,7 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { + if (flags === void 0) { flags = 16384; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 | 512)); @@ -25901,10 +26061,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 12288)) { - if (t.flags & (128 | 256)) { - var baseType = t.flags & 128 ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 131072) { + if (!(t.flags & 24576)) { + if (t.flags & (256 | 512)) { + var baseType = t.flags & 256 ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 262144) { var count = baseType.types.length; if (i + count <= types.length && types[i + count - 1] === baseType.types[count - 1]) { result.push(baseType); @@ -25916,9 +26076,9 @@ var ts; result.push(t); } } - if (flags & 8192) + if (flags & 16384) result.push(nullType); - if (flags & 4096) + if (flags & 8192) result.push(undefinedType); return result || types; } @@ -25933,8 +26093,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 172; }); - if (node.kind === 236) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 173; }); + if (node.kind === 237) { return getSymbolOfNode(node); } } @@ -25942,11 +26102,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 239 && + node.parent.kind === 240 && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 273 || ts.isAmbientModule(location); + return location.kind === 274 || ts.isAmbientModule(location); } function getNameOfSymbolAsWritten(symbol, context) { if (context && symbol.escapedName === "default" && !(context.flags & 16384) && @@ -25957,7 +26117,7 @@ var ts; } if (symbol.declarations && symbol.declarations.length) { if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { - var file = ts.getDeclarationOfKind(symbol, 273); + var file = ts.getDeclarationOfKind(symbol, 274); if (!file || !context.tracker.moduleResolverHost) { if (context.tracker.trackReferencedAmbientModule) { var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule); @@ -25978,26 +26138,26 @@ var ts; if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 231) { + if (declaration.parent && declaration.parent.kind === 232) { return ts.declarationNameToString(declaration.parent.name); } if (context && !context.encounteredError && !(context.flags & 131072)) { context.encounteredError = true; } switch (declaration.kind) { - case 204: + case 205: return "(Anonymous class)"; - case 191: case 192: + case 193: return "(Anonymous function)"; } } var nameType = symbol.nameType; if (nameType) { - if (nameType.flags & 32 && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { + if (nameType.flags & 64 && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { return "\"" + ts.escapeString(nameType.value, 34) + "\""; } - if (nameType && nameType.flags & 1024) { + if (nameType && nameType.flags & 2048) { return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; } } @@ -26014,67 +26174,67 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 291: - case 296: + case 292: + case 297: return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 181: + case 182: return isDeclarationVisible(node.parent.parent); - case 231: + case 232: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 238: - case 234: + case 239: case 235: case 236: - case 233: case 237: - case 242: + case 234: + case 238: + case 243: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 242 && parent.kind !== 273 && parent.flags & 4194304)) { + !(node.kind !== 243 && parent.kind !== 274 && parent.flags & 4194304)) { return isGlobalSourceFile(parent); } return isDeclarationVisible(parent); - case 151: - case 150: - case 155: - case 156: - case 153: case 152: + case 151: + case 156: + case 157: + case 154: + case 153: if (ts.hasModifier(node, 8 | 16)) { return false; } - case 154: - case 158: - case 157: + case 155: case 159: - case 148: - case 239: - case 162: + case 158: + case 160: + case 149: + case 240: case 163: - case 165: - case 161: + case 164: case 166: + case 162: case 167: case 168: case 169: - case 172: + case 170: + case 173: return isDeclarationVisible(node.parent); - case 244: case 245: - case 247: - return false; - case 147: - case 273: - case 241: - return true; + case 246: case 248: return false; + case 148: + case 274: + case 242: + return true; + case 249: + return false; default: return false; } @@ -26082,10 +26242,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 248) { + if (node.parent && node.parent.kind === 249) { exportSymbol = resolveName(node, node.escapedText, 67216319 | 67901928 | 1920 | 2097152, undefined, node, false); } - else if (node.parent.kind === 251) { + else if (node.parent.kind === 252) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 | 67901928 | 1920 | 2097152); } var result; @@ -26141,22 +26301,22 @@ var ts; } function hasType(target, propertyName) { if (propertyName === 0) { - return getSymbolLinks(target).type; + return !!getSymbolLinks(target).type; } if (propertyName === 2) { - return getSymbolLinks(target).declaredType; + return !!getSymbolLinks(target).declaredType; } if (propertyName === 1) { - return target.resolvedBaseConstructorType; + return !!target.resolvedBaseConstructorType; } if (propertyName === 3) { - return target.resolvedReturnType; + return !!target.resolvedReturnType; } if (propertyName === 4) { var bc = target.resolvedBaseConstraint; - return bc && bc !== circularConstraintType; + return !!bc && bc !== circularConstraintType; } - ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + return ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); } function popTypeResolution() { resolutionTargets.pop(); @@ -26164,20 +26324,19 @@ var ts; return resolutionResults.pop(); } function getDeclarationContainer(node) { - node = ts.findAncestor(ts.getRootDeclaration(node), function (node) { + return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 231: case 232: + case 233: + case 248: case 247: case 246: case 245: - case 244: return false; default: return true; } - }); - return node && node.parent; + }).parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype)); @@ -26195,14 +26354,14 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 146 && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 147 && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 12288); }); - if (source.flags & 16384) { + source = filterType(source, function (t) { return !(t.flags & 24576); }); + if (source.flags & 32768) { return emptyObjectType; } - if (source.flags & 131072) { + if (source.flags & 262144) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var members = ts.createSymbolTable(); @@ -26227,8 +26386,8 @@ var ts; function getTypeForBindingElement(declaration) { var pattern = declaration.parent; var parentType = getTypeForBindingElementParent(pattern.parent); - if (parentType === unknownType) { - return unknownType; + if (parentType === errorType) { + return errorType; } if (!parentType) { return declaration.initializer ? checkDeclarationInitializer(declaration) : parentType; @@ -26237,11 +26396,11 @@ var ts; return parentType; } var type; - if (pattern.kind === 179) { + if (pattern.kind === 180) { if (declaration.dotDotDotToken) { - if (!isValidSpreadType(parentType)) { + if (parentType.flags & 2 || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); - return unknownType; + return errorType; } var literalMembers = []; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { @@ -26258,13 +26417,13 @@ var ts; var isWellKnown = ts.isComputedPropertyName(name) && ts.isWellKnownSymbolSyntactically(name.expression); if (!isLate && !isWellKnown && isComputedNonLiteralName(name)) { var exprType = checkExpression(name.expression); - if (isTypeAssignableToKind(exprType, 1536)) { + if (isTypeAssignableToKind(exprType, 3072)) { if (noImplicitAny) { error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(exprType), typeToString(parentType)); } return anyType; } - var indexerType = isTypeAssignableToKind(exprType, 84) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); + var indexerType = isTypeAssignableToKind(exprType, 168) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!indexerType && noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { if (getIndexTypeOfType(parentType, 1)) { error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); @@ -26275,14 +26434,14 @@ var ts; } return indexerType || anyType; } - var nameType = isLate && checkComputedPropertyName(name); + var nameType = isLate ? checkComputedPropertyName(name) : undefined; var text = isLate ? getLateBoundNameFromType(nameType) : isWellKnown ? ts.getPropertyNameForKnownSymbolName(ts.idText(name.expression.name)) : ts.getTextOfPropertyName(name); if (strictNullChecks && declaration.flags & 4194304 && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } - if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 1536)) { + if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 3072)) { if (noImplicitAny) { error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(nameType), typeToString(parentType)); } @@ -26294,7 +26453,7 @@ var ts; getIndexTypeOfType(parentType, 0); if (!type) { error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); - return unknownType; + return errorType; } } } @@ -26315,11 +26474,11 @@ var ts; else { error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); } - return unknownType; + return errorType; } } } - if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 4096)) { + if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192)) { type = getTypeWithFacts(type, 131072); } return declaration.initializer ? @@ -26339,18 +26498,18 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 182 && expr.elements.length === 0; + return expr.kind === 183 && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 220) { - var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); - return indexType.flags & (32768 | 524288) ? getExtractStringType(indexType) : stringType; - } if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 221) { + var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); + return indexType.flags & (65536 | 1048576) ? getExtractStringType(indexType) : stringType; + } + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 222) { var forOfStatement = declaration.parent.parent; return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; } @@ -26364,7 +26523,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 231 && !ts.isBindingPattern(declaration.name) && + declaration.kind === 232 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 4194304)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -26373,10 +26532,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 148) { + if (declaration.kind === 149) { var func = declaration.parent; - if (func.kind === 156 && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 155); + if (func.kind === 157 && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 156); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -26422,18 +26581,18 @@ var ts; var jsDocType; var _loop_3 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 199 ? declaration : - declaration.kind === 184 ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = declaration.kind === 200 ? declaration : + declaration.kind === 185 ? ts.cast(declaration.parent, ts.isBinaryExpression) : undefined; if (!expression) { - return { value: unknownType }; + return { value: errorType }; } var special = ts.getSpecialPropertyAssignmentKind(expression); if (special === 4) { var thisContainer = ts.getThisContainer(expression, false); - declarationInConstructor = thisContainer.kind === 154 || - thisContainer.kind === 233 || - (thisContainer.kind === 191 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + declarationInConstructor = thisContainer.kind === 155 || + thisContainer.kind === 234 || + (thisContainer.kind === 192 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -26447,7 +26606,7 @@ var ts; if (!jsDocType) { jsDocType = declarationType; } - else if (jsDocType !== unknownType && declarationType !== unknownType && + else if (jsDocType !== errorType && declarationType !== errorType && !isTypeIdenticalTo(jsDocType, declarationType) && !(symbol.flags & 67108864)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); @@ -26502,11 +26661,11 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(12288 | 16777216)); }) ? constructorTypes : types; + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(24576 | 134217728)); }) ? constructorTypes : types; type = getUnionType(sourceTypes, 2); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~12288); }) === neverType) { + if (filterType(widened, function (t) { return !!(t.flags & ~24576); }) === neverType) { if (noImplicitAny) { reportImplicitAnyError(symbol.valueDeclaration, anyType); } @@ -26561,7 +26720,7 @@ var ts; members.set(symbol.escapedName, symbol); }); var result = createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); - result.flags |= 33554432; + result.flags |= 268435456; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; @@ -26571,7 +26730,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (elements.length === 0 || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); @@ -26583,7 +26742,9 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 179 + if (includePatternInType === void 0) { includePatternInType = false; } + if (reportErrors === void 0) { reportErrors = false; } + return pattern.kind === 180 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -26593,7 +26754,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (type.flags & 1024 && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 2048 && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -26608,7 +26769,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 148 ? root.parent : root; + var memberDeclaration = root.kind === 149 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -26634,23 +26795,25 @@ var ts; var jsonSourceFile = ts.cast(declaration, ts.isJsonSourceFile); return links.type = jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType; } - if (declaration.kind === 248) { + if (declaration.kind === 249) { return links.type = checkExpression(declaration.expression); } if (ts.isInJavaScriptFile(declaration) && ts.isJSDocPropertyLikeTag(declaration) && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { - return unknownType; + return errorType; } var type = void 0; - if (declaration.kind === 199 || - declaration.kind === 184 && declaration.parent.kind === 199) { + if (declaration.kind === 200 || + declaration.kind === 185 && declaration.parent.kind === 200) { type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isClassDeclaration(declaration) + || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) || ts.isMethodSignature(declaration)) { if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) { @@ -26678,7 +26841,7 @@ var ts; type = getWidenedTypeForVariableLikeDeclaration(declaration, true); } else { - ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration)); + return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol)); } if (!popTypeResolution()) { type = reportCircularityError(symbol); @@ -26689,7 +26852,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 155) { + if (accessor.kind === 156) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation && getTypeFromTypeNode(getterTypeAnnotation); } @@ -26710,8 +26873,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 155); - var setter = ts.getDeclarationOfKind(symbol, 156); + var getter = ts.getDeclarationOfKind(symbol, 156); + var setter = ts.getDeclarationOfKind(symbol, 157); if (getter && ts.isInJavaScriptFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -26719,7 +26882,7 @@ var ts; } } if (!pushTypeResolution(symbol, 0)) { - return unknownType; + return errorType; } var type = void 0; var getterReturnType = getAnnotatedAccessorType(getter); @@ -26752,7 +26915,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 155); + var getter_1 = ts.getDeclarationOfKind(symbol, 156); error(getter_1, 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)); } } @@ -26762,16 +26925,32 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 1081344 ? baseConstructorType : undefined; + return baseConstructorType.flags & 2162688 ? baseConstructorType : undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { + var jsDeclaration = ts.getDeclarationOfJSInitializer(symbol.valueDeclaration); + if (jsDeclaration) { + var jsSymbol = getSymbolOfNode(jsDeclaration); + if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { + symbol = cloneSymbol(symbol); + links = symbol; + if (ts.hasEntries(jsSymbol.exports)) { + symbol.exports = symbol.exports || ts.createSymbolTable(); + mergeSymbolTable(symbol.exports, jsSymbol.exports); + } + if (ts.hasEntries(jsSymbol.members)) { + symbol.members = symbol.members || ts.createSymbolTable(); + mergeSymbolTable(symbol.members, jsSymbol.members); + } + } + } if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 199 || - symbol.valueDeclaration.kind === 184 && symbol.valueDeclaration.parent.kind === 199) { + else if (symbol.valueDeclaration.kind === 200 || + symbol.valueDeclaration.kind === 185 && symbol.valueDeclaration.parent.kind === 200) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -26800,7 +26979,7 @@ var ts; var targetSymbol = resolveAlias(symbol); links.type = targetSymbol.flags & 67216319 ? getTypeOfSymbol(targetSymbol) - : unknownType; + : errorType; } return links.type; } @@ -26809,11 +26988,11 @@ var ts; if (!links.type) { if (symbolInstantiationDepth === 100) { error(symbol.valueDeclaration, ts.Diagnostics.Generic_type_instantiation_is_excessively_deep_and_possibly_infinite); - links.type = unknownType; + links.type = errorType; } else { if (!pushTypeResolution(symbol, 0)) { - return unknownType; + return errorType; } symbolInstantiationDepth++; var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); @@ -26829,7 +27008,7 @@ var ts; function reportCircularityError(symbol) { if (ts.getEffectiveTypeAnnotationNode(symbol.valueDeclaration)) { error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); - return unknownType; + return errorType; } if (noImplicitAny) { 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)); @@ -26858,7 +27037,7 @@ var ts; if (symbol.flags & 2097152) { return getTypeOfAlias(symbol); } - return unknownType; + return errorType; } function isReferenceToType(type, target) { return type !== undefined @@ -26874,11 +27053,12 @@ var ts; function check(type) { if (ts.getObjectFlags(type) & (3 | 4)) { var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 262144) { - return ts.forEach(type.types, check); + else if (type.flags & 524288) { + return ts.some(type.types, check); } + return false; } } function appendTypeParameters(typeParameters, declarations) { @@ -26895,51 +27075,51 @@ var ts; return undefined; } switch (node.kind) { - case 234: - case 204: case 235: - case 157: - case 158: - case 152: - case 162: - case 163: - case 283: - case 233: - case 153: - case 191: - case 192: + case 205: case 236: - case 295: + case 158: + case 159: + case 153: + case 163: + case 164: + case 284: + case 234: + case 154: + case 192: + case 193: + case 237: case 296: - case 291: - case 176: - case 170: + case 297: + case 292: + case 177: + case 171: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 176) { + if (node.kind === 177) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 170) { + else if (node.kind === 171) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 234 || node.kind === 204 || node.kind === 235) && + (node.kind === 235 || node.kind === 205 || node.kind === 236) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 235); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 236); return getOuterTypeParameters(declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 235 || - node.kind === 234 || - node.kind === 204 || + if (node.kind === 236 || + node.kind === 235 || + node.kind === 205 || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -26962,9 +27142,9 @@ var ts; if (isValidBaseType(type) && getSignaturesOfType(type, 1).length > 0) { return true; } - if (type.flags & 1081344) { + if (type.flags & 2162688) { var constraint = getBaseConstraintOfType(type); - return constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } return false; } @@ -26997,23 +27177,23 @@ var ts; return type.resolvedBaseConstructorType = undefinedType; } if (!pushTypeResolution(type, 1)) { - return unknownType; + return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); if (extended && baseTypeNode !== extended) { ts.Debug.assert(!extended.typeArguments); checkExpression(extended.expression); } - if (baseConstructorType.flags & (65536 | 262144)) { + if (baseConstructorType.flags & (131072 | 524288)) { resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); - return type.resolvedBaseConstructorType = unknownType; + return type.resolvedBaseConstructorType = errorType; } if (!(baseConstructorType.flags & 1) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - return type.resolvedBaseConstructorType = unknownType; + return type.resolvedBaseConstructorType = errorType; } type.resolvedBaseConstructorType = baseConstructorType; } @@ -27041,7 +27221,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (65536 | 262144 | 1))) { + if (!(baseConstructorType.flags & (131072 | 524288 | 1))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -27063,7 +27243,7 @@ var ts; } baseType = getReturnTypeOfSignature(constructors[0]); } - if (baseType === unknownType) { + if (baseType === errorType) { return type.resolvedBaseTypes = ts.emptyArray; } if (!isValidBaseType(baseType)) { @@ -27089,18 +27269,18 @@ var ts; return true; } function isValidBaseType(type) { - return type.flags & (65536 | 134217728 | 1) && !isGenericMappedType(type) || - type.flags & 262144 && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + return !!(type.flags & (131072 | 16777216 | 1)) && !isGenericMappedType(type) || + !!(type.flags & 524288) && !ts.some(type.types, function (t) { return !isValidBaseType(t); }); } 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 === 235 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 236 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); - if (baseType !== unknownType) { + if (baseType !== errorType) { if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === ts.emptyArray) { @@ -27125,7 +27305,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 235) { + if (declaration.kind === 236) { if (declaration.flags & 64) { return false; } @@ -27161,7 +27341,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(32768); + type.thisType = createType(65536); type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; @@ -27173,13 +27353,13 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { if (!pushTypeResolution(symbol, 2)) { - return unknownType; + return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 236; + return ts.isJSDocTypeAlias(d) || d.kind === 237; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; - var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType; + var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { @@ -27189,7 +27369,7 @@ var ts; } } else { - type = unknownType; + type = errorType; error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; @@ -27200,7 +27380,7 @@ var ts; if (expr.kind === 9) { return true; } - else if (expr.kind === 199) { + else if (expr.kind === 200) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -27214,12 +27394,12 @@ var ts; case 9: case 8: return true; - case 197: + case 198: return expr.operator === 38 && expr.operand.kind === 8; case 71: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 199: + case 200: return isStringConcatExpression(expr); default: return false; @@ -27233,7 +27413,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 237) { + if (declaration.kind === 238) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9) { @@ -27248,7 +27428,7 @@ var ts; return links.enumKind = hasNonLiteralMember ? 0 : 1; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 256 && !(type.flags & 131072) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 512 && !(type.flags & 262144) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); @@ -27260,7 +27440,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 237) { + if (declaration.kind === 238) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); @@ -27271,14 +27451,14 @@ var ts; } if (memberTypeList.length) { var enumType_1 = getUnionType(memberTypeList, 1, symbol, undefined); - if (enumType_1.flags & 131072) { - enumType_1.flags |= 256; + if (enumType_1.flags & 262144) { + enumType_1.flags |= 512; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(16); + var enumType = createType(32); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -27295,7 +27475,7 @@ var ts; function getDeclaredTypeOfTypeParameter(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(32768); + var type = createType(65536); type.symbol = symbol; links.declaredType = type; } @@ -27309,7 +27489,7 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - return tryGetDeclaredTypeOfSymbol(symbol) || unknownType; + return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { if (symbol.flags & (32 | 64)) { @@ -27335,6 +27515,7 @@ var ts; function isThislessType(node) { switch (node.kind) { case 119: + case 142: case 137: case 134: case 122: @@ -27344,11 +27525,11 @@ var ts; case 140: case 95: case 131: - case 177: + case 178: return true; - case 166: + case 167: return isThislessType(node.elementType); - case 161: + case 162: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -27363,7 +27544,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 154 || (returnType && isThislessType(returnType))) && + return (node.kind === 155 || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -27372,12 +27553,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 151: - case 150: - return isThislessVariableLikeDeclaration(declaration); - case 153: case 152: + case 151: + return isThislessVariableLikeDeclaration(declaration); case 154: + case 153: + case 155: return isThislessFunctionLikeDeclaration(declaration); } } @@ -27415,7 +27596,7 @@ var ts; return type; } function isTypeUsableAsLateBoundName(type) { - return !!(type.flags & 1120); + return !!(type.flags & 2240); } function isLateBindableName(node) { return ts.isComputedPropertyName(node) @@ -27424,7 +27605,7 @@ var ts; } function hasLateBindableName(node) { var name = ts.getNameOfDeclaration(node); - return name && isLateBindableName(name); + return !!name && isLateBindableName(name); } function hasNonBindableDynamicName(node) { return ts.hasDynamicName(node) && !hasLateBindableName(node); @@ -27433,12 +27614,13 @@ var ts; return ts.isDynamicName(node) && !isLateBindableName(node); } function getLateBoundNameFromType(type) { - if (type.flags & 1024) { + if (type.flags & 2048) { return "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); } - if (type.flags & 96) { + if (type.flags & 192) { return ts.escapeLeadingUnderscores("" + type.value); } + return ts.Debug.fail(); } function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) { ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 1024), "Expected a late-bound symbol."); @@ -27451,8 +27633,7 @@ var ts; symbol.declarations.push(member); } if (symbolFlags & 67216319) { - var valueDeclaration = symbol.valueDeclaration; - if (!valueDeclaration || valueDeclaration.kind !== member.kind) { + if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } } @@ -27544,7 +27725,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 262144) { + else if (type.flags & 524288) { return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); })); } return needApparentType ? getApparentType(type) : type; @@ -27803,7 +27984,7 @@ var ts; if (symbol.flags & 32) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (65536 | 262144 | 1081344)) { + if (baseConstructorType.flags & (131072 | 524288 | 2162688)) { members = ts.createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -27855,7 +28036,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 32 : 1120; + var include = keyofStringsOnly ? 64 : 2240; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { var prop = _a[_i]; @@ -27869,15 +28050,15 @@ var ts; } } else { - var keyType = constraintType.flags & 7372800 ? getApparentType(constraintType) : constraintType; - var iterationType = keyType.flags & 524288 ? getIndexType(getApparentType(keyType.type)) : keyType; + var keyType = constraintType.flags & 14745600 ? getApparentType(constraintType) : constraintType; + var iterationType = keyType.flags & 1048576 ? getIndexType(getApparentType(keyType.type)) : keyType; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); function addMemberForKeyType(t, _index, origin) { var templateMapper = combineTypeMappers(type.mapper, createTypeMapper([typeParameter], [t])); var propType = instantiateType(templateType, templateMapper); - if (t.flags & 1120) { + if (t.flags & 2240) { var propName = getLateBoundNameFromType(t); var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = !!(templateModifiers & 4 || @@ -27895,10 +28076,10 @@ var ts; prop.nameType = t; members.set(propName, prop); } - else if (t.flags & (1 | 2)) { + else if (t.flags & (1 | 4)) { stringIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1)); } - else if (t.flags & 4) { + else if (t.flags & 8) { numberIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1)); } } @@ -27909,20 +28090,20 @@ var ts; } function getConstraintTypeFromMappedType(type) { return type.constraintType || - (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || unknownType); + (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || errorType); } function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4)), type.mapper || identityMapper) : - unknownType); + errorType); } function getConstraintDeclarationForMappedType(type) { return type.declaration.typeParameter.constraint; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); - return constraintDeclaration.kind === 174 && + return constraintDeclaration.kind === 175 && constraintDeclaration.operator === 128; } function getModifiersTypeFromMappedType(type) { @@ -27933,8 +28114,8 @@ var ts; else { var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 32768 ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 524288 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 65536 ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 1048576 ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -27957,11 +28138,11 @@ var ts; return !!(ts.getObjectFlags(type) & 32 && getMappedTypeModifiers(type) & 4); } function isGenericMappedType(type) { - return ts.getObjectFlags(type) & 32 && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 65536) { + if (type.flags & 131072) { if (type.objectFlags & 4) { resolveTypeReferenceMembers(type); } @@ -27978,23 +28159,23 @@ var ts; resolveMappedTypeMembers(type); } } - else if (type.flags & 131072) { + else if (type.flags & 262144) { resolveUnionTypeMembers(type); } - else if (type.flags & 262144) { + else if (type.flags & 524288) { resolveIntersectionTypeMembers(type); } } return type; } function getPropertiesOfObjectType(type) { - if (type.flags & 65536) { + if (type.flags & 131072) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; } function getPropertyOfObjectType(type, name) { - if (type.flags & 65536) { + if (type.flags & 131072) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -28016,7 +28197,7 @@ var ts; } } } - if (type.flags & 131072) { + if (type.flags & 262144) { break; } } @@ -28026,13 +28207,13 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 393216 ? + return type.flags & 786432 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 131072)) { + if (!(unionType.flags & 262144)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -28050,9 +28231,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 32768 ? getConstraintOfTypeParameter(type) : - type.flags & 1048576 ? getConstraintOfIndexedAccess(type) : - type.flags & 2097152 ? getConstraintOfConditionalType(type) : + return type.flags & 65536 ? getConstraintOfTypeParameter(type) : + type.flags & 2097152 ? getConstraintOfIndexedAccess(type) : + type.flags & 4194304 ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -28062,12 +28243,12 @@ var ts; var objectType = getBaseConstraintOfType(type.objectType) || type.objectType; var indexType = getBaseConstraintOfType(type.indexType) || type.indexType; var constraint = !isGenericObjectType(objectType) && !isGenericIndexType(indexType) ? getIndexedAccessType(objectType, indexType) : undefined; - return constraint && constraint !== unknownType ? constraint : undefined; + return constraint && constraint !== errorType ? constraint : undefined; } function getDefaultConstraintOfConditionalType(type) { if (!type.resolvedDefaultConstraint) { var rootTrueType = type.root.trueType; - var rootTrueConstraint = rootTrueType.flags & 4194304 ? rootTrueType.substitute : rootTrueType; + var rootTrueConstraint = rootTrueType.flags & 8388608 ? rootTrueType.substitute : rootTrueType; type.resolvedDefaultConstraint = getUnionType([instantiateType(rootTrueConstraint, type.combinedMapper || type.mapper), getFalseTypeFromConditionalType(type)]); } return type.resolvedDefaultConstraint; @@ -28078,7 +28259,7 @@ var ts; if (constraint) { var mapper = makeUnaryTypeMapper(type.root.checkType, constraint); var instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper)); - if (!(instantiated.flags & 16384)) { + if (!(instantiated.flags & 32768)) { return instantiated; } } @@ -28093,19 +28274,19 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 7897088) { + if (t.flags & 15794176) { var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (32768 | 524288 | 2097152)) { + while (constraint && constraint.flags & (65536 | 1048576 | 4194304)) { constraint = getConstraintOfType(constraint); } if (constraint) { - if (!(constraint.flags & 131072)) { + if (!(constraint.flags & 262144)) { return undefined; } constraints = ts.append(constraints, constraint); } } - else if (t.flags & 134233854) { + else if (t.flags & 16809468) { hasDisjointDomainType = true; } } @@ -28113,7 +28294,7 @@ var ts; if (hasDisjointDomainType) { for (var _b = 0, _c = type.types; _b < _c.length; _b++) { var t = _c[_b]; - if (t.flags & 134233854) { + if (t.flags & 16809468) { constraints = ts.append(constraints, t); } } @@ -28123,7 +28304,7 @@ var ts; return undefined; } function getBaseConstraintOfInstantiableNonPrimitiveUnionOrIntersection(type) { - if (type.flags & (7372800 | 393216)) { + if (type.flags & (14745600 | 786432)) { var constraint = getResolvedBaseConstraint(type); if (constraint !== noConstraintType && constraint !== circularConstraintType) { return constraint; @@ -28132,7 +28313,7 @@ var ts; } function getBaseConstraintOfType(type) { var constraint = getBaseConstraintOfInstantiableNonPrimitiveUnionOrIntersection(type); - if (!constraint && type.flags & 524288) { + if (!constraint && type.flags & 1048576) { return keyofConstraintType; } return constraint; @@ -28163,13 +28344,13 @@ var ts; return result; } function computeBaseConstraint(t) { - if (t.flags & 32768) { + if (t.flags & 65536) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 393216) { + if (t.flags & 786432) { var types = t.types; var baseTypes = []; for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { @@ -28179,24 +28360,24 @@ var ts; baseTypes.push(baseType); } } - return t.flags & 131072 && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 262144 && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 262144 && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 524288 && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 524288) { + if (t.flags & 1048576) { return keyofConstraintType; } - if (t.flags & 1048576) { + if (t.flags & 2097152) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; - return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + return baseIndexedAccess && baseIndexedAccess !== errorType ? getBaseConstraint(baseIndexedAccess) : undefined; } - if (t.flags & 2097152) { + if (t.flags & 4194304) { var constraint = getConstraintOfConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 4194304) { + if (t.flags & 8388608) { return getBaseConstraint(t.substitute); } if (isGenericMappedType(t)) { @@ -28239,19 +28420,19 @@ var ts; return !!(typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameterDeclaration(decl) && decl.default; })); } function getApparentType(type) { - var t = type.flags & 7897088 ? getBaseConstraintOfType(type) || emptyObjectType : type; - return t.flags & 262144 ? getApparentTypeOfIntersectionType(t) : - t.flags & 34 ? globalStringType : - t.flags & 84 ? globalNumberType : - t.flags & 136 ? globalBooleanType : - t.flags & 1536 ? getGlobalESSymbolType(languageVersion >= 2) : - t.flags & 134217728 ? emptyObjectType : - t.flags & 524288 ? keyofConstraintType : + var t = type.flags & 15794176 ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 524288 ? getApparentTypeOfIntersectionType(t) : + t.flags & 68 ? globalStringType : + t.flags & 168 ? globalNumberType : + t.flags & 272 ? globalBooleanType : + t.flags & 3072 ? getGlobalESSymbolType(languageVersion >= 2) : + t.flags & 16777216 ? emptyObjectType : + t.flags & 1048576 ? keyofConstraintType : t; } function createUnionOrIntersectionProperty(containingType, name) { var props; - var isUnion = containingType.flags & 131072; + var isUnion = containingType.flags & 262144; var excludeModifiers = isUnion ? 24 : 0; var commonFlags = isUnion ? 0 : 16777216; var syntheticFlag = 4; @@ -28259,7 +28440,7 @@ var ts; for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var current = _a[_i]; var type = getApparentType(current); - if (type !== unknownType) { + if (type !== errorType) { var prop = getPropertyOfType(type, name); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop && !(modifiers & excludeModifiers)) { @@ -28341,7 +28522,7 @@ var ts; } function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 65536) { + if (type.flags & 131072) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -28355,13 +28536,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 393216) { + if (type.flags & 786432) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 458752) { + if (type.flags & 917504) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.callSignatures : resolved.constructSignatures; } @@ -28371,7 +28552,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 458752) { + if (type.flags & 917504) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -28419,10 +28600,10 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - return ts.isInJavaScriptFile(node) && (node.type && node.type.kind === 282 + return ts.isInJavaScriptFile(node) && (node.type && node.type.kind === 283 || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 282; + return isBracketed || !!typeExpression && typeExpression.type.kind === 283; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -28455,7 +28636,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 282; + return isBracketed || !!typeExpression && typeExpression.type.kind === 283; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -28515,7 +28696,7 @@ var ts; var hasLiteralTypes = false; var minArgumentCount = 0; var thisParameter = void 0; - var hasThisParameter = void 0; + var hasThisParameter = false; var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); var isUntypedSignatureInJSFile = !iife && @@ -28538,7 +28719,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 177) { + if (type && type.kind === 178) { hasLiteralTypes = true; } var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) || @@ -28550,16 +28731,16 @@ var ts; minArgumentCount = parameters.length; } } - if ((declaration.kind === 155 || declaration.kind === 156) && + if ((declaration.kind === 156 || declaration.kind === 157) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 155 ? 156 : 155; + var otherKind = declaration.kind === 156 ? 157 : 156; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 154 ? + var classType = declaration.kind === 155 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -28598,8 +28779,8 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 155 && !hasNonBindableDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 156); + if (declaration.kind === 156 && !hasNonBindableDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 157); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -28623,14 +28804,14 @@ var ts; switch (node.kind) { case 71: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 151: - case 153: - case 155: + case 152: + case 154: case 156: - return node.name.kind === 146 + case 157: + return node.name.kind === 147 && traverse(node.name); default: - return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && ts.forEachChild(node, traverse); + return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); } } } @@ -28640,16 +28821,15 @@ var ts; var result = []; for (var i = 0; i < symbol.declarations.length; i++) { var decl = symbol.declarations[i]; - var node = ts.isPropertyAccessExpression(decl) ? ts.getAssignedJavascriptInitializer(decl) : decl; - if (!ts.isFunctionLike(node)) + if (!ts.isFunctionLike(decl)) continue; - if (i > 0 && node.body) { + if (i > 0 && decl.body) { var previous = symbol.declarations[i - 1]; - if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { + if (decl.parent === previous.parent && decl.kind === previous.kind && decl.pos === previous.end) { continue; } } - result.push(getSignatureFromDeclaration(node)); + result.push(getSignatureFromDeclaration(decl)); } return result; } @@ -28682,7 +28862,7 @@ var ts; } else { var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 160 ? + signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 ? createTypePredicateFromTypePredicateNode(declaration.type) : noTypePredicate; } @@ -28693,7 +28873,7 @@ var ts; function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3)) { - return unknownType; + return errorType; } var type = void 0; if (signature.target) { @@ -28727,7 +28907,7 @@ var ts; } function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); + var type = getTypeOfSymbol(ts.last(signature.parameters)); if (ts.getObjectFlags(type) & 4 && type.target === globalArrayType) { return type.typeArguments[0]; } @@ -28777,7 +28957,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 154 || signature.declaration.kind === 158; + var isConstructor = signature.declaration.kind === 155 || signature.declaration.kind === 159; var type = createObjectType(16); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -28818,7 +28998,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 147); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 148); return decl && decl.constraint; } function getInferredTypeParameterConstraint(typeParameter) { @@ -28826,7 +29006,7 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 171 && declaration.parent.parent.kind === 161) { + if (declaration.parent.kind === 172 && declaration.parent.parent.kind === 162) { var typeReference = declaration.parent.parent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -28862,7 +29042,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 147).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 148).parent); } function getTypeListId(types) { var result = ""; @@ -28895,7 +29075,7 @@ var ts; result |= type.flags; } } - return result & 117440512; + return result & 939524096; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -28929,7 +29109,7 @@ var ts; var isJs = ts.isInJavaScriptFile(node); var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { - var missingAugmentsTag = isJs && node.parent.kind !== 289; + var missingAugmentsTag = isJs && node.parent.kind !== 290; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -28940,13 +29120,13 @@ var ts; var typeStr = typeToString(type, undefined, 2); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { - return unknownType; + return errorType; } } var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } - return checkNoTypeArguments(node, symbol) ? type : unknownType; + return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeAliasInstantiation(symbol, typeArguments) { var type = getDeclaredTypeOfSymbol(symbol); @@ -28969,17 +29149,17 @@ var ts; error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); - return unknownType; + return errorType; } return getTypeAliasInstantiation(symbol, typeArguments); } - return checkNoTypeArguments(node, symbol) ? type : unknownType; + return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 161: + case 162: return node.typeName; - case 206: + case 207: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -28996,7 +29176,7 @@ var ts; function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); if (symbol === unknownSymbol) { - return unknownType; + return errorType; } var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); if (type) { @@ -29005,11 +29185,11 @@ var ts; var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { return checkNoTypeArguments(node, symbol) ? - res.flags & 32768 ? getConstrainedTypeVariable(res, node) : res : - unknownType; + res.flags & 65536 ? getConstrainedTypeVariable(res, node) : res : + errorType; } if (!(symbol.flags & 67216319 && isJSDocTypeReference(node))) { - return unknownType; + return errorType; } var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); if (jsdocType) { @@ -29023,7 +29203,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var referenceType = valueType.symbol && valueType.symbol !== symbol && !isInferredClassType(valueType) && getTypeReferenceTypeWorker(node, valueType.symbol, typeArguments); if (referenceType || assignedType) { - return referenceType && assignedType ? getIntersectionType([assignedType, referenceType]) : referenceType || assignedType; + return (referenceType && assignedType ? getIntersectionType([assignedType, referenceType]) : referenceType || assignedType); } } function getTypeReferenceTypeWorker(node, symbol, typeArguments) { @@ -29046,13 +29226,13 @@ var ts; } } function getSubstitutionType(typeVariable, substitute) { - var result = createType(4194304); + var result = createType(8388608); result.typeVariable = typeVariable; result.substitute = substitute; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 167 && node.elementTypes.length === 1; + return node.kind === 168 && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -29061,9 +29241,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 285) { + while (node && !ts.isStatement(node) && node.kind !== 286) { var parent = node.parent; - if (parent.kind === 170 && node === parent.trueType) { + if (parent.kind === 171 && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -29074,7 +29254,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return node.flags & 2097152 && node.kind === 161; + return !!(node.flags & 2097152) && node.kind === 162; } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -29121,7 +29301,7 @@ var ts; var indexed = getTypeFromTypeNode(typeArgs[0]); var target = getTypeFromTypeNode(typeArgs[1]); var index = createIndexInfo(target, false); - return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType && index, indexed === numberType && index); + return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType ? index : undefined, indexed === numberType ? index : undefined); } return anyType; } @@ -29132,7 +29312,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 8192) : type; + return strictNullChecks ? getNullableType(type, 16384) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -29169,9 +29349,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 234: case 235: - case 237: + case 236: + case 238: return declaration; } } @@ -29180,7 +29360,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 65536)) { + if (!(type.flags & 131072)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -29285,7 +29465,7 @@ var ts; var typeParameters = []; var properties = []; for (var i = 0; i < arity; i++) { - var typeParameter = createType(32768); + var typeParameter = createType(65536); typeParameters.push(typeParameter); var property = createSymbol(4, "" + i); property.type = typeParameter; @@ -29302,7 +29482,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(32768); + type.thisType = createType(65536); type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; @@ -29335,16 +29515,16 @@ var ts; var combined = 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 13536 && combined & 13536) { + if (t.flags & 27072 && combined & 27072) { return true; } combined |= t.flags; - if (combined & 12288 && combined & (65536 | 134217728) || - combined & 134217728 && combined & (134233854 & ~134217728) || - combined & 34 && combined & (134233854 & ~34) || - combined & 84 && combined & (134233854 & ~84) || - combined & 1536 && combined & (134233854 & ~1536) || - combined & 6144 && combined & (134233854 & ~6144)) { + if (combined & 24576 && combined & (131072 | 16777216) || + combined & 16777216 && combined & (16809468 & ~16777216) || + combined & 68 && combined & (16809468 & ~68) || + combined & 168 && combined & (16809468 & ~168) || + combined & 3072 && combined & (16809468 & ~3072) || + combined & 12288 && combined & (16809468 & ~12288)) { return true; } } @@ -29352,24 +29532,24 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 131072) { + if (flags & 262144) { return addTypesToUnion(typeSet, includes, type.types); } - if (!(flags & 16384 || flags & 262144 && isEmptyIntersectionType(type))) { - includes |= flags & ~117440512; - if (flags & 1) { + if (!(flags & 32768 || flags & 524288 && isEmptyIntersectionType(type))) { + includes |= flags & ~939524096; + if (flags & 3) { if (type === wildcardType) - includes |= 33554432; + includes |= 268435456; } - else if (!strictNullChecks && flags & 12288) { - if (!(flags & 16777216)) - includes |= 16777216; + else if (!strictNullChecks && flags & 24576) { + if (!(flags & 134217728)) + includes |= 134217728; } else { var len = typeSet.length; var index = len && type.id > typeSet[len - 1].id ? ~len : ts.binarySearch(typeSet, type, getTypeId, ts.compareValues); if (index < 0) { - if (!(flags & 65536 && type.objectFlags & 16 && + if (!(flags & 131072 && type.objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { typeSet.splice(~index, 0, type); } @@ -29407,11 +29587,11 @@ var ts; } function isSetOfLiteralsFromSameEnum(types) { var first = types[0]; - if (first.flags & 256) { + if (first.flags & 512) { var firstEnum = getParentOfSymbol(first.symbol); for (var i = 1; i < types.length; i++) { var other = types[i]; - if (!(other.flags & 256) || (firstEnum !== getParentOfSymbol(other.symbol))) { + if (!(other.flags & 512) || (firstEnum !== getParentOfSymbol(other.symbol))) { return false; } } @@ -29436,10 +29616,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 32 && includes & 2 || - t.flags & 64 && includes & 4 || - t.flags & 1024 && includes & 512 || - t.flags & 96 && t.flags & 8388608 && containsType(types, t.regularType); + var remove = t.flags & 64 && includes & 4 || + t.flags & 128 && includes & 8 || + t.flags & 2048 && includes & 1024 || + t.flags & 192 && t.flags & 33554432 && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -29455,12 +29635,12 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (includes & 1) { - return includes & 33554432 ? wildcardType : anyType; + if (includes & 3) { + return includes & 1 ? includes & 268435456 ? wildcardType : anyType : unknownType; } switch (unionReduction) { case 1: - if (includes & 1120) { + if (includes & 2240) { removeRedundantLiteralTypes(typeSet, includes); } break; @@ -29469,11 +29649,11 @@ var ts; break; } if (typeSet.length === 0) { - return includes & 8192 ? includes & 16777216 ? nullType : nullWideningType : - includes & 4096 ? includes & 16777216 ? undefinedType : undefinedWideningType : + return includes & 16384 ? includes & 134217728 ? nullType : nullWideningType : + includes & 8192 ? includes & 134217728 ? undefinedType : undefinedWideningType : neverType; } - return getUnionTypeFromSortedList(typeSet, includes & 8374815 ? 0 : 268435456, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, includes & 16749629 ? 0 : 67108864, aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -29517,8 +29697,8 @@ var ts; var id = getTypeListId(types); var type = unionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(types, 12288); - type = createType(131072 | propagatedFlags | unionOfUnitTypes); + var propagatedFlags = getPropagatingFlagsOfTypes(types, 24576); + type = createType(262144 | propagatedFlags | unionOfUnitTypes); unionTypes.set(id, type); type.types = types; type.aliasSymbol = aliasSymbol; @@ -29536,20 +29716,20 @@ var ts; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 262144) { + if (flags & 524288) { return addTypesToIntersection(typeSet, includes, type.types); } if (ts.getObjectFlags(type) & 16 && isEmptyObjectType(type)) { - includes |= 67108864; + includes |= 536870912; } else { - includes |= flags & ~117440512; - if (flags & 1) { + includes |= flags & ~939524096; + if (flags & 3) { if (type === wildcardType) - includes |= 33554432; + includes |= 268435456; } - else if ((strictNullChecks || !(flags & 12288)) && !ts.contains(typeSet, type) && - !(flags & 65536 && type.objectFlags & 16 && + else if ((strictNullChecks || !(flags & 24576)) && !ts.contains(typeSet, type) && + !(flags & 131072 && type.objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192) && containsIdenticalType(typeSet, type))) { typeSet.push(type); @@ -29569,22 +29749,22 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 2 && includes & 32 || - t.flags & 4 && includes & 64 || - t.flags & 512 && includes & 1024; + var remove = t.flags & 4 && includes & 64 || + t.flags & 8 && includes & 128 || + t.flags & 1024 && includes & 2048; if (remove) { ts.orderedRemoveItemAt(types, i); } } } function intersectUnionsOfUnitTypes(types) { - var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 268435456) !== 0; }); + var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 67108864) !== 0; }); var unionType = types[unionIndex]; var intersection = unionType.types; var i = types.length - 1; var _loop_5 = function () { var t = types[i]; - if (t.flags & 268435456) { + if (t.flags & 67108864) { intersection = ts.filter(intersection, function (u) { return containsType(t.types, u); }); ts.orderedRemoveItemAt(types, i); } @@ -29596,45 +29776,48 @@ var ts; if (intersection === unionType.types) { return false; } - types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 268435456); + types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 67108864); return true; } function getIntersectionType(types, aliasSymbol, aliasTypeArguments) { - if (types.length === 0) { - return emptyObjectType; - } var typeSet = []; var includes = addTypesToIntersection(typeSet, 0, types); - if (includes & 16384) { + if (includes & 32768) { return neverType; } if (includes & 1) { - return includes & 33554432 ? wildcardType : anyType; + return includes & 268435456 ? wildcardType : anyType; } - if (includes & 2 && includes & 32 || - includes & 4 && includes & 64 || - includes & 512 && includes & 1024) { + if (!strictNullChecks && includes & 24576) { + return includes & 8192 ? undefinedType : nullType; + } + if (includes & 4 && includes & 64 || + includes & 8 && includes & 128 || + includes & 1024 && includes & 2048) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 67108864 && !(includes & 65536)) { + if (includes & 536870912 && !(includes & 131072)) { typeSet.push(emptyObjectType); } + if (typeSet.length === 0) { + return unknownType; + } if (typeSet.length === 1) { return typeSet[0]; } - if (includes & 131072) { - if (includes & 268435456 && intersectUnionsOfUnitTypes(typeSet)) { + if (includes & 262144) { + if (includes & 67108864 && intersectUnionsOfUnitTypes(typeSet)) { return getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } - var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 131072) !== 0; }); + var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 262144) !== 0; }); var unionType = typeSet[unionIndex_1]; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); var type = intersectionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 12288); - type = createType(262144 | propagatedFlags); + var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, 24576); + type = createType(524288 | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; @@ -29651,7 +29834,7 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(524288); + var result = createType(1048576); result.type = type; result.stringsOnly = stringsOnly; return result; @@ -29667,7 +29850,7 @@ var ts; if (!type && !ts.isKnownSymbol(prop)) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : - name && name.kind === 146 && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : + name && name.kind === 147 && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); } if (type && type.flags & include) { @@ -29685,16 +29868,16 @@ var ts; } function getIndexType(type, stringsOnly) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } - return type.flags & 131072 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - type.flags & 262144 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - maybeTypeOfKind(type, 7372800) ? getIndexTypeForGenericType(type, stringsOnly) : + return type.flags & 262144 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + type.flags & 524288 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + maybeTypeOfKind(type, 14745600) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 ? getConstraintTypeFromMappedType(type) : type === wildcardType ? wildcardType : type.flags & 1 ? keyofConstraintType : - stringsOnly ? getIndexInfoOfType(type, 0) ? stringType : getLiteralTypeFromPropertyNames(type, 32) : - getIndexInfoOfType(type, 0) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 1024)]) : - getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 32 | 1024)]) : - getLiteralTypeFromPropertyNames(type, 1120); + stringsOnly ? getIndexInfoOfType(type, 0) ? stringType : getLiteralTypeFromPropertyNames(type, 64) : + getIndexInfoOfType(type, 0) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 2048)]) : + getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 64 | 2048)]) : + getLiteralTypeFromPropertyNames(type, 2240); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -29705,7 +29888,7 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 16384 ? stringType : indexType; + return indexType.flags & 32768 ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); @@ -29717,20 +29900,20 @@ var ts; case 141: links.resolvedType = node.type.kind === 138 ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) - : unknownType; + : errorType; break; } } return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { - var type = createType(1048576); + var type = createType(2097152); type.objectType = objectType; type.indexType = indexType; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 185 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 186 ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -29742,7 +29925,7 @@ var ts; markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 99); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); - return unknownType; + return errorType; } if (cacheSymbol) { getNodeLinks(accessNode).resolvedSymbol = prop; @@ -29751,16 +29934,16 @@ var ts; return getTypeOfSymbol(prop); } } - if (!(indexType.flags & 12288) && isTypeAssignableToKind(indexType, 34 | 84 | 1536)) { + if (!(indexType.flags & 24576) && isTypeAssignableToKind(indexType, 68 | 168 | 3072)) { if (isTypeAny(objectType)) { return objectType; } - var indexInfo = isTypeAssignableToKind(indexType, 84) && getIndexInfoOfType(objectType, 1) || + var indexInfo = isTypeAssignableToKind(indexType, 168) && getIndexInfoOfType(objectType, 1) || getIndexInfoOfType(objectType, 0) || undefined; if (indexInfo) { - if (accessNode && !isTypeAssignableToKind(indexType, 2 | 4)) { - var indexNode = accessNode.kind === 185 ? accessNode.argumentExpression : accessNode.indexType; + if (accessNode && !isTypeAssignableToKind(indexType, 4 | 8)) { + var indexNode = accessNode.kind === 186 ? accessNode.argumentExpression : accessNode.indexType; error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -29768,7 +29951,7 @@ var ts; } return indexInfo.type; } - if (indexType.flags & 16384) { + if (indexType.flags & 32768) { return neverType; } if (accessExpression && !isConstEnumObjectType(objectType)) { @@ -29784,47 +29967,47 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 185 ? accessNode.argumentExpression : accessNode.indexType; - if (indexType.flags & (32 | 64)) { + var indexNode = accessNode.kind === 186 ? accessNode.argumentExpression : accessNode.indexType; + if (indexType.flags & (64 | 128)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (2 | 4)) { + else if (indexType.flags & (4 | 8)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } } - return unknownType; + return errorType; } function isGenericObjectType(type) { - return maybeTypeOfKind(type, 7372800 | 536870912); + return maybeTypeOfKind(type, 14745600 | 134217728); } function isGenericIndexType(type) { - return maybeTypeOfKind(type, 7372800 | 524288); + return maybeTypeOfKind(type, 14745600 | 1048576); } function isStringIndexOnlyType(type) { - if (type.flags & 65536 && !isGenericMappedType(type)) { + if (type.flags & 131072 && !isGenericMappedType(type)) { var t = resolveStructuredTypeMembers(type); return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && - t.stringIndexInfo && !t.numberIndexInfo; + !!t.stringIndexInfo && !t.numberIndexInfo; } return false; } function isMappedTypeToNever(type) { - return ts.getObjectFlags(type) & 32 && getTemplateTypeFromMappedType(type) === neverType; + return !!(ts.getObjectFlags(type) & 32) && getTemplateTypeFromMappedType(type) === neverType; } function getSimplifiedType(type) { - return type.flags & 1048576 ? getSimplifiedIndexedAccessType(type) : type; + return type.flags & 2097152 ? getSimplifiedIndexedAccessType(type) : type; } function getSimplifiedIndexedAccessType(type) { if (type.simplified) { return type.simplified === circularConstraintType ? type : type.simplified; } type.simplified = circularConstraintType; - var objectType = type.objectType; - if (objectType.flags & 262144 && isGenericObjectType(objectType)) { + var objectType = getSimplifiedType(type.objectType); + if (objectType.flags & 524288 && isGenericObjectType(objectType)) { if (ts.some(objectType.types, isStringIndexOnlyType)) { var regularTypes = []; var stringIndexTypes = []; @@ -29850,7 +30033,7 @@ var ts; if (isGenericMappedType(objectType)) { return type.simplified = substituteIndexedMappedType(objectType, type); } - if (objectType.flags & 32768) { + if (objectType.flags & 65536) { var constraint = getConstraintFromTypeParameter(objectType); if (constraint && isGenericMappedType(constraint)) { return type.simplified = substituteIndexedMappedType(constraint, type); @@ -29867,8 +30050,8 @@ var ts; if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 185) && isGenericObjectType(objectType)) { - if (objectType.flags & 1) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 186) && isGenericObjectType(objectType)) { + if (objectType.flags & 3) { return objectType; } var id = objectType.id + "," + indexType.id; @@ -29879,13 +30062,13 @@ var ts; return type; } var apparentObjectType = getApparentType(objectType); - if (indexType.flags & 131072 && !(indexType.flags & 8)) { + if (indexType.flags & 262144 && !(indexType.flags & 16)) { var propTypes = []; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; var propType = getPropertyTypeForIndexType(apparentObjectType, t, accessNode, false); - if (propType === unknownType) { - return unknownType; + if (propType === errorType) { + return errorType; } propTypes.push(propType); } @@ -29899,7 +30082,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var resolved = getIndexedAccessType(objectType, indexType, node); - links.resolvedType = resolved.flags & 1048576 && + links.resolvedType = resolved.flags & 2097152 && resolved.objectType === objectType && resolved.indexType === indexType ? getConstrainedTypeVariable(resolved, node) : resolved; @@ -29919,7 +30102,7 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - return type.flags & 4194304 ? type.typeVariable : type; + return type.flags & 8388608 ? type.typeVariable : type; } function getConditionalType(root, mapper) { var checkType = instantiateType(root.checkType, mapper); @@ -29927,7 +30110,7 @@ var ts; if (checkType === wildcardType || extendsType === wildcardType) { return wildcardType; } - var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 7897088); + var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 15794176); var combinedMapper; if (root.inferTypeParameters) { var context = createInferenceContext(root.inferTypeParameters, undefined, 0); @@ -29937,6 +30120,9 @@ var ts; combinedMapper = combineTypeMappers(mapper, context); } if (!isDeferred) { + if (extendsType.flags & 3) { + return instantiateType(root.trueType, mapper); + } if (checkType.flags & 1) { return getUnionType([instantiateType(root.trueType, combinedMapper || mapper), instantiateType(root.falseType, mapper)]); } @@ -29949,7 +30135,7 @@ var ts; } } var erasedCheckType = getActualTypeVariable(checkType); - var result = createType(2097152); + var result = createType(4194304); result.root = root; result.checkType = erasedCheckType; result.extendsType = extendsType; @@ -29981,7 +30167,7 @@ var ts; return true; } while (node) { - if (node.kind === 170) { + if (node.kind === 171) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -30004,7 +30190,7 @@ var ts; extendsType: getTypeFromTypeNode(node.extendsType), trueType: getTypeFromTypeNode(node.trueType), falseType: getTypeFromTypeNode(node.falseType), - isDistributive: !!(checkType.flags & 32768), + isDistributive: !!(checkType.flags & 65536), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -30040,12 +30226,12 @@ var ts; if (node.isTypeOf && node.typeArguments) { error(node, ts.Diagnostics.Type_arguments_cannot_be_used_here); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } if (!ts.isLiteralImportTypeNode(node)) { error(node.argument, ts.Diagnostics.String_literal_expected); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } var argumentType = getTypeFromTypeNode(node.argument); var targetMeaning = node.isTypeOf ? 67216319 : 67901928; @@ -30053,7 +30239,7 @@ var ts; var innerModuleSymbol = resolveExternalModule(node, moduleName, ts.Diagnostics.Cannot_find_module_0, node, false); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } var moduleSymbol_1 = resolveExternalModuleSymbol(innerModuleSymbol, false); if (!ts.nodeIsMissing(node.qualifier)) { @@ -30065,7 +30251,7 @@ var ts; var next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning); if (!next) { error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current)); - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } getNodeLinks(current).resolvedSymbol = next; getNodeLinks(current.parent).resolvedSymbol = next; @@ -30080,7 +30266,7 @@ var ts; else { error(node, targetMeaning === 67216319 ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); links.resolvedSymbol = unknownSymbol; - links.resolvedType = unknownType; + links.resolvedType = errorType; } } } @@ -30124,19 +30310,22 @@ var ts; if (left.flags & 1 || right.flags & 1) { return anyType; } - if (left.flags & 16384) { + if (left.flags & 2 || right.flags & 2) { + return unknownType; + } + if (left.flags & 32768) { return right; } - if (right.flags & 16384) { + if (right.flags & 32768) { return left; } - if (left.flags & 131072) { + if (left.flags & 262144) { return mapType(left, function (t) { return getSpreadType(t, right, symbol, typeFlags, objectFlags); }); } - if (right.flags & 131072) { + if (right.flags & 262144) { return mapType(right, function (t) { return getSpreadType(left, t, symbol, typeFlags, objectFlags); }); } - if (right.flags & (136 | 84 | 34 | 272 | 134217728 | 524288)) { + if (right.flags & (272 | 168 | 68 | 544 | 16777216 | 1048576)) { return left; } var members = ts.createSymbolTable(); @@ -30188,7 +30377,7 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getNonReadonlyIndexSignature(stringIndexInfo), getNonReadonlyIndexSignature(numberIndexInfo)); - spread.flags |= typeFlags | 33554432; + spread.flags |= typeFlags | 268435456; spread.objectFlags |= objectFlags | (128 | 1024); return spread; } @@ -30220,9 +30409,9 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 96 && !(type.flags & 8388608)) { + if (type.flags & 192 && !(type.flags & 33554432)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 8388608, type.value, type.symbol); + var freshType = createLiteralType(type.flags | 33554432, type.value, type.symbol); freshType.regularType = type; type.freshType = freshType; } @@ -30231,14 +30420,16 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 && type.flags & 8388608 ? type.regularType : type; + return type.flags & 192 && type.flags & 33554432 ? type.regularType : + type.flags & 262144 ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : + type; } function getLiteralType(value, enumId, symbol) { var qualifier = typeof value === "number" ? "#" : "@"; var key = enumId ? enumId + qualifier + value : qualifier + value; var type = literalTypes.get(key); if (!type) { - var flags = (typeof value === "number" ? 64 : 32) | (enumId ? 256 : 0); + var flags = (typeof value === "number" ? 128 : 64) | (enumId ? 512 : 0); literalTypes.set(key, type = createLiteralType(flags, value, symbol)); } return type; @@ -30251,7 +30442,7 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(1024); + var type = createType(2048); type.symbol = symbol; return type; } @@ -30266,14 +30457,14 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 235)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 236)) { if (!ts.hasModifier(container, 32) && - (container.kind !== 154 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 155 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); - return unknownType; + return errorType; } function getTypeFromThisTypeNode(node) { var links = getNodeLinks(node); @@ -30285,9 +30476,11 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119: - case 278: case 279: + case 280: return anyType; + case 142: + return unknownType; case 137: return stringType; case 134: @@ -30306,62 +30499,62 @@ var ts; return neverType; case 135: return node.flags & 65536 ? anyType : nonPrimitiveType; - case 173: + case 174: case 99: return getTypeFromThisTypeNode(node); - case 177: - return getTypeFromLiteralTypeNode(node); - case 161: - return getTypeFromTypeReference(node); - case 160: - return booleanType; - case 206: - return getTypeFromTypeReference(node); - case 164: - return getTypeFromTypeQueryNode(node); - case 166: - return getTypeFromArrayTypeNode(node); - case 167: - return getTypeFromTupleTypeNode(node); - case 168: - return getTypeFromUnionTypeNode(node); - case 169: - return getTypeFromIntersectionTypeNode(node); - case 280: - return getTypeFromJSDocNullableTypeNode(node); - case 282: - return addOptionality(getTypeFromTypeNode(node.type)); - case 172: - case 281: - case 277: - return getTypeFromTypeNode(node.type); - case 284: - return getTypeFromJSDocVariadicType(node); - case 162: - case 163: - case 165: - case 286: - case 283: - case 287: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 174: - return getTypeFromTypeOperatorNode(node); - case 175: - return getTypeFromIndexedAccessTypeNode(node); - case 176: - return getTypeFromMappedTypeNode(node); - case 170: - return getTypeFromConditionalTypeNode(node); - case 171: - return getTypeFromInferTypeNode(node); case 178: + return getTypeFromLiteralTypeNode(node); + case 162: + return getTypeFromTypeReference(node); + case 161: + return booleanType; + case 207: + return getTypeFromTypeReference(node); + case 165: + return getTypeFromTypeQueryNode(node); + case 167: + return getTypeFromArrayTypeNode(node); + case 168: + return getTypeFromTupleTypeNode(node); + case 169: + return getTypeFromUnionTypeNode(node); + case 170: + return getTypeFromIntersectionTypeNode(node); + case 281: + return getTypeFromJSDocNullableTypeNode(node); + case 283: + return addOptionality(getTypeFromTypeNode(node.type)); + case 173: + case 282: + case 278: + return getTypeFromTypeNode(node.type); + case 285: + return getTypeFromJSDocVariadicType(node); + case 163: + case 164: + case 166: + case 287: + case 284: + case 288: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + case 175: + return getTypeFromTypeOperatorNode(node); + case 176: + return getTypeFromIndexedAccessTypeNode(node); + case 177: + return getTypeFromMappedTypeNode(node); + case 171: + return getTypeFromConditionalTypeNode(node); + case 172: + return getTypeFromInferTypeNode(node); + case 179: return getTypeFromImportTypeNode(node); case 71: - case 145: + case 146: var symbol = getSymbolAtLocation(node); - return symbol && getDeclaredTypeOfSymbol(symbol); + return (symbol && getDeclaredTypeOfSymbol(symbol)); default: - return unknownType; + return errorType; } } function instantiateList(items, mapper, instantiator) { @@ -30434,10 +30627,10 @@ var ts; return function (t) { return t === source ? target : baseMapper(t); }; } function wildcardMapper(type) { - return type.flags & 32768 ? wildcardType : type; + return type.flags & 65536 ? wildcardType : type; } function cloneTypeParameter(typeParameter) { - var result = createType(32768); + var result = createType(65536); result.symbol = typeParameter.symbol; result.target = typeParameter; return result; @@ -30475,7 +30668,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 65536 | 7897088)) { + if (links.type && !maybeTypeOfKind(links.type, 131072 | 15794176)) { return symbol; } if (ts.getCheckFlags(symbol) & 1) { @@ -30546,35 +30739,35 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 145 || - node.parent.kind === 161 && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 146 || + node.parent.kind === 162 && node.parent.typeArguments && node === node.parent.typeName); } function isTypeParameterPossiblyReferenced(tp, node) { if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 212 ? "quit" : n === container_3; })) { - return ts.forEachChild(node, containsReference); + if (ts.findAncestor(node, function (n) { return n.kind === 213 ? "quit" : n === container_3; })) { + return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 173: - return tp.isThisType; + case 174: + return !!tp.isThisType; case 71: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 164: + case 165: return true; } - return ts.forEachChild(node, containsReference); + return !!ts.forEachChild(node, containsReference); } } function instantiateMappedType(type, mapper) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 524288) { + if (constraintType.flags & 1048576) { var typeVariable_1 = constraintType.type; - if (typeVariable_1.flags & 32768) { + if (typeVariable_1.flags & 65536) { var mappedTypeVariable = instantiateType(typeVariable_1, mapper); if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { @@ -30589,7 +30782,7 @@ var ts; return instantiateAnonymousType(type, mapper); } function isMappableType(type) { - return type.flags & (1 | 7372800 | 65536 | 262144); + return type.flags & (3 | 14745600 | 131072 | 524288); } function instantiateAnonymousType(type, mapper) { var result = createObjectType(type.objectFlags | 64, type.symbol); @@ -30621,7 +30814,7 @@ var ts; if (root.isDistributive) { var checkType_1 = root.checkType; var instantiatedType = mapper(checkType_1); - if (checkType_1 !== instantiatedType && instantiatedType.flags & (131072 | 16384)) { + if (checkType_1 !== instantiatedType && instantiatedType.flags & (262144 | 32768)) { return mapType(instantiatedType, function (t) { return getConditionalType(root, createReplacementMapper(checkType_1, t, mapper)); }); } } @@ -30629,10 +30822,10 @@ var ts; } function instantiateType(type, mapper) { if (type && mapper && mapper !== identityMapper) { - if (type.flags & 32768) { + if (type.flags & 65536) { return mapper(type); } - if (type.flags & 65536) { + if (type.flags & 131072) { if (type.objectFlags & 16) { return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations ? getAnonymousTypeInstantiation(type, mapper) : type; @@ -30646,65 +30839,69 @@ var ts; return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; } } - if (type.flags & 131072 && !(type.flags & 16382)) { + if (type.flags & 262144 && !(type.flags & 32764)) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getUnionType(newTypes, 1, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (type.flags & 262144) { + if (type.flags & 524288) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (type.flags & 524288) { + if (type.flags & 1048576) { return getIndexType(instantiateType(type.type, mapper)); } - if (type.flags & 1048576) { + if (type.flags & 2097152) { return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - if (type.flags & 2097152) { + if (type.flags & 4194304) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); } - if (type.flags & 4194304) { + if (type.flags & 8388608) { return instantiateType(type.typeVariable, mapper); } } return type; } function getWildcardInstantiation(type) { - return type.flags & (16382 | 1 | 16384) ? type : + return type.flags & (32764 | 3 | 32768) ? type : type.wildcardInstantiation || (type.wildcardInstantiation = instantiateType(type, wildcardMapper)); } function instantiateIndexInfo(info, mapper) { return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 153 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 191: case 192: - case 153: + case 193: + case 154: return isContextSensitiveFunctionLikeDeclaration(node); + case 184: + return ts.some(node.properties, isContextSensitive); case 183: - return ts.forEach(node.properties, isContextSensitive); - case 182: - return ts.forEach(node.elements, isContextSensitive); - case 200: + return ts.some(node.elements, isContextSensitive); + case 201: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 199: + case 200: return node.operatorToken.kind === 54 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 269: + case 270: return isContextSensitive(node.initializer); - case 190: + case 191: return isContextSensitive(node.expression); - case 262: - return ts.forEach(node.properties, isContextSensitive); - case 261: - return node.initializer && isContextSensitive(node.initializer); - case 264: - return node.expression && isContextSensitive(node.expression); + case 263: + return ts.some(node.properties, isContextSensitive); + case 262: { + var initializer = node.initializer; + return !!initializer && isContextSensitive(initializer); + } + case 265: { + var expression = node.expression; + return !!expression && isContextSensitive(expression); + } } return false; } @@ -30712,23 +30909,24 @@ var ts; if (node.typeParameters) { return false; } - if (ts.forEach(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { + if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 192) { + if (node.kind !== 193) { var parameter = ts.firstOrUndefined(node.parameters); if (!(parameter && ts.parameterIsThisKeyword(parameter))) { return true; } } - return node.body.kind === 212 ? false : isContextSensitive(node.body); + var body = node.body; + return body.kind === 213 ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 65536) { + if (type.flags & 131072) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(16, type.symbol); @@ -30739,7 +30937,7 @@ var ts; return result; } } - else if (type.flags & 262144) { + else if (type.flags & 524288) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -30760,9 +30958,9 @@ var ts; return isTypeRelatedTo(source, target, assignableRelation); } function isTypeDerivedFrom(source, target) { - return source.flags & 131072 ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 131072 ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 7372800 ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : + return source.flags & 262144 ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 262144 ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 14745600 ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : target === globalObjectType || target === globalFunctionType ? isTypeSubtypeOf(source, target) : hasBaseType(source, getTargetType(target)); } @@ -30793,8 +30991,8 @@ var ts; source = instantiateSignatureInContextOf(source, target, undefined, compareTypes); } var kind = target.declaration ? target.declaration.kind : 0; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 153 && - kind !== 152 && kind !== 154; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 && + kind !== 153 && kind !== 155; var result = -1; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -30822,7 +31020,7 @@ var ts; var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && - (getFalsyFlags(sourceType) & 12288) === (getFalsyFlags(targetType) & 12288); + (getFalsyFlags(sourceType) & 24576) === (getFalsyFlags(targetType) & 24576); var related = callbacks ? compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 : 1, false, reportErrors, errorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors); @@ -30927,10 +31125,10 @@ var ts; !t.numberIndexInfo; } function isEmptyObjectType(type) { - return type.flags & 65536 ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 134217728 ? true : - type.flags & 131072 ? ts.forEach(type.types, isEmptyObjectType) : - type.flags & 262144 ? !ts.forEach(type.types, function (t) { return !isEmptyObjectType(t); }) : + return type.flags & 131072 ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 16777216 ? true : + type.flags & 262144 ? ts.some(type.types, isEmptyObjectType) : + type.flags & 524288 ? !ts.some(type.types, function (t) { return !isEmptyObjectType(t); }) : false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -30966,71 +31164,71 @@ var ts; function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 1 || s & 16384 || source === wildcardType) + if (t & 3 || s & 32768 || source === wildcardType) return true; - if (t & 16384) + if (t & 32768) return false; - if (s & 34 && t & 2) + if (s & 68 && t & 4) return true; - if (s & 32 && s & 256 && - t & 32 && !(t & 256) && + if (s & 64 && s & 512 && + t & 64 && !(t & 512) && source.value === target.value) return true; - if (s & 84 && t & 4) + if (s & 168 && t & 8) return true; - if (s & 64 && s & 256 && - t & 64 && !(t & 256) && + if (s & 128 && s & 512 && + t & 128 && !(t & 512) && source.value === target.value) return true; - if (s & 136 && t & 8) + if (s & 272 && t & 16) return true; - if (s & 1536 && t & 512) + if (s & 3072 && t & 1024) return true; - if (s & 16 && t & 16 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 && t & 32 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 256 && t & 256) { - if (s & 131072 && t & 131072 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 512 && t & 512) { + if (s & 262144 && t & 262144 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 224 && t & 224 && + if (s & 448 && t & 448 && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } - if (s & 4096 && (!strictNullChecks || t & (4096 | 2048))) + if (s & 8192 && (!strictNullChecks || t & (8192 | 4096))) return true; - if (s & 8192 && (!strictNullChecks || t & 8192)) + if (s & 16384 && (!strictNullChecks || t & 16384)) return true; - if (s & 65536 && t & 134217728) + if (s & 131072 && t & 16777216) return true; - if (s & 1024 || t & 1024) + if (s & 2048 || t & 2048) return false; if (relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) { if (s & 1) return true; - if (s & (4 | 64) && !(s & 256) && (t & 16 || t & 64 && t & 256)) + if (s & (8 | 128) && !(s & 512) && (t & 32 || t & 128 && t & 512)) return true; } return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 && source.flags & 8388608) { + if (source.flags & 192 && source.flags & 33554432) { source = source.regularType; } - if (target.flags & 96 && target.flags & 8388608) { + if (target.flags & 192 && target.flags & 33554432) { target = target.regularType; } if (source === target || - relation === comparableRelation && !(target.flags & 16384) && isSimpleTypeRelatedTo(target, source, relation) || + relation === comparableRelation && !(target.flags & 32768) && isSimpleTypeRelatedTo(target, source, relation) || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 65536 && target.flags & 65536) { + if (source.flags & 131072 && target.flags & 131072) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1; } } - if (source.flags & 8355840 || target.flags & 8355840) { + if (source.flags & 16711680 || target.flags & 16711680) { return checkTypeRelatedTo(source, target, relation, undefined); } return false; @@ -31107,13 +31305,13 @@ var ts; } } function isUnionOrIntersectionTypeWithoutNullableConstituents(type) { - if (!(type.flags & 393216)) { + if (!(type.flags & 786432)) { return false; } var seenNonNullable = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 12288) { + if (t.flags & 24576) { continue; } if (seenNonNullable) { @@ -31124,22 +31322,23 @@ var ts; return false; } function isRelatedTo(source, target, reportErrors, headMessage) { - if (source.flags & 96 && source.flags & 8388608) { + if (reportErrors === void 0) { reportErrors = false; } + if (source.flags & 192 && source.flags & 33554432) { source = source.regularType; } - if (target.flags & 96 && target.flags & 8388608) { + if (target.flags & 192 && target.flags & 33554432) { target = target.regularType; } - if (source.flags & 4194304) { + if (source.flags & 8388608) { source = relation === definitelyAssignableRelation ? source.typeVariable : source.substitute; } - if (target.flags & 4194304) { + if (target.flags & 8388608) { target = target.typeVariable; } - if (source.flags & 1048576) { + if (source.flags & 2097152) { source = getSimplifiedType(source); } - if (target.flags & 1048576) { + if (target.flags & 2097152) { target = getSimplifiedType(target); } if (source === target) @@ -31147,11 +31346,11 @@ var ts; if (relation === identityRelation) { return isIdenticalTo(source, target); } - if (relation === comparableRelation && !(target.flags & 16384) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 32768) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1; - if (isObjectLiteralType(source) && source.flags & 8388608) { - var discriminantType = target.flags & 131072 ? findMatchingDiscriminantType(source, target) : undefined; + if (isObjectLiteralType(source) && source.flags & 33554432) { + var discriminantType = target.flags & 262144 ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -31163,8 +31362,8 @@ var ts; } } if (relation !== comparableRelation && - !(source.flags & 393216) && - !(target.flags & 131072) && + !(source.flags & 786432) && + !(target.flags & 262144) && !isIntersectionConstituent && source !== globalObjectType && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && @@ -31187,30 +31386,30 @@ var ts; var saveErrorInfo = errorInfo; var saveIsIntersectionConstituent = isIntersectionConstituent; isIntersectionConstituent = false; - if (source.flags & 131072) { + if (source.flags & 262144) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 16382)) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 16382)); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764)) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764)); } else { - if (target.flags & 131072) { - result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 16382) && !(target.flags & 16382)); + if (target.flags & 262144) { + result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 32764) && !(target.flags & 32764)); } - else if (target.flags & 262144) { + else if (target.flags & 524288) { isIntersectionConstituent = true; result = typeRelatedToEachType(source, target, reportErrors); } - else if (source.flags & 262144) { + else if (source.flags & 524288) { result = someTypeRelatedToType(source, target, false); } - if (!result && (source.flags & 8355840 || target.flags & 8355840)) { + if (!result && (source.flags & 16711680 || target.flags & 16711680)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { errorInfo = saveErrorInfo; } } } - if (!result && source.flags & 262144) { - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 131072)); + if (!result && source.flags & 524288) { + var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 262144)); if (constraint) { if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; @@ -31219,12 +31418,21 @@ var ts; } isIntersectionConstituent = saveIsIntersectionConstituent; if (!result && reportErrors) { - if (source.flags & 65536 && target.flags & 16382) { + if (source.flags & 131072 && target.flags & 32764) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 65536 && globalObjectType === source) { + else if (source.symbol && source.flags & 131072 && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } + else if (ts.getObjectFlags(source) & 4096 && target.flags & 524288) { + var targetTypes = target.types; + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); + var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); + if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType && + (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) { + return result; + } + } reportRelationError(headMessage, source, target); } return result; @@ -31232,27 +31440,27 @@ var ts; function isIdenticalTo(source, target) { var result; var flags = source.flags & target.flags; - if (flags & 65536) { + if (flags & 131072) { return recursiveTypeRelatedTo(source, target, false); } - if (flags & (131072 | 262144)) { + if (flags & (262144 | 524288)) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } } - if (flags & 524288) { + if (flags & 1048576) { return isRelatedTo(source.type, target.type, false); } - if (flags & 1048576) { + if (flags & 2097152) { if (result = isRelatedTo(source.objectType, target.objectType, false)) { if (result &= isRelatedTo(source.indexType, target.indexType, false)) { return result; } } } - if (flags & 2097152) { + if (flags & 4194304) { if (source.root.isDistributive === target.root.isDistributive) { if (result = isRelatedTo(source.checkType, target.checkType, false)) { if (result &= isRelatedTo(source.extendsType, target.extendsType, false)) { @@ -31265,13 +31473,13 @@ var ts; } } } - if (flags & 4194304) { + if (flags & 8388608) { return isRelatedTo(source.substitute, target.substitute, false); } return 0; } function hasExcessProperties(source, target, discriminant, reportErrors) { - if (maybeTypeOfKind(target, 65536) && !(ts.getObjectFlags(target) & 512)) { + if (maybeTypeOfKind(target, 131072) && !(ts.getObjectFlags(target) & 512)) { var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096); if ((relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { @@ -31283,7 +31491,8 @@ var ts; var _loop_6 = function (prop) { if (!isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { - ts.Debug.assert(!!errorNode); + if (!errorNode) + return { value: ts.Debug.fail() }; if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); } @@ -31294,8 +31503,9 @@ var ts; var propDeclaration = prop.valueDeclaration; ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike); errorNode = propDeclaration; - if (ts.isIdentifier(propDeclaration.name)) { - suggestion = getSuggestionForNonexistentProperty(propDeclaration.name, target); + var name = propDeclaration.name; + if (ts.isIdentifier(name)) { + suggestion = getSuggestionForNonexistentProperty(name, target); } } if (suggestion !== undefined) { @@ -31333,7 +31543,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 131072 && containsType(targetTypes, source)) { + if (target.flags & 262144 && containsType(targetTypes, source)) { return -1; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { @@ -31390,7 +31600,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 131072 && containsType(sourceTypes, target)) { + if (source.flags & 262144 && containsType(sourceTypes, target)) { return -1; } var len = sourceTypes.length; @@ -31520,7 +31730,7 @@ var ts; var result; var originalErrorInfo; var saveErrorInfo = errorInfo; - if (target.flags & 32768) { + if (target.flags & 65536) { if (ts.getObjectFlags(source) & 32 && getConstraintTypeFromMappedType(source) === getIndexType(target)) { if (!(getMappedTypeModifiers(source) & 4)) { var templateType = getTemplateTypeFromMappedType(source); @@ -31531,8 +31741,8 @@ var ts; } } } - else if (target.flags & 524288) { - if (source.flags & 524288) { + else if (target.flags & 1048576) { + if (source.flags & 1048576) { if (result = isRelatedTo(target.type, source.type, false)) { return result; } @@ -31547,7 +31757,7 @@ var ts; } } } - else if (target.flags & 1048576) { + else if (target.flags & 2097152) { var constraint = getConstraintForRelation(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { @@ -31560,7 +31770,7 @@ var ts; var template = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); if (!(modifiers & 8)) { - if (template.flags & 1048576 && template.objectType === source && + if (template.flags & 2097152 && template.objectType === source && template.indexType === getTypeParameterFromMappedType(target)) { return -1; } @@ -31574,8 +31784,8 @@ var ts; } } } - if (source.flags & 1081344) { - if (source.flags & 1048576 && target.flags & 1048576) { + if (source.flags & 2162688) { + if (source.flags & 2097152 && target.flags & 2097152) { if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } @@ -31585,8 +31795,8 @@ var ts; } } var constraint = getConstraintForRelation(source); - if (!constraint || (source.flags & 32768 && constraint.flags & 1)) { - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~134217728))) { + if (!constraint || (source.flags & 65536 && constraint.flags & 3)) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~16777216))) { errorInfo = saveErrorInfo; return result; } @@ -31599,14 +31809,14 @@ var ts; } } } - else if (source.flags & 524288) { + else if (source.flags & 1048576) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 2097152) { - if (target.flags & 2097152) { + else if (source.flags & 4194304) { + if (target.flags & 4194304) { if (isTypeIdenticalTo(source.extendsType, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { @@ -31650,11 +31860,11 @@ var ts; errorInfo = saveErrorInfo; } } - var sourceIsPrimitive = !!(source.flags & 16382); + var sourceIsPrimitive = !!(source.flags & 32764); if (relation !== identityRelation) { source = getApparentType(source); } - if (source.flags & (65536 | 262144) && target.flags & 65536) { + if (source.flags & (131072 | 524288) && target.flags & 131072) { var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; if (isPartialMappedType(target) && !isGenericMappedType(source) && isEmptyObjectType(source)) { result = -1; @@ -31792,14 +32002,14 @@ var ts; return result; } function isWeakType(type) { - if (type.flags & 65536) { + if (type.flags & 131072) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo && resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216); }); } - if (type.flags & 262144) { + if (type.flags & 524288) { return ts.every(type.types, isWeakType); } return false; @@ -31815,7 +32025,7 @@ var ts; return false; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 65536 && target.flags & 65536)) { + if (!(source.flags & 131072 && target.flags & 131072)) { return 0; } var sourceProperties = getPropertiesOfObjectType(source); @@ -31870,7 +32080,7 @@ var ts; } } else if (sourceSignatures.length === 1 && targetSignatures.length === 1) { - var eraseGenerics = relation === comparableRelation || compilerOptions.noStrictGenericChecks; + var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); } else { @@ -31921,7 +32131,7 @@ var ts; if (isIgnoredJsxProperty(source, prop, undefined)) { continue; } - if (prop.nameType && prop.nameType.flags & 1024) { + if (prop.nameType && prop.nameType.flags & 2048) { continue; } if (kind === 0 || isNumericLiteralName(prop.escapedName)) { @@ -31949,7 +32159,7 @@ var ts; return indexTypesIdenticalTo(source, target, kind); } var targetInfo = getIndexInfoOfType(target, kind); - if (!targetInfo || targetInfo.type.flags & 1 && !sourceIsPrimitive) { + if (!targetInfo || targetInfo.type.flags & 3 && !sourceIsPrimitive) { return -1; } var sourceInfo = getIndexInfoOfType(source, kind) || @@ -31958,7 +32168,7 @@ var ts; return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } if (isGenericMappedType(source)) { - return kind === 0 && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors); + return (kind === 0 && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); } if (isObjectTypeWithInferableIndex(source)) { var related = -1; @@ -32046,17 +32256,17 @@ var ts; } function hasCovariantVoidArgument(type, variances) { for (var i = 0; i < variances.length; i++) { - if (variances[i] === 1 && type.typeArguments[i].flags & 2048) { + if (variances[i] === 1 && type.typeArguments[i].flags & 4096) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 32768 && !getConstraintFromTypeParameter(type); + return type.flags & 65536 && !getConstraintFromTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { - return ts.getObjectFlags(type) & 4 && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return !!(ts.getObjectFlags(type) & 4) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } @@ -32124,13 +32334,13 @@ var ts; !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } function isDeeplyNestedType(type, stack, depth) { - if (depth >= 5 && type.flags & 65536) { + if (depth >= 5 && type.flags & 131072) { var symbol = type.symbol; if (symbol) { var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 65536 && t.symbol === symbol) { + if (t.flags & 131072 && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -32255,20 +32465,20 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 12288); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 24576); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 12288) : + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 24576) : getUnionType(types, 2); } function getCommonSubtype(types) { return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return ts.getObjectFlags(type) & 4 && type.target === globalArrayType; + return !!(ts.getObjectFlags(type) & 4) && type.target === globalArrayType; } function isArrayLikeType(type) { return ts.getObjectFlags(type) & 4 && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || - !(type.flags & 12288) && isTypeAssignableTo(type, anyReadonlyArrayType); + !(type.flags & 24576) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; @@ -32278,35 +32488,35 @@ var ts; return !!getPropertyOfType(type, "0"); } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (13536 | 16384)); + return !(type.flags & (27072 | 32768)); } function isUnitType(type) { - return !!(type.flags & 13536); + return !!(type.flags & 27072); } function isLiteralType(type) { - return type.flags & 8 ? true : - type.flags & 131072 ? type.flags & 256 ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : + return type.flags & 16 ? true : + type.flags & 262144 ? type.flags & 512 ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 256 ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 32 ? stringType : - type.flags & 64 ? numberType : - type.flags & 128 ? booleanType : - type.flags & 131072 ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + return type.flags & 512 ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 64 ? stringType : + type.flags & 128 ? numberType : + type.flags & 256 ? booleanType : + type.flags & 262144 ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { - return type.flags & 256 ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 32 && type.flags & 8388608 ? stringType : - type.flags & 64 && type.flags & 8388608 ? numberType : - type.flags & 128 ? booleanType : - type.flags & 131072 ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + return type.flags & 512 ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 64 && type.flags & 33554432 ? stringType : + type.flags & 128 && type.flags & 33554432 ? numberType : + type.flags & 256 ? booleanType : + type.flags & 262144 ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 1024 ? esSymbolType : - type.flags & 131072 ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : + return type.flags & 2048 ? esSymbolType : + type.flags & 262144 ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -32327,39 +32537,39 @@ var ts; return result; } function getFalsyFlags(type) { - return type.flags & 131072 ? getFalsyFlagsOfTypes(type.types) : - type.flags & 32 ? type.value === "" ? 32 : 0 : - type.flags & 64 ? type.value === 0 ? 64 : 0 : - type.flags & 128 ? type === falseType ? 128 : 0 : - type.flags & 14574; + return type.flags & 262144 ? getFalsyFlagsOfTypes(type.types) : + type.flags & 64 ? type.value === "" ? 64 : 0 : + type.flags & 128 ? type.value === 0 ? 128 : 0 : + type.flags & 256 ? type === falseType ? 256 : 0 : + type.flags & 29148; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 14560 ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 14560); }) : + return getFalsyFlags(type) & 29120 ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 29120); }) : type; } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 2 ? emptyStringType : - type.flags & 4 ? zeroType : - type.flags & 8 || type === falseType ? falseType : - type.flags & (2048 | 4096 | 8192) || - type.flags & 32 && type.value === "" || - type.flags & 64 && type.value === 0 ? type : + return type.flags & 4 ? emptyStringType : + type.flags & 8 ? zeroType : + type.flags & 16 || type === falseType ? falseType : + type.flags & (4096 | 8192 | 16384) || + type.flags & 64 && type.value === "" || + type.flags & 128 && type.value === 0 ? type : neverType; } function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (4096 | 8192); + var missing = (flags & ~type.flags) & (8192 | 16384); return missing === 0 ? type : - missing === 4096 ? getUnionType([type, undefinedType]) : - missing === 8192 ? getUnionType([type, nullType]) : + missing === 8192 ? getUnionType([type, undefinedType]) : + missing === 16384 ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type) { ts.Debug.assert(strictNullChecks); - return type.flags & 4096 ? type : getUnionType([type, undefinedType]); + return type.flags & 8192 ? type : getUnionType([type, undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { @@ -32402,7 +32612,7 @@ var ts; return members; } function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && type.flags & 8388608)) { + if (!(isObjectLiteralType(type) && type.flags & 33554432)) { return type; } var regularType = type.regularType; @@ -32412,7 +32622,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~8388608; + regularNew.flags = resolved.flags & ~33554432; regularNew.objectFlags |= 128; type.regularType = regularNew; return regularNew; @@ -32492,16 +32702,16 @@ var ts; return getWidenedTypeWithContext(type, undefined); } function getWidenedTypeWithContext(type, context) { - if (type.flags & 50331648) { - if (type.flags & 12288) { + if (type.flags & 402653184) { + if (type.flags & 24576) { return anyType; } if (isObjectLiteralType(type)) { return getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 131072) { + if (type.flags & 262144) { var unionContext_1 = context || createWideningContext(undefined, undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 12288 ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 24576 ? t : getWidenedTypeWithContext(t, unionContext_1); }); return getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 : 1); } if (isArrayType(type) || isTupleType(type)) { @@ -32512,8 +32722,8 @@ var ts; } function reportWideningErrorsInType(type) { var errorReported = false; - if (type.flags & 16777216) { - if (type.flags & 131072) { + if (type.flags & 134217728) { + if (type.flags & 262144) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -32538,7 +32748,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 16777216) { + if (t.flags & 134217728) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -32553,33 +32763,33 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 199: + case 200: + case 152: case 151: - case 150: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 148: + case 149: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 181: + case 182: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 233: + case 234: + case 154: case 153: - case 152: - case 155: case 156: - case 191: + case 157: case 192: + case 193: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 176: + case 177: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -32588,7 +32798,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && noImplicitAny && type.flags & 16777216) { + if (produceDiagnostics && noImplicitAny && type.flags & 134217728) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -32657,25 +32867,25 @@ var ts; } function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - return !!(type.flags & 7897088 || + return !!(type.flags & 15794176 || objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 2048 | 32) || objectFlags & 32 || - type.flags & 393216 && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 786432 && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { - type.couldContainTypeVariables = ts.forEach(type.types, couldContainTypeVariables); + type.couldContainTypeVariables = ts.some(type.types, couldContainTypeVariables); } return type.couldContainTypeVariables; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || type.flags & 393216 && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || !!(type.flags & 786432) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); } function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 32)) { + if (!(t.flags & 64)) { return; } var name = ts.escapeLeadingUnderscores(t.value); @@ -32687,7 +32897,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfo = type.flags & 2 ? createIndexInfo(emptyObjectType, false) : undefined; + var indexInfo = type.flags & 4 ? createIndexInfo(emptyObjectType, false) : undefined; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfo, undefined); } function inferTypeForHomomorphicMappedType(source, target) { @@ -32707,7 +32917,7 @@ var ts; } for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; - if (getTypeOfSymbol(prop).flags & 67108864) { + if (getTypeOfSymbol(prop).flags & 536870912) { return undefined; } } @@ -32727,7 +32937,7 @@ var ts; return getTypeFromInference(inference); } function getUnmatchedProperty(source, target, requireOptionalProperties) { - var properties = target.flags & 262144 ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); + var properties = target.flags & 524288 ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { var targetProp = properties_5[_i]; if (requireOptionalProperties || !(targetProp.flags & 16777216)) { @@ -32774,8 +32984,8 @@ var ts; } return; } - if (source.flags & 131072 && target.flags & 131072 && !(source.flags & 256 && target.flags & 256) || - source.flags & 262144 && target.flags & 262144) { + if (source.flags & 262144 && target.flags & 262144 && !(source.flags & 512 && target.flags & 512) || + source.flags & 524288 && target.flags & 524288) { if (source === target) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -32790,7 +33000,7 @@ var ts; (matchingTypes || (matchingTypes = [])).push(t); inferFromTypes(t, t); } - else if (t.flags & (64 | 32)) { + else if (t.flags & (128 | 64)) { var b = getBaseTypeOfLiteralType(t); if (typeIdenticalToSomeType(b, target.types)) { (matchingTypes || (matchingTypes = [])).push(t, b); @@ -32802,8 +33012,8 @@ var ts; target = removeTypesFromUnionOrIntersection(target, matchingTypes); } } - if (target.flags & 1081344) { - if (source.flags & 67108864 || source === silentNeverType) { + if (target.flags & 2162688) { + if (source.flags & 536870912 || source === silentNeverType) { return; } var inference = getInferenceInfoForType(target); @@ -32823,7 +33033,7 @@ var ts; inference.candidates = ts.append(inference.candidates, candidate); } } - if (!(priority & 8) && target.flags & 32768 && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 8) && target.flags & 65536 && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; } } @@ -32844,12 +33054,12 @@ var ts; } } } - else if (source.flags & 524288 && target.flags & 524288) { + else if (source.flags & 1048576 && target.flags & 1048576) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 2) && target.flags & 524288) { + else if ((isLiteralType(source) || source.flags & 4) && target.flags & 1048576) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; var savePriority = priority; @@ -32858,17 +33068,17 @@ var ts; priority = savePriority; contravariant = !contravariant; } - else if (source.flags & 1048576 && target.flags & 1048576) { + else if (source.flags & 2097152 && target.flags & 2097152) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 2097152 && target.flags & 2097152) { + else if (source.flags & 4194304 && target.flags & 4194304) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } - else if (target.flags & 393216) { + else if (target.flags & 786432) { var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; @@ -32889,7 +33099,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 131072) { + else if (source.flags & 262144) { var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { var sourceType = sourceTypes_3[_e]; @@ -32897,16 +33107,16 @@ var ts; } } else { - if (!(priority & 32 && source.flags & (262144 | 7897088))) { + if (!(priority & 32 && source.flags & (524288 | 15794176))) { source = getApparentType(source); } - if (source.flags & (65536 | 262144)) { + if (source.flags & (131072 | 524288)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; } (visited || (visited = ts.createMap())).set(key, true); - var isNonConstructorObject = target.flags & 65536 && + var isNonConstructorObject = target.flags & 131072 && !(ts.getObjectFlags(target) & 16 && target.symbol && target.symbol.flags & 32); var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { @@ -32934,7 +33144,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 1081344) { + if (type.flags & 2162688) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { var inference = inferences_1[_i]; if (type === inference.typeParameter) { @@ -32951,7 +33161,7 @@ var ts; } if (ts.getObjectFlags(target) & 32) { var constraintType = getConstraintTypeFromMappedType(target); - if (constraintType.flags & 524288) { + if (constraintType.flags & 1048576) { var inference = getInferenceInfoForType(constraintType.type); if (inference && !inference.isFixed) { var inferredType = inferTypeForHomomorphicMappedType(source, target); @@ -32964,7 +33174,7 @@ var ts; } return; } - if (constraintType.flags & 32768) { + if (constraintType.flags & 65536) { var savePriority = priority; priority |= 4; inferFromTypes(getIndexType(source), constraintType); @@ -33048,11 +33258,11 @@ var ts; reducedTypes.push(t); } } - return type.flags & 131072 ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 262144 ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return constraint && maybeTypeOfKind(constraint, 16382 | 524288); + return !!constraint && maybeTypeOfKind(constraint, 32764 | 1048576); } function isObjectLiteralType(type) { return !!(ts.getObjectFlags(type) & 128); @@ -33072,10 +33282,12 @@ var ts; } function getCovariantInference(inference, context, signature) { var candidates = widenObjectLiteralCandidates(inference.candidates); - var widenLiteralTypes = inference.topLevel && - !hasPrimitiveConstraint(inference.typeParameter) && + var primitiveConstraint = hasPrimitiveConstraint(inference.typeParameter); + var widenLiteralTypes = !primitiveConstraint && inference.topLevel && (inference.isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), inference.typeParameter)); - var baseCandidates = widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) : candidates; + var baseCandidates = primitiveConstraint ? ts.sameMap(candidates, getRegularTypeOfLiteralType) : + widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) : + candidates; var unwidenedType = context.flags & 1 || inference.priority & 28 ? getUnionType(baseCandidates, 2) : getCommonSupertype(baseCandidates); @@ -33089,7 +33301,7 @@ var ts; if (signature) { if (inference.candidates) { inferredType = getCovariantInference(inference, context, signature); - if (inferredType.flags & 16384 && inference.contraCandidates) { + if (inferredType.flags & 32768 && inference.contraCandidates) { inferredType = getContravariantInference(inference); } } @@ -33142,7 +33354,7 @@ var ts; return links.resolvedSymbol; } function isInTypeQuery(node) { - return !!ts.findAncestor(node, function (n) { return n.kind === 164 ? true : n.kind === 71 || n.kind === 145 ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 165 ? true : n.kind === 71 || n.kind === 146 ? false : "quit"; }); } function getFlowCacheKey(node) { if (node.kind === 71) { @@ -33152,13 +33364,13 @@ var ts; if (node.kind === 99) { return "0"; } - if (node.kind === 184) { + if (node.kind === 185) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 181) { + if (node.kind === 182) { var container = node.parent.parent; - var key = container.kind === 181 ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 182 ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -33166,12 +33378,13 @@ var ts; return undefined; } function getBindingElementNameText(element) { - if (element.parent.kind === 179) { + var parent = element.parent; + if (parent.kind === 180) { var name = element.propertyName || element.name; switch (name.kind) { case 71: return ts.idText(name); - case 146: + case 147: return ts.isStringOrNumericLiteral(name.expression) ? name.expression.text : undefined; case 9: case 8: @@ -33181,41 +33394,41 @@ var ts; } } else { - return "" + element.parent.elements.indexOf(element); + return "" + parent.elements.indexOf(element); } } function isMatchingReference(source, target) { switch (source.kind) { case 71: return target.kind === 71 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 231 || target.kind === 181) && + (target.kind === 232 || target.kind === 182) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99: return target.kind === 99; case 97: return target.kind === 97; - case 184: - return target.kind === 184 && + case 185: + return target.kind === 185 && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 181: - if (target.kind !== 184) + case 182: + if (target.kind !== 185) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 181 && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 182 && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 231) { + if (source.parent.parent.kind === 232) { var maybeId = source.parent.parent.initializer; - return maybeId && isMatchingReference(maybeId, t.expression); + return !!maybeId && isMatchingReference(maybeId, t.expression); } } return false; } function containsMatchingReference(source, target) { - while (source.kind === 184) { + while (source.kind === 185) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -33224,7 +33437,7 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 184 && + return target.kind === 185 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -33232,18 +33445,18 @@ var ts; if (expr.kind === 71) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 184) { + if (expr.kind === 185) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } return undefined; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 131072) { + if (type && type.flags & 262144) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && ts.getCheckFlags(prop) & 2) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.checkFlags & 32 && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = !!(prop.checkFlags & 32) && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -33276,7 +33489,7 @@ var ts; } } } - if (callExpression.expression.kind === 184 && + if (callExpression.expression.kind === 185 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -33290,7 +33503,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 131072)) { + if (!(source.flags & 262144)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -33303,11 +33516,11 @@ var ts; } function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 16384) { + if (assignedType.flags & 32768) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (!(reducedType.flags & 16384)) { + if (!(reducedType.flags & 32768)) { return reducedType; } } @@ -33328,53 +33541,53 @@ var ts; } function getTypeFacts(type) { var flags = type.flags; - if (flags & 2) { + if (flags & 4) { return strictNullChecks ? 4079361 : 4194049; } - if (flags & 32) { + if (flags & 64) { var isEmpty = type.value === ""; return strictNullChecks ? isEmpty ? 3030785 : 1982209 : isEmpty ? 3145473 : 4194049; } - if (flags & (4 | 16)) { + if (flags & (8 | 32)) { return strictNullChecks ? 4079234 : 4193922; } - if (flags & 64) { + if (flags & 128) { var isZero = type.value === 0; return strictNullChecks ? isZero ? 3030658 : 1982082 : isZero ? 3145346 : 4193922; } - if (flags & 8) { + if (flags & 16) { return strictNullChecks ? 4078980 : 4193668; } - if (flags & 136) { + if (flags & 272) { return strictNullChecks ? type === falseType ? 3030404 : 1981828 : type === falseType ? 3145092 : 4193668; } - if (flags & 65536) { + if (flags & 131072) { return isFunctionObjectType(type) ? strictNullChecks ? 1970144 : 4181984 : strictNullChecks ? 1972176 : 4184016; } - if (flags & (2048 | 4096)) { + if (flags & (4096 | 8192)) { return 2457472; } - if (flags & 8192) { + if (flags & 16384) { return 2340752; } - if (flags & 1536) { + if (flags & 3072) { return strictNullChecks ? 1981320 : 4193160; } - if (flags & 134217728) { + if (flags & 16777216) { return strictNullChecks ? 1972176 : 4184016; } - if (flags & 7897088) { + if (flags & 15794176) { return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } - if (flags & 393216) { + if (flags & 786432) { return getTypeFactsOfTypes(type.types); } return 4194303; @@ -33394,26 +33607,26 @@ var ts; return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || isNumericLiteralName(text) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || - unknownType; + errorType; } function getTypeOfDestructuredArrayElement(type, index) { return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || checkIteratedTypeOrElementType(type, undefined, false, false) || - unknownType; + errorType; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(type, undefined, false, false) || unknownType); + return createArrayType(checkIteratedTypeOrElementType(type, undefined, false, false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 182 && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 269 && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 183 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 270 && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 199 && parent.parent.left === parent || - parent.parent.kind === 221 && parent.parent.initializer === parent; + return parent.parent.kind === 200 && parent.parent.left === parent || + parent.parent.kind === 222 && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -33430,29 +33643,29 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 220: - return stringType; case 221: - return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || unknownType; - case 199: + return stringType; + case 222: + return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; + case 200: return getAssignedTypeOfBinaryExpression(parent); - case 193: + case 194: return undefinedType; - case 182: + case 183: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 203: + case 204: return getAssignedTypeOfSpreadExpression(parent); - case 269: - return getAssignedTypeOfPropertyAssignment(parent); case 270: + return getAssignedTypeOfPropertyAssignment(parent); + case 271: return getAssignedTypeOfShorthandPropertyAssignment(parent); } - return unknownType; + return errorType; } function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 179 ? + var type = pattern.kind === 180 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -33467,35 +33680,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 220) { + if (node.parent.parent.kind === 221) { return stringType; } - if (node.parent.parent.kind === 221) { - return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || unknownType; + if (node.parent.parent.kind === 222) { + return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } - return unknownType; + return errorType; } function getInitialType(node) { - return node.kind === 231 ? + return node.kind === 232 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 231 || node.kind === 181 ? + return node.kind === 232 || node.kind === 182 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 231 && node.initializer && + return node.kind === 232 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 181 && node.parent.kind === 199 && + node.kind !== 182 && node.parent.kind === 200 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 190: + case 191: return getReferenceCandidate(node.expression); - case 199: + case 200: switch (node.operatorToken.kind) { case 58: return getReferenceCandidate(node.left); @@ -33507,13 +33720,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 190 || - parent.kind === 199 && parent.operatorToken.kind === 58 && parent.left === node || - parent.kind === 199 && parent.operatorToken.kind === 26 && parent.right === node ? + return parent.kind === 191 || + parent.kind === 200 && parent.operatorToken.kind === 58 && parent.left === node || + parent.kind === 200 && parent.operatorToken.kind === 26 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 265) { + if (clause.kind === 266) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -33530,13 +33743,13 @@ var ts; return links.switchTypes; } function eachTypeContainedIn(source, types) { - return source.flags & 131072 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 262144 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 131072 && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 262144 && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 131072) { + if (source.flags & 262144) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -33545,27 +33758,27 @@ var ts; } return true; } - if (source.flags & 256 && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 512 && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 131072 ? ts.forEach(type.types, f) : f(type); + return type.flags & 262144 ? ts.forEach(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 131072) { + if (type.flags & 262144) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 268435456); + return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 67108864); } return f(type) ? type : neverType; } function mapType(type, mapper, noReductions) { - if (type.flags & 16384) { + if (type.flags & 32768) { return type; } - if (!(type.flags & 131072)) { + if (!(type.flags & 262144)) { return mapper(type); } var types = type.types; @@ -33592,11 +33805,11 @@ var ts; return filterType(type, function (t) { return (t.flags & kind) !== 0; }); } function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 32) || - isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64)) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 2 ? extractTypesOfKind(typeWithLiterals, 2 | 32) : - t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 64) : + return t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 64) : + t.flags & 8 ? extractTypesOfKind(typeWithLiterals, 8 | 128) : t; }); } @@ -33624,9 +33837,9 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 16384 ? + return elementType.flags & 32768 ? autoArrayType : - createArrayType(elementType.flags & 131072 ? + createArrayType(elementType.flags & 262144 ? getUnionType(elementType.types, 2) : elementType); } @@ -33643,7 +33856,7 @@ var ts; var hasEvolvingArrayType = false; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var t = types_14[_i]; - if (!(t.flags & 16384)) { + if (!(t.flags & 32768)) { if (!(ts.getObjectFlags(t) & 256)) { return false; } @@ -33660,15 +33873,15 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 184 && (parent.name.escapedText === "length" || - parent.parent.kind === 186 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 185 && + var isLengthPushOrUnshift = parent.kind === 185 && (parent.name.escapedText === "length" || + parent.parent.kind === 187 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 186 && parent.expression === root && - parent.parent.kind === 199 && + parent.parent.kind === 200 && parent.parent.operatorToken.kind === 58 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 84); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 168); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -33683,7 +33896,7 @@ var ts; var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); - return apparentType !== unknownType && ts.some(getSignaturesOfType(apparentType, 0), signatureHasTypePredicate); + return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0), signatureHasTypePredicate); } } return false; @@ -33699,16 +33912,16 @@ var ts; var key; var flowDepth = 0; if (flowAnalysisDisabled) { - return unknownType; + return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 142575359)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 33492479)) { return declaredType; } var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 208 && getTypeWithFacts(resultType, 524288).flags & 16384) { + if (reference.parent && reference.parent.kind === 209 && getTypeWithFacts(resultType, 524288).flags & 32768) { return declaredType; } return resultType; @@ -33716,7 +33929,7 @@ var ts; if (flowDepth === 2500) { flowAnalysisDisabled = true; reportFlowControlError(reference); - return unknownType; + return errorType; } flowDepth++; while (true) { @@ -33770,7 +33983,7 @@ var ts; } else if (flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 184 && reference.kind !== 99) { + if (container && container !== flowContainer && reference.kind !== 185 && reference.kind !== 99) { flow = container.flowNode; continue; } @@ -33802,7 +34015,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 131072) { + if (declaredType.flags & 262144) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); } return declaredType; @@ -33815,7 +34028,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 186 ? + var expr = node.kind === 187 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -33823,7 +34036,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 186) { + if (node.kind === 187) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -33831,7 +34044,7 @@ var ts; } else { var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 84)) { + if (isTypeAssignableToKind(indexType, 168)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -33845,7 +34058,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 16384) { + if (type.flags & 32768) { return flowType; } var assumeTrue = (flow.flags & 32) !== 0; @@ -33855,7 +34068,7 @@ var ts; return flowType; } var incomplete = isIncomplete(flowType); - var resultType = incomplete && narrowedType.flags & 16384 ? silentNeverType : narrowedType; + var resultType = incomplete && narrowedType.flags & 32768 ? silentNeverType : narrowedType; return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { @@ -33947,8 +34160,8 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 184 && - computedType.flags & 131072 && + return expr.kind === 185 && + computedType.flags & 262144 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); } @@ -33981,7 +34194,7 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if ((type.flags & (131072 | 65536)) || (type.flags & 32768 && type.isThisType)) { + if ((type.flags & (262144 | 131072)) || (type.flags & 65536 && type.isThisType)) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); }); } @@ -33998,10 +34211,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 194 && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 195 && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 194 && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 195 && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -34041,24 +34254,24 @@ var ts; assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (valueType.flags & 12288) { + if (valueType.flags & 24576) { if (!strictNullChecks) { return type; } var doubleEquals = operator === 32 || operator === 33; var facts = doubleEquals ? assumeTrue ? 65536 : 524288 : - valueType.flags & 8192 ? + valueType.flags & 16384 ? assumeTrue ? 32768 : 262144 : assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); } - if (type.flags & 134283777) { + if (type.flags & 16909315) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 16384 ? type : replacePrimitivesWithLiterals(narrowedType, valueType); + return narrowedType.flags & 32768 ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -34077,13 +34290,16 @@ var ts; if (operator === 33 || operator === 35) { assumeTrue = !assumeTrue; } - if (assumeTrue && !(type.flags & 131072)) { - var targetType = typeofTypesByName.get(literal.text); + if (type.flags & 1 && literal.text === "function") { + return type; + } + if (assumeTrue && !(type.flags & 262144)) { + var targetType = literal.text === "function" ? globalFunctionType : typeofTypesByName.get(literal.text); if (targetType) { if (isTypeSubtypeOf(targetType, type)) { return targetType; } - if (type.flags & 7897088) { + if (type.flags & 15794176) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(targetType, constraint)) { return getIntersectionType([type, targetType]); @@ -34104,13 +34320,13 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 16384 ? neverType : + var caseType = discriminantType.flags & 32768 ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); - return caseType.flags & 16384 ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 32768 ? defaultType : getUnionType([caseType, defaultType]); } function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); @@ -34156,9 +34372,9 @@ var ts; if (!assumeTrue) { return filterType(type, function (t) { return !isRelated(t, candidate); }); } - if (type.flags & 131072) { + if (type.flags & 262144) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 16384)) { + if (!(assignableType.flags & 32768)) { return assignableType; } } @@ -34192,7 +34408,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 185 || invokedExpression.kind === 184) { + if (invokedExpression.kind === 186 || invokedExpression.kind === 185) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -34210,15 +34426,15 @@ var ts; case 71: case 99: case 97: - case 184: + case 185: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 186: + case 187: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 190: + case 191: return narrowType(type, expr.expression, assumeTrue); - case 199: + case 200: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 197: + case 198: if (expr.operator === 51) { return narrowType(type, expr.operand, !assumeTrue); } @@ -34245,9 +34461,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 239 || - node.kind === 273 || - node.kind === 151; + node.kind === 240 || + node.kind === 274 || + node.kind === 152; }); } function isParameterAssigned(symbol) { @@ -34268,7 +34484,7 @@ var ts; if (node.kind === 71) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 148) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 149) { symbol.isAssigned = true; } } @@ -34282,21 +34498,21 @@ var ts; } function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 148 && + declaration.kind === 149 && declaration.initializer && - getFalsyFlags(declaredType) & 4096 && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 4096); + getFalsyFlags(declaredType) & 8192 && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 8192); return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072) : declaredType; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 184 || + return parent.kind === 185 || + parent.kind === 187 && parent.expression === node || parent.kind === 186 && parent.expression === node || - parent.kind === 185 && parent.expression === node || - parent.kind === 181 && parent.name === node && !!parent.initializer; + parent.kind === 182 && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { - return type.flags & 7372800 && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 12288); + return type.flags & 14745600 && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576); } function getConstraintForLocation(type, node) { if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) { @@ -34312,12 +34528,12 @@ var ts; function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { - return unknownType; + return errorType; } if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 192) { + if (container.kind === 193) { 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.hasModifier(container, 256)) { @@ -34333,7 +34549,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var declaration = localOrExportSymbol.valueDeclaration; if (localOrExportSymbol.flags & 32) { - if (declaration.kind === 234 + if (declaration.kind === 235 && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -34345,11 +34561,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 204) { + else if (declaration.kind === 205) { var container = ts.getThisContainer(node, false); - while (container !== undefined) { + while (container.kind !== 274) { if (container.parent === declaration) { - if (container.kind === 151 && ts.hasModifier(container, 32)) { + if (container.kind === 152 && ts.hasModifier(container, 32)) { getNodeLinks(declaration).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -34366,11 +34582,11 @@ var ts; if (!(localOrExportSymbol.flags & 3) && !(ts.isInJavaScriptFile(node) && localOrExportSymbol.flags & 512)) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); - return unknownType; + return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(symbol)); - return unknownType; + return errorType; } } var isAlias = localOrExportSymbol.flags & 2097152; @@ -34388,21 +34604,21 @@ var ts; if (!declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 148; + var isParameter = ts.getRootDeclaration(declaration).kind === 149; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; var isSpreadDestructuringAsignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); - while (flowContainer !== declarationContainer && (flowContainer.kind === 191 || - flowContainer.kind === 192 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 192 || + flowContainer.kind === 193 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAsignmentTarget || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || - isInTypeQuery(node) || node.parent.kind === 251) || - node.parent.kind === 208 || - declaration.kind === 231 && declaration.exclamationToken || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3) !== 0 || + isInTypeQuery(node) || node.parent.kind === 252) || + node.parent.kind === 209 || + declaration.kind === 232 && declaration.exclamationToken || declaration.flags & 4194304; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -34417,7 +34633,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 4096) && getFalsyFlags(flowType) & 4096) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 8192) && getFalsyFlags(flowType) & 8192) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); return type; } @@ -34429,7 +34645,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 268) { + symbol.valueDeclaration.parent.kind === 269) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -34447,8 +34663,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 219 && - ts.getAncestor(symbol.valueDeclaration, 232).parent === container && + if (container.kind === 220 && + ts.getAncestor(symbol.valueDeclaration, 233).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -34460,14 +34676,14 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 190) { + while (current.parent.kind === 191) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 197 || current.parent.kind === 198)) { + else if ((current.parent.kind === 198 || current.parent.kind === 199)) { var expr = current.parent; isAssigned = expr.operator === 43 || expr.operator === 44; } @@ -34478,7 +34694,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 151 || container.kind === 154) { + if (container.kind === 152 || container.kind === 155) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -34522,32 +34738,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 154) { + if (container.kind === 155) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 192) { + if (container.kind === 193) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 238: + case 239: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 237: + case 238: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 154: + case 155: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 152: case 151: - case 150: if (ts.hasModifier(container, 32)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 146: + case 147: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -34564,8 +34780,8 @@ var ts; if (container === void 0) { container = ts.getThisContainer(node, false); } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 191 && - container.parent.kind === 199 && + if (container.kind === 192 && + container.parent.kind === 200 && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent .left @@ -34588,14 +34804,14 @@ var ts; } if (ts.isInJavaScriptFile(node)) { var type = getTypeForThisExpressionFromJSDoc(container); - if (type && type !== unknownType) { + if (type && type !== errorType) { return getFlowTypeOfReference(node, type); } } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 283) { + if (jsdocType && jsdocType.kind === 284) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -34605,14 +34821,14 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 148; }); + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 186 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 187 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 192) { + while (container && container.kind === 193) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -34620,22 +34836,22 @@ var ts; var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; if (!canUseSuperExpression) { - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 146; }); - if (current && current.kind === 146) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 147; }); + if (current && current.kind === 147) { 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 === 183)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 184)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); } - return unknownType; + return errorType; } - if (!isCallExpression && container.kind === 154) { + if (!isCallExpression && container.kind === 155) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.hasModifier(container, 32) || isCallExpression) { @@ -34645,7 +34861,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 153 && ts.hasModifier(container, 256)) { + if (container.kind === 154 && ts.hasModifier(container, 256)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -34656,10 +34872,10 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 183) { + if (container.parent.kind === 184) { 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 unknownType; + return errorType; } else { return anyType; @@ -34668,16 +34884,16 @@ var ts; var classLikeDeclaration = container.parent; if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); - return unknownType; + return errorType; } var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classLikeDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; if (!baseClassType) { - return unknownType; + return errorType; } - if (container.kind === 154 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 155 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); - return unknownType; + return errorType; } return nodeCheckFlag === 512 ? getBaseConstructorTypeOfClass(classType) @@ -34687,24 +34903,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 154; + return container.kind === 155; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 183) { + if (ts.isClassLike(container.parent) || container.parent.kind === 184) { if (ts.hasModifier(container, 32)) { - return container.kind === 153 || - container.kind === 152 || - container.kind === 155 || - container.kind === 156; + return container.kind === 154 || + container.kind === 153 || + container.kind === 156 || + container.kind === 157; } else { - return container.kind === 153 || - container.kind === 152 || - container.kind === 155 || + return container.kind === 154 || + container.kind === 153 || container.kind === 156 || + container.kind === 157 || + container.kind === 152 || container.kind === 151 || - container.kind === 150 || - container.kind === 154; + container.kind === 155; } } } @@ -34712,10 +34928,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 153 || - func.kind === 155 || - func.kind === 156) && func.parent.kind === 183 ? func.parent : - func.kind === 191 && func.parent.kind === 269 ? func.parent.parent : + return (func.kind === 154 || + func.kind === 156 || + func.kind === 157) && func.parent.kind === 184 ? func.parent : + func.kind === 192 && func.parent.kind === 270 ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -34723,11 +34939,11 @@ var ts; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 262144 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 524288 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 192) { + if (func.kind === 193) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -34751,7 +34967,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 269) { + if (literal.parent.kind !== 270) { break; } literal = literal.parent.parent; @@ -34760,9 +34976,9 @@ var ts; return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); } var parent = func.parent; - if (parent.kind === 199 && parent.operatorToken.kind === 58) { + if (parent.kind === 200 && parent.operatorToken.kind === 58) { var target = parent.left; - if (target.kind === 184 || target.kind === 185) { + if (target.kind === 185 || target.kind === 186) { var expression = target.expression; if (inJs && ts.isIdentifier(expression)) { var sourceFile = ts.getSourceFileOfNode(parent); @@ -34815,7 +35031,7 @@ var ts; if (funcHasRestParameters && indexOfParameter === (func.parameters.length - 1) && isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); + return getTypeOfSymbol(ts.last(contextualSignature.parameters)); } } } @@ -34826,7 +35042,7 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 148) { + if (declaration.kind === 149) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -34838,7 +35054,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 181) { + if (parentDeclaration.kind !== 182) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -34892,7 +35108,7 @@ var ts; return false; } function getContextualReturnType(functionDecl) { - if (functionDecl.kind === 154 || + if (functionDecl.kind === 155 || ts.getEffectiveReturnTypeNode(functionDecl) || isGetAccessorWithAnnotatedSetAccessor(functionDecl)) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); @@ -34913,7 +35129,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 188) { + if (template.parent.kind === 189) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -34926,7 +35142,7 @@ var ts; return node === right && isContextSensitiveAssignment(binaryExpression) ? getTypeOfExpression(left) : undefined; case 54: var type = getContextualType(binaryExpression); - return !type && node === right && !ts.getDeclaredJavascriptInitializer(binaryExpression.parent) && !ts.getAssignedJavascriptInitializer(binaryExpression) ? + return !type && node === right && !ts.isDefaultedJavascriptInitializer(binaryExpression) ? getTypeOfExpression(left) : type; case 53: case 26: @@ -34949,12 +35165,12 @@ var ts; case 6: return false; default: - ts.Debug.assertNever(kind); + return ts.Debug.assertNever(kind); } } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 458752 ? getPropertyOfType(t, name) : undefined; + var prop = t.flags & 917504 ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }, true); } @@ -34962,7 +35178,7 @@ var ts; return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }, true); } function contextualTypeIsTupleLikeType(type) { - return !!(type.flags & 131072 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); + return !!(type.flags & 262144 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } function getContextualTypeForObjectLiteralMethod(node) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); @@ -35021,10 +35237,26 @@ var ts; return getContextualType(attribute.parent); } } + function isPossiblyDiscriminantValue(node) { + switch (node.kind) { + case 9: + case 8: + case 13: + case 101: + case 86: + case 95: + case 71: + return true; + case 185: + case 191: + return isPossiblyDiscriminantValue(node.expression); + } + return false; + } function getApparentTypeOfContextualType(node) { var contextualType = getContextualType(node); contextualType = contextualType && mapType(contextualType, getApparentType); - if (!(contextualType && contextualType.flags & 131072 && ts.isObjectLiteralExpression(node))) { + if (!(contextualType && contextualType.flags & 262144 && ts.isObjectLiteralExpression(node))) { return contextualType; } var match; @@ -35032,10 +35264,10 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 269) + if (prop.kind !== 270) continue; - if (isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { - var discriminatingType = getTypeOfNode(prop.initializer); + if (isPossiblyDiscriminantValue(prop.initializer) && isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { + var discriminatingType = checkExpression(prop.initializer); for (var _b = 0, _c = contextualType.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, prop.symbol.escapedName); @@ -35062,58 +35294,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 231: - case 148: + case 232: + case 149: + case 152: case 151: - case 150: - case 181: + case 182: return getContextualTypeForInitializerExpression(node); - case 192: - case 224: + case 193: + case 225: return getContextualTypeForReturnExpression(node); - case 202: + case 203: return getContextualTypeForYieldOperand(parent); - case 186: case 187: + case 188: return getContextualTypeForArgument(parent, node); - case 189: - case 207: + case 190: + case 208: return getTypeFromTypeNode(parent.type); - case 199: + case 200: return getContextualTypeForBinaryOperand(node); - case 269: case 270: - return getContextualTypeForObjectLiteralElement(parent); case 271: + return getContextualTypeForObjectLiteralElement(parent); + case 272: return getApparentTypeOfContextualType(parent.parent); - case 182: { + case 183: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 200: + case 201: return getContextualTypeForConditionalOperand(node); - case 210: - ts.Debug.assert(parent.parent.kind === 201); + case 211: + ts.Debug.assert(parent.parent.kind === 202); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 190: { + case 191: { var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 264: + case 265: return getContextualTypeForJsxExpression(parent); - case 261: - case 263: + case 262: + case 264: return getContextualTypeForJsxAttribute(parent); + case 257: case 256: - case 255: return getContextualJsxElementAttributesType(parent); } return undefined; } function getContextualMapper(node) { - node = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); - return node ? node.contextualMapper : identityMapper; + var ancestor = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); + return ancestor ? ancestor.contextualMapper : identityMapper; } function getContextualJsxElementAttributesType(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { @@ -35127,12 +35359,12 @@ var ts; return mapType(valueType, function (t) { return getJsxSignaturesParameterTypes(t, isJs, node); }); } function getJsxSignaturesParameterTypes(valueType, isJs, context) { - if (valueType.flags & 2) { + if (valueType.flags & 4) { return anyType; } - else if (valueType.flags & 32) { + else if (valueType.flags & 64) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, context); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { var stringLiteralTypeName = valueType.value; var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); if (intrinsicProp) { @@ -35151,7 +35383,7 @@ var ts; signatures = getSignaturesOfType(valueType, 0); ctor = false; if (signatures.length === 0) { - return unknownType; + return errorType; } } var links = getNodeLinks(context); @@ -35172,7 +35404,7 @@ var ts; function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); - if (intrinsicAttribs !== unknownType) { + if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); } return propsType; @@ -35200,7 +35432,7 @@ var ts; else { var apparentAttributesType = attributesType; var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context); - if (intrinsicClassAttribs !== unknownType) { + if (intrinsicClassAttribs !== errorType) { var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol); var hostClassType = getReturnTypeOfSignature(sig); apparentAttributesType = intersectTypes(typeParams @@ -35208,7 +35440,7 @@ var ts; : intrinsicClassAttribs, apparentAttributesType); } var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); - if (intrinsicAttribs !== unknownType) { + if (intrinsicAttribs !== errorType) { apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType); } return apparentAttributesType; @@ -35238,7 +35470,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 191 || node.kind === 192; + return node.kind === 192 || node.kind === 193; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -35251,7 +35483,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 153 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 || ts.isObjectLiteralMethod(node)); var type; if (ts.isInJavaScriptFile(node)) { var jsdoc = ts.getJSDocType(node); @@ -35265,7 +35497,7 @@ var ts; if (!type) { return undefined; } - if (!(type.flags & 131072)) { + if (!(type.flags & 262144)) { return getContextualCallSignature(type, node); } var signatureList; @@ -35300,8 +35532,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false, false); } function hasDefaultValue(node) { - return (node.kind === 181 && !!node.initializer) || - (node.kind === 199 && node.operatorToken.kind === 58); + return (node.kind === 182 && !!node.initializer) || + (node.kind === 200 && node.operatorToken.kind === 58); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; @@ -35311,7 +35543,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); for (var index = 0; index < elements.length; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 203) { + if (inDestructuringPattern && e.kind === 204) { var restArrayType = checkExpression(e.expression, checkMode); var restElementType = getIndexTypeOfType(restArrayType, 1) || getIteratedTypeOrElementType(restArrayType, undefined, false, false, false); @@ -35324,7 +35556,7 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 203; + hasSpreadElement = hasSpreadElement || e.kind === 204; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -35334,7 +35566,7 @@ var ts; } if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 180 || pattern.kind === 182)) { + if (pattern && (pattern.kind === 181 || pattern.kind === 183)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -35342,7 +35574,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 205) { + if (patternElement.kind !== 206) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); @@ -35360,7 +35592,7 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 146: + case 147: return isNumericComputedName(name); case 71: return isNumericLiteralName(name.escapedText); @@ -35372,7 +35604,7 @@ var ts; } } function isNumericComputedName(name) { - return isTypeAssignableToKind(checkComputedPropertyName(name), 84); + return isTypeAssignableToKind(checkComputedPropertyName(name), 168); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -35384,8 +35616,8 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (links.resolvedType.flags & 12288 || - !isTypeAssignableToKind(links.resolvedType, 34 | 84 | 1536) && + if (links.resolvedType.flags & 24576 || + !isTypeAssignableToKind(links.resolvedType, 68 | 168 | 3072) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -35411,22 +35643,25 @@ var ts; var propertiesTable; var propertiesArray = []; var spread = emptyObjectType; - var propagatedFlags = 8388608; + var propagatedFlags = 33554432; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 179 || contextualType.pattern.kind === 183); + (contextualType.pattern.kind === 180 || contextualType.pattern.kind === 184); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; var hasComputedNumberProperty = false; - if (isInJSFile && node.properties.length === 0) { - var symbol = getSymbolOfNode(node); - if (symbol.exports) { - propertiesTable = symbol.exports; - symbol.exports.forEach(function (symbol) { return propertiesArray.push(getMergedSymbol(symbol)); }); - return createObjectLiteralType(); + if (isInJSFile) { + var decl = ts.getDeclarationOfJSInitializer(node); + if (decl) { + var symbol = getMergedSymbol(decl.symbol); + if (symbol && ts.hasEntries(symbol.exports)) { + propertiesTable = symbol.exports; + symbol.exports.forEach(function (symbol) { return propertiesArray.push(getMergedSymbol(symbol)); }); + return createObjectLiteralType(); + } } } propertiesTable = ts.createSymbolTable(); @@ -35434,13 +35669,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 146 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 147 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 269 || - memberDecl.kind === 270 || + if (memberDecl.kind === 270 || + memberDecl.kind === 271 || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 269 ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 270 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 270 ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 271 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -35450,7 +35685,7 @@ var ts; } } typeFlags |= type.flags; - var nameType = computedNameType && computedNameType.flags & 1120 ? + var nameType = computedNameType && computedNameType.flags & 2240 ? computedNameType : undefined; var prop = nameType ? createSymbol(4 | member.flags, getLateBoundNameFromType(nameType), 1024) : @@ -35459,8 +35694,8 @@ var ts; prop.nameType = nameType; } if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 269 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 270 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 270 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 271 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216; } @@ -35483,7 +35718,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 271) { + else if (memberDecl.kind === 272) { if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } @@ -35498,17 +35733,17 @@ var ts; var type = checkExpression(memberDecl.expression); if (!isValidSpreadType(type)) { error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); - return unknownType; + return errorType; } spread = getSpreadType(spread, type, node.symbol, propagatedFlags, 0); offset = i + 1; continue; } else { - ts.Debug.assert(memberDecl.kind === 155 || memberDecl.kind === 156); + ts.Debug.assert(memberDecl.kind === 156 || memberDecl.kind === 157); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 1120)) { + if (computedNameType && !(computedNameType.flags & 2240)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -35549,8 +35784,8 @@ var ts; var stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0) : undefined; var numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8388608; - result.flags |= 33554432 | freshObjectLiteralFlag | (typeFlags & 117440512); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 33554432; + result.flags |= 268435456 | freshObjectLiteralFlag | (typeFlags & 939524096); result.objectFlags |= 128; if (patternWithComputedProperties) { result.objectFlags |= 512; @@ -35558,17 +35793,17 @@ var ts; if (inDestructuringPattern) { result.pattern = node; } - if (!(result.flags & 12288)) { - propagatedFlags |= (result.flags & 117440512); + if (!(result.flags & 24576)) { + propagatedFlags |= (result.flags & 939524096); } return result; } } function isValidSpreadType(type) { - return !!(type.flags & (1 | 134217728) || - getFalsyFlags(type) & 14560 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || - type.flags & 65536 && !isGenericMappedType(type) || - type.flags & 393216 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); + return !!(type.flags & (3 | 16777216) || + getFalsyFlags(type) & 29120 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || + type.flags & 131072 && !isGenericMappedType(type) || + type.flags & 786432 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } function checkJsxSelfClosingElement(node, checkMode) { checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); @@ -35598,13 +35833,13 @@ var ts; } function isJsxIntrinsicIdentifier(tagName) { switch (tagName.kind) { - case 184: + case 185: case 99: return false; case 71: return ts.isIntrinsicJsxName(tagName.escapedText); default: - ts.Debug.fail(); + return ts.Debug.fail(); } } function checkJsxAttribute(node, checkMode) { @@ -35639,7 +35874,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 263); + ts.Debug.assert(attributeDecl.kind === 264); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, 0, 4096); attributesTable = ts.createSymbolTable(); @@ -35661,7 +35896,7 @@ var ts; spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, 0, 4096); } } - var parent = openingLikeElement.parent.kind === 254 ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 255 ? openingLikeElement.parent : undefined; if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { @@ -35686,7 +35921,7 @@ var ts; return typeToIntersect || (spread === emptyObjectType ? createJsxAttributesType() : spread); function createJsxAttributesType() { var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, undefined, undefined); - result.flags |= 33554432; + result.flags |= 268435456; result.objectFlags |= 128 | 4096; return result; } @@ -35713,13 +35948,13 @@ var ts; var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); var typeSymbol = exports && getSymbol(exports, name, 67901928); - return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : unknownType; + return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } function getIntrinsicTagSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { if (!ts.isIdentifier(node.tagName)) return ts.Debug.fail(); var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText); @@ -35781,6 +36016,7 @@ var ts; return instantiatedSignatures; } function getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, reportErrors) { + if (reportErrors === void 0) { reportErrors = false; } if (!node.typeArguments) { return; } @@ -35831,7 +36067,7 @@ var ts; if (!propsType) { return undefined; } - if (propsType.flags & 262144) { + if (propsType.flags & 524288) { var propsApparentType = []; for (var _i = 0, _a = propsType.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -35842,7 +36078,7 @@ var ts; return getApparentType(propsType); } function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 131072)); + ts.Debug.assert(!(elementType.flags & 262144)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); if (jsxStatelessElementType) { @@ -35853,7 +36089,7 @@ var ts; paramType = getApparentTypeOfJsxPropsType(paramType); if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== unknownType) { + if (intrinsicAttributes !== errorType) { paramType = intersectTypes(intrinsicAttributes, paramType); } return paramType; @@ -35864,7 +36100,7 @@ var ts; return undefined; } function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 131072)); + ts.Debug.assert(!(elementType.flags & 262144)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); if (jsxStatelessElementType) { @@ -35898,7 +36134,7 @@ var ts; result = allMatchingAttributesType; } var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== unknownType) { + if (intrinsicAttributes !== errorType) { result = intersectTypes(intrinsicAttributes, result); } return result; @@ -35934,7 +36170,7 @@ var ts; return results; } function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (elementType.flags & 131072) { + if (elementType.flags & 262144) { var types = elementType.types; return getUnionType(types.map(function (type) { return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); @@ -35943,12 +36179,12 @@ var ts; if (isTypeAny(elementType)) { return elementType; } - else if (elementType.flags & 2) { + else if (elementType.flags & 4) { return anyType; } - else if (elementType.flags & 32) { + else if (elementType.flags & 64) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, openingLikeElement); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { var stringLiteralTypeName = elementType.value; var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); if (intrinsicProp) { @@ -35964,9 +36200,9 @@ var ts; } var instantiatedSignatures = getInstantiatedJsxSignatures(openingLikeElement, elementType, true); if (!ts.length(instantiatedSignatures)) { - return unknownType; + return errorType; } - var elemInstanceType = getUnionType(ts.map(instantiatedSignatures, getReturnTypeOfSignature), 2); + var elemInstanceType = getUnionType(instantiatedSignatures.map(getReturnTypeOfSignature), 2); var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) : defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType); @@ -35977,7 +36213,7 @@ var ts; checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } var isJs = ts.isInJavaScriptFile(openingLikeElement); - return getUnionType(ts.map(instantiatedSignatures, function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, true); })); + return getUnionType(instantiatedSignatures.map(function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, true); })); } function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) { ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName)); @@ -35991,7 +36227,7 @@ var ts; return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0).type; } else { - return links.resolvedJsxElementAttributesType = unknownType; + return links.resolvedJsxElementAttributesType = errorType; } } return links.resolvedJsxElementAttributesType; @@ -36022,7 +36258,7 @@ var ts; } function getJsxElementClassTypeAt(location) { var type = getJsxType(JsxNames.ElementClass, location); - if (type === unknownType) + if (type === errorType) return undefined; return type; } @@ -36073,7 +36309,7 @@ var ts; } } function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 65536) { + if (targetType.flags & 131072) { var resolved = resolveStructuredTypeMembers(targetType); if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || @@ -36082,7 +36318,7 @@ var ts; return true; } } - else if (targetType.flags & 393216) { + else if (targetType.flags & 786432) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -36146,11 +36382,11 @@ var ts; return type; } else { - return unknownType; + return errorType; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 151; + return s.valueDeclaration ? s.valueDeclaration.kind : 152; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; @@ -36167,9 +36403,9 @@ var ts; } function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 184 || node.kind === 231 ? + var errorNode = node.kind === 185 || node.kind === 232 ? node.name : - node.kind === 178 ? + node.kind === 179 ? node : node.right; if (ts.getCheckFlags(prop) & 256) { @@ -36220,7 +36456,7 @@ var ts; if (flags & 32) { return true; } - if (type.flags & 32768) { + if (type.flags & 65536) { type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); } if (!type || !hasBaseType(type, enclosingClass)) { @@ -36232,21 +36468,25 @@ var ts; function symbolHasNonMethodDeclaration(symbol) { return forEachProperty(symbol, function (prop) { var propKind = getDeclarationKindFromSymbol(prop); - return propKind !== 153 && propKind !== 152; + return propKind !== 154 && propKind !== 153; }); } function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 12288; + if (type.flags & 2) { + error(node, ts.Diagnostics.Object_is_of_type_unknown); + return errorType; + } + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 24576; if (kind) { - error(node, kind & 4096 ? kind & 8192 ? + error(node, kind & 8192 ? kind & 16384 ? (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); var t = getNonNullableType(type); - return t.flags & (12288 | 16384) ? unknownType : t; + return t.flags & (24576 | 32768) ? errorType : t; } return type; } @@ -36276,9 +36516,9 @@ var ts; var indexInfo = getIndexInfoOfType(apparentType, 0); if (!(indexInfo && indexInfo.type)) { if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, leftType.flags & 32768 && leftType.isThisType ? apparentType : leftType); + reportNonexistentProperty(right, leftType.flags & 65536 && leftType.isThisType ? apparentType : leftType); } - return unknownType; + return errorType; } if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) { error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType)); @@ -36293,14 +36533,14 @@ var ts; if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, ts.idText(right)); - return unknownType; + return errorType; } } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); } - if (node.kind !== 184 || + if (node.kind !== 185 || assignmentKind === 1 || - prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 131072)) { + prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 262144)) { return propType; } var assumeUninitialized = false; @@ -36308,13 +36548,13 @@ var ts; var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 154 && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 155 && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 4096) && getFalsyFlags(flowType) & 4096) { + if (assumeUninitialized && !(getFalsyFlags(propType) & 8192) && getFalsyFlags(flowType) & 8192) { error(right, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); return propType; } @@ -36330,8 +36570,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); } - else if (valueDeclaration.kind === 234 && - node.parent.kind !== 161 && + else if (valueDeclaration.kind === 235 && + node.parent.kind !== 162 && !(valueDeclaration.flags & 4194304) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.idText(right)); @@ -36340,9 +36580,9 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 151: + case 152: return true; - case 269: + case 270: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -36374,7 +36614,7 @@ var ts; } function reportNonexistentProperty(propNode, containingType) { var errorInfo; - if (containingType.flags & 131072 && !(containingType.flags & 16382)) { + if (containingType.flags & 262144 && !(containingType.flags & 32764)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText)) { @@ -36507,20 +36747,20 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 184: + case 185: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); - case 145: + case 146: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 178: + case 179: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 178 ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 179 ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { - var propType = getTypeOfFuncClassEnumModule(method); + var propType = getTypeOfPropertyOfType(actualThisType, method.escapedName); var signatures = getSignaturesOfType(getNonNullableType(propType), 0); ts.Debug.assert(signatures.length !== 0); return signatures.some(function (sig) { @@ -36537,16 +36777,16 @@ var ts; return instantiateType(signatureThisType, createSignatureTypeMapper(sig, getInferredTypes(context))); } function isValidPropertyAccessWithType(node, left, propertyName, type) { - if (type === unknownType || isTypeAny(type)) { + if (type === errorType || isTypeAny(type)) { return true; } var prop = getPropertyOfType(type, propertyName); return prop ? checkPropertyAccessibility(node, left, type, prop) - : ts.isInJavaScriptFile(node) && (type.flags & 131072) && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, left, propertyName, elementType); }); + : ts.isInJavaScriptFile(node) && (type.flags & 262144) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, left, propertyName, elementType); }); } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 232) { + if (initializer.kind === 233) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -36568,7 +36808,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 220 && + if (node.kind === 221 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -36586,7 +36826,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 187 && node.parent.expression === node) { + if (node.parent.kind === 188 && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -36596,26 +36836,26 @@ var ts; var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); } - return unknownType; + return errorType; } var indexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : checkExpression(indexExpression); - if (objectType === unknownType || objectType === silentNeverType) { + if (objectType === errorType || objectType === silentNeverType) { return objectType; } if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); - return unknownType; + return errorType; } return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === unknownType) { + if (expressionType === errorType) { return false; } if (!ts.isWellKnownSymbolSyntactically(expression)) { return false; } - if ((expressionType.flags & 1536) === 0) { + if ((expressionType.flags & 3072) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -36645,10 +36885,10 @@ var ts; if (callLikeExpressionMayHaveTypeArguments(node)) { ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 188) { + if (node.kind === 189) { checkExpression(node.template); } - else if (node.kind !== 149) { + else if (node.kind !== 150) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -36673,7 +36913,7 @@ var ts; var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { if (lastParent && parent === lastParent) { - index++; + index = index + 1; } else { lastParent = parent; @@ -36699,7 +36939,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 203) { + if (arg && arg.kind === 204) { return i; } } @@ -36709,17 +36949,16 @@ var ts; if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } var argCount; var typeArguments; - var callIsIncomplete; + var callIsIncomplete = false; var spreadArgIndex = -1; if (ts.isJsxOpeningLikeElement(node)) { return true; } - if (node.kind === 188) { + if (node.kind === 189) { argCount = args.length; - typeArguments = undefined; - if (node.template.kind === 201) { - var lastSpan = ts.lastOrUndefined(node.template.templateSpans); - ts.Debug.assert(lastSpan !== undefined); + typeArguments = node.typeArguments; + if (node.template.kind === 202) { + var lastSpan = ts.last(node.template.templateSpans); callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; } else { @@ -36728,13 +36967,13 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 149) { + else if (node.kind === 150) { typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); } else { if (!node.arguments) { - ts.Debug.assert(node.kind === 187); + ts.Debug.assert(node.kind === 188); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -36762,7 +37001,7 @@ var ts; (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters); } function getSingleCallSignature(type) { - if (type.flags & 65536) { + if (type.flags & 131072) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -36797,7 +37036,7 @@ var ts; inference.inferredType = undefined; } } - if (node.kind !== 149) { + if (node.kind !== 150) { var contextualType = getContextualType(node); if (contextualType) { var instantiatedType = instantiateType(contextualType, cloneTypeMapper(getContextualMapper(node))); @@ -36818,7 +37057,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 205) { + if (arg === undefined || arg.kind !== 206) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -36849,7 +37088,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (!constraint) continue; - var errorInfo = reportErrors && headMessage && (function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }); + var errorInfo = reportErrors && headMessage ? (function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }) : undefined; var typeArgumentHeadMessage = headMessage || ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; if (!mapper) { mapper = createTypeMapper(typeParameters, typeArgumentTypes); @@ -36883,12 +37122,12 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 187) { + if (thisType && thisType !== voidType && node.kind !== 188) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; 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, getThisTypeOfSignature(signature), relation, errorNode, headMessage_1)) { + if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1)) { return false; } } @@ -36896,7 +37135,7 @@ var ts; var argCount = getEffectiveArgumentCount(node, args, signature); for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); - if (arg === undefined || arg.kind !== 205) { + if (arg === undefined || arg.kind !== 206) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i) || checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined); @@ -36910,25 +37149,25 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 186) { + if (node.kind === 187) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 184 || callee.kind === 185) { + if (callee.kind === 185 || callee.kind === 186) { return callee.expression; } } } function getEffectiveCallArguments(node) { - if (node.kind === 188) { + if (node.kind === 189) { var template = node.template; var args_4 = [undefined]; - if (template.kind === 201) { + if (template.kind === 202) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); } return args_4; } - else if (node.kind === 149) { + else if (node.kind === 150) { return undefined; } else if (ts.isJsxOpeningLikeElement(node)) { @@ -36939,22 +37178,24 @@ var ts; } } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 149) { + if (node.kind === 150) { switch (node.parent.kind) { - case 234: - case 204: + case 235: + case 205: return 1; - case 151: + case 152: return 2; - case 153: - case 155: + case 154: case 156: + case 157: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 148: + case 149: return 3; + default: + return ts.Debug.fail(); } } else { @@ -36962,51 +37203,52 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 234) { + if (node.kind === 235) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 148) { + if (node.kind === 149) { node = node.parent; - if (node.kind === 154) { + if (node.kind === 155) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 151 || - node.kind === 153 || - node.kind === 155 || - node.kind === 156) { + if (node.kind === 152 || + node.kind === 154 || + node.kind === 156 || + node.kind === 157) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 234) { + if (node.kind === 235) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 148) { + if (node.kind === 149) { node = node.parent; - if (node.kind === 154) { + if (node.kind === 155) { return anyType; } } - if (node.kind === 151 || - node.kind === 153 || - node.kind === 155 || - node.kind === 156) { + if (node.kind === 152 || + node.kind === 154 || + node.kind === 156 || + node.kind === 157) { var element = node; - switch (element.name.kind) { + var name = element.name; + switch (name.kind) { case 71: - return getLiteralType(ts.idText(element.name)); + return getLiteralType(ts.idText(name)); case 8: case 9: - return getLiteralType(element.name.text); - case 146: - var nameType = checkComputedPropertyName(element.name); - if (isTypeAssignableToKind(nameType, 1536)) { + return getLiteralType(name.text); + case 147: + var nameType = checkComputedPropertyName(name); + if (isTypeAssignableToKind(nameType, 3072)) { return nameType; } else { @@ -37014,32 +37256,32 @@ var ts; } default: ts.Debug.fail("Unsupported property name."); - return unknownType; + return errorType; } } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 234) { + if (node.kind === 235) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 148) { + if (node.kind === 149) { return numberType; } - if (node.kind === 151) { + if (node.kind === 152) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 153 || - node.kind === 155 || - node.kind === 156) { + if (node.kind === 154 || + node.kind === 156 || + node.kind === 157) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } function getEffectiveDecoratorArgumentType(node, argIndex) { if (argIndex === 0) { @@ -37052,29 +37294,29 @@ var ts; return getEffectiveDecoratorThirdArgumentType(node.parent); } ts.Debug.fail("Decorators should not have a fourth synthetic argument."); - return unknownType; + return errorType; } function getEffectiveArgumentType(node, argIndex) { - if (node.kind === 149) { + if (node.kind === 150) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 188) { + else if (argIndex === 0 && node.kind === 189) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 149 || - (argIndex === 0 && node.kind === 188)) { + if (node.kind === 150 || + (argIndex === 0 && node.kind === 189)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 149) { + if (node.kind === 150) { return node.expression; } - else if (argIndex === 0 && node.kind === 188) { + else if (argIndex === 0 && node.kind === 189) { return node.template; } else { @@ -37093,8 +37335,8 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, fallbackError) { - var isTaggedTemplate = node.kind === 188; - var isDecorator = node.kind === 149; + var isTaggedTemplate = node.kind === 189; + var isDecorator = node.kind === 150; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; if (!isDecorator) { @@ -37127,7 +37369,7 @@ var ts; var candidateForArgumentError; var candidateForTypeArgumentError; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 186 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 187 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -37278,9 +37520,10 @@ var ts; if (node.expression.kind === 97) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { + ts.forEach(node.arguments, checkExpression); return anySignature; } - if (superType !== unknownType) { + if (superType !== errorType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); @@ -37294,13 +37537,13 @@ var ts; return silentNeverSignature; } var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { + if (apparentType === errorType) { return resolveErrorCall(node); } var callSignatures = getSignaturesOfType(apparentType, 0); var constructSignatures = getSignaturesOfType(apparentType, 1); if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, constructSignatures.length)) { - if (funcType !== unknownType && node.typeArguments) { + if (funcType !== errorType && node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); } return resolveUntypedCall(node); @@ -37317,8 +37560,8 @@ var ts; return resolveCall(node, callSignatures, candidatesOutArray); } function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { - return isTypeAny(funcType) || isTypeAny(apparentFuncType) && funcType.flags & 32768 || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (131072 | 16384)) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && funcType.flags & 65536 || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (262144 | 32768)) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray) { if (node.arguments && languageVersion < 1) { @@ -37332,7 +37575,7 @@ var ts; return silentNeverSignature; } expressionType = getApparentType(expressionType); - if (expressionType === unknownType) { + if (expressionType === errorType) { return resolveErrorCall(node); } if (isTypeAny(expressionType)) { @@ -37423,7 +37666,7 @@ var ts; function resolveTaggedTemplateExpression(node, candidatesOutArray) { var tagType = checkExpression(node.tag); var apparentType = getApparentType(tagType); - if (apparentType === unknownType) { + if (apparentType === errorType) { return resolveErrorCall(node); } var callSignatures = getSignaturesOfType(apparentType, 0); @@ -37439,23 +37682,25 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 234: - case 204: + case 235: + case 205: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 148: + case 149: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 151: + case 152: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 153: - case 155: + case 154: case 156: + case 157: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; + default: + return ts.Debug.fail(); } } function resolveDecorator(node, candidatesOutArray) { var funcType = checkExpression(node.expression); var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { + if (apparentType === errorType) { return resolveErrorCall(node); } var callSignatures = getSignaturesOfType(apparentType, 0); @@ -37470,8 +37715,7 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorInfo = void 0; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); + var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); invocationErrorRecovery(apparentType, 0); @@ -37487,7 +37731,7 @@ var ts; }); } function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { - ts.Debug.assert(!(elementType.flags & 131072)); + ts.Debug.assert(!(elementType.flags & 262144)); var callSignatures = elementType && getSignaturesOfType(elementType, 0); if (callSignatures && callSignatures.length > 0) { return resolveCall(openingLikeElement, callSignatures, candidatesOutArray); @@ -37496,16 +37740,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 186: - return resolveCallExpression(node, candidatesOutArray); case 187: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 188: + return resolveNewExpression(node, candidatesOutArray); + case 189: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 149: + case 150: return resolveDecorator(node, candidatesOutArray); + case 257: case 256: - case 255: var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { var sfcResult = getResolvedJsxStatelessFunctionSignature(node, exprType, candidatesOutArray); @@ -37519,7 +37763,7 @@ var ts; return ts.length(sigs) ? sigs[0] : unknownSignature; }) || unknownSignature; } - ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); + throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } function getResolvedSignature(node, candidatesOutArray) { var links = getNodeLinks(node); @@ -37539,15 +37783,11 @@ var ts; var symbol = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? getSymbolOfNode(node) : ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : undefined; - return symbol && symbol.members !== undefined; + return !!symbol && symbol.members !== undefined; } return false; } function getJavaScriptClassType(symbol) { - var initializer = ts.getDeclaredJavascriptInitializer(symbol.valueDeclaration); - if (initializer) { - symbol = getSymbolOfNode(initializer); - } var inferred; if (isJavaScriptConstructor(symbol.valueDeclaration)) { inferred = getInferredClassType(symbol); @@ -37578,7 +37818,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 184) { + while (parent && parent.kind === 185) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58) { @@ -37605,12 +37845,12 @@ var ts; if (node.expression.kind === 97) { return voidType; } - if (node.kind === 187) { + if (node.kind === 188) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 154 && - declaration.kind !== 158 && - declaration.kind !== 163 && + declaration.kind !== 155 && + declaration.kind !== 159 && + declaration.kind !== 164 && !ts.isJSDocConstructSignature(declaration)) { var funcSymbol = checkExpression(node.expression).symbol; if (!funcSymbol && node.expression.kind === 71) { @@ -37630,10 +37870,20 @@ var ts; return resolveExternalModuleTypeByLiteral(node.arguments[0]); } var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1536 && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 3072 && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - return returnType; + var jsAssignmentType; + if (ts.isInJavaScriptFile(node)) { + var decl = ts.getDeclarationOfJSInitializer(node); + if (decl) { + var jsSymbol = getSymbolOfNode(decl); + if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { + jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, jsObjectLiteralIndexInfo, undefined); + } + } + } + return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -37662,7 +37912,7 @@ var ts; for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 4096 || specifierType.flags & 8192 || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 8192 || specifierType.flags & 16384 || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } var moduleSymbol = resolveExternalModuleName(node, specifier); @@ -37675,7 +37925,7 @@ var ts; return createPromiseReturnType(node, anyType); } function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) { - if (allowSyntheticDefaultImports && type && type !== unknownType) { + if (allowSyntheticDefaultImports && type && type !== errorType) { var synthType = type; if (!synthType.syntheticType) { var file = ts.find(originalSymbol.declarations, ts.isSourceFile); @@ -37712,9 +37962,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 233 + ? 234 : resolvedRequire.flags & 3 - ? 231 + ? 232 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -37736,7 +37986,7 @@ var ts; var exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(checkExpression(expression, checkMode))); checkSourceElement(type); var targetType = getTypeFromTypeNode(type); - if (produceDiagnostics && targetType !== unknownType) { + if (produceDiagnostics && targetType !== errorType) { var widenedType = getWidenedType(exprType); if (!isTypeComparableTo(targetType, widenedType)) { checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Type_0_cannot_be_converted_to_type_1); @@ -37755,14 +38005,15 @@ var ts; if (node.keywordToken === 91) { return checkImportMetaProperty(node); } + return ts.Debug.assertNever(node.keywordToken); } function checkNewTargetMetaProperty(node) { var container = ts.getNewTargetContainer(node); if (!container) { error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); - return unknownType; + return errorType; } - else if (container.kind === 154) { + else if (container.kind === 155) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -37778,7 +38029,7 @@ var ts; var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 1048576), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); - return node.name.escapedText === "meta" ? getGlobalImportMetaType() : unknownType; + return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); @@ -37833,9 +38084,9 @@ var ts; } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { - var parameter = ts.lastOrUndefined(signature.parameters); + var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -37880,7 +38131,7 @@ var ts; error(func, ts.isImportCall(func) ? ts.Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option : ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); - return unknownType; + return errorType; } else if (!getGlobalPromiseConstructorSymbol(true)) { error(func, ts.isImportCall(func) ? @@ -37891,11 +38142,11 @@ var ts; } function getReturnTypeFromBody(func, checkMode) { if (!func.body) { - return unknownType; + return errorType; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 212) { + if (func.body.kind !== 213) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2) { type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -37998,7 +38249,7 @@ var ts; if (!(func.flags & 128)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 226 && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -38015,7 +38266,7 @@ var ts; if (functionFlags & 2) { type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - if (type.flags & 16384) { + if (type.flags & 32768) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -38035,11 +38286,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 191: case 192: + case 193: return true; - case 153: - return func.parent.kind === 183; + case 154: + return func.parent.kind === 184; default: return false; } @@ -38048,14 +38299,14 @@ var ts; if (!produceDiagnostics) { return; } - if (returnType && maybeTypeOfKind(returnType, 1 | 2048)) { + if (returnType && maybeTypeOfKind(returnType, 3 | 4096)) { return; } - if (func.kind === 152 || ts.nodeIsMissing(func.body) || func.body.kind !== 212 || !functionHasImplicitReturn(func)) { + if (func.kind === 153 || ts.nodeIsMissing(func.body) || func.body.kind !== 213 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; - if (returnType && returnType.flags & 16384) { + if (returnType && returnType.flags & 32768) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (returnType && !hasExplicitReturn) { @@ -38078,12 +38329,12 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 153 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 || ts.isObjectLiteralMethod(node)); if (checkMode === 1 && isContextSensitive(node)) { return anyFunctionType; } var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 191) { + if (!hasGrammarError && node.kind === 192) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -38120,7 +38371,7 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 153 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnTypeNode = ts.getEffectiveReturnTypeNode(node); var returnOrPromisedType = returnTypeNode && @@ -38134,7 +38385,7 @@ var ts; if (!returnTypeNode) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 212) { + if (node.body.kind === 213) { checkSourceElement(node.body); } else { @@ -38152,7 +38403,7 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAssignableToKind(type, 84)) { + if (!isTypeAssignableToKind(type, 168)) { error(operand, diagnostic); return false; } @@ -38168,10 +38419,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 184 || expr.kind === 185) && + (expr.kind === 185 || expr.kind === 186) && expr.expression.kind === 99) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 154)) { + if (!(func && func.kind === 155)) { return true; } return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); @@ -38181,13 +38432,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 184 || expr.kind === 185) { + if (expr.kind === 185 || expr.kind === 186) { var node = ts.skipParentheses(expr.expression); if (node.kind === 71) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 245; + return !!declaration && declaration.kind === 246; } } } @@ -38195,7 +38446,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipOuterExpressions(expr, 2 | 1); - if (node.kind !== 71 && node.kind !== 184 && node.kind !== 185) { + if (node.kind !== 71 && node.kind !== 185 && node.kind !== 186) { error(expr, invalidReferenceMessage); return false; } @@ -38204,7 +38455,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 184 && expr.kind !== 185) { + if (expr.kind !== 185 && expr.kind !== 186) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -38253,7 +38504,7 @@ var ts; case 38: case 52: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKind(operandType, 1536)) { + if (maybeTypeOfKind(operandType, 3072)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; @@ -38270,7 +38521,7 @@ var ts; } return numberType; } - return unknownType; + return errorType; } function checkPostfixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -38284,10 +38535,10 @@ var ts; return numberType; } function maybeTypeOfKind(type, kind) { - if (type.flags & kind || kind & 536870912 && isGenericMappedType(type)) { + if (type.flags & kind & ~134217728 || kind & 134217728 && isGenericMappedType(type)) { return true; } - if (type.flags & 393216) { + if (type.flags & 786432) { var types = type.types; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; @@ -38302,26 +38553,26 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (1 | 2048 | 4096 | 8192)) { + if (strict && source.flags & (3 | 4096 | 8192 | 16384)) { return false; } - return (kind & 84 && isTypeAssignableTo(source, numberType)) || - (kind & 34 && isTypeAssignableTo(source, stringType)) || - (kind & 136 && isTypeAssignableTo(source, booleanType)) || - (kind & 2048 && isTypeAssignableTo(source, voidType)) || - (kind & 16384 && isTypeAssignableTo(source, neverType)) || - (kind & 8192 && isTypeAssignableTo(source, nullType)) || - (kind & 4096 && isTypeAssignableTo(source, undefinedType)) || - (kind & 512 && isTypeAssignableTo(source, esSymbolType)) || - (kind & 134217728 && isTypeAssignableTo(source, nonPrimitiveType)); + return !!(kind & 168) && isTypeAssignableTo(source, numberType) || + !!(kind & 68) && isTypeAssignableTo(source, stringType) || + !!(kind & 272) && isTypeAssignableTo(source, booleanType) || + !!(kind & 4096) && isTypeAssignableTo(source, voidType) || + !!(kind & 32768) && isTypeAssignableTo(source, neverType) || + !!(kind & 16384) && isTypeAssignableTo(source, nullType) || + !!(kind & 8192) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 1024) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 16777216) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 131072 ? + return source.flags & 262144 ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return ts.getObjectFlags(type) & 16 && type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { return (symbol.flags & 128) !== 0; @@ -38331,7 +38582,7 @@ var ts; return silentNeverType; } if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 16382)) { + allTypesAssignableToKind(leftType, 32764)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { @@ -38345,10 +38596,10 @@ var ts; } leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 84 | 1536))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 168 | 3072))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAssignableToKind(rightType, 134217728 | 7372800)) { + if (!isTypeAssignableToKind(rightType, 16777216 | 14745600)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; @@ -38366,9 +38617,9 @@ var ts; return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 269 || property.kind === 270) { + if (property.kind === 270 || property.kind === 271) { var name = property.name; - if (name.kind === 146) { + if (name.kind === 147) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -38381,7 +38632,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 270) { + if (property.kind === 271) { return checkDestructuringAssignment(property, type); } else { @@ -38392,7 +38643,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 271) { + else if (property.kind === 272) { if (languageVersion < 6) { checkExternalEmitHelpers(property, 4); } @@ -38415,7 +38666,7 @@ var ts; if (languageVersion < 2 && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512); } - var elementType = checkIteratedTypeOrElementType(sourceType, node, false, false) || unknownType; + var elementType = checkIteratedTypeOrElementType(sourceType, node, false, false) || errorType; for (var i = 0; i < elements.length; i++) { checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); } @@ -38424,8 +38675,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 205) { - if (element.kind !== 203) { + if (element.kind !== 206) { + if (element.kind !== 204) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -38451,7 +38702,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 199 && restExpression.operatorToken.kind === 58) { + if (restExpression.kind === 200 && restExpression.operatorToken.kind === 58) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -38464,11 +38715,11 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 270) { + if (exprOrAssignment.kind === 271) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && - !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 4096)) { + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 8192)) { sourceType = getTypeWithFacts(sourceType, 131072); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); @@ -38478,21 +38729,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 199 && target.operatorToken.kind === 58) { + if (target.kind === 200 && target.operatorToken.kind === 58) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 183) { + if (target.kind === 184) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 182) { + if (target.kind === 183) { 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 === 271 ? + var error = target.parent.kind === 272 ? 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; if (checkReferenceExpression(target, error)) { @@ -38506,35 +38757,35 @@ var ts; case 71: case 9: case 12: - case 188: - case 201: + case 189: + case 202: case 13: case 8: case 101: case 86: case 95: case 140: - case 191: - case 204: case 192: - case 182: + case 205: + case 193: case 183: - case 194: - case 208: + case 184: + case 195: + case 209: + case 256: case 255: - case 254: return true; - case 200: + case 201: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 199: + case 200: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 197: case 198: + case 199: switch (node.operator) { case 51: case 37: @@ -38543,15 +38794,15 @@ var ts; return true; } return false; - case 195: - case 189: - case 207: + case 196: + case 190: + case 208: default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 12288) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 24576) !== 0 || isTypeComparableTo(source, target); } function checkBinaryExpression(node, checkMode) { if (ts.isInJavaScriptFile(node) && ts.getAssignedJavascriptInitializer(node)) { @@ -38561,7 +38812,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 && (left.kind === 183 || left.kind === 182)) { + if (operator === 58 && (left.kind === 184 || left.kind === 183)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -38595,8 +38846,8 @@ var ts; leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); var suggestedOperator = void 0; - if ((leftType.flags & 136) && - (rightType.flags & 136) && + if ((leftType.flags & 272) && + (rightType.flags & 272) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } @@ -38613,19 +38864,19 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 34) && !isTypeAssignableToKind(rightType, 34)) { + if (!isTypeAssignableToKind(leftType, 68) && !isTypeAssignableToKind(rightType, 68)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 84, true) && isTypeAssignableToKind(rightType, 84, true)) { + if (isTypeAssignableToKind(leftType, 168, true) && isTypeAssignableToKind(rightType, 168, true)) { resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 34, true) || isTypeAssignableToKind(rightType, 34, true)) { + else if (isTypeAssignableToKind(leftType, 68, true) || isTypeAssignableToKind(rightType, 68, true)) { resultType = stringType; } else if (isTypeAny(leftType) || isTypeAny(rightType)) { - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + resultType = leftType === errorType || rightType === errorType ? errorType : anyType; } if (resultType && !checkForDisallowedESSymbolOperand(operator)) { return resultType; @@ -38685,6 +38936,8 @@ var ts; error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } return rightType; + default: + return ts.Debug.fail(); } function checkSpecialAssignment(left, right) { var special = ts.getSpecialPropertyAssignmentKind(left.parent); @@ -38696,7 +38949,7 @@ var ts; if (propType.symbol && propType.symbol.flags & 32) { var name = prop.escapedName; var symbol = resolveName(prop.valueDeclaration, name, 67901928, undefined, name, false); - if (symbol) { + if (symbol && symbol.declarations.some(function (d) { return d.kind === 297; })) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); } @@ -38708,8 +38961,8 @@ var ts; return node.kind === 71 && node.escapedText === "eval"; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKind(leftType, 1536) ? left : - maybeTypeOfKind(rightType, 1536) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 3072) ? left : + maybeTypeOfKind(rightType, 3072) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -38769,7 +39022,9 @@ var ts; } } var func = ts.getContainingFunction(node); - var functionFlags = func ? ts.getFunctionFlags(func) : 0; + if (!func) + return anyType; + var functionFlags = ts.getFunctionFlags(func); if (!(functionFlags & 1)) { return anyType; } @@ -38800,14 +39055,14 @@ var ts; } function checkTemplateExpression(node) { ts.forEach(node.templateSpans, function (templateSpan) { - if (maybeTypeOfKind(checkExpression(templateSpan.expression), 1536)) { + if (maybeTypeOfKind(checkExpression(templateSpan.expression), 3072)) { error(templateSpan.expression, ts.Diagnostics.Type_0_cannot_be_converted_to_type_1, typeToString(esSymbolType), typeToString(stringType)); } }); return stringType; } function getContextNode(node) { - if (node.kind === 262) { + if (node.kind === 263) { return node.parent.parent; } return node; @@ -38840,17 +39095,16 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 189 || node.kind === 207; + return node.kind === 190 || node.kind === 208; } function checkDeclarationInitializer(declaration) { - var inJs = ts.isInJavaScriptFile(declaration); - var initializer = inJs && ts.getDeclaredJavascriptInitializer(declaration) || declaration.initializer; + var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, true); var widened = ts.getCombinedNodeFlags(declaration) & 2 || (ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration)) || isTypeAssertion(initializer) ? type : getWidenedLiteralType(type); - if (inJs) { - if (widened.flags & 12288) { + if (ts.isInJavaScriptFile(declaration)) { + if (widened.flags & 24576) { if (noImplicitAny) { reportImplicitAnyError(declaration, anyType); } @@ -38865,33 +39119,23 @@ var ts; } return widened; } - function isTypeParameterWithKeyofConstraint(type) { - if (type.flags & 32768) { - var constraintDeclaration = getConstraintDeclaration(type); - return constraintDeclaration && constraintDeclaration.kind === 174 && - constraintDeclaration.operator === 128; - } - return false; - } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 393216) { + if (contextualType.flags & 786432) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 7372800) { + if (contextualType.flags & 14745600) { var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; - return isTypeParameterWithKeyofConstraint(contextualType) && maybeTypeOfKind(candidateType, 32 | 64 | 1024) || - constraint.flags & 2 && maybeTypeOfKind(candidateType, 32) || - constraint.flags & 4 && maybeTypeOfKind(candidateType, 64) || - constraint.flags & 8 && maybeTypeOfKind(candidateType, 128) || - constraint.flags & 512 && maybeTypeOfKind(candidateType, 1024) || + return maybeTypeOfKind(constraint, 4) && maybeTypeOfKind(candidateType, 64) || + maybeTypeOfKind(constraint, 8) && maybeTypeOfKind(candidateType, 128) || + maybeTypeOfKind(constraint, 1024) && maybeTypeOfKind(candidateType, 2048) || isLiteralOfContextualType(candidateType, constraint); } - return contextualType.flags & (32 | 524288) && maybeTypeOfKind(candidateType, 32) || - contextualType.flags & 64 && maybeTypeOfKind(candidateType, 64) || + return !!(contextualType.flags & (64 | 1048576) && maybeTypeOfKind(candidateType, 64) || contextualType.flags & 128 && maybeTypeOfKind(candidateType, 128) || - contextualType.flags & 1024 && maybeTypeOfKind(candidateType, 1024); + contextualType.flags & 256 && maybeTypeOfKind(candidateType, 256) || + contextualType.flags & 2048 && maybeTypeOfKind(candidateType, 2048)); } return false; } @@ -38904,14 +39148,14 @@ var ts; getWidenedLiteralLikeTypeForContextualType(type, contextualType); } function checkPropertyAssignment(node, checkMode) { - if (node.name.kind === 146) { + if (node.name.kind === 147) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); } function checkObjectLiteralMethod(node, checkMode) { checkGrammarMethod(node); - if (node.name.kind === 146) { + if (node.name.kind === 147) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -38933,7 +39177,7 @@ var ts; return type; } function getTypeOfExpression(node, cache) { - if (node.kind === 186 && node.expression.kind !== 97 && !ts.isRequireCall(node, true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 187 && node.expression.kind !== 97 && !ts.isRequireCall(node, true) && !isSymbolOrSymbolForCall(node)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -38951,7 +39195,7 @@ var ts; } function checkExpression(node, checkMode) { var type; - if (node.kind === 145) { + if (node.kind === 146) { type = checkQualifiedName(node); } else { @@ -38959,10 +39203,10 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 184 && node.parent.expression === node) || - (node.parent.kind === 185 && node.parent.expression === node) || - ((node.kind === 71 || node.kind === 145) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 164 && node.parent.exprName === node)); + var ok = (node.parent.kind === 185 && node.parent.expression === node) || + (node.parent.kind === 186 && node.parent.expression === node) || + ((node.kind === 71 || node.kind === 146) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 165 && node.parent.exprName === node)); 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); } @@ -38996,76 +39240,76 @@ var ts; return trueType; case 86: return falseType; - case 201: + case 202: return checkTemplateExpression(node); case 12: return globalRegExpType; - case 182: - return checkArrayLiteral(node, checkMode); case 183: - return checkObjectLiteral(node, checkMode); + return checkArrayLiteral(node, checkMode); case 184: - return checkPropertyAccessExpression(node); + return checkObjectLiteral(node, checkMode); case 185: - return checkIndexedAccess(node); + return checkPropertyAccessExpression(node); case 186: + return checkIndexedAccess(node); + case 187: if (node.expression.kind === 91) { return checkImportCallExpression(node); } - case 187: - return checkCallExpression(node); case 188: - return checkTaggedTemplateExpression(node); - case 190: - return checkParenthesizedExpression(node, checkMode); - case 204: - return checkClassExpression(node); - case 191: - case 192: - return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 194: - return checkTypeOfExpression(node); + return checkCallExpression(node); case 189: - case 207: - return checkAssertion(node); - case 208: - return checkNonNullAssertion(node); - case 209: - return checkMetaProperty(node); - case 193: - return checkDeleteExpression(node); - case 195: - return checkVoidExpression(node); - case 196: - return checkAwaitExpression(node); - case 197: - return checkPrefixUnaryExpression(node); - case 198: - return checkPostfixUnaryExpression(node); - case 199: - return checkBinaryExpression(node, checkMode); - case 200: - return checkConditionalExpression(node, checkMode); - case 203: - return checkSpreadExpression(node, checkMode); + return checkTaggedTemplateExpression(node); + case 191: + return checkParenthesizedExpression(node, checkMode); case 205: + return checkClassExpression(node); + case 192: + case 193: + return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + case 195: + return checkTypeOfExpression(node); + case 190: + case 208: + return checkAssertion(node); + case 209: + return checkNonNullAssertion(node); + case 210: + return checkMetaProperty(node); + case 194: + return checkDeleteExpression(node); + case 196: + return checkVoidExpression(node); + case 197: + return checkAwaitExpression(node); + case 198: + return checkPrefixUnaryExpression(node); + case 199: + return checkPostfixUnaryExpression(node); + case 200: + return checkBinaryExpression(node, checkMode); + case 201: + return checkConditionalExpression(node, checkMode); + case 204: + return checkSpreadExpression(node, checkMode); + case 206: return undefinedWideningType; - case 202: + case 203: return checkYieldExpression(node); - case 264: + case 265: return checkJsxExpression(node, checkMode); - case 254: - return checkJsxElement(node, checkMode); case 255: - return checkJsxSelfClosingElement(node, checkMode); - case 258: - return checkJsxFragment(node, checkMode); - case 262: - return checkJsxAttributes(node, checkMode); + return checkJsxElement(node, checkMode); case 256: + return checkJsxSelfClosingElement(node, checkMode); + case 259: + return checkJsxFragment(node, checkMode); + case 263: + return checkJsxAttributes(node, checkMode); + case 257: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } - return unknownType; + return errorType; } function checkTypeParameter(node) { if (node.expression) { @@ -39094,7 +39338,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92)) { - if (!(func.kind === 154 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 155 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -39105,7 +39349,7 @@ 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 === 154 || func.kind === 158 || func.kind === 163) { + if (func.kind === 155 || func.kind === 159 || func.kind === 164) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -39167,13 +39411,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 193: + case 158: + case 234: case 192: - case 157: - case 233: - case 191: - case 162: + case 163: + case 154: case 153: - case 152: var parent = node.parent; if (node === parent.type) { return parent; @@ -39191,7 +39435,7 @@ var ts; error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 180 || name.kind === 179) { + else if (name.kind === 181 || name.kind === 180) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -39199,12 +39443,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 159) { + if (node.kind === 160) { checkGrammarIndexSignature(node); } - else if (node.kind === 162 || node.kind === 233 || node.kind === 163 || - node.kind === 157 || node.kind === 154 || - node.kind === 158) { + else if (node.kind === 163 || node.kind === 234 || node.kind === 164 || + node.kind === 158 || node.kind === 155 || + node.kind === 159) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -39229,10 +39473,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 158: + case 159: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 157: + case 158: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -39256,7 +39500,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 159 && node.kind !== 283) { + if (node.kind !== 160 && node.kind !== 284) { registerForUnusedIdentifiersCheck(node); } } @@ -39273,7 +39517,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154) { + if (member.kind === 155) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { @@ -39284,20 +39528,21 @@ var ts; else { var isStatic = ts.hasModifier(member, 32); var names = isStatic ? staticNames : instanceNames; - var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); - if (memberName) { + var name = member.name; + var memberName = name && ts.getPropertyNameForPropertyNameNode(name); + if (name && memberName) { switch (member.kind) { - case 155: - addName(names, member.name, memberName, 1); - break; case 156: - addName(names, member.name, memberName, 2); + addName(names, name, memberName, 1); break; - case 151: - addName(names, member.name, memberName, 3); + case 157: + addName(names, name, memberName, 2); break; - case 153: - addName(names, member.name, memberName, 4); + case 152: + addName(names, name, memberName, 3); + break; + case 154: + addName(names, name, memberName, 4); break; } } @@ -39348,15 +39593,16 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150) { + if (member.kind === 151) { var memberName = void 0; - switch (member.name.kind) { + var name = member.name; + switch (name.kind) { case 9: case 8: - memberName = member.name.text; + memberName = name.text; break; case 71: - memberName = ts.idText(member.name); + memberName = ts.idText(name); break; default: continue; @@ -39372,7 +39618,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 235) { + if (node.kind === 236) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -39417,7 +39663,7 @@ var ts; if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); checkFunctionOrMethodDeclaration(node); - if (ts.hasModifier(node, 128) && node.kind === 153 && node.body) { + if (ts.hasModifier(node, 128) && node.kind === 154 && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -39438,7 +39684,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 151 && + return n.kind === 152 && !ts.hasModifier(n, 32) && !!n.initializer; } @@ -39458,7 +39704,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 215 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 216 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -39482,18 +39728,18 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 155) { + if (node.kind === 156) { if (!(node.flags & 4194304) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 146) { + if (node.name.kind === 147) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { - var otherKind = node.kind === 155 ? 156 : 155; + var otherKind = node.kind === 156 ? 157 : 156; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -39509,7 +39755,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 155) { + if (node.kind === 156) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -39546,7 +39792,7 @@ var ts; } function getTypeParametersForTypeReference(node) { var type = getTypeFromTypeReference(node); - if (type !== unknownType) { + if (type !== errorType) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { return symbol.flags & 524288 && getSymbolLinks(symbol).typeParameters || @@ -39557,11 +39803,11 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 161 && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 162 && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } var type = getTypeFromTypeReference(node); - if (type !== unknownType) { + if (type !== errorType) { if (node.typeArguments) { ts.forEach(node.typeArguments, checkSourceElement); if (produceDiagnostics) { @@ -39571,7 +39817,7 @@ var ts; } } } - if (type.flags & 16 && getNodeLinks(node).resolvedSymbol.flags & 8) { + if (type.flags & 32 && getNodeLinks(node).resolvedSymbol.flags & 8) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -39610,19 +39856,19 @@ var ts; ts.forEach(node.types, checkSourceElement); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 1048576)) { + if (!(type.flags & 2097152)) { return type; } var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) { - if (accessNode.kind === 185 && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 186 && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } return type; } - if (getIndexInfoOfType(getApparentType(objectType), 1) && isTypeAssignableToKind(indexType, 84)) { + if (getIndexInfoOfType(getApparentType(objectType), 1) && isTypeAssignableToKind(indexType, 168)) { return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); @@ -39651,7 +39897,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 170 && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -39665,9 +39911,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 235 && - n.parent.kind !== 234 && - n.parent.kind !== 204 && + if (n.parent.kind !== 236 && + n.parent.kind !== 235 && + n.parent.kind !== 205 && n.flags & 4194304) { if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { flags |= 1; @@ -39747,7 +39993,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 153 || node.kind === 152) && + var reportError = (node.kind === 154 || node.kind === 153) && ts.hasModifier(node, 32) !== ts.hasModifier(subsequentNode, 32); if (reportError) { var diagnostic = ts.hasModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -39780,11 +40026,11 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304; - var inAmbientContextOrInterface = node.parent.kind === 235 || node.parent.kind === 165 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 236 || node.parent.kind === 166 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 233 || node.kind === 153 || node.kind === 152 || node.kind === 154) { + if (node.kind === 234 || node.kind === 154 || node.kind === 153 || node.kind === 155) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -39904,39 +40150,39 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 235: case 236: - case 296: - case 291: + case 237: + case 297: + case 292: return 2; - case 238: + case 239: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4 | 1 : 4; - case 234: - case 237: + case 235: + case 238: return 2 | 1; - case 273: + case 274: return 2 | 1 | 4; - case 248: + case 249: if (!ts.isEntityNameExpression(d.expression)) { return 1; } d = d.expression; - case 242: + case 243: + case 246: case 245: - case 244: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); return result_3; - case 231: - case 181: - case 233: - case 247: + case 232: + case 182: + case 234: + case 248: return 1; default: - ts.Debug.fail(ts.Debug.showSyntaxKind(d)); + return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); } } } @@ -39980,7 +40226,7 @@ var ts; return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2); } function checkAwaitedType(type, errorNode, diagnosticMessage) { - return getAwaitedType(type, errorNode, diagnosticMessage) || unknownType; + return getAwaitedType(type, errorNode, diagnosticMessage) || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage) { var typeAsAwaitable = type; @@ -39990,7 +40236,7 @@ var ts; if (isTypeAny(type)) { return typeAsAwaitable.awaitedTypeOfType = type; } - if (type.flags & 131072) { + if (type.flags & 262144) { var types = void 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -40020,7 +40266,8 @@ var ts; var thenFunction = getTypeOfPropertyOfType(type, "then"); if (thenFunction && getSignaturesOfType(thenFunction, 0).length > 0) { if (errorNode) { - ts.Debug.assert(!!diagnosticMessage); + if (!diagnosticMessage) + return ts.Debug.fail(); error(errorNode, diagnosticMessage); } return undefined; @@ -40031,49 +40278,49 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); var returnType = getTypeFromTypeNode(returnTypeNode); if (languageVersion >= 2) { - if (returnType === unknownType) { - return unknownType; + if (returnType === errorType) { + return errorType; } var globalPromiseType = getGlobalPromiseType(true); if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); - return unknownType; + return errorType; } } else { markTypeNodeAsReferenced(returnTypeNode); - if (returnType === unknownType) { - return unknownType; + if (returnType === errorType) { + return errorType; } var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode); if (promiseConstructorName === undefined) { error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); - return unknownType; + return errorType; } var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67216319, true); - var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; - if (promiseConstructorType === unknownType) { + var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; + if (promiseConstructorType === errorType) { if (promiseConstructorName.kind === 71 && 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 { error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); } - return unknownType; + return errorType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(true); if (globalPromiseConstructorLikeType === emptyObjectType) { error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); - return unknownType; + return errorType; } if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value)) { - return unknownType; + return errorType; } var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67216319); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); - return unknownType; + return errorType; } } return checkAwaitedType(returnType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -40088,26 +40335,28 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 234: + case 235: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 148: + case 149: expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); + errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 151: + case 152: expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); + errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 153: - case 155: + case 154: case 156: + case 157: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); break; + default: + return ts.Debug.fail(); } checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; }); } @@ -40136,12 +40385,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { + case 170: case 169: - case 168: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 172) { + while (typeNode.kind === 173) { typeNode = typeNode.type; } if (typeNode.kind === 131) { @@ -40166,9 +40415,9 @@ var ts; } } return commonEntityName; - case 172: + case 173: return getEntityNameForDecoratorMetadata(node.type); - case 161: + case 162: return node.typeName; } } @@ -40189,13 +40438,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 148) { + if (node.kind === 149) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 234: + case 235: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -40204,19 +40453,19 @@ var ts; } } break; - case 153: - case 155: + case 154: case 156: + case 157: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 151: + case 152: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 148: + case 149: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -40255,12 +40504,12 @@ var ts; return; } if (!containsArgumentsReference(decl)) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 145 ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 146 ? node.name.right : node.name)); } 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 === 145 ? 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 === 146 ? node.name.right : node.name)); } } } @@ -40289,7 +40538,7 @@ var ts; switch (node.kind) { case 71: return node; - case 184: + case 185: return node.name; default: return undefined; @@ -40299,7 +40548,7 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); - if (node.name && node.name.kind === 146) { + if (node.name && node.name.kind === 147) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { @@ -40315,7 +40564,7 @@ var ts; } } } - var body = node.kind === 152 ? undefined : node.body; + var body = node.kind === 153 ? undefined : node.body; checkSourceElement(body); var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if ((functionFlags & 1) === 0) { @@ -40348,41 +40597,41 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 234: - case 204: + case 235: + case 205: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 235: + case 236: checkUnusedTypeParameters(node, addDiagnostic); break; - case 273: - case 238: - case 212: - case 240: - case 219: + case 274: + case 239: + case 213: + case 241: case 220: case 221: + case 222: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 154: - case 191: - case 233: - case 192: - case 153: case 155: + case 192: + case 234: + case 193: + case 154: case 156: + case 157: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 152: - case 157: + case 153: case 158: - case 162: + case 159: case 163: - case 236: + case 164: + case 237: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -40392,15 +40641,8 @@ var ts; } function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; - if (isIdentifierThatStartsWithUnderScore(node)) { - var declaration_2 = ts.getRootDeclaration(node.parent); - if ((declaration_2.kind === 231 && ts.isForInOrOfStatement(declaration_2.parent.parent)) || - declaration_2.kind === 147) { - return; - } - } var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(0, ts.createDiagnosticForNodeSpan(ts.getSourceFileOfNode(declaration), declaration, node, message, name)); + addDiagnostic(0, ts.createDiagnosticForNode(node, message, name)); } function parameterNameStartsWithUnderscore(parameterName) { return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); @@ -40413,11 +40655,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 153: - case 151: - case 155: + case 154: + case 152: case 156: - if (member.kind === 156 && member.symbol.flags & 32768) { + case 157: + if (member.kind === 157 && member.symbol.flags & 32768) { break; } var symbol = getSymbolOfNode(member); @@ -40425,7 +40667,7 @@ var ts; addDiagnostic(0, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 154: + case 155: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) { @@ -40433,8 +40675,8 @@ var ts; } } break; - case 159: - case 211: + case 160: + case 212: break; default: ts.Debug.fail(); @@ -40471,6 +40713,7 @@ var ts; return; var unusedImports = ts.createMap(); var unusedDestructures = ts.createMap(); + var unusedVariables = ts.createMap(); nodeWithLocals.locals.forEach(function (local) { if (local.flags & 262144 ? !(local.flags & 3 && !(local.isReferenced & 3)) : local.isReferenced || local.exportSymbol) { return; @@ -40488,6 +40731,11 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } } + else if (ts.isVariableDeclaration(declaration)) { + if (!isIdentifierThatStartsWithUnderScore(declaration.name) || !ts.isForInOrOfStatement(declaration.parent.parent)) { + addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); + } + } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); if (parameter) { @@ -40505,49 +40753,76 @@ var ts; unusedImports.forEach(function (_a) { var importClause = _a[0], unuseds = _a[1]; var importDecl = importClause.parent; - if (forEachImportedDeclaration(importClause, function (d) { return !ts.contains(unuseds, d); })) { + var nDeclarations = (importClause.name ? 1 : 0) + + (importClause.namedBindings ? + (importClause.namedBindings.kind === 246 ? 1 : importClause.namedBindings.elements.length) + : 0); + if (nDeclarations === unuseds.length) { + addDiagnostic(0, unuseds.length === 1 + ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) + : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); + } + else { for (var _i = 0, unuseds_1 = unuseds; _i < unuseds_1.length; _i++) { var unused = unuseds_1[_i]; errorUnusedLocal(unused, ts.idText(unused.name), addDiagnostic); } } - else if (unuseds.length === 1) { - addDiagnostic(0, ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name))); - } - else { - addDiagnostic(0, ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); - } }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0; - if (!bindingPattern.elements.every(function (e) { return ts.contains(bindingElements, e); })) { + if (bindingPattern.elements.length === bindingElements.length) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 && bindingPattern.parent.parent.kind === 233) { + addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); + } + else { + addDiagnostic(kind, bindingElements.length === 1 + ? ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(ts.first(bindingElements).name, ts.isIdentifier))) + : ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused)); + } + } + else { for (var _i = 0, bindingElements_1 = bindingElements; _i < bindingElements_1.length; _i++) { var e = bindingElements_1[_i]; addDiagnostic(kind, ts.createDiagnosticForNode(e, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(e.name, ts.isIdentifier)))); } } - else if (bindingElements.length === 1) { - addDiagnostic(kind, ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(ts.first(bindingElements).name, ts.isIdentifier)))); + }); + unusedVariables.forEach(function (_a) { + var declarationList = _a[0], declarations = _a[1]; + if (declarationList.declarations.length === declarations.length) { + addDiagnostic(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 === 214 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { - addDiagnostic(kind, ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused)); + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var decl = declarations_5[_i]; + addDiagnostic(0, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(decl.name, ts.isIdentifier)))); + } } }); } + function bindingNameText(name) { + switch (name.kind) { + case 71: + return ts.idText(name); + case 181: + case 180: + return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); + default: + return ts.Debug.assertNever(name); + } + } function isImportedDeclaration(node) { - return node.kind === 244 || node.kind === 247 || node.kind === 245; + return node.kind === 245 || node.kind === 248 || node.kind === 246; } function importClauseFromImported(decl) { - return decl.kind === 244 ? decl : decl.kind === 245 ? decl.parent : decl.parent.parent; - } - function forEachImportedDeclaration(importClause, cb) { - var defaultName = importClause.name, namedBindings = importClause.namedBindings; - return (defaultName && cb(importClause)) || - namedBindings && (namedBindings.kind === 245 ? cb(namedBindings) : ts.forEach(namedBindings.elements, cb)); + return decl.kind === 245 ? decl : decl.kind === 246 ? decl.parent : decl.parent.parent; } function checkBlock(node) { - if (node.kind === 212) { + if (node.kind === 213) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -40576,19 +40851,19 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 151 || - node.kind === 150 || + if (node.kind === 152 || + node.kind === 151 || + node.kind === 154 || node.kind === 153 || - node.kind === 152 || - node.kind === 155 || - node.kind === 156) { + node.kind === 156 || + node.kind === 157) { return false; } if (node.flags & 4194304) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 148 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 149 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -40605,6 +40880,7 @@ var ts; } return true; } + return false; }); } function checkIfNewTargetIsCapturedInEnclosingScope(node) { @@ -40619,6 +40895,7 @@ var ts; } return true; } + return false; }); } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { @@ -40632,7 +40909,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 273 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 274 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -40644,7 +40921,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 273 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 274 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(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)); } } @@ -40652,7 +40929,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 231 && !node.initializer) { + if (node.kind === 232 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -40664,15 +40941,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 232); - var container = varDeclList.parent.kind === 213 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233); + var container = varDeclList.parent.kind === 214 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 212 && ts.isFunctionLike(container.parent) || + (container.kind === 213 && ts.isFunctionLike(container.parent) || + container.kind === 240 || container.kind === 239 || - container.kind === 238 || - container.kind === 273); + container.kind === 274); 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); @@ -40682,7 +40959,7 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 148) { + if (ts.getRootDeclaration(node).kind !== 149) { return; } var func = ts.getContainingFunction(node); @@ -40691,7 +40968,7 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 184) { + if (n.kind === 185) { return visit(n.expression); } else if (n.kind === 71) { @@ -40705,8 +40982,8 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 148 || - symbol.valueDeclaration.kind === 181) { + if (symbol.valueDeclaration.kind === 149 || + symbol.valueDeclaration.kind === 182) { if (symbol.valueDeclaration.pos < node.pos) { return; } @@ -40715,7 +40992,7 @@ var ts; return "quit"; } return ts.isFunctionLike(current.parent) || - (current.parent.kind === 151 && + (current.parent.kind === 152 && !(ts.hasModifier(current.parent, 32)) && ts.isClassLike(current.parent.parent)); })) { @@ -40741,17 +41018,17 @@ var ts; if (!node.name) { return; } - if (node.name.kind === 146) { + if (node.name.kind === 147) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 181) { - if (node.parent.kind === 179 && languageVersion < 6) { + if (node.kind === 182) { + if (node.parent.kind === 180 && languageVersion < 6) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 146) { + if (node.propertyName && node.propertyName.kind === 147) { checkComputedPropertyName(node.propertyName); } var parent = node.parent.parent; @@ -40766,17 +41043,17 @@ var ts; } } if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 180 && languageVersion < 2 && compilerOptions.downlevelIteration) { + if (node.name.kind === 181 && languageVersion < 2 && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512); } ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 148 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 149 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - if (node.initializer && node.parent.parent.kind !== 220) { + if (node.initializer && node.parent.parent.kind !== 221) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); @@ -40791,15 +41068,15 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfSymbol(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 220) { - var initializer = ts.isInJavaScriptFile(node) && ts.getDeclaredJavascriptInitializer(node) || node.initializer; + var initializer = ts.getEffectiveInitializer(node); + if (initializer && node.parent.parent.kind !== 221) { checkTypeAssignableTo(checkExpressionCached(initializer), type, node, undefined); checkParameterInitializer(node); } } else { var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); - if (type !== unknownType && declarationType !== unknownType && + if (type !== errorType && declarationType !== errorType && !isTypeIdenticalTo(type, declarationType) && !(symbol.flags & 67108864)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); @@ -40812,9 +41089,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 151 && node.kind !== 150) { + if (node.kind !== 152 && node.kind !== 151) { checkExportsOnMergedDeclarations(node); - if (node.kind === 231 || node.kind === 181) { + if (node.kind === 232 || node.kind === 182) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -40823,14 +41100,14 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 151 || nextDeclaration.kind === 150 + var message = nextDeclaration.kind === 152 || nextDeclaration.kind === 151 ? 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; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 148 && right.kind === 231) || - (left.kind === 231 && right.kind === 148)) { + if ((left.kind === 149 && right.kind === 232) || + (left.kind === 232 && right.kind === 149)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -40865,7 +41142,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 214) { + if (node.thenStatement.kind === 215) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -40882,12 +41159,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 232) { + if (node.initializer && node.initializer.kind === 233) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 232) { + if (node.initializer.kind === 233) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -40914,14 +41191,14 @@ var ts; else if (compilerOptions.downlevelIteration && languageVersion < 2) { checkExternalEmitHelpers(node, 256); } - if (node.initializer.kind === 232) { + if (node.initializer.kind === 233) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); - if (varExpr.kind === 182 || varExpr.kind === 183) { - checkDestructuringAssignment(varExpr, iteratedType || unknownType); + if (varExpr.kind === 183 || varExpr.kind === 184) { + checkDestructuringAssignment(varExpr, iteratedType || errorType); } else { var leftType = checkExpression(varExpr); @@ -40939,7 +41216,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 232) { + if (node.initializer.kind === 233) { 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); @@ -40949,7 +41226,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 182 || varExpr.kind === 183) { + if (varExpr.kind === 183 || varExpr.kind === 184) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -40959,7 +41236,7 @@ var ts; checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } - if (rightType === neverType || !isTypeAssignableToKind(rightType, 134217728 | 7372800)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 16777216 | 14745600)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -41001,14 +41278,14 @@ var ts; var reportedError = false; var hasStringConstituent = false; if (allowStringInput) { - if (arrayType.flags & 131072) { + if (arrayType.flags & 262144) { var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 34); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 68); }); if (filteredTypes !== arrayTypes) { arrayType = getUnionType(filteredTypes, 2); } } - else if (arrayType.flags & 34) { + else if (arrayType.flags & 68) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; @@ -41019,7 +41296,7 @@ var ts; reportedError = true; } } - if (arrayType.flags & 16384) { + if (arrayType.flags & 32768) { return stringType; } } @@ -41044,7 +41321,7 @@ var ts; } var arrayElementType = getIndexTypeOfType(arrayType, 1); if (hasStringConstituent && arrayElementType) { - if (arrayElementType.flags & 34) { + if (arrayElementType.flags & 68) { return stringType; } return getUnionType([arrayElementType, stringType], 2); @@ -41077,11 +41354,11 @@ var ts; } } var asyncMethodType = allowAsyncIterables && getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); - var methodType = asyncMethodType || (allowSyncIterables && getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator"))); + var methodType = asyncMethodType || (allowSyncIterables ? getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")) : undefined); if (isTypeAny(methodType)) { return undefined; } - var signatures = methodType && getSignaturesOfType(methodType, 0); + var signatures = methodType ? getSignaturesOfType(methodType, 0) : undefined; if (!ts.some(signatures)) { if (errorNode) { reportTypeNotIterableError(errorNode, type, allowAsyncIterables); @@ -41168,14 +41445,14 @@ var ts; checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return node.kind === 155 - && ts.getEffectiveSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 156)) !== undefined; + return node.kind === 156 + && ts.getEffectiveSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 157)) !== undefined; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = (ts.getFunctionFlags(func) & 3) === 2 ? getPromisedTypeOfPromise(returnType) : returnType; - return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 2048 | 1); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 4096 | 3); } function checkReturnStatement(node) { if (checkGrammarStatementInAmbientContext(node)) { @@ -41190,17 +41467,17 @@ var ts; var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(func); var isGenerator = functionFlags & 1; - if (strictNullChecks || node.expression || returnType.flags & 16384) { + if (strictNullChecks || node.expression || returnType.flags & 32768) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; if (isGenerator) { return; } - else if (func.kind === 156) { + else if (func.kind === 157) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 154) { + else if (func.kind === 155) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -41218,7 +41495,7 @@ var ts; } } } - else if (func.kind !== 154 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { + else if (func.kind !== 155 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -41243,7 +41520,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 266 && !hasDuplicateDefaultClause) { + if (clause.kind === 267 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -41255,7 +41532,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 265) { + if (produceDiagnostics && clause.kind === 266) { var caseType = checkExpression(clause.expression); var caseIsLiteral = isLiteralType(caseType); var comparedExpressionType = expressionType; @@ -41279,10 +41556,11 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 227 && current.label.escapedText === node.label.escapedText) { + if (current.kind === 228 && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } + return false; }); } checkSourceElement(node.statement); @@ -41338,8 +41616,8 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1); }); - if (ts.getObjectFlags(type) & 1 && ts.isClassLike(type.symbol.valueDeclaration)) { - var classDeclaration = type.symbol.valueDeclaration; + 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.hasModifier(member, 32) && hasNonBindableDynamicName(member)) { @@ -41372,8 +41650,8 @@ var ts; } var errorNode; if (propDeclaration && - (propDeclaration.kind === 199 || - ts.getNameOfDeclaration(propDeclaration).kind === 146 || + (propDeclaration.kind === 200 || + ts.getNameOfDeclaration(propDeclaration).kind === 147 || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -41395,6 +41673,7 @@ var ts; function checkTypeNameIsReserved(name, message) { switch (name.escapedText) { case "any": + case "unknown": case "number": case "boolean": case "string": @@ -41404,6 +41683,12 @@ var ts; error(name, message, name.escapedText); } } + function checkClassNameCollisionWithObject(name) { + if (languageVersion === 1 && name.escapedText === "Object" + && moduleKind !== ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.ESNext) { + error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); + } + } function checkTypeParameters(typeParameterDeclarations) { if (typeParameterDeclarations) { var seenDefault = false; @@ -41440,8 +41725,8 @@ var ts; var type = getDeclaredTypeOfSymbol(symbol); if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { var name = symbolToString(symbol); - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } @@ -41450,8 +41735,8 @@ var ts; function areTypeParametersIdentical(declarations, targetParameters) { var maxTypeArgumentCount = ts.length(targetParameters); var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters); - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration); var numTypeParameters = sourceParameters.length; if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) { @@ -41503,6 +41788,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + if (!(node.flags & 4194304)) { + checkClassNameCollisionWithObject(node.name); + } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); checkExportsOnMergedDeclarations(node); @@ -41541,10 +41829,10 @@ var ts; issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); } checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseConstructorType.flags & 1081344 && !isMixinConstructorType(staticType)) { + if (baseConstructorType.flags & 2162688 && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 1081344)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 2162688)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); if (ts.forEach(constructors, function (sig) { return getReturnTypeOfSignature(sig) !== baseType_1; })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); @@ -41563,7 +41851,7 @@ var ts; checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); - if (t !== unknownType) { + if (t !== errorType) { if (isValidBaseType(t)) { var genericDiag = t.symbol && t.symbol.flags & 32 ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : @@ -41629,7 +41917,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 234 || d.kind === 235; + return d.kind === 235 || d.kind === 236; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -41647,7 +41935,7 @@ var ts; if (derived === base) { var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128))) { - if (derivedClassDecl.kind === 204) { + if (derivedClassDecl.kind === 205) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -41660,7 +41948,7 @@ var ts; if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) { continue; } - if (isPrototypeProperty(base) && isPrototypeProperty(derived) || base.flags & 98308 && derived.flags & 98308) { + if (isPrototypeProperty(base) || base.flags & 98308 && derived.flags & 98308) { continue; } var errorMessage = void 0; @@ -41726,7 +42014,7 @@ var ts; var propName = member.name; if (ts.isIdentifier(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 1 || getFalsyFlags(type) & 4096)) { + if (!(type.flags & 3 || getFalsyFlags(type) & 8192)) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -41736,7 +42024,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 151 && + return node.kind === 152 && !ts.hasModifier(node, 32 | 128) && !node.exclamationToken && !node.initializer; @@ -41745,7 +42033,7 @@ var ts; var reference = ts.createPropertyAccess(ts.createThis(), propName); reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 4096); + return !(getFalsyFlags(flowType) & 8192); } function checkInterfaceDeclaration(node) { if (!checkGrammarDecoratorsAndModifiers(node)) @@ -41756,7 +42044,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 235); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -41852,7 +42140,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 197: + case 198: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -41862,7 +42150,7 @@ var ts; } } break; - case 199: + case 200: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -41890,18 +42178,22 @@ var ts; case 8: checkGrammarNumericLiteral(expr); return +expr.text; - case 190: + case 191: return evaluate(expr.expression); case 71: - return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), expr.escapedText); + var identifier = expr; + if (isInfinityOrNaNString(identifier.escapedText)) { + return +(identifier.escapedText); + } + return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); + case 186: case 185: - case 184: 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 === 184) { + if (ex.kind === 185) { name = ex.name.escapedText; } else { @@ -41933,8 +42225,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 || - node.kind === 184 && isConstantMemberAccess(node.expression) || - node.kind === 185 && isConstantMemberAccess(node.expression) && + node.kind === 185 && isConstantMemberAccess(node.expression) || + node.kind === 186 && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9; } function checkEnumDeclaration(node) { @@ -41963,7 +42255,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 237) { + if (declaration.kind !== 238) { return false; } var enumDeclaration = declaration; @@ -41984,10 +42276,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; - if ((declaration.kind === 234 || - (declaration.kind === 233 && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 235 || + (declaration.kind === 234 && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304)) { return declaration; } @@ -42035,7 +42327,7 @@ var ts; if (symbol.flags & 512 && symbol.declarations.length > 1 && !inAmbientContext - && isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { + && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -42045,7 +42337,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, 234); + var mergedClass = ts.getDeclarationOfKind(symbol, 235); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -42088,22 +42380,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 213: + case 214: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 248: case 249: + case 250: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 242: case 243: + case 244: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 181: - case 231: + case 182: + case 232: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -42112,12 +42404,12 @@ var ts; } break; } - case 234: - case 237: - case 233: case 235: case 238: + case 234: case 236: + case 239: + case 237: if (isGlobalAugmentation) { return; } @@ -42135,12 +42427,12 @@ var ts; switch (node.kind) { case 71: return node; - case 145: + case 146: do { node = node.left; } while (node.kind !== 71); return node; - case 184: + case 185: do { node = node.expression; } while (node.kind !== 71); @@ -42149,16 +42441,16 @@ var ts; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (ts.nodeIsMissing(moduleName)) { + if (!moduleName || ts.nodeIsMissing(moduleName)) { return false; } if (!ts.isStringLiteral(moduleName)) { error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 239 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 273 && !inAmbientExternalModule) { - error(moduleName, node.kind === 249 ? + var inAmbientExternalModule = node.parent.kind === 240 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 274 && !inAmbientExternalModule) { + error(moduleName, node.kind === 250 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -42179,13 +42471,13 @@ var ts; (symbol.flags & 67901928 ? 67901928 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 251 ? + var message = node.kind === 252 ? 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 === 251 + && node.kind === 252 && !(target.flags & 67216319) && !(node.flags & 4194304)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -42211,7 +42503,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 245) { + if (importClause.namedBindings.kind === 246) { checkImportBinding(importClause.namedBindings); } else { @@ -42234,7 +42526,7 @@ var ts; if (ts.hasModifier(node, 1)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 253) { + if (node.moduleReference.kind !== 254) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319) { @@ -42265,10 +42557,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 239 && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 239 && + var inAmbientExternalModule = node.parent.kind === 240 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 && !node.moduleSpecifier && node.flags & 4194304; - if (node.parent.kind !== 273 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 274 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -42284,7 +42576,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 273 || node.parent.kind === 239 || node.parent.kind === 238; + var isInAppropriateContext = node.parent.kind === 274 || node.parent.kind === 240 || node.parent.kind === 239; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -42310,8 +42602,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 273 ? node.parent : node.parent.parent; - if (container.kind === 238 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 274 ? node.parent : node.parent.parent; + if (container.kind === 239 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -42374,8 +42666,8 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; + 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))); } @@ -42390,165 +42682,165 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 233 && declaration.kind !== 153) || + return (declaration.kind !== 234 && declaration.kind !== 154) || !!declaration.body; } function checkSourceElement(node) { if (!node) { return; } - if (ts.isInJavaScriptFile(node) && node.jsDoc) { - for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { - var tags = _a[_i].tags; - ts.forEach(tags, checkSourceElement); - } + if (ts.isInJavaScriptFile(node)) { + ts.forEach(node.jsDoc, function (_a) { + var tags = _a.tags; + return ts.forEach(tags, checkSourceElement); + }); } var kind = node.kind; if (cancellationToken) { switch (kind) { - case 238: - case 234: + case 239: case 235: - case 233: + case 236: + case 234: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 147: - return checkTypeParameter(node); case 148: + return checkTypeParameter(node); + case 149: return checkParameter(node); + case 152: case 151: - case 150: return checkPropertyDeclaration(node); - case 162: case 163: - case 157: + case 164: case 158: case 159: - return checkSignatureDeclaration(node); - case 153: - case 152: - return checkMethodDeclaration(node); - case 154: - return checkConstructorDeclaration(node); - case 155: - case 156: - return checkAccessorDeclaration(node); - case 161: - return checkTypeReferenceNode(node); case 160: + return checkSignatureDeclaration(node); + case 154: + case 153: + return checkMethodDeclaration(node); + case 155: + return checkConstructorDeclaration(node); + case 156: + case 157: + return checkAccessorDeclaration(node); + case 162: + return checkTypeReferenceNode(node); + case 161: return checkTypePredicate(node); - case 164: - return checkTypeQuery(node); case 165: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 166: - return checkArrayType(node); + return checkTypeLiteral(node); case 167: - return checkTupleType(node); + return checkArrayType(node); case 168: + return checkTupleType(node); case 169: - return checkUnionOrIntersectionType(node); - case 172: - return checkSourceElement(node.type); - case 174: - return checkTypeOperator(node); case 170: - return checkConditionalType(node); + return checkUnionOrIntersectionType(node); + case 173: + return checkSourceElement(node.type); + case 175: + return checkTypeOperator(node); case 171: + return checkConditionalType(node); + case 172: return checkInferType(node); - case 178: + case 179: return checkImportType(node); - case 289: + case 290: return checkJSDocAugmentsTag(node); - case 296: - case 291: - return checkJSDocTypeAliasTag(node); + case 297: case 292: + return checkJSDocTypeAliasTag(node); + case 293: return checkJSDocParameterTag(node); - case 283: + case 284: checkSignatureDeclaration(node); + case 282: case 281: - case 280: - case 278: case 279: - case 286: + case 280: + case 287: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 284: + case 285: checkJSDocVariadicType(node); return; - case 277: + case 278: return checkSourceElement(node.type); - case 175: - return checkIndexedAccessType(node); case 176: + return checkIndexedAccessType(node); + case 177: return checkMappedType(node); - case 233: - return checkFunctionDeclaration(node); - case 212: - case 239: - return checkBlock(node); - case 213: - return checkVariableStatement(node); - case 215: - return checkExpressionStatement(node); - case 216: - return checkIfStatement(node); - case 217: - return checkDoStatement(node); - case 218: - return checkWhileStatement(node); - case 219: - return checkForStatement(node); - case 220: - return checkForInStatement(node); - case 221: - return checkForOfStatement(node); - case 222: - case 223: - return checkBreakOrContinueStatement(node); - case 224: - return checkReturnStatement(node); - case 225: - return checkWithStatement(node); - case 226: - return checkSwitchStatement(node); - case 227: - return checkLabeledStatement(node); - case 228: - return checkThrowStatement(node); - case 229: - return checkTryStatement(node); - case 231: - return checkVariableDeclaration(node); - case 181: - return checkBindingElement(node); case 234: - return checkClassDeclaration(node); - case 235: - return checkInterfaceDeclaration(node); - case 236: - return checkTypeAliasDeclaration(node); - case 237: - return checkEnumDeclaration(node); - case 238: - return checkModuleDeclaration(node); - case 243: - return checkImportDeclaration(node); - case 242: - return checkImportEqualsDeclaration(node); - case 249: - return checkExportDeclaration(node); - case 248: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 213: + case 240: + return checkBlock(node); case 214: + return checkVariableStatement(node); + case 216: + return checkExpressionStatement(node); + case 217: + return checkIfStatement(node); + case 218: + return checkDoStatement(node); + case 219: + return checkWhileStatement(node); + case 220: + return checkForStatement(node); + case 221: + return checkForInStatement(node); + case 222: + return checkForOfStatement(node); + case 223: + case 224: + return checkBreakOrContinueStatement(node); + case 225: + return checkReturnStatement(node); + case 226: + return checkWithStatement(node); + case 227: + return checkSwitchStatement(node); + case 228: + return checkLabeledStatement(node); + case 229: + return checkThrowStatement(node); case 230: + return checkTryStatement(node); + case 232: + return checkVariableDeclaration(node); + case 182: + return checkBindingElement(node); + case 235: + return checkClassDeclaration(node); + case 236: + return checkInterfaceDeclaration(node); + case 237: + return checkTypeAliasDeclaration(node); + case 238: + return checkEnumDeclaration(node); + case 239: + return checkModuleDeclaration(node); + case 244: + return checkImportDeclaration(node); + case 243: + return checkImportEqualsDeclaration(node); + case 250: + return checkExportDeclaration(node); + case 249: + return checkExportAssignment(node); + case 215: + case 231: checkGrammarStatementInAmbientContext(node); return; - case 252: + case 253: return checkMissingDeclaration(node); } } @@ -42570,7 +42862,7 @@ var ts; if (!ts.isJSDocTypeExpression(parent)) { error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature); } - var paramTag = parent.parent; + var paramTag = node.parent.parent; if (!ts.isJSDocParameterTag(paramTag)) { error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature); return; @@ -42587,8 +42879,8 @@ var ts; function getTypeFromJSDocVariadicType(node) { var type = getTypeFromTypeNode(node.type); var parent = node.parent; - var paramTag = parent.parent; - if (ts.isJSDocTypeExpression(parent) && ts.isJSDocParameterTag(paramTag)) { + 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); @@ -42610,20 +42902,20 @@ var ts; } } function checkDeferredNodes() { - for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { - var node = deferredNodes_1[_i]; + for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { + var node = _a[_i]; switch (node.kind) { - case 191: case 192: + case 193: + case 154: case 153: - case 152: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 155: case 156: + case 157: checkAccessorDeclaration(node); break; - case 204: + case 205: checkClassExpressionDeferred(node); break; } @@ -42638,9 +42930,9 @@ var ts; function unusedIsError(kind) { switch (kind) { case 0: - return compilerOptions.noUnusedLocals; + return !!compilerOptions.noUnusedLocals; case 1: - return compilerOptions.noUnusedParameters; + return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); } @@ -42737,24 +43029,24 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 238: + case 239: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475); break; - case 237: + case 238: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 204: + case 205: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 234: case 235: + case 236: if (!isStatic) { copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928); } break; - case 191: + case 192: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -42792,27 +43084,27 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 147: - case 234: + case 148: case 235: case 236: case 237: + case 238: return true; + default: + return false; } } - function isTypeReferenceIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 145) { + function isTypeReferenceIdentifier(node) { + while (node.parent.kind === 146) { node = node.parent; } - return node.parent && node.parent.kind === 161; + return node.parent.kind === 162; } - function isHeritageClauseElementIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 184) { + function isHeritageClauseElementIdentifier(node) { + while (node.parent.kind === 185) { node = node.parent; } - return node.parent && node.parent.kind === 206; + return node.parent.kind === 207; } function forEachEnclosingClass(node, callback) { var result; @@ -42840,14 +43132,14 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 145) { + while (nodeOnRightSide.parent.kind === 146) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 242) { - return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; + if (nodeOnRightSide.parent.kind === 243) { + return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 248) { - return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; + if (nodeOnRightSide.parent.kind === 249) { + return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; } @@ -42872,7 +43164,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 178 && parent.qualifier === node) { + if (parent && parent.kind === 179 && parent.qualifier === node) { return parent; } return undefined; @@ -42882,21 +43174,21 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 184 && + entityName.parent.kind === 185 && entityName.parent === entityName.parent.parent.left) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 248 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 249 && ts.isEntityNameExpression(entityName)) { var success = resolveEntityName(entityName, 67216319 | 67901928 | 1920 | 2097152, true); if (success && success !== unknownSymbol) { return success; } } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 242); + var importEqualsDeclaration = ts.getAncestor(entityName, 243); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -42913,7 +43205,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 206) { + if (entityName.parent.kind === 207) { meaning = 67901928; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 67216319; @@ -42928,10 +43220,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 292) { + if (entityName.parent.kind === 293) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 147 && entityName.parent.parent.kind === 295) { + if (entityName.parent.kind === 148 && entityName.parent.parent.kind === 296) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -42947,12 +43239,12 @@ var ts; } return resolveEntityName(entityName, 67216319, false, true); } - else if (entityName.kind === 184 || entityName.kind === 145) { + else if (entityName.kind === 185 || entityName.kind === 146) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 184) { + if (entityName.kind === 185) { checkPropertyAccessExpression(entityName); } else { @@ -42962,38 +43254,40 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 161 ? 67901928 : 1920; + var meaning = entityName.parent.kind === 162 ? 67901928 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 261) { + else if (entityName.parent.kind === 262) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 160) { + if (entityName.parent.kind === 161) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 273) { + if (node.kind === 274) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } + var parent = node.parent; + var grandParent = parent.parent; if (node.flags & 8388608) { return undefined; } if (isDeclarationNameOrImportPropertyName(node)) { - return getSymbolOfNode(node.parent); + return getSymbolOfNode(parent); } else if (ts.isLiteralComputedPropertyDeclarationName(node)) { - return getSymbolOfNode(node.parent.parent); + return getSymbolOfNode(parent.parent); } if (node.kind === 71) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 181 && - node.parent.parent.kind === 179 && - node === node.parent.propertyName) { - var typeOfPattern = getTypeOfNode(node.parent.parent); + else if (parent.kind === 182 && + grandParent.kind === 180 && + node === parent.propertyName) { + var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); if (propertyDeclaration) { return propertyDeclaration; @@ -43002,8 +43296,8 @@ var ts; } switch (node.kind) { case 71: - case 184: - case 145: + case 185: + case 146: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99: var container = ts.getThisContainer(node, false); @@ -43016,43 +43310,43 @@ var ts; if (ts.isInExpressionContext(node)) { return checkExpression(node).symbol; } - case 173: + case 174: return getTypeFromThisTypeNode(node).symbol; case 97: return checkExpression(node).symbol; case 123: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 154) { + if (constructorDeclaration && constructorDeclaration.kind === 155) { return constructorDeclaration.parent.symbol; } return undefined; case 9: case 13: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 243 || node.parent.kind === 249) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 244 || node.parent.kind === 250) && node.parent.moduleSpecifier === node) || ((ts.isInJavaScriptFile(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); } case 8: - var objectType = ts.isElementAccessExpression(node.parent) - ? node.parent.argumentExpression === node ? getTypeOfExpression(node.parent.expression) : undefined - : ts.isLiteralTypeNode(node.parent) && ts.isIndexedAccessTypeNode(node.parent.parent) - ? getTypeFromTypeNode(node.parent.parent.objectType) + var objectType = ts.isElementAccessExpression(parent) + ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined + : ts.isLiteralTypeNode(parent) && ts.isIndexedAccessTypeNode(grandParent) + ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); case 79: case 89: case 36: return getSymbolOfNode(node.parent); - case 178: + case 179: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 270) { + if (location && location.kind === 271) { return resolveEntityName(location.name, 67216319 | 2097152); } return undefined; @@ -43064,7 +43358,7 @@ var ts; } function getTypeOfNode(node) { if (node.flags & 8388608) { - return unknownType; + return errorType; } if (ts.isPartOfTypeNode(node)) { var typeFromTypeNode = getTypeFromTypeNode(node); @@ -43107,29 +43401,29 @@ var ts; var symbol = getSymbolAtLocation(node); if (symbol) { var declaredType = getDeclaredTypeOfSymbol(symbol); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); + return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol); } } - return unknownType; + return errorType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 183 || expr.kind === 182); - if (expr.parent.kind === 221) { + ts.Debug.assert(expr.kind === 184 || expr.kind === 183); + if (expr.parent.kind === 222) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); - return checkDestructuringAssignment(expr, iteratedType || unknownType); + return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 199) { + if (expr.parent.kind === 200) { var iteratedType = getTypeOfExpression(expr.parent.right); - return checkDestructuringAssignment(expr, iteratedType || unknownType); + return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 269) { + if (expr.parent.kind === 270) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); - return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 182); + ts.Debug.assert(expr.parent.kind === 183); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); - var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false, false) || unknownType; - return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || unknownType); + var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, false, false) || errorType; + return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || errorType); } function getPropertySymbolOfDestructuringAssignment(location) { var typeOfObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(location.parent.parent); @@ -43186,11 +43480,11 @@ var ts; } return target; } - function isArgumentsLocalBinding(node) { - if (!ts.isGeneratedIdentifier(node)) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function isArgumentsLocalBinding(nodeIn) { + if (!ts.isGeneratedIdentifier(nodeIn)) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 184 && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 185 && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -43216,11 +43510,10 @@ var ts; } } function isNameOfModuleOrEnumDeclaration(node) { - var parent = node.parent; - return parent && ts.isModuleOrEnumDeclaration(parent) && node === parent.name; + return ts.isModuleOrEnumDeclaration(node.parent) && node === node.parent.name; } - function getReferencedExportContainer(node, prefixLocals) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedExportContainer(nodeIn, prefixLocals) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node, isNameOfModuleOrEnumDeclaration(node)); if (symbol) { @@ -43233,7 +43526,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 273) { + if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 274) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -43244,8 +43537,8 @@ var ts; } } } - function getReferencedImportDeclaration(node) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedImportDeclaration(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node); if (isNonLocalAlias(symbol, 67216319)) { @@ -43267,7 +43560,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 212 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 213 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -43279,9 +43572,9 @@ var ts; } return false; } - function getReferencedDeclarationWithCollidingName(node) { - if (!ts.isGeneratedIdentifier(node)) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedDeclarationWithCollidingName(nodeIn) { + if (!ts.isGeneratedIdentifier(nodeIn)) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node); if (symbol && isSymbolOfDeclarationWithCollidingName(symbol)) { @@ -43291,8 +43584,8 @@ var ts; } return undefined; } - function isDeclarationWithCollidingName(node) { - node = ts.getParseTreeNode(node, ts.isDeclaration); + function isDeclarationWithCollidingName(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); if (node) { var symbol = getSymbolOfNode(node); if (symbol) { @@ -43303,16 +43596,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 242: - case 244: + case 243: case 245: - case 247: - case 251: - return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 249: - var exportClause = node.exportClause; - return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); + case 246: case 248: + case 252: + return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); + case 250: + var exportClause = node.exportClause; + return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); + case 249: return node.expression && node.expression.kind === 71 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -43320,9 +43613,9 @@ var ts; } return false; } - function isTopLevelValueImportEqualsWithEntityName(node) { - node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 273 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + function isTopLevelValueImportEqualsWithEntityName(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); + if (node === undefined || node.parent.kind !== 274 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -43333,11 +43626,11 @@ var ts; if (target === unknownSymbol) { return true; } - return target.flags & 67216319 && + return !!(target.flags & 67216319) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { - return isConstEnumSymbol(s) || s.constEnumOnlyModule; + return isConstEnumSymbol(s) || !!s.constEnumOnlyModule; } function isReferencedAliasDeclaration(node, checkChildren) { if (ts.isAliasSymbolDeclaration(node)) { @@ -43351,7 +43644,7 @@ var ts; } } if (checkChildren) { - return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); + return !!ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); } return false; } @@ -43367,10 +43660,10 @@ var ts; return false; } function isRequiredInitializedParameter(parameter) { - return strictNullChecks && + return !!strictNullChecks && !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && - parameter.initializer && + !!parameter.initializer && !ts.hasModifier(parameter, 92); } function isOptionalUninitializedParameterProperty(parameter) { @@ -43380,7 +43673,7 @@ var ts; ts.hasModifier(parameter, 92); } function getNodeCheckFlags(node) { - return getNodeLinks(node).flags; + return getNodeLinks(node).flags || 0; } function getEnumMemberValue(node) { computeEnumMemberValues(node.parent); @@ -43388,15 +43681,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 272: - case 184: + case 273: case 185: + case 186: return true; } return false; } function getConstantValue(node) { - if (node.kind === 272) { + if (node.kind === 273) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -43408,10 +43701,10 @@ var ts; return undefined; } function isFunctionType(type) { - return type.flags & 65536 && getSignaturesOfType(type, 0).length > 0; + return !!(type.flags & 131072) && getSignaturesOfType(type, 0).length > 0; } - function getTypeReferenceSerializationKind(typeName, location) { - typeName = ts.getParseTreeNode(typeName, ts.isEntityName); + function getTypeReferenceSerializationKind(typeNameIn, location) { + var typeName = ts.getParseTreeNode(typeNameIn, ts.isEntityName); if (!typeName) return ts.TypeReferenceSerializationKind.Unknown; if (location) { @@ -43432,31 +43725,31 @@ var ts; } } if (!typeSymbol) { - return ts.TypeReferenceSerializationKind.ObjectType; - } - var type = getDeclaredTypeOfSymbol(typeSymbol); - if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 1) { + var type = getDeclaredTypeOfSymbol(typeSymbol); + if (type === errorType) { + return ts.TypeReferenceSerializationKind.Unknown; + } + else if (type.flags & 3) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 2048 | 12288 | 16384)) { + else if (isTypeAssignableToKind(type, 4096 | 24576 | 32768)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 136)) { + else if (isTypeAssignableToKind(type, 272)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 84)) { + else if (isTypeAssignableToKind(type, 168)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 34)) { + else if (isTypeAssignableToKind(type, 68)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 1536)) { + else if (isTypeAssignableToKind(type, 3072)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -43469,16 +43762,16 @@ var ts; return ts.TypeReferenceSerializationKind.ObjectType; } } - function createTypeOfDeclaration(declaration, enclosingDeclaration, flags, tracker, addUndefined) { - declaration = ts.getParseTreeNode(declaration, ts.isVariableLikeOrAccessor); + function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { + var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { return ts.createToken(119); } var symbol = getSymbolOfNode(declaration); var type = symbol && !(symbol.flags & (2048 | 131072)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) - : unknownType; - if (type.flags & 1024 && + : errorType; + if (type.flags & 2048 && type.symbol === symbol) { flags |= 1048576; } @@ -43487,16 +43780,16 @@ var ts; } return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker); } - function createReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, tracker) { - signatureDeclaration = ts.getParseTreeNode(signatureDeclaration, ts.isFunctionLike); + function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { + var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { return ts.createToken(119); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024, tracker); } - function createTypeOfExpression(expr, enclosingDeclaration, flags, tracker) { - expr = ts.getParseTreeNode(expr, ts.isExpression); + function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { + var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { return ts.createToken(119); } @@ -43520,9 +43813,9 @@ var ts; } return resolveName(location, reference.escapedText, 67216319 | 1048576 | 2097152, undefined, undefined, true); } - function getReferencedValueDeclaration(reference) { - if (!ts.isGeneratedIdentifier(reference)) { - reference = ts.getParseTreeNode(reference, ts.isIdentifier); + function getReferencedValueDeclaration(referenceIn) { + if (!ts.isGeneratedIdentifier(referenceIn)) { + var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier); if (reference) { var symbol = getReferencedValueSymbol(reference); if (symbol) { @@ -43535,7 +43828,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 && type.flags & 8388608); + return !!(type.flags & 192 && type.flags & 33554432); } return false; } @@ -43575,7 +43868,7 @@ var ts; }, getNodeCheckFlags: function (node) { node = ts.getParseTreeNode(node); - return node ? getNodeCheckFlags(node) : undefined; + return node ? getNodeCheckFlags(node) : 0; }, isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, @@ -43588,8 +43881,8 @@ var ts; createLiteralConstValue: createLiteralConstValue, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, - getConstantValue: function (node) { - node = ts.getParseTreeNode(node, canHaveConstantValue); + getConstantValue: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue); return node ? getConstantValue(node) : undefined; }, collectLinkedAliases: collectLinkedAliases, @@ -43602,20 +43895,20 @@ var ts; getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName, getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol, isLiteralConstDeclaration: isLiteralConstDeclaration, - isLateBound: function (node) { - node = ts.getParseTreeNode(node, ts.isDeclaration); + isLateBound: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); return !!(symbol && ts.getCheckFlags(symbol) & 1024); }, getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); - var otherKind = accessor.kind === 156 ? 155 : 156; + var otherKind = accessor.kind === 157 ? 156 : 157; 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 === 156 ? accessor : otherAccessor; - var getAccessor = accessor.kind === 155 ? accessor : otherAccessor; + var setAccessor = accessor.kind === 157 ? accessor : otherAccessor; + var getAccessor = accessor.kind === 156 ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -43625,14 +43918,14 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 206 && node.parent.parent && node.parent.parent.kind === 267; + return node.parent && node.parent.kind === 207 && node.parent.parent && node.parent.parent.kind === 268; } function getTypeReferenceDirectivesForEntityName(node) { if (!fileToDirective) { return undefined; } var meaning = 67901928 | 1920; - if ((node.kind === 71 && isInTypeQuery(node)) || (node.kind === 184 && !isInHeritageClause(node))) { + if ((node.kind === 71 && isInTypeQuery(node)) || (node.kind === 185 && !isInHeritageClause(node))) { meaning = 67216319 | 1048576; } var symbol = resolveEntityName(node, meaning, true); @@ -43675,7 +43968,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 273 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 274 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -43689,12 +43982,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 238 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 239 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined); if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 273); + return ts.getDeclarationOfKind(moduleSymbol, 274); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -43736,7 +44029,7 @@ var ts; addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", 0, true); - getSymbolLinks(unknownSymbol).type = unknownType; + getSymbolLinks(unknownSymbol).type = errorType; globalArrayType = getGlobalType("Array", 1, true); globalObjectType = getGlobalType("Object", 0, true); globalFunctionType = getGlobalType("Function", 0, true); @@ -43804,7 +44097,7 @@ var ts; case 16384: return "__asyncValues"; case 32768: return "__exportStar"; case 65536: return "__makeTemplateObject"; - default: ts.Debug.fail("Unrecognized helper"); + default: return ts.Debug.fail("Unrecognized helper"); } } function resolveHelpersModule(node, errorNode) { @@ -43821,14 +44114,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 153 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 154 && !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 === 155 || node.kind === 156) { + else if (node.kind === 156 || node.kind === 157) { 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); @@ -43846,16 +44139,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 132) { - if (node.kind === 150 || node.kind === 152) { + if (node.kind === 151 || node.kind === 153) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 159) { + if (node.kind === 160) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 76: - if (node.kind !== 237 && node.parent.kind === 234) { + if (node.kind !== 238 && node.parent.kind === 235) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76)); } break; @@ -43875,7 +44168,7 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 239 || node.parent.kind === 273) { + else if (node.parent.kind === 240 || node.parent.kind === 274) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { @@ -43898,10 +44191,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 239 || node.parent.kind === 273) { + else if (node.parent.kind === 240 || node.parent.kind === 274) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 148) { + else if (node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -43914,7 +44207,7 @@ var ts; if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 151 && node.kind !== 150 && node.kind !== 159 && node.kind !== 148) { + else if (node.kind !== 152 && node.kind !== 151 && node.kind !== 160 && node.kind !== 149) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; @@ -43933,17 +44226,17 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 234) { + else if (node.parent.kind === 235) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 148) { + else if (node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; case 79: - var container = node.parent.kind === 273 ? node.parent : node.parent.parent; - if (container.kind === 238 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 274 ? node.parent : node.parent.parent; + if (container.kind === 239 && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512; @@ -43955,13 +44248,13 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 234) { + else if (node.parent.kind === 235) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 148) { + else if (node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304) && node.parent.kind === 239) { + else if ((node.parent.flags & 4194304) && node.parent.kind === 240) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; @@ -43971,14 +44264,14 @@ var ts; if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 234) { - if (node.kind !== 153 && - node.kind !== 151 && - node.kind !== 155 && - node.kind !== 156) { + if (node.kind !== 235) { + if (node.kind !== 154 && + node.kind !== 152 && + node.kind !== 156 && + node.kind !== 157) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 234 && ts.hasModifier(node.parent, 128))) { + if (!(node.parent.kind === 235 && ts.hasModifier(node.parent, 128))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -43997,7 +44290,7 @@ var ts; else if (flags & 2 || node.parent.flags & 4194304) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 148) { + else if (node.kind === 149) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -44005,7 +44298,7 @@ var ts; break; } } - if (node.kind === 154) { + if (node.kind === 155) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -44018,20 +44311,21 @@ var ts; else if (flags & 64) { return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly"); } - return; + return false; } - else if ((node.kind === 243 || node.kind === 242) && flags & 2) { + else if ((node.kind === 244 || node.kind === 243) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 148 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 149 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 148 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 149 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { return checkGrammarAsyncModifier(node, lastAsync); } + return false; } function reportObviousModifierErrors(node) { return !node.modifiers @@ -44042,37 +44336,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 155: case 156: - case 154: - case 151: - case 150: - case 153: + case 157: + case 155: case 152: - case 159: - case 238: + case 151: + case 154: + case 153: + case 160: + case 239: + case 244: case 243: - case 242: + case 250: case 249: - case 248: - case 191: case 192: - case 148: + case 193: + case 149: return false; default: - if (node.parent.kind === 239 || node.parent.kind === 273) { + if (node.parent.kind === 240 || node.parent.kind === 274) { return false; } switch (node.kind) { - case 233: - return nodeHasAnyModifiersExcept(node, 120); case 234: - return nodeHasAnyModifiersExcept(node, 117); + return nodeHasAnyModifiersExcept(node, 120); case 235: - case 213: + return nodeHasAnyModifiersExcept(node, 117); case 236: - return true; + case 214: case 237: + return true; + case 238: return nodeHasAnyModifiersExcept(node, 76); default: ts.Debug.fail(); @@ -44085,10 +44379,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 153: - case 233: - case 191: + case 154: + case 234: case 192: + case 193: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -44098,6 +44392,7 @@ var ts; if (list && list.hasTrailingComma) { return grammarErrorAtPos(list[0], list.end - ",".length, ",".length, diag); } + return false; } function checkGrammarTypeParameterList(typeParameters, file) { if (typeParameters && typeParameters.length === 0) { @@ -44105,6 +44400,7 @@ var ts; var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); } + return false; } function checkGrammarParameterList(parameters) { var seenOptionalParameter = false; @@ -44184,10 +44480,10 @@ var ts; } if (parameter.type.kind !== 137 && parameter.type.kind !== 134) { var type = getTypeFromTypeNode(parameter.type); - if (type.flags & 2 || type.flags & 4) { + 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(getTypeFromTypeNode(node.type))); } - if (type.flags & 131072 && allTypesAssignableToKind(type, 32, true)) { + if (type.flags & 262144 && allTypesAssignableToKind(type, 64, true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); @@ -44195,6 +44491,7 @@ var ts; if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); } + return false; } function checkGrammarIndexSignature(node) { return checkGrammarDecoratorsAndModifiers(node) || checkGrammarIndexSignatureParameters(node); @@ -44206,6 +44503,7 @@ var ts; var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); } + return false; } function checkGrammarTypeArguments(node, typeArguments) { return checkGrammarForDisallowedTrailingComma(typeArguments) || @@ -44215,11 +44513,12 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 205) { + if (arg.kind === 206) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } + return false; } function checkGrammarArguments(args) { return checkGrammarForOmittedArgument(args); @@ -44233,7 +44532,7 @@ var ts; var listType = ts.tokenToString(node.token); return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); } - return ts.forEach(types, checkGrammarExpressionWithTypeArguments); + return ts.some(types, checkGrammarExpressionWithTypeArguments); } function checkGrammarExpressionWithTypeArguments(node) { return checkGrammarTypeArguments(node, node.typeArguments); @@ -44288,19 +44587,20 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 146) { + if (node.kind !== 147) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 199 && computedPropertyName.expression.operatorToken.kind === 26) { + if (computedPropertyName.expression.kind === 200 && computedPropertyName.expression.operatorToken.kind === 26) { 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 === 233 || - node.kind === 191 || - node.kind === 153); + ts.Debug.assert(node.kind === 234 || + node.kind === 192 || + node.kind === 154); if (node.flags & 4194304) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -44310,9 +44610,7 @@ var ts; } } function checkGrammarForInvalidQuestionMark(questionToken, message) { - if (questionToken) { - return grammarErrorOnNode(questionToken, message); - } + return !!questionToken && grammarErrorOnNode(questionToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { var Flags; @@ -44325,43 +44623,43 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 271) { + if (prop.kind === 272) { continue; } var name = prop.name; - if (name.kind === 146) { + if (name.kind === 147) { checkGrammarComputedPropertyName(name); } - if (prop.kind === 270 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 271 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 120 || prop.kind !== 153) { + if (mod.kind !== 120 || prop.kind !== 154) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; switch (prop.kind) { - case 269: case 270: + case 271: checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8) { checkGrammarNumericLiteral(name); } - case 153: + case 154: currentKind = 1; break; - case 155: + case 156: currentKind = 2; break; - case 156: + case 157: currentKind = 4; break; default: - ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); + throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); } var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { @@ -44394,7 +44692,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 263) { + if (attr.kind === 264) { continue; } var name = attr.name, initializer = attr.initializer; @@ -44404,7 +44702,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 264 && !initializer.expression) { + if (initializer && initializer.kind === 265 && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -44413,12 +44711,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 221 && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 222 && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384) === 0) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 232) { + if (forInOrOfStatement.initializer.kind === 233) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -44426,20 +44724,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 220 + var diagnostic = forInOrOfStatement.kind === 221 ? 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 === 220 + var diagnostic = forInOrOfStatement.kind === 221 ? 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 === 220 + var diagnostic = forInOrOfStatement.kind === 221 ? 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); @@ -44466,11 +44764,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 155 ? + return grammarErrorOnNode(accessor.name, kind === 156 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 156) { + else if (kind === 157) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -44487,12 +44785,13 @@ var ts; } } } + return false; } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 155 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 156 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 155 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 156 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -44503,7 +44802,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 231: + case 232: var decl = parent; if (decl.name.kind !== 71) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -44515,13 +44814,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 151: + case 152: if (!ts.hasModifier(parent, 32) || !ts.hasModifier(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 150: + case 151: if (!ts.hasModifier(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); } @@ -44540,8 +44839,8 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 153) { - if (node.parent.kind === 183) { + if (node.kind === 154) { + if (node.parent.kind === 184) { if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 120)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } @@ -44560,14 +44859,14 @@ var ts; if (node.flags & 4194304) { 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 === 153 && !node.body) { + else if (node.kind === 154 && !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 === 235) { + else if (node.parent.kind === 236) { 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 === 165) { + else if (node.parent.kind === 166) { 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); } } @@ -44578,9 +44877,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 227: + case 228: if (node.label && current.label.escapedText === node.label.escapedText) { - var isMisplacedContinueLabel = node.kind === 222 + var isMisplacedContinueLabel = node.kind === 223 && !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); @@ -44588,8 +44887,8 @@ var ts; return false; } break; - case 226: - if (node.kind === 223 && !node.label) { + case 227: + if (node.kind === 224 && !node.label) { return false; } break; @@ -44602,13 +44901,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 223 + var message = node.kind === 224 ? 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 === 223 + var message = node.kind === 224 ? 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); @@ -44621,7 +44920,7 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - if (node.name.kind === 180 || node.name.kind === 179) { + if (node.name.kind === 181 || node.name.kind === 180) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -44634,11 +44933,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 197 && expr.operator === 38 && + expr.kind === 198 && expr.operator === 38 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 220 && node.parent.parent.kind !== 221) { + if (node.parent.parent.kind !== 221 && node.parent.parent.kind !== 222) { if (node.flags & 4194304) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -44665,7 +44964,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 213 || !node.type || node.initializer || node.flags & 4194304)) { + if (node.exclamationToken && (node.parent.parent.kind !== 214 || !node.type || node.initializer || node.flags & 4194304)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -44690,6 +44989,7 @@ var ts; } } } + return false; } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 71) { @@ -44706,6 +45006,7 @@ var ts; } } } + return false; } function checkGrammarVariableDeclarationList(declarationList) { var declarations = declarationList.declarations; @@ -44715,18 +45016,19 @@ var ts; if (!declarationList.declarations.length) { return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); } + return false; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 216: case 217: case 218: - case 225: case 219: + case 226: case 220: case 221: + case 222: return false; - case 227: + case 228: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -44766,6 +45068,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2)); return true; } + return false; } function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile); @@ -44773,6 +45076,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); return true; } + return false; } function grammarErrorOnNode(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); @@ -44780,11 +45084,12 @@ var ts; diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2)); return true; } + return false; } function checkGrammarConstructorTypeParameters(node) { - var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - if (ts.isNodeArray(typeParameters)) { - var pos = typeParameters.pos, end = typeParameters.end; + var jsdocTypeParameters = ts.isInJavaScriptFile(node) && ts.getJSDocTypeParameterDeclarations(node); + if (node.typeParameters || jsdocTypeParameters && jsdocTypeParameters.length) { + var _a = node.typeParameters || jsdocTypeParameters && jsdocTypeParameters[0] || node, pos = _a.pos, end = _a.end; return grammarErrorAtPos(node, pos, end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); } } @@ -44800,7 +45105,7 @@ var ts; return true; } } - else if (node.parent.kind === 235) { + else if (node.parent.kind === 236) { 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; } @@ -44808,7 +45113,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 165) { + else if (node.parent.kind === 166) { 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; } @@ -44825,13 +45130,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 235 || - node.kind === 236 || + if (node.kind === 236 || + node.kind === 237 || + node.kind === 244 || node.kind === 243 || - node.kind === 242 || + node.kind === 250 || node.kind === 249 || - node.kind === 248 || - node.kind === 241 || + node.kind === 242 || ts.hasModifier(node, 2 | 1 | 512)) { return false; } @@ -44840,12 +45145,13 @@ 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 === 213) { + if (ts.isDeclaration(decl) || decl.kind === 214) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } } } + return false; } function checkGrammarSourceFile(node) { return !!(node.flags & 4194304) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); @@ -44859,7 +45165,7 @@ var ts; if (!links.hasReportedStatementInAmbientContext && ts.isFunctionLike(node.parent)) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 212 || node.parent.kind === 239 || node.parent.kind === 273) { + if (node.parent.kind === 213 || node.parent.kind === 240 || node.parent.kind === 274) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -44868,6 +45174,7 @@ var ts; else { } } + return false; } function checkGrammarNumericLiteral(node) { if (node.numericLiteralFlags & 32) { @@ -44875,10 +45182,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, 177)) { + else if (ts.isChildOfNodeWithKind(node, 178)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 272)) { + else if (ts.isChildOfNodeWithKind(node, 273)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -44887,6 +45194,7 @@ var ts; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + return false; } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); @@ -44895,6 +45203,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2)); return true; } + return false; } function getAmbientModules() { if (!ambientModulesCache) { @@ -44921,13 +45230,14 @@ var ts; if (ts.isSpreadElement(nodeArguments[0])) { return grammarErrorOnNode(nodeArguments[0], ts.Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element); } + return false; } } ts.createTypeChecker = createTypeChecker; function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 247: - case 251: + case 248: + case 252: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -44935,13 +45245,13 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 244: - case 242: case 245: - case 247: + case 243: + case 246: + case 248: return true; case 71: - return decl.parent.kind === 247; + return decl.parent.kind === 248; default: return false; } @@ -44990,7 +45300,7 @@ var ts; ts.createNodeArray = createNodeArray; function getSynthesizedClone(node) { if (node === undefined) { - return undefined; + return node; } var clone = createSynthesizedNode(node.kind); clone.flags |= node.flags; @@ -45183,7 +45493,7 @@ var ts; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; function createQualifiedName(left, right) { - var node = createSynthesizedNode(145); + var node = createSynthesizedNode(146); node.left = left; node.right = asName(right); return node; @@ -45198,12 +45508,12 @@ var ts; ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26) || - expression.kind === 301 ? + expression.kind === 302 ? createParen(expression) : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(146); + var node = createSynthesizedNode(147); node.expression = parenthesizeForComputedName(expression); return node; } @@ -45215,7 +45525,7 @@ var ts; } ts.updateComputedPropertyName = updateComputedPropertyName; function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(147); + var node = createSynthesizedNode(148); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -45231,7 +45541,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(148); + var node = createSynthesizedNode(149); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -45255,7 +45565,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(149); + var node = createSynthesizedNode(150); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -45267,7 +45577,7 @@ var ts; } ts.updateDecorator = updateDecorator; function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(150); + var node = createSynthesizedNode(151); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -45287,7 +45597,7 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(151); + var node = createSynthesizedNode(152); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -45311,7 +45621,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(152, typeParameters, parameters, type); + var node = createSignatureDeclaration(153, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -45328,7 +45638,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(153); + var node = createSynthesizedNode(154); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -45356,7 +45666,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(154); + var node = createSynthesizedNode(155); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -45376,7 +45686,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(155); + var node = createSynthesizedNode(156); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -45399,7 +45709,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(156); + var node = createSynthesizedNode(157); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -45420,7 +45730,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(157, typeParameters, parameters, type); + return createSignatureDeclaration(158, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -45428,7 +45738,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(158, typeParameters, parameters, type); + return createSignatureDeclaration(159, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -45436,7 +45746,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(159); + var node = createSynthesizedNode(160); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -45474,7 +45784,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(160); + var node = createSynthesizedNode(161); node.parameterName = asName(parameterName); node.type = type; return node; @@ -45488,7 +45798,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(161); + var node = createSynthesizedNode(162); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -45502,7 +45812,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(162, typeParameters, parameters, type); + return createSignatureDeclaration(163, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -45510,7 +45820,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(163, typeParameters, parameters, type); + return createSignatureDeclaration(164, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -45518,7 +45828,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(164); + var node = createSynthesizedNode(165); node.exprName = exprName; return node; } @@ -45530,7 +45840,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(165); + var node = createSynthesizedNode(166); node.members = createNodeArray(members); return node; } @@ -45542,7 +45852,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(166); + var node = createSynthesizedNode(167); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -45554,7 +45864,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(167); + var node = createSynthesizedNode(168); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -45566,7 +45876,7 @@ var ts; } ts.updateTypleTypeNode = updateTypleTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(168, types); + return createUnionOrIntersectionTypeNode(169, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -45574,7 +45884,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169, types); + return createUnionOrIntersectionTypeNode(170, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -45593,7 +45903,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(170); + var node = createSynthesizedNode(171); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -45611,7 +45921,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(171); + var node = createSynthesizedNode(172); node.typeParameter = typeParameter; return node; } @@ -45623,7 +45933,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(178); + var node = createSynthesizedNode(179); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -45641,7 +45951,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(172); + var node = createSynthesizedNode(173); node.type = type; return node; } @@ -45653,11 +45963,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(173); + return createSynthesizedNode(174); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(174); + var node = createSynthesizedNode(175); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -45668,7 +45978,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(175); + var node = createSynthesizedNode(176); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -45682,7 +45992,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(176); + var node = createSynthesizedNode(177); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -45700,7 +46010,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(177); + var node = createSynthesizedNode(178); node.literal = literal; return node; } @@ -45712,7 +46022,7 @@ var ts; } ts.updateLiteralTypeNode = updateLiteralTypeNode; function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(179); + var node = createSynthesizedNode(180); node.elements = createNodeArray(elements); return node; } @@ -45724,7 +46034,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(180); + var node = createSynthesizedNode(181); node.elements = createNodeArray(elements); return node; } @@ -45736,7 +46046,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(181); + var node = createSynthesizedNode(182); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -45754,7 +46064,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(182); + var node = createSynthesizedNode(183); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -45768,7 +46078,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(183); + var node = createSynthesizedNode(184); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -45782,7 +46092,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(184); + var node = createSynthesizedNode(185); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072); @@ -45797,7 +46107,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(185); + var node = createSynthesizedNode(186); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -45811,7 +46121,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(186); + var node = createSynthesizedNode(187); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -45827,7 +46137,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187); + var node = createSynthesizedNode(188); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -45843,7 +46153,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(188); + var node = createSynthesizedNode(189); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -45866,7 +46176,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(189); + var node = createSynthesizedNode(190); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -45880,7 +46190,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(190); + var node = createSynthesizedNode(191); node.expression = expression; return node; } @@ -45892,7 +46202,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(191); + var node = createSynthesizedNode(192); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -45916,7 +46226,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(192); + var node = createSynthesizedNode(193); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -45950,7 +46260,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(193); + var node = createSynthesizedNode(194); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -45962,7 +46272,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(194); + var node = createSynthesizedNode(195); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -45974,7 +46284,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(195); + var node = createSynthesizedNode(196); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -45986,7 +46296,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(196); + var node = createSynthesizedNode(197); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -45998,7 +46308,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(197); + var node = createSynthesizedNode(198); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -46011,7 +46321,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(198); + var node = createSynthesizedNode(199); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -46024,7 +46334,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(199); + var node = createSynthesizedNode(200); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); @@ -46041,7 +46351,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(200); + var node = createSynthesizedNode(201); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -46071,7 +46381,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(201); + var node = createSynthesizedNode(202); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -46109,7 +46419,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(202); + var node = createSynthesizedNode(203); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 ? asteriskTokenOrExpression : expression; return node; @@ -46123,7 +46433,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(203); + var node = createSynthesizedNode(204); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -46135,7 +46445,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(204); + var node = createSynthesizedNode(205); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -46156,11 +46466,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(205); + return createSynthesizedNode(206); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(206); + var node = createSynthesizedNode(207); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -46174,7 +46484,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(207); + var node = createSynthesizedNode(208); node.expression = expression; node.type = type; return node; @@ -46188,7 +46498,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(208); + var node = createSynthesizedNode(209); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -46200,7 +46510,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(209); + var node = createSynthesizedNode(210); node.keywordToken = keywordToken; node.name = name; return node; @@ -46213,7 +46523,7 @@ var ts; } ts.updateMetaProperty = updateMetaProperty; function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(210); + var node = createSynthesizedNode(211); node.expression = expression; node.literal = literal; return node; @@ -46227,11 +46537,11 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(211); + return createSynthesizedNode(212); } ts.createSemicolonClassElement = createSemicolonClassElement; function createBlock(statements, multiLine) { - var block = createSynthesizedNode(212); + var block = createSynthesizedNode(213); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -46239,7 +46549,7 @@ var ts; } ts.createBlock = createBlock; function createExpressionStatement(expression) { - var node = createSynthesizedNode(215); + var node = createSynthesizedNode(216); node.expression = expression; return node; } @@ -46251,7 +46561,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(213); + var node = createSynthesizedNode(214); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -46266,7 +46576,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(214); + return createSynthesizedNode(215); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression) { @@ -46280,7 +46590,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(216); + var node = createSynthesizedNode(217); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -46296,7 +46606,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(217); + var node = createSynthesizedNode(218); node.statement = statement; node.expression = expression; return node; @@ -46310,7 +46620,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(218); + var node = createSynthesizedNode(219); node.expression = expression; node.statement = statement; return node; @@ -46324,7 +46634,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(219); + var node = createSynthesizedNode(220); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -46342,7 +46652,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(220); + var node = createSynthesizedNode(221); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -46358,7 +46668,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(221); + var node = createSynthesizedNode(222); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -46376,7 +46686,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(222); + var node = createSynthesizedNode(223); node.label = asName(label); return node; } @@ -46388,7 +46698,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(223); + var node = createSynthesizedNode(224); node.label = asName(label); return node; } @@ -46400,7 +46710,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(224); + var node = createSynthesizedNode(225); node.expression = expression; return node; } @@ -46412,7 +46722,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(225); + var node = createSynthesizedNode(226); node.expression = expression; node.statement = statement; return node; @@ -46426,7 +46736,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(226); + var node = createSynthesizedNode(227); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -46440,7 +46750,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(227); + var node = createSynthesizedNode(228); node.label = asName(label); node.statement = statement; return node; @@ -46454,7 +46764,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(228); + var node = createSynthesizedNode(229); node.expression = expression; return node; } @@ -46466,7 +46776,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(229); + var node = createSynthesizedNode(230); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -46482,11 +46792,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(230); + return createSynthesizedNode(231); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(231); + var node = createSynthesizedNode(232); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -46502,7 +46812,8 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { - var node = createSynthesizedNode(232); + if (flags === void 0) { flags = 0; } + var node = createSynthesizedNode(233); node.flags |= flags & 3; node.declarations = createNodeArray(declarations); return node; @@ -46515,7 +46826,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(233); + var node = createSynthesizedNode(234); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -46541,7 +46852,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(234); + var node = createSynthesizedNode(235); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -46563,7 +46874,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235); + var node = createSynthesizedNode(236); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -46585,7 +46896,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(236); + var node = createSynthesizedNode(237); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -46605,7 +46916,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(237); + var node = createSynthesizedNode(238); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -46623,7 +46934,8 @@ var ts; } ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { - var node = createSynthesizedNode(238); + if (flags === void 0) { flags = 0; } + var node = createSynthesizedNode(239); node.flags |= flags & (16 | 4 | 512); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -46642,7 +46954,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(239); + var node = createSynthesizedNode(240); node.statements = createNodeArray(statements); return node; } @@ -46654,7 +46966,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(240); + var node = createSynthesizedNode(241); node.clauses = createNodeArray(clauses); return node; } @@ -46666,7 +46978,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(241); + var node = createSynthesizedNode(242); node.name = asName(name); return node; } @@ -46678,7 +46990,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(242); + var node = createSynthesizedNode(243); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -46696,7 +47008,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(243); + var node = createSynthesizedNode(244); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -46714,7 +47026,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(244); + var node = createSynthesizedNode(245); node.name = name; node.namedBindings = namedBindings; return node; @@ -46728,7 +47040,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(245); + var node = createSynthesizedNode(246); node.name = name; return node; } @@ -46740,7 +47052,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(246); + var node = createSynthesizedNode(247); node.elements = createNodeArray(elements); return node; } @@ -46752,7 +47064,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(247); + var node = createSynthesizedNode(248); node.propertyName = propertyName; node.name = name; return node; @@ -46766,7 +47078,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(248); + var node = createSynthesizedNode(249); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -46783,7 +47095,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(249); + var node = createSynthesizedNode(250); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -46801,7 +47113,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(250); + var node = createSynthesizedNode(251); node.elements = createNodeArray(elements); return node; } @@ -46813,7 +47125,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(251); + var node = createSynthesizedNode(252); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -46827,7 +47139,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createExternalModuleReference(expression) { - var node = createSynthesizedNode(253); + var node = createSynthesizedNode(254); node.expression = expression; return node; } @@ -46839,7 +47151,7 @@ var ts; } ts.updateExternalModuleReference = updateExternalModuleReference; function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(254); + var node = createSynthesizedNode(255); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -46855,7 +47167,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(255); + var node = createSynthesizedNode(256); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -46871,7 +47183,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256); + var node = createSynthesizedNode(257); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -46887,7 +47199,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(257); + var node = createSynthesizedNode(258); node.tagName = tagName; return node; } @@ -46899,7 +47211,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(258); + var node = createSynthesizedNode(259); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -46915,7 +47227,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(261); + var node = createSynthesizedNode(262); node.name = name; node.initializer = initializer; return node; @@ -46929,7 +47241,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(262); + var node = createSynthesizedNode(263); node.properties = createNodeArray(properties); return node; } @@ -46941,7 +47253,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(263); + var node = createSynthesizedNode(264); node.expression = expression; return node; } @@ -46953,7 +47265,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(264); + var node = createSynthesizedNode(265); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -46966,7 +47278,7 @@ var ts; } ts.updateJsxExpression = updateJsxExpression; function createCaseClause(expression, statements) { - var node = createSynthesizedNode(265); + var node = createSynthesizedNode(266); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -46980,7 +47292,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(266); + var node = createSynthesizedNode(267); node.statements = createNodeArray(statements); return node; } @@ -46992,7 +47304,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(267); + var node = createSynthesizedNode(268); node.token = token; node.types = createNodeArray(types); return node; @@ -47005,7 +47317,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(268); + var node = createSynthesizedNode(269); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -47019,7 +47331,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(269); + var node = createSynthesizedNode(270); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -47034,7 +47346,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(270); + var node = createSynthesizedNode(271); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -47048,7 +47360,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(271); + var node = createSynthesizedNode(272); node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; return node; } @@ -47060,7 +47372,7 @@ var ts; } ts.updateSpreadAssignment = updateSpreadAssignment; function createEnumMember(name, initializer) { - var node = createSynthesizedNode(272); + var node = createSynthesizedNode(273); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -47079,7 +47391,7 @@ var ts; (referencedFiles !== undefined && node.referencedFiles !== referencedFiles) || (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(273); + var updated = createSynthesizedNode(274); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -47118,6 +47430,8 @@ var ts; updated.parseDiagnostics = node.parseDiagnostics; if (node.bindDiagnostics !== undefined) updated.bindDiagnostics = node.bindDiagnostics; + if (node.bindSuggestionDiagnostics !== undefined) + updated.bindSuggestionDiagnostics = node.bindSuggestionDiagnostics; if (node.lineMap !== undefined) updated.lineMap = node.lineMap; if (node.classifiableNames !== undefined) @@ -47150,28 +47464,28 @@ var ts; } ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createSynthesizedNode(299); + var node = createSynthesizedNode(300); node.original = original; setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(303); + var node = createSynthesizedNode(304); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(302); + var node = createSynthesizedNode(303); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(300); + var node = createSynthesizedNode(301); node.expression = expression; node.original = original; setTextRange(node, original); @@ -47187,7 +47501,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 301) { + if (node.kind === 302) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26) { @@ -47197,7 +47511,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(301); + var node = createSynthesizedNode(302); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -47210,20 +47524,20 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(274); + var node = ts.createNode(275); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text) { - var node = ts.createNode(275); + var node = ts.createNode(276); node.text = text; return node; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration) { - var node = ts.createNode(276); + var node = ts.createNode(277); node.javascriptText = javascript; node.declarationText = declaration; return node; @@ -47328,7 +47642,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 273) { + if (node.kind === 274) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -47736,7 +48050,7 @@ var ts; ts.createSpreadHelper = createSpreadHelper; function createForOfBindingStatement(node, boundValue) { if (ts.isVariableDeclarationList(node)) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); + var firstDeclaration = ts.first(node.declarations); var updatedDeclaration = ts.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, undefined, boundValue); return ts.setTextRange(ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(node, [updatedDeclaration])), node); } @@ -47759,7 +48073,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 227 + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -47777,19 +48091,20 @@ var ts; case 8: case 9: return false; - case 182: + case 183: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 183: + case 184: return target.properties.length > 0; default: return true; } } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { + if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } var callee = skipOuterExpressions(expression, 7); var thisArg; var target; @@ -47809,7 +48124,7 @@ var ts; } else { switch (callee.kind) { - case 184: { + case 185: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); @@ -47821,7 +48136,7 @@ var ts; } break; } - case 185: { + case 186: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); @@ -47874,14 +48189,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 155: case 156: - return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 269: - return createExpressionForPropertyAssignment(property, receiver); + case 157: + return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); case 270: + return createExpressionForPropertyAssignment(property, receiver); + case 271: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 153: + case 154: return createExpressionForMethodDeclaration(property, receiver); } } @@ -47953,6 +48268,7 @@ var ts; } ts.getDeclarationName = getDeclarationName; function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (emitFlags === void 0) { emitFlags = 0; } var nodeName = ts.getNameOfDeclaration(node); if (nodeName && ts.isIdentifier(nodeName) && !ts.isGeneratedIdentifier(nodeName)) { var name = ts.getMutableClone(nodeName); @@ -47977,7 +48293,7 @@ var ts; function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); ts.setTextRange(qualifiedName, name); - var emitFlags; + var emitFlags = 0; if (!allowSourceMaps) emitFlags |= 48; if (!allowComments) @@ -47992,7 +48308,8 @@ var ts; } ts.convertToFunctionBody = convertToFunctionBody; function convertFunctionDeclarationToExpression(node) { - ts.Debug.assert(!!node.body); + if (!node.body) + return ts.Debug.fail(); var updated = ts.createFunctionExpression(node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body); ts.setOriginalNode(updated, node); ts.setTextRange(updated, node); @@ -48037,7 +48354,7 @@ var ts; ts.addStandardPrologue = addStandardPrologue; function addCustomPrologue(target, source, statementOffset, visitor) { var numStatements = source.length; - while (statementOffset < numStatements) { + while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; if (ts.getEmitFlags(statement) & 1048576) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); @@ -48081,7 +48398,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 190) { + if (skipped.kind === 191) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -48090,15 +48407,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(199, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(199, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(200, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(200, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 202) { + && operand.kind === 203) { return false; } return true; @@ -48137,7 +48454,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 199 && node.operatorToken.kind === 37) { + if (node.kind === 200 && node.operatorToken.kind === 37) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -48152,7 +48469,7 @@ var ts; return 0; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(200, 55); + var conditionalPrecedence = ts.getOperatorPrecedence(201, 55); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { @@ -48163,17 +48480,17 @@ var ts; ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; function parenthesizeSubexpressionOfConditionalExpression(e) { var emittedExpression = ts.skipPartiallyEmittedExpressions(e); - return emittedExpression.kind === 199 && emittedExpression.operatorToken.kind === 26 || - emittedExpression.kind === 301 + return emittedExpression.kind === 200 && emittedExpression.operatorToken.kind === 26 || + emittedExpression.kind === 302 ? ts.createParen(e) : e; } ts.parenthesizeSubexpressionOfConditionalExpression = parenthesizeSubexpressionOfConditionalExpression; function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 204 || - check.kind === 191 || - check.kind === 301 || + return (check.kind === 205 || + check.kind === 192 || + check.kind === 302 || ts.isBinaryExpression(check) && check.operatorToken.kind === 26) ? ts.createParen(e) : e; @@ -48182,9 +48499,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, true); switch (leftmostExpr.kind) { - case 186: - return ts.createParen(expression); case 187: + return ts.createParen(expression); + case 188: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -48195,7 +48512,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 187 || emittedExpression.arguments)) { + && (emittedExpression.kind !== 188 || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -48233,7 +48550,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(199, 26); + var commaPrecedence = ts.getOperatorPrecedence(200, 26); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -48244,29 +48561,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 191 || kind === 192) { + if (kind === 192 || kind === 193) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, false).kind; - if (leftmostExpressionKind === 183 || leftmostExpressionKind === 191) { + if (leftmostExpressionKind === 184 || leftmostExpressionKind === 192) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 170 ? ts.createParenthesizedType(member) : member; + return member.kind === 171 ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 168: case 169: - case 162: + case 170: case 163: + case 164: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -48274,9 +48591,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 164: - case 174: - case 171: + case 165: + case 175: + case 172: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -48302,24 +48619,24 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 198: + case 199: node = node.operand; continue; - case 199: + case 200: node = node.left; continue; - case 200: + case 201: node = node.condition; continue; - case 186: + case 187: if (stopAtCallExpressions) { return node; } + case 186: case 185: - case 184: node = node.expression; continue; - case 300: + case 301: node = node.expression; continue; } @@ -48327,7 +48644,7 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, false).kind === 183) { + if (!ts.isBlock(body) && getLeftmostExpression(body, false).kind === 184) { return ts.setTextRange(ts.createParen(body), body); } return body; @@ -48343,13 +48660,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7; } switch (node.kind) { - case 190: + case 191: return (kinds & 1) !== 0; - case 189: - case 207: + case 190: case 208: + case 209: return (kinds & 2) !== 0; - case 300: + case 301: return (kinds & 4) !== 0; } return false; @@ -48374,7 +48691,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 208) { + while (ts.isAssertionExpression(node) || node.kind === 209) { node = node.expression; } return node; @@ -48382,15 +48699,15 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 190: return ts.updateParen(outerExpression, expression); - case 189: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 207: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 208: return ts.updateNonNullExpression(outerExpression, expression); - case 300: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 191: return ts.updateParen(outerExpression, expression); + case 190: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 208: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 209: return ts.updateNonNullExpression(outerExpression, expression); + case 301: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } function isIgnorableParen(node) { - return node.kind === 190 + return node.kind === 191 && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -48452,10 +48769,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 243 && node.importClause) { + if (node.kind === 244 && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 249 && node.moduleSpecifier) { + if (node.kind === 250 && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -48496,8 +48813,9 @@ var ts; return bindingElement.initializer; } if (ts.isPropertyAssignment(bindingElement)) { - return ts.isAssignmentExpression(bindingElement.initializer, true) - ? bindingElement.initializer.right + var initializer = bindingElement.initializer; + return ts.isAssignmentExpression(initializer, true) + ? initializer.right : undefined; } if (ts.isShorthandPropertyAssignment(bindingElement)) { @@ -48517,11 +48835,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 269: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 270: - return bindingElement.name; + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 271: + return bindingElement.name; + case 272: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -48537,11 +48855,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 148: - case 181: + case 149: + case 182: return bindingElement.dotDotDotToken; - case 203: - case 271: + case 204: + case 272: return bindingElement; } return undefined; @@ -48549,7 +48867,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 181: + case 182: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -48557,7 +48875,7 @@ var ts; : propertyName; } break; - case 269: + case 270: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -48565,7 +48883,7 @@ var ts; : propertyName; } break; - case 271: + case 272: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -48579,11 +48897,11 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 179: case 180: - case 182: - return name.elements; + case 181: case 183: + return name.elements; + case 184: return name.properties; } } @@ -48622,11 +48940,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 180: - case 182: - return convertToArrayAssignmentPattern(node); - case 179: + case 181: case 183: + return convertToArrayAssignmentPattern(node); + case 180: + case 184: return convertToObjectAssignmentPattern(node); } } @@ -48763,257 +49081,257 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 144) || kind === 173) { + if ((kind > 0 && kind <= 145) || kind === 174) { return node; } switch (kind) { case 71: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 145: - return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); case 146: - return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); case 147: - return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); + return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); case 148: - return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); case 149: - return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 150: - return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); case 151: - return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 152: - return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); + return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 153: - return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); case 154: - return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 155: - return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); case 156: - return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 157: - return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); case 158: - return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 159: - return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 160: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 161: - return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); + return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); case 162: - return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); case 163: - return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 164: - return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); + return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 165: - return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); + return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); case 166: - return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); + return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); case 167: - return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); case 168: - return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); case 169: - return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); case 170: - return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); + return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); case 171: - return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 178: - return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); + return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); case 172: - return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174: - return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 175: - return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 176: - return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 177: - return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); + return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); case 179: - return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); + return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); + case 173: + return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 175: + return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 176: + return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); + case 177: + return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); + case 178: + return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); case 180: - return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); + return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); case 181: - return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); case 182: - return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); + return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); case 183: - return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); + return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); case 184: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); case 185: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); case 186: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); case 187: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); case 188: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); case 189: - return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); case 190: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 191: - return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 192: - return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); + return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 193: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); case 194: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 195: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); case 196: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); case 197: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); case 198: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); case 199: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); case 200: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); case 201: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); case 202: - return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); case 203: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); case 204: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 205: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 206: - return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 207: - return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); case 208: - return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); case 209: - return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 210: + return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); + case 211: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 212: - return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 213: + return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 214: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 215: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 216: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); case 217: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); case 218: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); case 219: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 220: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 221: - return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 222: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); + return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 223: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); case 224: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); case 225: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); case 226: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 227: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); case 228: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 229: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 230: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 231: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 232: - return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); case 233: - return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); case 234: - return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 235: - return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); + return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); case 236: - return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); case 237: - return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); + return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); case 238: - return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); case 239: - return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); case 240: - return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); + return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 241: - return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); case 242: - return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); + return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); case 243: - return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); case 244: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); + return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 245: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); case 246: - return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); case 247: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); case 248: - return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); case 249: - return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); case 250: - return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); + return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); case 251: + return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); + case 252: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 253: - return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); case 254: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); case 255: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); case 256: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); case 257: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); case 258: + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + case 259: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 261: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 262: - return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); case 263: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); case 264: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); case 265: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 266: - return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); case 267: - return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); + return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); case 268: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); case 269: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); case 270: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); case 271: - return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); case 272: - return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); case 273: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 274: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 300: - return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); case 301: + return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + case 302: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: return node; @@ -49039,52 +49357,52 @@ var ts; var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; - if ((kind > 0 && kind <= 144)) { + if ((kind > 0 && kind <= 145)) { return initial; } - if ((kind >= 160 && kind <= 177)) { + if ((kind >= 161 && kind <= 178)) { return initial; } var result = initial; switch (node.kind) { - case 211: - case 214: - case 205: - case 230: - case 299: + case 212: + case 215: + case 206: + case 231: + case 300: break; - case 145: + case 146: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 146: + case 147: result = reduceNode(node.expression, cbNode, result); break; - case 148: + case 149: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149: + case 150: result = reduceNode(node.expression, cbNode, result); break; - case 150: + case 151: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 151: + case 152: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153: + case 154: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -49093,53 +49411,48 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 154: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; case 155: - result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; case 156: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 157: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 179: case 180: + case 181: result = reduceNodes(node.elements, cbNodes, result); break; - case 181: + case 182: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 182: + case 183: result = reduceNodes(node.elements, cbNodes, result); break; - case 183: - result = reduceNodes(node.properties, cbNodes, result); - break; case 184: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.properties, cbNodes, result); break; case 185: result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); + result = reduceNode(node.name, cbNode, result); break; case 186: result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); + result = reduceNode(node.argumentExpression, cbNode, result); break; case 187: result = reduceNode(node.expression, cbNode, result); @@ -49147,14 +49460,19 @@ var ts; result = reduceNodes(node.arguments, cbNodes, result); break; case 188: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 189: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 189: + case 190: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 191: + case 192: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -49162,262 +49480,262 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 192: + case 193: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 190: - case 193: + case 191: case 194: case 195: case 196: - case 202: + case 197: case 203: - case 208: + case 204: + case 209: result = reduceNode(node.expression, cbNode, result); break; - case 197: case 198: + case 199: result = reduceNode(node.operand, cbNode, result); break; - case 199: + case 200: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 200: + case 201: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 201: + case 202: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 204: + case 205: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 206: + case 207: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 207: + case 208: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; - case 210: + case 211: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 212: + case 213: result = reduceNodes(node.statements, cbNodes, result); break; - case 213: + case 214: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 215: + case 216: result = reduceNode(node.expression, cbNode, result); break; - case 216: + case 217: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 217: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; case 218: - case 225: - result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); break; case 219: + case 226: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 220: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220: case 221: + case 222: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 224: - case 228: + case 225: + case 229: result = reduceNode(node.expression, cbNode, result); break; - case 226: + case 227: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 227: + case 228: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 229: + case 230: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 231: + case 232: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 232: - result = reduceNodes(node.declarations, cbNodes, result); - break; case 233: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); + result = reduceNodes(node.declarations, cbNodes, result); break; case 234: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.heritageClauses, cbNodes, result); - result = reduceNodes(node.members, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); break; - case 237: + case 235: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; case 238: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.body, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); break; case 239: - result = reduceNodes(node.statements, cbNodes, result); + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); break; case 240: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 241: result = reduceNodes(node.clauses, cbNodes, result); break; - case 242: + case 243: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 243: + case 244: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 244: + case 245: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 245: - result = reduceNode(node.name, cbNode, result); - break; case 246: - case 250: - result = reduceNodes(node.elements, cbNodes, result); + result = reduceNode(node.name, cbNode, result); break; case 247: case 251: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 248: + case 252: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 248: + case 249: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 249: + case 250: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 253: + case 254: result = reduceNode(node.expression, cbNode, result); break; - case 254: + case 255: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 258: + case 259: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 255: case 256: + case 257: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 262: + case 263: result = reduceNodes(node.properties, cbNodes, result); break; - case 257: + case 258: result = reduceNode(node.tagName, cbNode, result); break; - case 261: + case 262: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 263: - result = reduceNode(node.expression, cbNode, result); - break; case 264: result = reduceNode(node.expression, cbNode, result); break; case 265: result = reduceNode(node.expression, cbNode, result); + break; case 266: + result = reduceNode(node.expression, cbNode, result); + case 267: result = reduceNodes(node.statements, cbNodes, result); break; - case 267: + case 268: result = reduceNodes(node.types, cbNodes, result); break; - case 268: + case 269: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 269: + case 270: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270: + case 271: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 271: + case 272: result = reduceNode(node.expression, cbNode, result); break; - case 272: + case 273: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 273: + case 274: result = reduceNodes(node.statements, cbNodes, result); break; - case 300: + case 301: result = reduceNode(node.expression, cbNode, result); break; - case 301: + case 302: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -49431,8 +49749,8 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements) - : ts.prependRange(statements, declarations); + ? ts.setTextRange(ts.createNodeArray(ts.prependStatements(statements.slice(), declarations)), statements) + : ts.prependStatements(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; function liftToBlock(nodes) { @@ -49470,7 +49788,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 206)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 207)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -49511,7 +49829,7 @@ var ts; }); Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, { __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 65536 ? ts.formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 131072 ? ts.formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { return this.checker.typeToString(this); } }, }); var nodeConstructors = [ @@ -49560,12 +49878,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName && e.propertyName.escapedText === "default"; + return e.propertyName !== undefined && e.propertyName.escapedText === "default"; } function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 273 ? transformSourceFile(node) : transformBundle(node); + return node.kind === 274 ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -49593,7 +49911,7 @@ var ts; } ts.getImportNeedsImportStarHelper = getImportNeedsImportStarHelper; function getImportNeedsImportDefaultHelper(node) { - return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings))); + return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (!!node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings))); } ts.getImportNeedsImportDefaultHelper = getImportNeedsImportDefaultHelper; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { @@ -49609,16 +49927,16 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 243: + case 244: externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 242: - if (node.moduleReference.kind === 253) { + case 243: + if (node.moduleReference.kind === 254) { externalImports.push(node); } break; - case 249: + case 250: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -49645,12 +49963,12 @@ var ts; } } break; - case 248: + case 249: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 213: + case 214: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -49658,7 +49976,7 @@ var ts; } } break; - case 233: + case 234: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -49676,7 +49994,7 @@ var ts; } } break; - case 234: + case 235: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -49783,7 +50101,7 @@ var ts; var flattenContext = { context: context, level: level, - downlevelIteration: context.getCompilerOptions().downlevelIteration, + downlevelIteration: !!context.getCompilerOptions().downlevelIteration, hoistTempVariables: true, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -49848,13 +50166,14 @@ var ts; return false; } function flattenDestructuringBinding(node, visitor, context, level, rval, hoistTempVariables, skipInitializer) { + if (hoistTempVariables === void 0) { hoistTempVariables = false; } var pendingExpressions; var pendingDeclarations = []; var declarations = []; var flattenContext = { context: context, level: level, - downlevelIteration: context.getCompilerOptions().downlevelIteration, + downlevelIteration: !!context.getCompilerOptions().downlevelIteration, hoistTempVariables: hoistTempVariables, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -49880,7 +50199,7 @@ var ts; } else { context.hoistVariableDeclaration(temp); - var pendingDeclaration = ts.lastOrUndefined(pendingDeclarations); + var pendingDeclaration = ts.last(pendingDeclarations); pendingDeclaration.pendingExpressions = ts.append(pendingDeclaration.pendingExpressions, ts.createAssignment(temp, pendingDeclaration.value)); ts.addRange(pendingDeclaration.pendingExpressions, pendingExpressions); pendingDeclaration.value = temp; @@ -50147,8 +50466,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(184); context.enableSubstitution(185); + context.enableSubstitution(186); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -50160,14 +50479,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 274) { + if (node.kind === 275) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 276) { + if (prepend.kind === 277) { return ts.createUnparsedSourceFile(prepend.javascriptText); } return prepend; @@ -50196,15 +50515,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 273: + case 274: + case 241: case 240: - case 239: - case 212: + case 213: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 235: case 234: - case 233: if (ts.hasModifier(node, 2)) { break; } @@ -50212,7 +50531,7 @@ var ts; recordEmittedDeclarationInScope(node); } else { - ts.Debug.assert(node.kind === 234 || ts.hasModifier(node, 512)); + ts.Debug.assert(node.kind === 235 || ts.hasModifier(node, 512)); } break; } @@ -50234,10 +50553,10 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { + case 244: case 243: - case 242: - case 248: case 249: + case 250: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -50252,13 +50571,13 @@ var ts; return node; } switch (node.kind) { - case 243: + case 244: return visitImportDeclaration(node); - case 242: + case 243: return visitImportEqualsDeclaration(node); - case 248: - return visitExportAssignment(node); case 249: + return visitExportAssignment(node); + case 250: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -50268,11 +50587,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 249 || - node.kind === 243 || + if (node.kind === 250 || node.kind === 244 || - (node.kind === 242 && - node.moduleReference.kind === 253)) { + node.kind === 245 || + (node.kind === 243 && + node.moduleReference.kind === 254)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -50288,15 +50607,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 154: - return undefined; - case 151: - case 159: case 155: + return undefined; + case 152: + case 160: case 156: - case 153: + case 157: + case 154: return visitorWorker(node); - case 211: + case 212: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -50326,87 +50645,88 @@ var ts; case 76: case 124: case 132: - case 166: case 167: - case 165: - case 160: - case 147: + case 168: + case 166: + case 161: + case 148: case 119: + case 142: case 122: case 137: case 134: case 131: case 105: case 138: - case 163: - case 162: case 164: - case 161: - case 168: + case 163: + case 165: + case 162: case 169: case 170: - case 172: + case 171: case 173: case 174: case 175: case 176: case 177: - case 159: - case 149: - case 236: - return undefined; - case 151: - return visitPropertyDeclaration(node); - case 241: - return undefined; - case 154: - return visitConstructor(node); - case 235: - return ts.createNotEmittedStatement(node); - case 234: - return visitClassDeclaration(node); - case 204: - return visitClassExpression(node); - case 267: - return visitHeritageClause(node); - case 206: - return visitExpressionWithTypeArguments(node); - case 153: - return visitMethodDeclaration(node); - case 155: - return visitGetAccessor(node); - case 156: - return visitSetAccessor(node); - case 233: - return visitFunctionDeclaration(node); - case 191: - return visitFunctionExpression(node); - case 192: - return visitArrowFunction(node); - case 148: - return visitParameter(node); - case 190: - return visitParenthesizedExpression(node); - case 189: - case 207: - return visitAssertionExpression(node); - case 186: - return visitCallExpression(node); - case 187: - return visitNewExpression(node); - case 188: - return visitTaggedTemplateExpression(node); - case 208: - return visitNonNullExpression(node); + case 178: + case 160: + case 150: case 237: - return visitEnumDeclaration(node); - case 213: - return visitVariableStatement(node); - case 231: - return visitVariableDeclaration(node); - case 238: - return visitModuleDeclaration(node); + return undefined; + case 152: + return visitPropertyDeclaration(node); case 242: + return undefined; + case 155: + return visitConstructor(node); + case 236: + return ts.createNotEmittedStatement(node); + case 235: + return visitClassDeclaration(node); + case 205: + return visitClassExpression(node); + case 268: + return visitHeritageClause(node); + case 207: + return visitExpressionWithTypeArguments(node); + case 154: + return visitMethodDeclaration(node); + case 156: + return visitGetAccessor(node); + case 157: + return visitSetAccessor(node); + case 234: + return visitFunctionDeclaration(node); + case 192: + return visitFunctionExpression(node); + case 193: + return visitArrowFunction(node); + case 149: + return visitParameter(node); + case 191: + return visitParenthesizedExpression(node); + case 190: + case 208: + return visitAssertionExpression(node); + case 187: + return visitCallExpression(node); + case 188: + return visitNewExpression(node); + case 189: + return visitTaggedTemplateExpression(node); + case 209: + return visitNonNullExpression(node); + case 238: + return visitEnumDeclaration(node); + case 214: + return visitVariableStatement(node); + case 232: + return visitVariableDeclaration(node); + case 239: + return visitModuleDeclaration(node); + case 243: return visitImportEqualsDeclaration(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -50414,7 +50734,8 @@ var ts; } function visitSourceFile(node) { var alwaysStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") && - !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015); + !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015) && + !ts.isJsonSourceFile(node); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict)); } function shouldEmitDecorateCallForClass(node) { @@ -50484,7 +50805,7 @@ var ts; statement.pos = closingBraceLocation.pos; ts.setEmitFlags(statement, 1536 | 384); statements.push(statement); - ts.prependRange(statements, context.endLexicalEnvironment()); + ts.prependStatements(statements, context.endLexicalEnvironment()); var iife = ts.createImmediatelyInvokedArrowFunction(statements); ts.setEmitFlags(iife, 33554432); var varStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ @@ -50626,7 +50947,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 215 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 216 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -50660,7 +50981,7 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 151 + return member.kind === 152 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } @@ -50735,12 +51056,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 155: case 156: + case 157: return getAllDecoratorsOfAccessors(node, member); - case 153: + case 154: return getAllDecoratorsOfMethod(member); - case 151: + case 152: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -50819,7 +51140,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 151 + ? member.kind === 152 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -50903,37 +51224,37 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 153 - || kind === 155 + return kind === 154 || kind === 156 - || kind === 151; + || kind === 157 + || kind === 152; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 153; + return node.kind === 154; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 234: - case 204: + case 235: + case 205: return ts.getFirstConstructorWithBody(node) !== undefined; - case 153: - case 155: + case 154: case 156: + case 157: return true; } return false; } function serializeTypeOfNode(node) { switch (node.kind) { - case 151: - case 148: - case 155: - return serializeTypeNode(node.type); + case 152: + case 149: case 156: + return serializeTypeNode(node.type); + case 157: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 234: - case 204: - case 153: + case 235: + case 205: + case 154: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -50965,7 +51286,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 155) { + if (container && node.kind === 156) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -50992,22 +51313,22 @@ var ts; case 95: case 131: return ts.createVoidZero(); - case 172: + case 173: return serializeTypeNode(node.type); - case 162: case 163: + case 164: return ts.createIdentifier("Function"); - case 166: case 167: + case 168: return ts.createIdentifier("Array"); - case 160: + case 161: case 122: return ts.createIdentifier("Boolean"); case 137: return ts.createIdentifier("String"); case 135: return ts.createIdentifier("Object"); - case 177: + case 178: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); @@ -51025,18 +51346,19 @@ var ts; return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 161: + case 162: return serializeTypeReferenceNode(node); + case 170: case 169: - case 168: return serializeUnionOrIntersectionType(node); - case 164: - case 174: + case 165: case 175: case 176: - case 165: + case 177: + case 166: case 119: - case 173: + case 142: + case 174: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -51047,7 +51369,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 172) { + while (typeNode.kind === 173) { typeNode = typeNode.type; } if (typeNode.kind === 131) { @@ -51074,7 +51396,8 @@ var ts; return serializedUnion || ts.createVoidZero(); } function serializeTypeReferenceNode(node) { - switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) { + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, true); var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -51100,8 +51423,9 @@ var ts; case ts.TypeReferenceSerializationKind.Promise: return ts.createIdentifier("Promise"); case ts.TypeReferenceSerializationKind.ObjectType: - default: return ts.createIdentifier("Object"); + default: + return ts.Debug.assertNever(kind); } } function serializeEntityNameAsExpression(node, useFallback) { @@ -51115,7 +51439,7 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } return name; - case 145: + case 146: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -51370,7 +51694,7 @@ var ts; var statements = []; startLexicalEnvironment(); var members = ts.map(node.members, transformEnumMember); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); ts.addRange(statements, members); currentNamespaceContainerName = savedCurrentNamespaceLocalName; return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); @@ -51400,7 +51724,7 @@ var ts; } } function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules); } function hasNamespaceQualifiedExportName(node) { return isExportOfNamespace(node) @@ -51432,11 +51756,11 @@ var ts; function addVarForEnumOrModuleDeclaration(statements, node) { var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, false, true)) - ], currentScope.kind === 273 ? 0 : 1)); + ], currentScope.kind === 274 ? 0 : 1)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 237) { + if (node.kind === 238) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -51497,7 +51821,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 239) { + if (body.kind === 240) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -51515,19 +51839,19 @@ var ts; var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; statementsLocation = ts.moveRangePos(moduleBlock.statements, -1); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); ts.setTextRange(block, blockLocation); - if (body.kind !== 239) { + if (body.kind !== 240) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 238) { + if (moduleDeclaration.body.kind === 239) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -51547,7 +51871,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 245) { + if (node.kind === 246) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -51682,15 +52006,15 @@ var ts; if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; context.enableSubstitution(71); - context.enableSubstitution(270); - context.enableEmitNotification(238); + context.enableSubstitution(271); + context.enableEmitNotification(239); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 238; + return ts.getOriginalNode(node).kind === 239; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 237; + return ts.getOriginalNode(node).kind === 238; } function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -51736,9 +52060,9 @@ var ts; switch (node.kind) { case 71: return substituteExpressionIdentifier(node); - case 184: - return substitutePropertyAccessExpression(node); case 185: + return substitutePropertyAccessExpression(node); + case 186: return substituteElementAccessExpression(node); } return node; @@ -51768,9 +52092,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 !== 273) { - var substitute = (applicableSubstitutions & 2 && container.kind === 238) || - (applicableSubstitutions & 8 && container.kind === 237); + if (container && container.kind !== 274) { + var substitute = (applicableSubstitutions & 2 && container.kind === 239) || + (applicableSubstitutions & 8 && container.kind === 238); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } @@ -51887,15 +52211,15 @@ var ts; switch (node.kind) { case 120: return undefined; - case 196: + case 197: return visitAwaitExpression(node); - case 153: + case 154: return visitMethodDeclaration(node); - case 233: + case 234: return visitFunctionDeclaration(node); - case 191: - return visitFunctionExpression(node); case 192: + return visitFunctionExpression(node); + case 193: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -51904,27 +52228,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 213: + case 214: return visitVariableStatementInAsyncBody(node); - case 219: - return visitForStatementInAsyncBody(node); case 220: - return visitForInStatementInAsyncBody(node); + return visitForStatementInAsyncBody(node); case 221: + return visitForInStatementInAsyncBody(node); + case 222: return visitForOfStatementInAsyncBody(node); - case 268: + case 269: return visitCatchClauseInAsyncBody(node); - case 212: - case 226: - case 240: - case 265: - case 266: - case 229: - case 217: - case 218: - case 216: - case 225: + case 213: case 227: + case 241: + case 266: + case 267: + case 230: + case 218: + case 219: + case 217: + case 226: + case 228: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -51973,8 +52297,9 @@ var ts; : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, ts.liftToBlock)); } function visitForStatementInAsyncBody(node) { - return ts.updateFor(node, isVariableDeclarationListWithCollidingName(node.initializer) - ? visitVariableDeclarationListWithCollidingNames(node.initializer, false) + var initializer = node.initializer; + return ts.updateFor(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, ts.liftToBlock)); } function visitAwaitExpression(node) { @@ -52015,10 +52340,10 @@ var ts; } } function isVariableDeclarationListWithCollidingName(node) { - return node + return !!node && ts.isVariableDeclarationList(node) && !(node.flags & 3) - && ts.forEach(node.declarations, collidesWithParameterName); + && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { hoistVariableDeclarationList(node); @@ -52072,7 +52397,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 === 192; + var isArrowFunction = node.kind === 193; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames; enclosingFunctionParameterNames = ts.createUnderscoreEscapedMap(); @@ -52085,7 +52410,7 @@ var ts; var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.createBlock(statements, true); ts.setTextRange(block, node.body); if (languageVersion >= 2) { @@ -52136,14 +52461,14 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(186); - context.enableSubstitution(184); + context.enableSubstitution(187); context.enableSubstitution(185); - context.enableEmitNotification(234); - context.enableEmitNotification(153); - context.enableEmitNotification(155); - context.enableEmitNotification(156); + context.enableSubstitution(186); + context.enableEmitNotification(235); context.enableEmitNotification(154); + context.enableEmitNotification(156); + context.enableEmitNotification(157); + context.enableEmitNotification(155); } } function onEmitNode(hint, node, emitCallback) { @@ -52168,11 +52493,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 184: - return substitutePropertyAccessExpression(node); case 185: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 186: + return substituteElementAccessExpression(node); + case 187: return substituteCallExpression(node); } return node; @@ -52203,11 +52528,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 234 - || kind === 154 - || kind === 153 + return kind === 235 || kind === 155 - || kind === 156; + || kind === 154 + || kind === 156 + || kind === 157; } function createSuperAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096) { @@ -52291,45 +52616,47 @@ var ts; return node; } switch (node.kind) { - case 196: + case 197: return visitAwaitExpression(node); - case 202: + case 203: return visitYieldExpression(node); - case 227: + case 225: + return visitReturnStatement(node); + case 228: return visitLabeledStatement(node); - case 183: + case 184: return visitObjectLiteralExpression(node); - case 199: + case 200: return visitBinaryExpression(node, noDestructuringValue); - case 231: + case 232: return visitVariableDeclaration(node); - case 221: + case 222: return visitForOfStatement(node, undefined); - case 219: + case 220: return visitForStatement(node); - case 195: + case 196: return visitVoidExpression(node); - case 154: - return visitConstructorDeclaration(node); - case 153: - return visitMethodDeclaration(node); case 155: - return visitGetAccessorDeclaration(node); + return visitConstructorDeclaration(node); + case 154: + return visitMethodDeclaration(node); case 156: + return visitGetAccessorDeclaration(node); + case 157: return visitSetAccessorDeclaration(node); - case 233: + case 234: return visitFunctionDeclaration(node); - case 191: - return visitFunctionExpression(node); case 192: + return visitFunctionExpression(node); + case 193: return visitArrowFunction(node); - case 148: + case 149: return visitParameter(node); - case 215: + case 216: return visitExpressionStatement(node); - case 190: + case 191: return visitParenthesizedExpression(node, noDestructuringValue); - case 268: + case 269: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -52353,10 +52680,16 @@ var ts; } return ts.visitEachChild(node, visitor, context); } + function visitReturnStatement(node) { + if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) { + return ts.updateReturn(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : ts.createVoidZero())); + } + return ts.visitEachChild(node, visitor, context); + } function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 221 && statement.awaitModifier) { + if (statement.kind === 222 && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -52368,7 +52701,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 === 271) { + if (e.kind === 272) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -52377,7 +52710,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 269 + chunkObject = ts.append(chunkObject, e.kind === 270 ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -52390,7 +52723,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 1048576) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 183) { + if (objects.length && objects[0].kind !== 184) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -52502,7 +52835,7 @@ var ts; var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, callValues), node.expression), ts.createVariableDeclaration(result) - ]), node.expression), 2097152), ts.createComma(ts.createAssignment(result, createDownlevelAwait(callNext)), ts.createLogicalNot(getDone)), undefined, convertForOfStatementHead(node, createDownlevelAwait(getValue))), node), 256); + ]), node.expression), 2097152), ts.createComma(ts.createAssignment(result, createDownlevelAwait(callNext)), ts.createLogicalNot(getDone)), undefined, convertForOfStatementHead(node, getValue)), node), 256); return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ @@ -52596,7 +52929,7 @@ var ts; var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor); appendObjectRestAssignmentsIfNeeded(statements, node); statements.push(ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression(undefined, ts.createToken(39), node.name && ts.getGeneratedNameForNode(node.name), undefined, [], undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset)))))); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.updateBlock(node.body, statements); if (languageVersion >= 2) { if (resolver.getNodeCheckFlags(node) & 4096) { @@ -52622,7 +52955,7 @@ var ts; var leadingStatements = endLexicalEnvironment(); if (statementOffset > 0 || ts.some(statements) || ts.some(leadingStatements)) { var block = ts.convertToFunctionBody(body, true); - ts.prependRange(statements, leadingStatements); + ts.prependStatements(statements, leadingStatements); ts.addRange(statements, block.statements.slice(statementOffset)); return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(statements), block.statements)); } @@ -52646,14 +52979,14 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(186); - context.enableSubstitution(184); + context.enableSubstitution(187); context.enableSubstitution(185); - context.enableEmitNotification(234); - context.enableEmitNotification(153); - context.enableEmitNotification(155); - context.enableEmitNotification(156); + context.enableSubstitution(186); + context.enableEmitNotification(235); context.enableEmitNotification(154); + context.enableEmitNotification(156); + context.enableEmitNotification(157); + context.enableEmitNotification(155); } } function onEmitNode(hint, node, emitCallback) { @@ -52678,11 +53011,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 184: - return substitutePropertyAccessExpression(node); case 185: - return substituteElementAccessExpression(node); + return substitutePropertyAccessExpression(node); case 186: + return substituteElementAccessExpression(node); + case 187: return substituteCallExpression(node); } return node; @@ -52713,11 +53046,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 234 - || kind === 154 - || kind === 153 + return kind === 235 || kind === 155 - || kind === 156; + || kind === 154 + || kind === 156 + || kind === 157; } function createSuperAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096) { @@ -52812,13 +53145,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 254: - return visitJsxElement(node, false); case 255: + return visitJsxElement(node, false); + case 256: return visitJsxSelfClosingElement(node, false); - case 258: + case 259: return visitJsxFragment(node, false); - case 264: + case 265: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -52828,13 +53161,13 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 264: + case 265: return visitJsxExpression(node); - case 254: - return visitJsxElement(node, true); case 255: + return visitJsxElement(node, true); + case 256: return visitJsxSelfClosingElement(node, true); - case 258: + case 259: return visitJsxFragment(node, true); default: return ts.Debug.failBadSyntaxKind(node); @@ -52898,7 +53231,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 264) { + else if (node.kind === 265) { if (node.expression === undefined) { return ts.createTrue(); } @@ -52958,7 +53291,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 254) { + if (node.kind === 255) { return getTagName(node.openingElement); } else { @@ -53258,7 +53591,7 @@ var ts; return node; } switch (node.kind) { - case 199: + case 200: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -53416,14 +53749,14 @@ var ts; hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return hierarchyFacts & 4096 - && node.kind === 224 + return (hierarchyFacts & 4096) !== 0 + && node.kind === 225 && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 212))) + || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 213))) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432) !== 0; } @@ -53451,63 +53784,63 @@ var ts; switch (node.kind) { case 115: return undefined; - case 234: + case 235: return visitClassDeclaration(node); - case 204: + case 205: return visitClassExpression(node); - case 148: + case 149: return visitParameter(node); - case 233: + case 234: return visitFunctionDeclaration(node); - case 192: + case 193: return visitArrowFunction(node); - case 191: + case 192: return visitFunctionExpression(node); - case 231: + case 232: return visitVariableDeclaration(node); case 71: return visitIdentifier(node); - case 232: + case 233: return visitVariableDeclarationList(node); - case 226: - return visitSwitchStatement(node); - case 240: - return visitCaseBlock(node); - case 212: - return visitBlock(node, false); - case 223: - case 222: - return visitBreakOrContinueStatement(node); case 227: + return visitSwitchStatement(node); + case 241: + return visitCaseBlock(node); + case 213: + return visitBlock(node, false); + case 224: + case 223: + return visitBreakOrContinueStatement(node); + case 228: return visitLabeledStatement(node); - case 217: case 218: - return visitDoOrWhileStatement(node, undefined); case 219: - return visitForStatement(node, undefined); + return visitDoOrWhileStatement(node, undefined); case 220: - return visitForInStatement(node, undefined); + return visitForStatement(node, undefined); case 221: + return visitForInStatement(node, undefined); + case 222: return visitForOfStatement(node, undefined); - case 215: + case 216: return visitExpressionStatement(node); - case 183: + case 184: return visitObjectLiteralExpression(node); - case 268: + case 269: return visitCatchClause(node); - case 270: + case 271: return visitShorthandPropertyAssignment(node); - case 146: + case 147: return visitComputedPropertyName(node); - case 182: + case 183: return visitArrayLiteralExpression(node); - case 186: - return visitCallExpression(node); case 187: + return visitCallExpression(node); + case 188: return visitNewExpression(node); - case 190: + case 191: return visitParenthesizedExpression(node, true); - case 199: + case 200: return visitBinaryExpression(node, true); case 13: case 14: @@ -53518,28 +53851,28 @@ var ts; return visitStringLiteral(node); case 8: return visitNumericLiteral(node); - case 188: + case 189: return visitTaggedTemplateExpression(node); - case 201: - return visitTemplateExpression(node); case 202: - return visitYieldExpression(node); + return visitTemplateExpression(node); case 203: + return visitYieldExpression(node); + case 204: return visitSpreadElement(node); case 97: return visitSuperKeyword(false); case 99: return visitThisKeyword(node); - case 209: + case 210: return visitMetaProperty(node); - case 153: + case 154: return visitMethodDeclaration(node); - case 155: case 156: + case 157: return visitAccessorDeclaration(node); - case 213: + case 214: return visitVariableStatement(node); - case 224: + case 225: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -53556,7 +53889,7 @@ var ts; if (taggedTemplateStringDeclarations) { statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(taggedTemplateStringDeclarations))); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0, 0); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -53620,13 +53953,14 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 223 ? 2 : 4; + var jump = node.kind === 224 ? 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; - if (!node.label) { - if (node.kind === 223) { + var label = node.label; + if (!label) { + if (node.kind === 224) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -53636,13 +53970,13 @@ var ts; } } else { - if (node.kind === 223) { - labelMarker = "break-" + node.label.escapedText; - setLabeledJump(convertedLoopState, true, ts.idText(node.label), labelMarker); + if (node.kind === 224) { + labelMarker = "break-" + label.escapedText; + setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + node.label.escapedText; - setLabeledJump(convertedLoopState, false, ts.idText(node.label), labelMarker); + labelMarker = "continue-" + label.escapedText; + setLabeledJump(convertedLoopState, false, ts.idText(label), labelMarker); } } var returnExpression = ts.createLiteral(labelMarker); @@ -53725,7 +54059,7 @@ var ts; statement.pos = closingBraceLocation.pos; ts.setEmitFlags(statement, 1536 | 384); statements.push(statement); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), node.members), true); ts.setEmitFlags(block, 1536); return block; @@ -53751,7 +54085,7 @@ var ts; convertedLoopState = savedConvertedLoopState; } function transformConstructorParameters(constructor, hasSynthesizedSuper) { - return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) + return ts.visitParameterList(constructor && !hasSynthesizedSuper ? constructor.parameters : undefined, visitor, context) || []; } function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { @@ -53772,7 +54106,7 @@ var ts; } ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; @@ -53788,7 +54122,7 @@ var ts; && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createFileLevelUniqueName("_this"))); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); if (constructor) { prependCaptureNewTargetIfNeeded(statements, constructor, false); } @@ -53800,17 +54134,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 224) { + if (statement.kind === 225) { return true; } - else if (statement.kind === 216) { + else if (statement.kind === 217) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 212) { + else if (statement.kind === 213) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -53839,7 +54173,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 215 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 216 && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -53847,8 +54181,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 | 32768))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 199 - || superCallExpression.left.kind !== 186) { + if (superCallExpression.kind !== 200 + || superCallExpression.left.kind !== 187) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); @@ -53949,7 +54283,7 @@ var ts; statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 && node.kind !== 192) { + if (node.transformFlags & 32768 && node.kind !== 193) { captureThisForNode(statements, node, ts.createThis()); } } @@ -53967,18 +54301,18 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 192: + case 193: return statements; - case 153: - case 155: + case 154: case 156: + case 157: newTarget = ts.createVoidZero(); break; - case 154: + case 155: newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); break; - case 233: - case 191: + case 234: + case 192: newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 93, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); break; default: @@ -53998,20 +54332,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 211: + case 212: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 153: + case 154: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 155: case 156: + case 157: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 154: + case 155: break; default: ts.Debug.failBadSyntaxKind(node); @@ -54136,7 +54470,7 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 233 || node.kind === 191)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 234 || node.kind === 192)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); @@ -54170,7 +54504,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 192); + ts.Debug.assert(node.kind === 193); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -54190,7 +54524,7 @@ var ts; closeBraceLocation = body; } var lexicalEnvironment = context.endLexicalEnvironment(); - ts.prependRange(statements, lexicalEnvironment); + ts.prependStatements(statements, lexicalEnvironment); prependCaptureNewTargetIfNeeded(statements, node, false); if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { multiLine = true; @@ -54223,9 +54557,9 @@ var ts; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 190: + case 191: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 199: + case 200: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -54233,9 +54567,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 190: + case 191: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 199: + case 200: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -54293,11 +54627,10 @@ var ts; ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 - && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); if (firstDeclaration) { - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, ts.last(declarations).end)); } } return declarationList; @@ -54361,14 +54694,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 217: case 218: - return visitDoOrWhileStatement(node, outermostLabeledStatement); case 219: - return visitForStatement(node, outermostLabeledStatement); + return visitDoOrWhileStatement(node, outermostLabeledStatement); case 220: - return visitForInStatement(node, outermostLabeledStatement); + return visitForStatement(node, outermostLabeledStatement); case 221: + return visitForInStatement(node, outermostLabeledStatement); + case 222: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -54392,35 +54725,34 @@ var ts; } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; - if (ts.isVariableDeclarationList(node.initializer)) { + var initializer = node.initializer; + if (ts.isVariableDeclarationList(initializer)) { if (node.initializer.flags & 3) { enableSubstitutionsForBlockScopedBindings(); } - var firstOriginalDeclaration = ts.firstOrUndefined(node.initializer.declarations); + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, boundValue); var declarationList = ts.setTextRange(ts.createVariableDeclarationList(declarations), node.initializer); ts.setOriginalNode(declarationList, node.initializer); - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(declarations[0].pos, ts.last(declarations).end)); statements.push(ts.createVariableStatement(undefined, declarationList)); } else { statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, boundValue) - ]), ts.moveRangePos(node.initializer, -1)), node.initializer)), ts.moveRangeEnd(node.initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { - var assignment = ts.createAssignment(node.initializer, boundValue); + var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); statements.push(ts.createStatement(visitBinaryExpression(assignment, false))); } else { - assignment.end = node.initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(node.initializer, -1))); + assignment.end = initializer.end; + statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -54493,7 +54825,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 146) { + if (property.name.kind === 147) { numInitialProperties = i; break; } @@ -54555,11 +54887,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 219: case 220: case 221: + case 222: var initializer = node.initializer; - if (initializer && initializer.kind === 232) { + if (initializer && initializer.kind === 233) { loopInitializer = initializer; } break; @@ -54595,7 +54927,7 @@ var ts; if (loopOutParameters.length) { copyOutParameters(loopOutParameters, 1, statements_4); } - ts.prependRange(statements_4, lexicalEnvironment); + ts.prependStatements(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, true); } if (ts.isBlock(loopBody)) { @@ -54785,20 +55117,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 155: case 156: + case 157: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 153: + case 154: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 269: + case 270: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 270: + case 271: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -54873,7 +55205,7 @@ var ts; var body = node.transformFlags & (32768 | 128) ? transformFunctionBody(node) : visitFunctionBodyDownLevel(node); - if (node.kind === 155) { + if (node.kind === 156) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -54897,7 +55229,7 @@ var ts; } function visitArrayLiteralExpression(node) { if (node.transformFlags & 64) { - return transformAndSpreadElements(node.elements, true, node.multiLine, node.elements.hasTrailingComma); + return transformAndSpreadElements(node.elements, true, !!node.multiLine, !!node.elements.hasTrailingComma); } return ts.visitEachChild(node, visitor, context); } @@ -54912,11 +55244,11 @@ var ts; } function visitTypeScriptClassWrapper(node) { var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock); - var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.firstOrUndefined(stmt.declarationList.declarations).initializer; }; + var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.first(stmt.declarationList.declarations).initializer; }; var bodyStatements = ts.visitNodes(body.statements, visitor, ts.isStatement); var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer); var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); }); - var varStatement = ts.cast(ts.firstOrUndefined(classStatements), ts.isVariableStatement); + var varStatement = ts.cast(ts.first(classStatements), ts.isVariableStatement); var variable = varStatement.declarationList.declarations[0]; var initializer = ts.skipOuterExpressions(variable.initializer); var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression); @@ -55004,7 +55336,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 182 + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -55150,13 +55482,13 @@ var ts; if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; context.enableSubstitution(99); - context.enableEmitNotification(154); - context.enableEmitNotification(153); context.enableEmitNotification(155); + context.enableEmitNotification(154); context.enableEmitNotification(156); + context.enableEmitNotification(157); + context.enableEmitNotification(193); context.enableEmitNotification(192); - context.enableEmitNotification(191); - context.enableEmitNotification(233); + context.enableEmitNotification(234); } } function onSubstituteNode(hint, node) { @@ -55179,14 +55511,13 @@ var ts; return node; } function isNameOfDeclarationWithCollidingName(node) { - var parent = node.parent; - switch (parent.kind) { - case 181: - case 234: - case 237: - case 231: - return parent.name === node - && resolver.isDeclarationWithCollidingName(parent); + switch (node.parent.kind) { + case 182: + case 235: + case 238: + case 232: + return node.parent.name === node + && resolver.isDeclarationWithCollidingName(node.parent); } return false; } @@ -55245,11 +55576,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 215) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 186) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187) { return false; } var callTarget = statementExpression.expression; @@ -55257,7 +55588,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 203) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204) { return false; } var expression = callArgument.expression; @@ -55301,24 +55632,24 @@ var ts; if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(256); context.enableEmitNotification(257); - context.enableEmitNotification(255); + context.enableEmitNotification(258); + context.enableEmitNotification(256); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(184); - context.enableSubstitution(269); + context.enableSubstitution(185); + context.enableSubstitution(270); return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { return node; } function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 256: case 257: - case 255: + case 258: + case 256: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -55354,7 +55685,7 @@ var ts; } function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token >= 72 && token <= 107) { + if (token !== undefined && token >= 72 && token <= 107) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -55416,6 +55747,7 @@ var ts; case 4: return "yield"; case 5: return "yield*"; case 7: return "endfinally"; + default: return undefined; } } function transformGenerators(context) { @@ -55479,13 +55811,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 217: - return visitDoStatement(node); case 218: + return visitDoStatement(node); + case 219: return visitWhileStatement(node); - case 226: - return visitSwitchStatement(node); case 227: + return visitSwitchStatement(node); + case 228: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -55493,24 +55825,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 233: + case 234: return visitFunctionDeclaration(node); - case 191: + case 192: return visitFunctionExpression(node); - case 155: case 156: + case 157: return visitAccessorDeclaration(node); - case 213: + case 214: return visitVariableStatement(node); - case 219: - return visitForStatement(node); case 220: + return visitForStatement(node); + case 221: return visitForInStatement(node); - case 223: - return visitBreakStatement(node); - case 222: - return visitContinueStatement(node); case 224: + return visitBreakStatement(node); + case 223: + return visitContinueStatement(node); + case 225: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -55526,21 +55858,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 199: - return visitBinaryExpression(node); case 200: + return visitBinaryExpression(node); + case 201: return visitConditionalExpression(node); - case 202: + case 203: return visitYieldExpression(node); - case 182: - return visitArrayLiteralExpression(node); case 183: + return visitArrayLiteralExpression(node); + case 184: return visitObjectLiteralExpression(node); - case 185: - return visitElementAccessExpression(node); case 186: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 187: + return visitCallExpression(node); + case 188: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -55548,9 +55880,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 233: + case 234: return visitFunctionDeclaration(node); - case 191: + case 192: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -55634,7 +55966,7 @@ var ts; var statementOffset = ts.addPrologue(statements, body.statements, false, visitor); transformAndEmitStatements(body.statements, statementOffset); var buildResult = build(); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); statements.push(ts.createReturn(buildResult)); inGeneratorFunctionBody = savedInGeneratorFunctionBody; inStatementContainingYield = savedInStatementContainingYield; @@ -55672,13 +56004,14 @@ var ts; } } function visitBinaryExpression(node) { - switch (ts.getExpressionAssociativity(node)) { + var assoc = ts.getExpressionAssociativity(node); + switch (assoc) { case 0: return visitLeftAssociativeBinaryExpression(node); case 1: return visitRightAssociativeBinaryExpression(node); default: - ts.Debug.fail("Unknown associativity."); + return ts.Debug.assertNever(assoc); } } function isCompoundAssignment(kind) { @@ -55706,10 +56039,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 184: + case 185: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 185: + case 186: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -55910,35 +56243,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 212: + case 213: return transformAndEmitBlock(node); - case 215: - return transformAndEmitExpressionStatement(node); case 216: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 217: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 218: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 219: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 220: + return transformAndEmitForStatement(node); + case 221: return transformAndEmitForInStatement(node); - case 222: - return transformAndEmitContinueStatement(node); case 223: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 224: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 225: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 226: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 227: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 228: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 229: + return transformAndEmitThrowStatement(node); + case 230: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -56232,7 +56565,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 266 && defaultClauseIndex === -1) { + if (clause.kind === 267 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -56242,7 +56575,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 265) { + if (clause.kind === 266) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -56332,7 +56665,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 16777216) !== 0; + return !!node && (node.transformFlags & 16777216) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -56419,7 +56752,8 @@ var ts; } function endBlock() { var block = peekBlock(); - ts.Debug.assert(block !== undefined, "beginBlock was never called."); + if (block === undefined) + return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; blockActions[index] = 1; blockOffsets[index] = operations ? operations.length : 0; @@ -56662,7 +56996,7 @@ var ts; return 0; } function createLabel(label) { - if (label > 0) { + if (label !== undefined && label > 0) { if (labelExpressions === undefined) { labelExpressions = []; } @@ -57033,7 +57367,7 @@ var ts; name: "typescript:generator", scoped: false, priority: 6, - text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" + text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; })(ts || (ts = {})); var ts; @@ -57057,11 +57391,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71); - context.enableSubstitution(199); - context.enableSubstitution(197); + context.enableSubstitution(200); context.enableSubstitution(198); - context.enableSubstitution(270); - context.enableEmitNotification(273); + context.enableSubstitution(199); + context.enableSubstitution(271); + context.enableEmitNotification(274); var moduleInfoMap = []; var deferredExports = []; var currentSourceFile; @@ -57100,7 +57434,7 @@ var ts; ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); addExportEqualsIfNeeded(statements, false); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { ts.addEmitHelper(updated, exportStarHelper); @@ -57215,7 +57549,7 @@ var ts; } ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); addExportEqualsIfNeeded(statements, true); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var body = ts.createBlock(statements, true); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { ts.addEmitHelper(body, exportStarHelper); @@ -57246,23 +57580,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 243: + case 244: return visitImportDeclaration(node); - case 242: + case 243: return visitImportEqualsDeclaration(node); - case 249: + case 250: return visitExportDeclaration(node); - case 248: + case 249: return visitExportAssignment(node); - case 213: + case 214: return visitVariableStatement(node); - case 233: - return visitFunctionDeclaration(node); case 234: + return visitFunctionDeclaration(node); + case 235: return visitClassDeclaration(node); - case 302: - return visitMergeDeclarationMarker(node); case 303: + return visitMergeDeclarationMarker(node); + case 304: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -57287,24 +57621,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 269: + case 270: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 270: + case 271: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 271: + case 272: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 153: - case 155: + case 154: case 156: + case 157: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -57619,7 +57953,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 213) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -57651,10 +57985,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 245: + case 246: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 246: + case 247: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -57762,7 +58096,7 @@ var ts; return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 273) { + if (node.kind === 274) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -57804,10 +58138,10 @@ var ts; switch (node.kind) { case 71: return substituteExpressionIdentifier(node); - case 199: + case 200: return substituteBinaryExpression(node); + case 199: case 198: - case 197: return substituteUnaryExpression(node); } return node; @@ -57822,7 +58156,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 273) { + if (exportContainer && exportContainer.kind === 274) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -57865,7 +58199,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 198 + var expression = node.kind === 199 ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 ? 59 : 60), ts.createLiteral(1)), node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -57929,11 +58263,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71); - context.enableSubstitution(270); - context.enableSubstitution(199); - context.enableSubstitution(197); + context.enableSubstitution(271); + context.enableSubstitution(200); context.enableSubstitution(198); - context.enableEmitNotification(273); + context.enableSubstitution(199); + context.enableEmitNotification(274); var moduleInfoMap = []; var deferredExports = []; var exportFunctionsMap = []; @@ -58019,7 +58353,7 @@ var ts; ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement); var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset); ts.addRange(statements, hoistedStatements); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -58037,7 +58371,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 249 && externalImport.exportClause) { + if (externalImport.kind === 250 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -58060,7 +58394,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 249) { + if (externalImport.kind !== 250) { continue; } if (!externalImport.exportClause) { @@ -58111,15 +58445,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 243: + case 244: if (!entry.importClause) { break; } - case 242: + case 243: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 249: + case 250: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -58141,13 +58475,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 243: + case 244: return visitImportDeclaration(node); - case 242: + case 243: return visitImportEqualsDeclaration(node); - case 249: + case 250: return undefined; - case 248: + case 249: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -58268,7 +58602,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 2097152) === 0 - && (enclosingBlockScopedContainer.kind === 273 + && (enclosingBlockScopedContainer.kind === 274 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -58290,7 +58624,7 @@ var ts; : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 213) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -58329,10 +58663,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 245: + case 246: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 246: + case 247: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -58432,43 +58766,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 213: + case 214: return visitVariableStatement(node); - case 233: - return visitFunctionDeclaration(node); case 234: + return visitFunctionDeclaration(node); + case 235: return visitClassDeclaration(node); - case 219: - return visitForStatement(node); case 220: - return visitForInStatement(node); + return visitForStatement(node); case 221: + return visitForInStatement(node); + case 222: return visitForOfStatement(node); - case 217: - return visitDoStatement(node); case 218: + return visitDoStatement(node); + case 219: return visitWhileStatement(node); - case 227: + case 228: return visitLabeledStatement(node); - case 225: - return visitWithStatement(node); case 226: + return visitWithStatement(node); + case 227: return visitSwitchStatement(node); - case 240: + case 241: return visitCaseBlock(node); - case 265: - return visitCaseClause(node); case 266: + return visitCaseClause(node); + case 267: return visitDefaultClause(node); - case 229: + case 230: return visitTryStatement(node); - case 268: + case 269: return visitCatchClause(node); - case 212: + case 213: return visitBlock(node); - case 302: - return visitMergeDeclarationMarker(node); case 303: + return visitMergeDeclarationMarker(node); + case 304: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -58477,7 +58811,7 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateFor(node, 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 = ts.updateFor(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)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -58500,9 +58834,6 @@ var ts; && shouldHoistVariableDeclarationList(node); } function visitForInitializer(node) { - if (!node) { - return node; - } if (shouldHoistForInitializer(node)) { var expressions = void 0; for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { @@ -58565,7 +58896,7 @@ var ts; } function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 - && node.kind === 199) { + && node.kind === 200) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -58608,7 +58939,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 273; + return container !== undefined && container.kind === 274; } else { return false; @@ -58623,7 +58954,7 @@ var ts; return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 273) { + if (node.kind === 274) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -58657,7 +58988,7 @@ var ts; } function substituteUnspecified(node) { switch (node.kind) { - case 270: + case 271: return substituteShorthandPropertyAssignment(node); } return node; @@ -58681,10 +59012,10 @@ var ts; switch (node.kind) { case 71: return substituteExpressionIdentifier(node); - case 199: + case 200: return substituteBinaryExpression(node); - case 197: case 198: + case 199: return substituteUnaryExpression(node); } return node; @@ -58736,14 +59067,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 198 + var expression = node.kind === 199 ? ts.setTextRange(ts.createPrefix(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 === 198) { + if (node.kind === 199) { expression = node.operator === 43 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -58760,7 +59091,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 273) { + if (exportContainer && exportContainer.kind === 274) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -58788,7 +59119,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(273); + context.enableEmitNotification(274); context.enableSubstitution(71); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -58815,9 +59146,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 242: + case 243: return undefined; - case 248: + case 249: return visitExportAssignment(node); } return node; @@ -58903,7 +59234,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 === 234) { + else if (node.parent.kind === 235) { 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 : @@ -58932,7 +59263,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 === 234) { + else if (node.parent.kind === 235) { 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 : @@ -58976,18 +59307,18 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); + 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 === 231 || node.kind === 181) { + if (node.kind === 232 || node.kind === 182) { 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 === 151 || node.kind === 150 || - (node.kind === 148 && ts.hasModifier(node.parent, 8))) { + else if (node.kind === 152 || node.kind === 151 || + (node.kind === 149 && ts.hasModifier(node.parent, 8))) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -58995,7 +59326,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 === 234 || node.kind === 148) { + else if (node.parent.kind === 235 || node.kind === 149) { 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 : @@ -59019,7 +59350,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 156) { + if (node.kind === 157) { if (ts.hasModifier(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 : @@ -59056,23 +59387,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 158: + case 159: 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 157: + case 158: 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 159: + case 160: 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 154: case 153: - case 152: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -59080,7 +59411,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 === 234) { + else if (node.parent.kind === 235) { 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 : @@ -59093,7 +59424,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 233: + case 234: 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 : @@ -59101,7 +59432,7 @@ var ts; ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; break; default: - ts.Debug.fail("This is unknown kind for signature: " + node.kind); + return ts.Debug.fail("This is unknown kind for signature: " + node.kind); } return { diagnosticMessage: diagnosticMessage, @@ -59118,27 +59449,27 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 154: + case 155: 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 158: - case 163: + case 159: + case 164: 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 157: + case 158: 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 159: + case 160: 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 154: case 153: - case 152: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -59146,7 +59477,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 === 234) { + else if (node.parent.parent.kind === 235) { 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 : @@ -59158,52 +59489,52 @@ 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 233: - case 162: + case 234: + case 163: 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; default: - ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } } function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 234: + case 235: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 235: + case 236: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 158: + case 159: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157: + case 158: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 154: case 153: - case 152: if (ts.hasModifier(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 === 234) { + else if (node.parent.parent.kind === 235) { 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 233: + case 234: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 236: + case 237: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: - ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); + return ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); } return { diagnosticMessage: diagnosticMessage, @@ -59213,7 +59544,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 234) { + if (node.parent.parent.kind === 235) { diagnosticMessage = node.parent.token === 108 ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; @@ -59353,16 +59684,16 @@ var ts; } } function transformRoot(node) { - if (node.kind === 273 && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 274 && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 274) { + if (node.kind === 275) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { if (sourceFile.isDeclarationFile || ts.isSourceFileJavaScript(sourceFile)) - return; + return undefined; hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; enclosingDeclaration = sourceFile; @@ -59384,7 +59715,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 276) { + if (prepend.kind === 277) { return ts.createUnparsedSourceFile(prepend.declarationText); } })); @@ -59479,7 +59810,7 @@ var ts; return name; } else { - if (name.kind === 180) { + if (name.kind === 181) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -59487,7 +59818,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 205) { + if (elem.kind === 206) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -59521,7 +59852,7 @@ var ts; if (shouldPrintWithInitializer(node)) { return; } - var shouldUseResolverType = node.kind === 148 && + var shouldUseResolverType = node.kind === 149 && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { @@ -59530,7 +59861,7 @@ var ts; if (!ts.getParseTreeNode(node)) { return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(119); } - if (node.kind === 156) { + if (node.kind === 157) { return ts.createKeywordTypeNode(119); } errorNameNode = node.name; @@ -59539,12 +59870,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 231 || node.kind === 181) { + if (node.kind === 232 || node.kind === 182) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 148 - || node.kind === 151 - || node.kind === 150) { + if (node.kind === 149 + || node.kind === 152 + || node.kind === 151) { 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)); @@ -59561,19 +59892,19 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 233: - case 238: - case 235: case 234: + case 239: case 236: + case 235: case 237: + case 238: return !resolver.isDeclarationVisible(node); - case 231: + case 232: return !getBindingNameVisible(node); - case 242: case 243: + case 244: + case 250: case 249: - case 248: return false; } return false; @@ -59583,7 +59914,7 @@ var ts; return false; } if (ts.isBindingPattern(elem.name)) { - return ts.forEach(elem.name.elements, getBindingNameVisible); + return ts.some(elem.name.elements, getBindingNameVisible); } else { return resolver.isDeclarationVisible(elem); @@ -59625,8 +59956,8 @@ var ts; } function rewriteModuleSpecifier(parent, input) { if (!input) - return; - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 238 && parent.kind !== 178); + return undefined; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 && parent.kind !== 179); if (input.kind === 9 && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -59638,7 +59969,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 253) { + if (decl.moduleReference.kind === 254) { var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.name, ts.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); } @@ -59658,7 +59989,7 @@ var ts; if (!decl.importClause.namedBindings) { return visibleDefaultBinding && ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 245) { + if (decl.importClause.namedBindings.kind === 246) { var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; } @@ -59738,61 +60069,61 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 165 || input.kind === 176) && input.parent.kind !== 236); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 || input.kind === 177) && input.parent.kind !== 237); if (shouldEnterSuppressNewDiagnosticsContextContext) { suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 206: { + case 207: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 161: { + case 162: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 158: + case 159: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 154: { + case 155: { var isPrivate = ts.hasModifier(input, 8); - var ctor = ts.createSignatureDeclaration(154, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0), undefined); + var ctor = ts.createSignatureDeclaration(155, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0), undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 153: { - var sig = ts.createSignatureDeclaration(152, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 154: { + var sig = ts.createSignatureDeclaration(153, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 155: { - var newNode = ensureAccessor(input); - return cleanup(newNode); - } case 156: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 151: + case 157: { + var newNode = ensureAccessor(input); + return cleanup(newNode); + } + case 152: return cleanup(ts.updateProperty(input, undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 150: + case 151: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 152: { + case 153: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 157: { + case 158: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 159: { + case 160: { return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119))); } - case 231: { + case 232: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -59800,13 +60131,13 @@ var ts; suppressNewDiagnosticContexts = true; return cleanup(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 147: { + case 148: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, undefined, undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 170: { + case 171: { var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree); var oldEnclosingDecl = enclosingDeclaration; @@ -59816,13 +60147,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 162: { + case 163: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 163: { + case 164: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 178: { + case 179: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -59851,7 +60182,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 153 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 154 && ts.hasModifier(node.parent, 8); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -59860,14 +60191,14 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249: { + case 250: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; } return ts.updateExportDeclaration(input, undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 248: { + case 249: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -59895,10 +60226,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 242: { + case 243: { return transformImportEqualsDeclaration(input); } - case 243: { + case 244: { return transformImportDeclaration(input); } } @@ -59918,18 +60249,18 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 236: + case 237: return cleanup(ts.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 235: { + case 236: { return cleanup(ts.updateInterfaceDeclaration(input, undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 233: { + case 234: { return cleanup(ts.updateFunctionDeclaration(input, undefined, ensureModifiers(input, isPrivate), undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined)); } - case 238: { + case 239: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 239) { + if (inner && inner.kind === 240) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -59947,7 +60278,7 @@ var ts; return cleanup(ts.updateModuleDeclaration(input, undefined, mods, input.name, body)); } } - case 234: { + case 235: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -60009,10 +60340,10 @@ var ts; return cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 213: { + case 214: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 237: { + case 238: { return cleanup(ts.updateEnumDeclaration(input, undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -60029,7 +60360,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 238) { + if (input.kind === 239) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -60050,7 +60381,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 205) { + if (e.kind === 206) { return; } if (e.name) { @@ -60104,7 +60435,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 ^ (4 | 256); var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0; - var parentIsFile = node.parent.kind === 273; + var parentIsFile = node.parent.kind === 274; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1) | 512 | 2); additions = 0; @@ -60151,7 +60482,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 235) { + if (node.kind === 236) { return true; } return false; @@ -60170,7 +60501,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 155 + return accessor.kind === 156 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -60179,51 +60510,51 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 231: + case 232: + case 152: case 151: - case 150: - case 148: + case 149: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 233: - case 238: - case 242: - case 235: case 234: - case 236: - case 237: - case 213: + case 239: case 243: + case 236: + case 235: + case 237: + case 238: + case 214: + case 244: + case 250: case 249: - case 248: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 158: - case 154: - case 153: - case 155: - case 156: - case 151: - case 150: - case 152: - case 157: case 159: - case 231: - case 147: - case 206: - case 161: - case 170: + case 155: + case 154: + case 156: + case 157: + case 152: + case 151: + case 153: + case 158: + case 160: + case 232: + case 148: + case 207: case 162: + case 171: case 163: - case 178: + case 164: + case 179: return true; } return false; @@ -60286,7 +60617,7 @@ var ts; } ts.getTransformers = getTransformers; function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(304); + var enabledSyntaxKindFeatures = new Array(305); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -60521,7 +60852,7 @@ var ts; return currentSource.skipTrivia ? currentSource.skipTrivia(pos) : ts.skipTrivia(currentSourceText, pos); } function initialize(filePath, sourceMapFilePath, sourceFileOrBundle, outputSourceMapDataList) { - if (disabled) { + if (disabled || ts.fileExtensionIs(filePath, ".json")) { return; } if (sourceMapData) { @@ -60552,7 +60883,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 273) { + if (sourceFileOrBundle.kind === 274) { sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { @@ -60612,7 +60943,7 @@ var ts; sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } function emitPos(pos) { - if (disabled || ts.positionIsSynthesized(pos)) { + if (disabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(currentSource)) { return; } if (extendedDiagnostics) { @@ -60649,12 +60980,12 @@ var ts; } } function emitNodeWithSourceMap(hint, node, emitCallback) { - if (disabled) { + if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0; var range = emitNode && emitNode.sourceMapRange; var _a = range || node, pos = _a.pos, end = _a.end; var source = range && range.source; @@ -60663,7 +60994,7 @@ var ts; source = undefined; if (source) setSourceFile(source); - if (node.kind !== 299 + if (node.kind !== 300 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -60680,7 +61011,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 299 + if (node.kind !== 300 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -60690,11 +61021,11 @@ var ts; } } function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { - if (disabled) { + if (disabled || ts.isInJsonFile(node)) { return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; tokenPos = skipSourceTrivia(range ? range.pos : tokenPos); if ((emitFlags & 128) === 0 && tokenPos >= 0) { @@ -60708,12 +61039,18 @@ var ts; } return tokenPos; } + function isJsonSourceMapSource(sourceFile) { + return ts.fileExtensionIs(sourceFile.fileName, ".json"); + } function setSourceFile(sourceFile) { if (disabled) { return; } currentSource = sourceFile; currentSourceText = currentSource.text; + if (isJsonSourceMapSource(sourceFile)) { + return; + } var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, currentSource.fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true); sourceMapSourceIndex = sourceMapData.sourceMapSources.indexOf(source); @@ -60727,8 +61064,8 @@ var ts; } } function getText() { - if (disabled) { - return; + if (disabled || isJsonSourceMapSource(currentSource)) { + return undefined; } encodeLastRecordedSourceMapSpan(); return JSON.stringify({ @@ -60742,8 +61079,8 @@ var ts; }); } function getSourceMappingURL() { - if (disabled) { - return; + if (disabled || isJsonSourceMapSource(currentSource)) { + return undefined; } if (compilerOptions.inlineSourceMap) { var base64SourceMapText = ts.base64encode(ts.sys, getText()); @@ -60795,7 +61132,7 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = printerOptions.removeComments; + var disabled = !!printerOptions.removeComments; return { reset: reset, setWriter: setWriter, @@ -60813,7 +61150,7 @@ var ts; if (node) { hasWrittenComment = false; var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0; var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; if ((pos < 0 && end < 0) || (pos === end)) { emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); @@ -60822,7 +61159,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 299; + var isEmittedNode = node.kind !== 300; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 10; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 10; if (!skipLeadingComments) { @@ -60836,7 +61173,7 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 232) { + if (node.kind === 233) { declarationListContainerEnd = end; } } @@ -61077,10 +61414,10 @@ var ts; detachedCommentsInfo = undefined; } function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; } function forEachLeadingCommentWithoutDetachedComments(cb) { - var pos = ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos; + var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); } @@ -61120,6 +61457,7 @@ var ts; var infoExtension = ".tsbundleinfo"; var brackets = createBracketsMap(); function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { @@ -61144,17 +61482,17 @@ var ts; ts.forEachEmittedFile = forEachEmittedFile; function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 274) { + if (sourceFile.kind === 275) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; var declarationMapPath = ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var bundleInfoPath = options.references && jsFilePath && (ts.removeFileExtension(jsFilePath) + infoExtension); + var bundleInfoPath = options.references && jsFilePath ? (ts.removeFileExtension(jsFilePath) + infoExtension) : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: bundleInfoPath }; } else { var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var sourceMapFilePath = ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); var isJs = ts.isSourceFileJavaScript(sourceFile); var declarationFilePath = ((forceDtsPaths || options.declaration) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; var declarationMapPath = ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; @@ -61211,7 +61549,7 @@ var ts; emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), emittedFiles: emittedFilesList, - sourceMaps: sourceMapDataList + sourceMaps: sourceMapDataList, }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, bundleInfoPath = _a.bundleInfoPath; @@ -61286,8 +61624,8 @@ var ts; declarationTransform.dispose(); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 274 ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 273 ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 275 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 274 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -61304,7 +61642,7 @@ var ts; if (sourceMapFilePath) { ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, mapRecorder.getText(), false, sourceFiles); } - ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); + ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); if (bundleInfoPath) { bundleInfo.totalLength = writer.getTextPos(); ts.writeFile(host, emitterDiagnostics, bundleInfoPath, JSON.stringify(bundleInfo, undefined, 2), false); @@ -61381,9 +61719,9 @@ var ts; break; } switch (node.kind) { - case 273: return printFile(node); - case 274: return printBundle(node); - case 275: return printUnparsedSource(node); + case 274: return printFile(node); + case 275: return printBundle(node); + case 276: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -61540,8 +61878,7 @@ var ts; return getPipelinePhase(currentPhase + 1, hint); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assertDefined(onEmitNode); - onEmitNode(hint, node, getNextPipelinePhase(0, hint)); + ts.Debug.assertDefined(onEmitNode)(hint, node, getNextPipelinePhase(0, hint)); } function pipelineEmitWithComments(hint, node) { ts.Debug.assertDefined(emitNodeWithComments); @@ -61553,9 +61890,8 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assertDefined(onEmitSourceMapOfNode); ts.Debug.assert(hint !== 0 && hint !== 2); - onEmitSourceMapOfNode(hint, node, pipelineEmitWithHint); + ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { if (hint === 0) @@ -61572,220 +61908,220 @@ var ts; case 15: case 16: return emitLiteral(node); - case 275: + case 276: return emitUnparsedSource(node); case 71: return emitIdentifier(node); - case 145: - return emitQualifiedName(node); case 146: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 147: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 148: - return emitParameter(node); + return emitTypeParameter(node); case 149: - return emitDecorator(node); + return emitParameter(node); case 150: - return emitPropertySignature(node); + return emitDecorator(node); case 151: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 152: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 153: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 154: - return emitConstructor(node); + return emitMethodDeclaration(node); case 155: + return emitConstructor(node); case 156: - return emitAccessorDeclaration(node); case 157: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 158: - return emitConstructSignature(node); + return emitCallSignature(node); case 159: - return emitIndexSignature(node); + return emitConstructSignature(node); case 160: - return emitTypePredicate(node); + return emitIndexSignature(node); case 161: - return emitTypeReference(node); + return emitTypePredicate(node); case 162: - return emitFunctionType(node); - case 283: - return emitJSDocFunctionType(node); + return emitTypeReference(node); case 163: - return emitConstructorType(node); + return emitFunctionType(node); + case 284: + return emitJSDocFunctionType(node); case 164: - return emitTypeQuery(node); + return emitConstructorType(node); case 165: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 166: - return emitArrayType(node); + return emitTypeLiteral(node); case 167: - return emitTupleType(node); + return emitArrayType(node); case 168: - return emitUnionType(node); + return emitTupleType(node); case 169: - return emitIntersectionType(node); + return emitUnionType(node); case 170: - return emitConditionalType(node); + return emitIntersectionType(node); case 171: - return emitInferType(node); + return emitConditionalType(node); case 172: - return emitParenthesizedType(node); - case 206: - return emitExpressionWithTypeArguments(node); + return emitInferType(node); case 173: - return emitThisType(); + return emitParenthesizedType(node); + case 207: + return emitExpressionWithTypeArguments(node); case 174: - return emitTypeOperator(node); + return emitThisType(); case 175: - return emitIndexedAccessType(node); + return emitTypeOperator(node); case 176: - return emitMappedType(node); + return emitIndexedAccessType(node); case 177: - return emitLiteralType(node); + return emitMappedType(node); case 178: + return emitLiteralType(node); + case 179: return emitImportTypeNode(node); - case 278: + case 279: write("*"); return; - case 279: + case 280: write("?"); return; - case 280: - return emitJSDocNullableType(node); case 281: - return emitJSDocNonNullableType(node); + return emitJSDocNullableType(node); case 282: + return emitJSDocNonNullableType(node); + case 283: return emitJSDocOptionalType(node); - case 284: + case 285: return emitJSDocVariadicType(node); - case 179: - return emitObjectBindingPattern(node); case 180: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 181: + return emitArrayBindingPattern(node); + case 182: return emitBindingElement(node); - case 210: - return emitTemplateSpan(node); case 211: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 212: - return emitBlock(node); + return emitSemicolonClassElement(); case 213: - return emitVariableStatement(node); + return emitBlock(node); case 214: - return emitEmptyStatement(); + return emitVariableStatement(node); case 215: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 216: - return emitIfStatement(node); + return emitExpressionStatement(node); case 217: - return emitDoStatement(node); + return emitIfStatement(node); case 218: - return emitWhileStatement(node); + return emitDoStatement(node); case 219: - return emitForStatement(node); + return emitWhileStatement(node); case 220: - return emitForInStatement(node); + return emitForStatement(node); case 221: - return emitForOfStatement(node); + return emitForInStatement(node); case 222: - return emitContinueStatement(node); + return emitForOfStatement(node); case 223: - return emitBreakStatement(node); + return emitContinueStatement(node); case 224: - return emitReturnStatement(node); + return emitBreakStatement(node); case 225: - return emitWithStatement(node); + return emitReturnStatement(node); case 226: - return emitSwitchStatement(node); + return emitWithStatement(node); case 227: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 228: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 229: - return emitTryStatement(node); + return emitThrowStatement(node); case 230: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 231: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 232: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 233: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 234: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 235: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 236: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 237: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 238: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 239: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 240: - return emitCaseBlock(node); + return emitModuleBlock(node); case 241: - return emitNamespaceExportDeclaration(node); + return emitCaseBlock(node); case 242: - return emitImportEqualsDeclaration(node); + return emitNamespaceExportDeclaration(node); case 243: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 244: - return emitImportClause(node); + return emitImportDeclaration(node); case 245: - return emitNamespaceImport(node); + return emitImportClause(node); case 246: - return emitNamedImports(node); + return emitNamespaceImport(node); case 247: - return emitImportSpecifier(node); + return emitNamedImports(node); case 248: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 249: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 250: - return emitNamedExports(node); + return emitExportDeclaration(node); case 251: - return emitExportSpecifier(node); + return emitNamedExports(node); case 252: - return; + return emitExportSpecifier(node); case 253: + return; + case 254: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 256: - case 259: - return emitJsxOpeningElementOrFragment(node); case 257: case 260: - return emitJsxClosingElementOrFragment(node); + return emitJsxOpeningElementOrFragment(node); + case 258: case 261: - return emitJsxAttribute(node); + return emitJsxClosingElementOrFragment(node); case 262: - return emitJsxAttributes(node); + return emitJsxAttribute(node); case 263: - return emitJsxSpreadAttribute(node); + return emitJsxAttributes(node); case 264: - return emitJsxExpression(node); + return emitJsxSpreadAttribute(node); case 265: - return emitCaseClause(node); + return emitJsxExpression(node); case 266: - return emitDefaultClause(node); + return emitCaseClause(node); case 267: - return emitHeritageClause(node); + return emitDefaultClause(node); case 268: - return emitCatchClause(node); + return emitHeritageClause(node); case 269: - return emitPropertyAssignment(node); + return emitCatchClause(node); case 270: - return emitShorthandPropertyAssignment(node); + return emitPropertyAssignment(node); case 271: - return emitSpreadAssignment(node); + return emitShorthandPropertyAssignment(node); case 272: + return emitSpreadAssignment(node); + case 273: return emitEnumMember(node); } if (ts.isExpression(node)) { @@ -61814,69 +62150,69 @@ var ts; case 91: writeTokenNode(node, writeKeyword); return; - case 182: - return emitArrayLiteralExpression(node); case 183: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 184: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 185: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 186: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 187: - return emitNewExpression(node); + return emitCallExpression(node); case 188: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 189: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 190: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 191: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 192: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 193: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 194: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 195: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 196: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 197: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 198: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 199: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 200: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 201: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 202: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 203: - return emitSpreadExpression(node); + return emitYieldExpression(node); case 204: - return emitClassExpression(node); + return emitSpreadExpression(node); case 205: + return emitClassExpression(node); + case 206: return; - case 207: - return emitAsExpression(node); case 208: - return emitNonNullExpression(node); + return emitAsExpression(node); case 209: + return emitNonNullExpression(node); + case 210: return emitMetaProperty(node); - case 254: - return emitJsxElement(node); case 255: + return emitJsxElement(node); + case 256: return emitJsxSelfClosingElement(node); - case 258: + case 259: return emitJsxFragment(node); - case 300: - return emitPartiallyEmittedExpression(node); case 301: + return emitPartiallyEmittedExpression(node); + case 302: return emitCommaList(node); } } @@ -61893,7 +62229,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 274 ? node : undefined; + var bundle = node.kind === 275 ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -61992,7 +62328,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 283 && !node.name) { + if (node.parent && node.parent.kind === 284 && !node.name) { emit(node.type); } else { @@ -62050,7 +62386,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 155 ? "get" : "set"); + writeKeyword(node.kind === 156 ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -62298,7 +62634,7 @@ var ts; increaseIndent(); } var preferNewLine = node.multiLine ? 32768 : 0; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 ? 32 : 0; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 32 : 0; emitList(node, node.properties, 263122 | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); @@ -62421,7 +62757,7 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 197 + return operand.kind === 198 && ((node.operator === 37 && (operand.operator === 37 || operand.operator === 43)) || (node.operator === 38 && (operand.operator === 38 || operand.operator === 44))); } @@ -62535,7 +62871,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 216) { + if (node.elseStatement.kind === 217) { writeSpace(); emit(node.elseStatement); } @@ -62598,7 +62934,7 @@ var ts; emitTokenWithComment(19, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(144, node.initializer.end, writeKeyword, node); + emitTokenWithComment(145, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(20, node.expression.end, writePunctuation, node); @@ -62606,7 +62942,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 232) { + if (node.kind === 233) { emit(node); } else { @@ -62891,7 +63227,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 238) { + while (body.kind === 239) { writePunctuation("."); emit(body.name); body = body.body; @@ -62936,7 +63272,7 @@ var ts; if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(142, node.importClause.end, writeKeyword, node); + emitTokenWithComment(143, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -62988,7 +63324,7 @@ var ts; if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(142, fromPos, writeKeyword, node); + emitTokenWithComment(143, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -63185,7 +63521,7 @@ var ts; emitSourceFileWorker(node); } function emitSyntheticTripleSlashReferencesIfNeeded(node) { - emitTripleSlashDirectives(node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || []); + emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || []); } function emitTripleSlashDirectivesIfNeeded(node) { if (node.isDeclarationFile) @@ -63429,7 +63765,7 @@ var ts; if (isUndefined && format & 8192) { return; } - var isEmpty = isUndefined || start >= children.length || count === 0; + var isEmpty = children === undefined || start >= children.length || count === 0; if (isEmpty && format & 16384) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); @@ -63470,7 +63806,7 @@ var ts; increaseIndent(); } var previousSibling = void 0; - var shouldDecreaseIndentAfterEmit = void 0; + var shouldDecreaseIndentAfterEmit = false; for (var i = 0; i < count; i++) { var child = children[start + i]; if (previousSibling) { @@ -63746,7 +64082,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 190 && ts.nodeIsSynthesized(node)) { + while (node.kind === 191 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -63805,81 +64141,81 @@ var ts; if (!node) return; switch (node.kind) { - case 212: + case 213: ts.forEach(node.statements, generateNames); break; - case 227: - case 225: - case 217: + case 228: + case 226: case 218: + case 219: generateNames(node.statement); break; - case 216: + case 217: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 219: - case 221: case 220: + case 222: + case 221: generateNames(node.initializer); generateNames(node.statement); break; - case 226: + case 227: generateNames(node.caseBlock); break; - case 240: + case 241: ts.forEach(node.clauses, generateNames); break; - case 265: case 266: + case 267: ts.forEach(node.statements, generateNames); break; - case 229: + case 230: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 268: + case 269: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 213: + case 214: generateNames(node.declarationList); break; - case 232: + case 233: ts.forEach(node.declarations, generateNames); break; - case 231: - case 148: - case 181: - case 234: + case 232: + case 149: + case 182: + case 235: generateNameIfNeeded(node.name); break; - case 233: + case 234: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 179: case 180: + case 181: ts.forEach(node.elements, generateNames); break; - case 243: - generateNames(node.importClause); - break; case 244: - generateNameIfNeeded(node.name); - generateNames(node.namedBindings); + generateNames(node.importClause); break; case 245: generateNameIfNeeded(node.name); + generateNames(node.namedBindings); break; case 246: - ts.forEach(node.elements, generateNames); + generateNameIfNeeded(node.name); break; case 247: + ts.forEach(node.elements, generateNames); + break; + case 248: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -63888,12 +64224,12 @@ var ts; if (!node) return; switch (node.kind) { - case 269: case 270: - case 151: - case 153: - case 155: + case 271: + case 152: + case 154: case 156: + case 157: generateNameIfNeeded(node.name); break; } @@ -64027,21 +64363,21 @@ var ts; switch (node.kind) { case 71: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8)); + case 239: case 238: - case 237: return generateNameForModuleOrEnum(node); - case 243: - case 249: + case 244: + case 250: return generateNameForImportOrExportDeclaration(node); - case 233: case 234: - case 248: + case 235: + case 249: return generateNameForExportDefault(); - case 204: + case 205: return generateNameForClassExpression(); - case 153: - case 155: + case 154: case 156: + case 157: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); @@ -64056,7 +64392,7 @@ var ts; case 3: return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16), !!(name.autoGenerateFlags & 8)); } - ts.Debug.fail("Unsupported GeneratedIdentifierKind."); + return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } function getNodeForGeneratedName(name) { var autoGenerateId = name.autoGenerateId; @@ -64723,8 +65059,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? - configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -64752,7 +65087,7 @@ var ts; function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) { var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; - var host = createProgramOptions.host, oldProgram = createProgramOptions.oldProgram; + var oldProgram = createProgramOptions.oldProgram; var program; var files = []; var commonSourceDirectory; @@ -64769,7 +65104,7 @@ var ts; var modulesWithElidedImports = ts.createMap(); var sourceFilesFoundSearchingNodeModules = ts.createMap(); ts.performance.mark("beforeProgram"); - host = host || createCompilerHost(options); + var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHost(host); var skipDefaultLib = options.noLib; var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); }); @@ -64876,6 +65211,7 @@ var ts; getOptionsDiagnostics: getOptionsDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getSemanticDiagnostics: getSemanticDiagnostics, + getSuggestionDiagnostics: getSuggestionDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, getTypeChecker: getTypeChecker, getClassifiableNames: getClassifiableNames, @@ -65251,7 +65587,7 @@ var ts; return nodes; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules.get(file.path); + return !!sourceFilesFoundSearchingNodeModules.get(file.path); } function isSourceFileDefaultLibrary(file) { if (file.hasNoDefaultLib) { @@ -65265,7 +65601,7 @@ var ts; return equalityComparer(file.fileName, getDefaultLibraryFileName()); } else { - return ts.forEach(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); }); + return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); }); } } function getDiagnosticsProducingTypeChecker() { @@ -65382,11 +65718,24 @@ var ts; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); - if (isCheckJs) { - diagnostics = ts.concatenate(diagnostics, sourceFile.jsDocDiagnostics); + var diagnostics; + for (var _i = 0, _a = [bindDiagnostics, checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile, isCheckJs ? sourceFile.jsDocDiagnostics : undefined]; _i < _a.length; _i++) { + var diags = _a[_i]; + if (diags) { + for (var _b = 0, diags_1 = diags; _b < diags_1.length; _b++) { + var diag = diags_1[_b]; + if (shouldReportDiagnostic(diag)) { + diagnostics = ts.append(diagnostics, diag); + } + } + } } - return ts.filter(diagnostics, shouldReportDiagnostic); + return diagnostics; + }); + } + function getSuggestionDiagnostics(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken); }); } function shouldReportDiagnostic(diagnostic) { @@ -65416,62 +65765,62 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 148: - case 151: + case 149: + case 152: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - case 153: - case 152: case 154: + case 153: case 155: case 156: - case 191: - case 233: + case 157: case 192: - case 231: + case 234: + case 193: + case 232: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 242: + case 243: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 248: + case 249: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 267: + case 268: var heritageClause = node; if (heritageClause.token === 108) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 235: + case 236: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 238: + case 239: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 236: + case 237: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 237: + case 238: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 208: + case 209: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 207: + case 208: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 189: + case 190: ts.Debug.fail(); } var prevParent = parent; @@ -65484,25 +65833,25 @@ 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_to_remove_this_warning)); } switch (parent.kind) { - case 234: - case 153: - case 152: + case 235: case 154: + case 153: case 155: case 156: - case 191: - case 233: + case 157: case 192: + case 234: + case 193: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 213: + case 214: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 213); + return checkModifiers(nodes, parent.kind === 214); } break; - case 151: + case 152: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; @@ -65513,17 +65862,17 @@ var ts; return; } break; - case 148: + case 149: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 186: case 187: - case 206: - case 255: + case 188: + case 207: case 256: + case 257: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; @@ -66274,9 +66623,9 @@ var ts; if (ts.isObjectLiteralExpression(pathProp.initializer)) { for (var _a = 0, _b = ts.getPropertyAssignment(pathProp.initializer, key); _a < _b.length; _a++) { var keyProps = _b[_a]; - if (ts.isArrayLiteralExpression(keyProps.initializer) && - keyProps.initializer.elements.length > valueIndex) { - programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, keyProps.initializer.elements[valueIndex], message, arg0, arg1, arg2)); + var initializer = keyProps.initializer; + if (ts.isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) { + programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, arg0, arg1, arg2)); needCompilerDiagnostic = false; } } @@ -66378,6 +66727,7 @@ var ts; return false; } programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, arrayLiteral.elements[index], message, arg0, arg1, arg2)); + return false; } function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(toPath(emitFileName), true); @@ -66395,13 +66745,16 @@ var ts; if (out) { return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts"); } + if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { + return true; + } if (options.outDir) { return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); } if (ts.fileExtensionIsOneOf(filePath, ts.supportedJavascriptExtensions) || ts.fileExtensionIs(filePath, ".d.ts")) { var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath(ts.combinePaths(filePathWithoutExtension, ".ts")) || - !!getSourceFileByPath(ts.combinePaths(filePathWithoutExtension, ".tsx")); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts")) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx")); } return false; } @@ -66529,7 +66882,7 @@ var ts; for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var version_1 = sourceFile.version; - var oldInfo = useOldState && oldState.fileInfos.get(sourceFile.path); + var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.path) : undefined; if (referencedMap) { var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName); if (newReferences) { @@ -66576,7 +66929,8 @@ var ts; return false; } var info = state.fileInfos.get(sourceFile.path); - ts.Debug.assert(!!info); + if (!info) + return ts.Debug.fail(); var prevSignature = info.signature; var latestSignature; if (sourceFile.isDeclarationFile) { @@ -66701,7 +67055,7 @@ var ts; var ts; (function (ts) { function hasSameKeys(map1, map2) { - return map1 === map2 || map1 && map2 && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); + 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); @@ -66723,7 +67077,7 @@ var ts; ts.copyEntries(oldState.changedFilesSet, state.changedFilesSet); } var referencedMap = state.referencedMap; - var oldReferencedMap = useOldState && oldState.referencedMap; + var oldReferencedMap = useOldState ? oldState.referencedMap : undefined; state.fileInfos.forEach(function (info, sourceFilePath) { var oldInfo; var newReferences; @@ -66889,7 +67243,7 @@ var ts; assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile); if (!targetSourceFile) { var sourceMaps = []; - var emitSkipped = void 0; + var emitSkipped = false; var diagnostics = void 0; var emittedFiles = []; var affectedEmitResult = void 0; @@ -67000,7 +67354,7 @@ var ts; var customFailedLookupPaths = ts.createMap(); var directoryWatchesOfFailedLookups = ts.createMap(); var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory())); - var rootPath = rootDir && resolutionHost.toPath(rootDir); + var rootPath = (rootDir && resolutionHost.toPath(rootDir)); var typeRootsWatches = ts.createMap(); return { startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions, @@ -67052,7 +67406,7 @@ var ts; return false; } var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path); - return value && !!value.length; + return !!value && !!value.length; } function createHasInvalidatedResolution(forceAllFilesAsInvalidated) { if (allFilesHaveInvalidatedResolution || forceAllFilesAsInvalidated) { @@ -67061,7 +67415,7 @@ var ts; } var collected = filesWithInvalidatedResolutions; filesWithInvalidatedResolutions = undefined; - return function (path) { return (collected && collected.has(path)) || + return function (path) { return (!!collected && collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } function clearPerDirectoryResolutions() { @@ -67209,19 +67563,20 @@ var ts; if (isNodeModulesDirectory(dirPath)) { return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath }, ts.getDirectoryPath(dirPath)); } - var subDirectory; + var subDirectoryPath, subDirectory; if (rootPath !== undefined) { while (!isInDirectoryPath(dirPath, rootPath)) { var parentPath = ts.getDirectoryPath(dirPath); if (parentPath === dirPath) { break; } - subDirectory = dirPath.slice(parentPath.length + ts.directorySeparator.length); + subDirectoryPath = dirPath; + subDirectory = dir; dirPath = parentPath; dir = ts.getDirectoryPath(dir); } } - return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath, subDirectory: subDirectory }, dirPath); + return filterFSRootDirectoriesToWatch({ dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath }, dirPath); } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -67240,7 +67595,7 @@ var ts; for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) { var failedLookupLocation = failedLookupLocations_1[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, ignore = _a.ignore, subDirectory = _a.subDirectory; + var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, ignore = _a.ignore; if (!ignore) { if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) { var refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0; @@ -67250,7 +67605,7 @@ var ts; setAtRoot = true; } else { - setDirectoryWatcher(dir, dirPath, subDirectory); + setDirectoryWatcher(dir, dirPath); } } } @@ -67258,19 +67613,13 @@ var ts; setDirectoryWatcher(rootDir, rootPath); } } - function setDirectoryWatcher(dir, dirPath, subDirectory) { + function setDirectoryWatcher(dir, dirPath) { var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); if (dirWatcher) { dirWatcher.refCount++; } else { - dirWatcher = { watcher: createDirectoryWatcher(dir, dirPath), refCount: 1 }; - directoryWatchesOfFailedLookups.set(dirPath, dirWatcher); - } - if (subDirectory) { - var subDirectoryMap = dirWatcher.subDirectoryMap || (dirWatcher.subDirectoryMap = ts.createMap()); - var existing = subDirectoryMap.get(subDirectory) || 0; - subDirectoryMap.set(subDirectory, existing + 1); + directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath), refCount: 1 }); } } function stopWatchFailedLookupLocationOfResolution(resolution) { @@ -67286,7 +67635,7 @@ var ts; for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) { var failedLookupLocation = failedLookupLocations_2[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore, subDirectory = _a.subDirectory; + var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore; if (!ignore) { var refCount = customFailedLookupPaths.get(failedLookupLocationPath); if (refCount) { @@ -67302,7 +67651,7 @@ var ts; removeAtRoot = true; } else { - removeDirectoryWatcher(dirPath, subDirectory); + removeDirectoryWatcher(dirPath); } } } @@ -67310,39 +67659,18 @@ var ts; removeDirectoryWatcher(rootPath); } } - function removeDirectoryWatcher(dirPath, subDirectory) { + function removeDirectoryWatcher(dirPath) { var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); - if (subDirectory) { - var existing = dirWatcher.subDirectoryMap.get(subDirectory); - if (existing === 1) { - dirWatcher.subDirectoryMap.delete(subDirectory); - } - else { - dirWatcher.subDirectoryMap.set(subDirectory, existing - 1); - } - } dirWatcher.refCount--; } - function inWatchedSubdirectory(dirPath, fileOrDirectoryPath) { - var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); - if (!dirWatcher || !dirWatcher.subDirectoryMap) - return false; - return ts.forEachKey(dirWatcher.subDirectoryMap, function (subDirectory) { - var fullSubDirectory = dirPath + "/" + subDirectory; - return fullSubDirectory === fileOrDirectoryPath || isInDirectoryPath(fullSubDirectory, fileOrDirectoryPath); - }); - } function createDirectoryWatcher(directory, dirPath) { return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) { var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory); if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } - if (!allFilesHaveInvalidatedResolution && - (dirPath === rootPath || isNodeModulesDirectory(dirPath) || ts.getDirectoryPath(fileOrDirectoryPath) === dirPath || inWatchedSubdirectory(dirPath, fileOrDirectoryPath))) { - if (invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) { - resolutionHost.onInvalidatedResolution(); - } + if (!allFilesHaveInvalidatedResolution && invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) { + resolutionHost.onInvalidatedResolution(); } }, 1); } @@ -67394,7 +67722,7 @@ var ts; removeResolutionsOfFile(filePath); invalidateResolutions(function (resolution, getResolutionWithResolvedFileName) { var result = getResolutionWithResolvedFileName(resolution); - return result && resolutionHost.toPath(result.resolvedFileName) === filePath; + return !!result && resolutionHost.toPath(result.resolvedFileName) === filePath; }); } function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) { @@ -67441,7 +67769,7 @@ var ts; return rootPath; } var _a = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath), dirPath = _a.dirPath, ignore = _a.ignore; - return !ignore && directoryWatchesOfFailedLookups.has(dirPath) && dirPath; + return !ignore && directoryWatchesOfFailedLookups.has(dirPath) ? dirPath : undefined; } function createTypeRootsWatch(typeRootPath, typeRoot) { return resolutionHost.watchTypeRootsDirectory(typeRoot, function (fileOrDirectory) { @@ -67663,9 +67991,9 @@ var ts; system.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } function createWatchCompilerHostOfConfigFile(configFileName, optionsToExtend, system, createProgram, reportDiagnostic, reportWatchStatus) { - reportDiagnostic = reportDiagnostic || createDiagnosticReporter(system); - var host = createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus); - host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; + var diagnosticReporter = reportDiagnostic || createDiagnosticReporter(system); + var host = createWatchCompilerHost(system, createProgram, diagnosticReporter, reportWatchStatus); + host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, diagnosticReporter, diagnostic); }; host.configFileName = configFileName; host.optionsToExtend = optionsToExtend; return host; @@ -67709,7 +68037,7 @@ var ts; var configFileSpecs; var configFileParsingDiagnostics; var hasChangedConfigFileParsingErrors = false; - var cachedDirectoryStructureHost = configFileName && ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames); + var cachedDirectoryStructureHost = configFileName === undefined ? undefined : ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames); if (cachedDirectoryStructureHost && host.onCachedDirectoryStructureHostCreate) { host.onCachedDirectoryStructureHostCreate(cachedDirectoryStructureHost); } @@ -67759,7 +68087,7 @@ var ts; readFile: readFile, trace: trace, directoryExists: directoryStructureHost.directoryExists && (function (path) { return directoryStructureHost.directoryExists(path); }), - getDirectories: directoryStructureHost.getDirectories && (function (path) { return directoryStructureHost.getDirectories(path); }), + getDirectories: (directoryStructureHost.getDirectories && (function (path) { return directoryStructureHost.getDirectories(path); })), realpath: host.realpath && (function (s) { return host.realpath(s); }), getEnvironmentVariable: host.getEnvironmentVariable ? (function (name) { return host.getEnvironmentVariable(name); }) : (function () { return ""; }), onReleaseOldSourceFile: onReleaseOldSourceFile, @@ -68246,6 +68574,7 @@ var ts; "es2018.promise": "lib.es2018.promise.d.ts", "es2018.regexp": "lib.es2018.regexp.d.ts", "esnext.array": "lib.esnext.array.d.ts", + "esnext.symbol": "lib.esnext.symbol.d.ts", "esnext.asynciterable": "lib.esnext.asynciterable.d.ts", }), }, @@ -68869,7 +69198,7 @@ var ts; case "string": return ts.map(values, function (v) { return v || ""; }); default: - return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + return ts.mapDefined(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }); } } ts.parseListTypeOption = parseListTypeOption; @@ -68990,6 +69319,7 @@ var ts; } return optionNameMap.get(optionName); } + ts.getOptionFromName = getOptionFromName; function getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host) { var configFileText; try { @@ -69124,7 +69454,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 269) { + if (element.kind !== 270) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -69195,13 +69525,13 @@ var ts; case 8: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 197: + case 198: if (valueExpression.operator !== 38 || valueExpression.operand.kind !== 8) { break; } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 183: + case 184: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; if (option) { @@ -69211,7 +69541,7 @@ var ts; else { return convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined); } - case 182: + case 183: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -69248,6 +69578,7 @@ var ts; var expectedType = ts.isString(option.type) ? option.type : "string"; return typeof value === expectedType; } + return false; } function generateTSConfig(options, fileNames, newLine) { var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); @@ -69669,13 +70000,10 @@ var ts; } function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { - return undefined; + return false; } var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption.compileOnSave, basePath, errors); - if (typeof result === "boolean" && result) { - return result; - } - return false; + return typeof result === "boolean" && result; } function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var errors = []; @@ -69704,7 +70032,7 @@ var ts; return options; } function getDefaultTypeAcquisition(configFileName) { - return { enable: configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; + return { enable: !!configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; } function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) { var options = getDefaultTypeAcquisition(configFileName); @@ -70193,35 +70521,35 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 148: - case 231: - case 181: - case 151: - case 150: - case 269: - case 270: - case 153: + case 149: + case 232: + case 182: case 152: + case 151: + case 270: + case 271: case 154: + case 153: case 155: case 156: - case 233: - case 191: - case 192: - case 268: - case 261: - return 1; - case 147: - case 235: - case 236: - case 165: - return 2; - case 296: - return node.name === undefined ? 1 | 2 : 2; - case 272: + case 157: case 234: + case 192: + case 193: + case 269: + case 262: + return 1; + case 148: + case 236: + case 237: + case 166: + return 2; + case 297: + return node.name === undefined ? 1 | 2 : 2; + case 273: + case 235: return 1 | 2; - case 238: + case 239: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -70231,25 +70559,25 @@ var ts; else { return 4; } - case 237: - case 246: + case 238: case 247: - case 242: - case 243: case 248: + case 243: + case 244: case 249: + case 250: return 7; - case 273: + case 274: return 4 | 1; } return 7; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 273) { + if (node.kind === 274) { return 1; } - else if (node.parent.kind === 248) { + else if (node.parent.kind === 249) { return 7; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -70277,11 +70605,11 @@ var ts; } ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { - var name = node.kind === 145 ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 242 ? 7 : 4; + var name = node.kind === 146 ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 243 ? 7 : 4; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 145) { + while (node.parent.kind === 146) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -70293,27 +70621,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 145) { - while (root.parent && root.parent.kind === 145) { + if (root.parent.kind === 146) { + while (root.parent && root.parent.kind === 146) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 161 && !isLastClause; + return root.parent.kind === 162 && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 184) { - while (root.parent && root.parent.kind === 184) { + if (root.parent.kind === 185) { + while (root.parent && root.parent.kind === 185) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 206 && root.parent.parent.kind === 267) { + if (!isLastClause && root.parent.kind === 207 && root.parent.parent.kind === 268) { var decl = root.parent.parent.parent; - return (decl.kind === 234 && root.parent.parent.token === 108) || - (decl.kind === 235 && root.parent.parent.token === 85); + return (decl.kind === 235 && root.parent.parent.token === 108) || + (decl.kind === 236 && root.parent.parent.token === 85); } return false; } @@ -70324,30 +70652,30 @@ var ts; switch (node.kind) { case 99: return !ts.isExpressionNode(node); - case 173: + case 174: return true; } switch (node.parent.kind) { - case 161: + case 162: return true; - case 178: + case 179: return !node.parent.isTypeOf; - case 206: + case 207: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 186); + return isCallOrNewExpressionTarget(node, 187); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 187); + return isCallOrNewExpressionTarget(node, 188); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { var target = climbPastPropertyAccess(node); - return target && target.parent && target.parent.kind === kind && target.parent.expression === target; + return !!target && !!target.parent && target.parent.kind === kind && target.parent.expression === target; } function climbPastPropertyAccess(node) { return isRightSideOfPropertyAccess(node) ? node.parent : node; @@ -70355,7 +70683,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 227 && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 228 && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -70376,15 +70704,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 145 && node.parent.right === node; + return node.parent.kind === 146 && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 184 && node.parent.name === node; + return node && node.parent && node.parent.kind === 185 && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 238 && node.parent.name === node; + return node.parent.kind === 239 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -70394,22 +70722,24 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 151: - case 150: - case 269: - case 272: - case 153: case 152: - case 155: + case 151: + case 270: + case 273: + case 154: + case 153: case 156: - case 238: + case 157: + case 239: return ts.getNameOfDeclaration(node.parent) === node; - case 185: + case 186: return node.parent.argumentExpression === node; - case 146: + case 147: return true; - case 177: - return node.parent.parent.kind === 175; + case 178: + return node.parent.parent.kind === 176; + default: + return false; } } ts.isLiteralNameOfPropertyDeclarationOrIndexAccess = isLiteralNameOfPropertyDeclarationOrIndexAccess; @@ -70428,17 +70758,17 @@ var ts; return undefined; } switch (node.kind) { - case 273: + case 274: + case 154: case 153: - case 152: - case 233: - case 191: - case 155: - case 156: case 234: + case 192: + case 156: + case 157: case 235: - case 237: + case 236: case 238: + case 239: return node; } } @@ -70446,49 +70776,49 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 273: + case 274: return ts.isExternalModule(node) ? "module" : "script"; - case 238: + case 239: return "module"; - case 234: - case 204: + case 235: + case 205: return "class"; - case 235: return "interface"; - case 236: - case 291: - case 296: + case 236: return "interface"; + case 237: + case 292: + case 297: return "type"; - case 237: return "enum"; - case 231: + case 238: return "enum"; + case 232: return getKindOfVariableDeclaration(node); - case 181: + case 182: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); + case 193: + case 234: case 192: - case 233: - case 191: return "function"; - case 155: return "getter"; - case 156: return "setter"; + case 156: return "getter"; + case 157: return "setter"; + case 154: case 153: - case 152: return "method"; + case 152: case 151: - case 150: return "property"; - case 159: return "index"; - case 158: return "construct"; - case 157: return "call"; - case 154: return "constructor"; - case 147: return "type parameter"; - case 272: return "enum member"; - case 148: return ts.hasModifier(node, 92) ? "property" : "parameter"; - case 242: - case 247: - case 244: - case 251: + case 160: return "index"; + case 159: return "construct"; + case 158: return "call"; + case 155: return "constructor"; + case 148: return "type parameter"; + case 273: return "enum member"; + case 149: return ts.hasModifier(node, 92) ? "property" : "parameter"; + case 243: + case 248: case 245: + case 252: + case 246: return "alias"; - case 199: + case 200: var kind = ts.getSpecialPropertyAssignmentKind(node); var right = node.right; switch (kind) { @@ -70528,7 +70858,7 @@ var ts; case 99: return true; case 71: - return ts.identifierIsThisKeyword(node) && node.parent.kind === 148; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 149; default: return false; } @@ -70549,6 +70879,10 @@ var ts; return r.pos <= pos && pos <= r.end; } ts.rangeContainsPosition = rangeContainsPosition; + function rangeContainsPositionExclusive(r, pos) { + return r.pos < pos && pos < r.end; + } + ts.rangeContainsPositionExclusive = rangeContainsPositionExclusive; function startEndContainsRange(start, end, range) { return start <= range.pos && end >= range.end; } @@ -70573,45 +70907,45 @@ var ts; } ts.positionBelongsToNode = positionBelongsToNode; function isCompletedNode(n, sourceFile) { - if (ts.nodeIsMissing(n)) { + if (n === undefined || ts.nodeIsMissing(n)) { return false; } switch (n.kind) { - case 234: case 235: - case 237: - case 183: - case 179: - case 165: - case 212: - case 239: + case 236: + case 238: + case 184: + case 180: + case 166: + case 213: case 240: - case 246: - case 250: + case 241: + case 247: + case 251: return nodeEndsWith(n, 18, sourceFile); - case 268: + case 269: return isCompletedNode(n.block, sourceFile); - case 187: + case 188: if (!n.arguments) { return true; } - case 186: - case 190: - case 172: + case 187: + case 191: + case 173: return nodeEndsWith(n, 20, sourceFile); - case 162: case 163: + case 164: return isCompletedNode(n.type, sourceFile); - case 154: case 155: case 156: - case 233: - case 191: - case 153: - case 152: - case 158: case 157: + case 234: case 192: + case 154: + case 153: + case 159: + case 158: + case 193: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -70619,63 +70953,63 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 20, sourceFile); - case 238: - return n.body && isCompletedNode(n.body, sourceFile); - case 216: + case 239: + return !!n.body && isCompletedNode(n.body, sourceFile); + case 217: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 215: + case 216: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 25, sourceFile); - case 182: - case 180: - case 185: - case 146: - case 167: + case 183: + case 181: + case 186: + case 147: + case 168: return nodeEndsWith(n, 22, sourceFile); - case 159: + case 160: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 22, sourceFile); - case 265: case 266: + case 267: return false; - case 219: case 220: case 221: - case 218: + case 222: + case 219: return isCompletedNode(n.statement, sourceFile); - case 217: + case 218: return hasChildOfKind(n, 106, sourceFile) ? nodeEndsWith(n, 20, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 164: + case 165: return isCompletedNode(n.exprName, sourceFile); - case 194: - case 193: case 195: - case 202: + case 194: + case 196: case 203: + case 204: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 188: + case 189: return isCompletedNode(n.template, sourceFile); - case 201: + case 202: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 210: + case 211: return ts.nodeIsPresent(n.literal); - case 249: - case 243: + case 250: + case 244: return ts.nodeIsPresent(n.moduleSpecifier); - case 197: + case 198: return isCompletedNode(n.operand, sourceFile); - case 199: - return isCompletedNode(n.right, sourceFile); case 200: + return isCompletedNode(n.right, sourceFile); + case 201: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -70684,11 +71018,11 @@ var ts; function nodeEndsWith(n, expectedLastToken, sourceFile) { var children = n.getChildren(sourceFile); if (children.length) { - var last_2 = ts.lastOrUndefined(children); - if (last_2.kind === expectedLastToken) { + var lastChild = ts.last(children); + if (lastChild.kind === expectedLastToken) { return true; } - else if (last_2.kind === 25 && children.length !== 1) { + else if (lastChild.kind === 25 && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -70730,6 +71064,7 @@ var ts; } ts.getTouchingToken = getTouchingToken; function getTokenAtPosition(sourceFile, position, includeJsDocComment, includeEndPosition) { + if (includeEndPosition === void 0) { includeEndPosition = false; } return getTokenAtPositionWorker(sourceFile, position, true, undefined, includeEndPosition, includeJsDocComment); } ts.getTokenAtPosition = getTokenAtPosition; @@ -70815,7 +71150,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 273 || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 274 || ts.isJSDocCommentContainingNode(n)); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length, sourceFile); return candidate && findRightmostToken(candidate, sourceFile); @@ -70848,7 +71183,7 @@ var ts; function isInString(sourceFile, position, previousToken) { if (previousToken === void 0) { previousToken = findPrecedingToken(position, sourceFile); } if (previousToken && ts.isStringTextContainingNode(previousToken)) { - var start = previousToken.getStart(); + var start = previousToken.getStart(sourceFile); var end = previousToken.getEnd(); if (start < position && position < end) { return true; @@ -70871,13 +71206,13 @@ var ts; if (token.kind === 27 && token.parent.kind === 10) { return true; } - if (token.kind === 27 && token.parent.kind === 264) { + if (token.kind === 27 && token.parent.kind === 265) { return true; } - if (token && token.kind === 18 && token.parent.kind === 264) { + if (token && token.kind === 18 && token.parent.kind === 265) { return true; } - if (token.kind === 27 && token.parent.kind === 257) { + if (token.kind === 27 && token.parent.kind === 258) { return true; } return false; @@ -70895,10 +71230,11 @@ var ts; var tokenKind = token.kind; var remainingMatchingTokens = 0; while (true) { - token = findPrecedingToken(token.getFullStart(), sourceFile); - if (!token) { + var preceding = findPrecedingToken(token.getFullStart(), sourceFile); + if (!preceding) { return undefined; } + token = preceding; if (token.kind === matchingTokenKind) { if (remainingMatchingTokens === 0) { return token; @@ -70911,15 +71247,18 @@ var ts; } } ts.findPrecedingMatchingToken = findPrecedingMatchingToken; - function isPossiblyTypeArgumentPosition(token, sourceFile) { + function isPossiblyTypeArgumentPosition(tokenIn, sourceFile) { + var token = tokenIn; var remainingLessThanTokens = 0; + var nTypeArguments = 0; while (token) { switch (token.kind) { case 27: token = findPrecedingToken(token.getFullStart(), sourceFile); - var tokenIsIdentifier = token && ts.isIdentifier(token); - if (!remainingLessThanTokens || !tokenIsIdentifier) { - return tokenIsIdentifier; + if (!token || !ts.isIdentifier(token)) + return undefined; + if (!remainingLessThanTokens) { + return { called: token, nTypeArguments: nTypeArguments }; } remainingLessThanTokens--; break; @@ -70935,19 +71274,21 @@ var ts; case 18: token = findPrecedingMatchingToken(token, 17, sourceFile); if (!token) - return false; + return undefined; break; case 20: token = findPrecedingMatchingToken(token, 19, sourceFile); if (!token) - return false; + return undefined; break; case 22: token = findPrecedingMatchingToken(token, 21, sourceFile); if (!token) - return false; + return undefined; break; case 26: + nTypeArguments++; + break; case 36: case 71: case 9: @@ -70966,11 +71307,11 @@ var ts; if (ts.isTypeNode(token)) { break; } - return false; + return undefined; } token = findPrecedingToken(token.getFullStart(), sourceFile); } - return false; + return undefined; } ts.isPossiblyTypeArgumentPosition = isPossiblyTypeArgumentPosition; function isInComment(sourceFile, position, tokenAtPosition, predicate) { @@ -71011,10 +71352,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 161 || node.kind === 186) { + if (node.kind === 162 || node.kind === 187) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 234 || node.kind === 235) { + if (ts.isFunctionLike(node) || node.kind === 235 || node.kind === 236) { return node.typeParameters; } return undefined; @@ -71037,9 +71378,9 @@ var ts; return 17 <= kind && kind <= 70; } ts.isPunctuation = isPunctuation; - function isInsideTemplateLiteral(node, position) { + function isInsideTemplateLiteral(node, position, sourceFile) { return ts.isTemplateLiteralKind(node.kind) - && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); + && (node.getStart(sourceFile) < position && position < node.end) || (!!node.isUnterminated && position === node.end); } ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { @@ -71059,18 +71400,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 182 || - node.kind === 183) { - if (node.parent.kind === 199 && + if (node.kind === 183 || + node.kind === 184) { + if (node.parent.kind === 200 && node.parent.left === node && node.parent.operatorToken.kind === 58) { return true; } - if (node.parent.kind === 221 && + if (node.parent.kind === 222 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 269 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 270 ? node.parent.parent : node.parent)) { return true; } } @@ -71124,6 +71465,7 @@ var ts; 105, 140, 141, + 142, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -71159,7 +71501,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 146 + return name.kind === 147 ? ts.isStringOrNumericLiteral(name.expression) ? name.expression.text : undefined : ts.getTextOfIdentifierOrLiteral(name); } @@ -71180,14 +71522,14 @@ var ts; return ts.createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host)); } ts.hostGetCanonicalFileName = hostGetCanonicalFileName; - function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier) { - return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier) : undefined; + function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, preferences) { + return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, preferences) : undefined; } ts.makeImportIfNecessary = makeImportIfNecessary; - function makeImport(defaultImport, namedImports, moduleSpecifier) { + function makeImport(defaultImport, namedImports, moduleSpecifier, preferences) { return ts.createImportDeclaration(undefined, undefined, defaultImport || namedImports ? ts.createImportClause(defaultImport, namedImports && namedImports.length ? ts.createNamedImports(namedImports) : undefined) - : undefined, typeof moduleSpecifier === "string" ? ts.createLiteral(moduleSpecifier) : moduleSpecifier); + : undefined, typeof moduleSpecifier === "string" ? ts.createLiteral(moduleSpecifier, preferences.quotePreference === "single") : moduleSpecifier); } ts.makeImport = makeImport; function symbolNameNoDefault(symbol) { @@ -71215,6 +71557,24 @@ var ts; return propSymbol; } ts.getPropertySymbolFromBindingElement = getPropertySymbolFromBindingElement; + function getPropertySymbolsFromBaseTypes(symbol, propertyName, checker, cb) { + var seen = ts.createMap(); + return recur(symbol); + function recur(symbol) { + if (!(symbol.flags & (32 | 64)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) + return; + return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { + var type = checker.getTypeAtLocation(typeReference); + var propertySymbol = type && type.symbol && checker.getPropertyOfType(type, propertyName); + return type && propertySymbol && (ts.firstDefined(checker.getRootSymbols(propertySymbol), cb) || recur(type.symbol)); + }); }); + } + } + ts.getPropertySymbolsFromBaseTypes = getPropertySymbolsFromBaseTypes; + function isMemberSymbolInBaseType(memberSymbol, checker) { + return getPropertySymbolsFromBaseTypes(memberSymbol.parent, memberSymbol.name, checker, function (_) { return true; }) || false; + } + ts.isMemberSymbolInBaseType = isMemberSymbolInBaseType; var NodeSet = (function () { function NodeSet() { this.map = ts.createMap(); @@ -71234,10 +71594,25 @@ var ts; return NodeSet; }()); ts.NodeSet = NodeSet; + function getParentNodeInSpan(node, file, span) { + if (!node) + return undefined; + while (node.parent) { + if (ts.isSourceFile(node.parent) || !spanContainsNode(span, node.parent, file)) { + return node; + } + node = node.parent; + } + } + ts.getParentNodeInSpan = getParentNodeInSpan; + function spanContainsNode(span, node, file) { + return ts.textSpanContainsPosition(span, node.getStart(file)) && + node.getEnd() <= ts.textSpanEnd(span); + } })(ts || (ts = {})); (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 148; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 149; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -71406,18 +71781,21 @@ var ts; } ts.mapToDisplayParts = mapToDisplayParts; function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { + if (flags === void 0) { flags = 0; } return mapToDisplayParts(function (writer) { - typechecker.writeType(type, enclosingDeclaration, flags | 1024, writer); + typechecker.writeType(type, enclosingDeclaration, flags | 1024 | 16384, writer); }); } ts.typeToDisplayParts = typeToDisplayParts; function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { + if (flags === void 0) { flags = 0; } return mapToDisplayParts(function (writer) { typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8, writer); }); } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + if (flags === void 0) { flags = 0; } flags |= 16384 | 1024 | 32 | 8192; return mapToDisplayParts(function (writer) { typechecker.writeSignature(signature, enclosingDeclaration, flags, undefined, writer); @@ -71425,8 +71803,8 @@ var ts; } ts.signatureToDisplayParts = signatureToDisplayParts; function isImportOrExportSpecifierName(location) { - return location.parent && - (location.parent.kind === 247 || location.parent.kind === 251) && + return !!location.parent && + (location.parent.kind === 248 || location.parent.kind === 252) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -71448,7 +71826,7 @@ var ts; scriptKinds[_i - 2] = arguments[_i]; } var scriptKind = getScriptKind(fileName, host); - return ts.forEach(scriptKinds, function (k) { return k === scriptKind; }); + return ts.some(scriptKinds, function (k) { return k === scriptKind; }); } ts.scriptKindIs = scriptKindIs; function getScriptKind(fileName, host) { @@ -71516,9 +71894,9 @@ var ts; function getFirstChild(node) { return node.forEachChild(function (child) { return child; }); } - function getUniqueName(baseName, fileText) { + function getUniqueName(baseName, sourceFile) { var nameText = baseName; - for (var i = 1; ts.stringContains(fileText, nameText); i++) { + for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { nameText = baseName + "_" + i; } return nameText; @@ -71533,7 +71911,7 @@ var ts; for (var _b = 0, textChanges_1 = textChanges_2; _b < textChanges_1.length; _b++) { var change = textChanges_1[_b]; var span = change.span, newText = change.newText; - var index = newText.indexOf(name); + var index = indexInTextChange(newText, name); if (index !== -1) { lastPos = span.start + delta + index; if (!preferLastLocation) { @@ -71548,6 +71926,16 @@ var ts; return lastPos; } ts.getRenameLocation = getRenameLocation; + function indexInTextChange(change, name) { + if (ts.startsWith(change, name)) + return 0; + var idx = change.indexOf(" " + name); + if (idx === -1) + idx = change.indexOf("." + name); + if (idx === -1) + idx = change.indexOf('"' + name); + return idx === -1 ? -1 : idx + 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -71757,6 +72145,8 @@ var ts; case 9: case 17: return ts.TokenClass.Identifier; + default: + return undefined; } } function canFollow(keyword1, keyword2) { @@ -71888,10 +72278,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { - case 238: - case 234: + case 239: case 235: - case 233: + case 236: + case 234: cancellationToken.throwIfCancellationRequested(); } } @@ -71976,6 +72366,7 @@ var ts; case 22: return "jsx attribute"; case 23: return "jsx text"; case 24: return "jsx attribute string literal value"; + default: return undefined; } } function convertClassificationsToSpans(classifications) { @@ -72072,18 +72463,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 292: + case 293: processJSDocParameterTag(tag); break; - case 295: + case 296: processJSDocTemplateTag(tag); pos = tag.end; break; - case 294: + case 295: processElement(tag.typeExpression); pos = tag.end; break; - case 293: + case 294: processElement(tag.typeExpression); pos = tag.end; break; @@ -72164,22 +72555,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 256: + case 257: if (token.parent.tagName === token) { return 19; } break; - case 257: + case 258: if (token.parent.tagName === token) { return 20; } break; - case 255: + case 256: if (token.parent.tagName === token) { return 21; } break; - case 261: + case 262: if (token.parent.name === token) { return 22; } @@ -72198,18 +72589,19 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { + var parent = token.parent; if (tokenKind === 58) { - if (token.parent.kind === 231 || - token.parent.kind === 151 || - token.parent.kind === 148 || - token.parent.kind === 261) { + if (parent.kind === 232 || + parent.kind === 152 || + parent.kind === 149 || + parent.kind === 262) { return 5; } } - if (token.parent.kind === 199 || - token.parent.kind === 197 || - token.parent.kind === 198 || - token.parent.kind === 200) { + if (parent.kind === 200 || + parent.kind === 198 || + parent.kind === 199 || + parent.kind === 201) { return 5; } } @@ -72219,7 +72611,7 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 261 ? 24 : 6; + return token.parent.kind === 262 ? 24 : 6; } else if (tokenKind === 12) { return 6; @@ -72233,32 +72625,32 @@ var ts; else if (tokenKind === 71) { if (token) { switch (token.parent.kind) { - case 234: + case 235: if (token.parent.name === token) { return 11; } return; - case 147: + case 148: if (token.parent.name === token) { return 15; } return; - case 235: + case 236: if (token.parent.name === token) { return 13; } return; - case 237: + case 238: if (token.parent.name === token) { return 12; } return; - case 238: + case 239: if (token.parent.name === token) { return 14; } return; - case 148: + case 149: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 : 17; } @@ -72496,8 +72888,8 @@ var ts; var ambientModules = checker.getAmbientModules().map(function (sym) { return ts.stripQuotes(sym.name); }); var nonRelativeModuleNames = ambientModules.filter(function (moduleName) { return ts.startsWith(moduleName, fragment); }); if (fragmentDirectory !== undefined) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(fragmentDirectory); - return nonRelativeModuleNames.map(function (nonRelativeModuleName) { return ts.removePrefix(nonRelativeModuleName, moduleNameWithSeperator_1); }); + var moduleNameWithSeparator_1 = ts.ensureTrailingDirectorySeparator(fragmentDirectory); + return nonRelativeModuleNames.map(function (nonRelativeModuleName) { return ts.removePrefix(nonRelativeModuleName, moduleNameWithSeparator_1); }); } return nonRelativeModuleNames; } @@ -72634,7 +73026,7 @@ var ts; return ts.directoryProbablyExists(path, host); } catch (_a) { } - return undefined; + return false; } function tryIOAndConsumeErrors(host, toApply) { var args = []; @@ -72691,7 +73083,7 @@ var ts; && (contextToken.kind === 72 || contextToken.kind === 77 || contextToken.kind === 71)) { return getLabelCompletionAtPosition(contextToken.parent); } - var completionData = getCompletionData(program, log, sourceFile, position, preferences, undefined); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, undefined); if (!completionData) { return undefined; } @@ -72754,7 +73146,7 @@ var ts; }] }; } var entries = []; - if (ts.isSourceFileJavaScript(sourceFile)) { + if (isUncheckedFile(sourceFile, compilerOptions)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap); getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); } @@ -72770,6 +73162,9 @@ var ts; } return { isGlobalCompletion: isInSnippetScope, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; } + function isUncheckedFile(sourceFile, compilerOptions) { + return ts.isSourceFileJavaScript(sourceFile) && !ts.isCheckJsEnabledForFile(sourceFile, compilerOptions); + } function isMemberCompletionKind(kind) { switch (kind) { case 0: @@ -72918,38 +73313,38 @@ var ts; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { switch (node.parent.kind) { - case 177: + case 178: switch (node.parent.parent.kind) { - case 161: + case 162: return { kind: 2, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(node.parent), typeChecker), isNewIdentifier: false }; - case 175: + case 176: return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(node.parent.parent.objectType)); - case 178: + case 179: return { kind: 0, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; default: return undefined; } - case 269: + case 270: if (ts.isObjectLiteralExpression(node.parent.parent) && node.parent.name === node) { return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(node.parent.parent)); } return fromContextualType(); - case 185: { + case 186: { var _a = node.parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { return stringLiteralCompletionsFromProperties(typeChecker.getTypeAtLocation(expression)); } return undefined; } - case 186: case 187: + case 188: if (!ts.isRequireCall(node.parent, false) && !ts.isImportCall(node.parent)) { - var argumentInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } - case 243: - case 249: - case 253: + case 244: + case 250: + case 254: return { kind: 0, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; default: return fromContextualType(); @@ -72967,7 +73362,7 @@ var ts; if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) return; var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); - isNewIdentifier = isNewIdentifier || !!(type.flags & 2); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4); return getStringLiteralTypes(type, checker, uniques); }); return { kind: 2, types: types, isNewIdentifier: isNewIdentifier }; @@ -72982,12 +73377,13 @@ var ts; type = ts.skipConstraint(type); return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, typeChecker, uniques); }) - : type.isStringLiteral() && !(type.flags & 256) && ts.addToSeen(uniques, type.value) + : type.isStringLiteral() && !(type.flags & 512) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { - var completionData = getCompletionData(program, log, sourceFile, position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); + var compilerOptions = program.getCompilerOptions(); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); if (!completionData) { return { type: "none" }; } @@ -72997,7 +73393,7 @@ var ts; var symbols = completionData.symbols, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer; return ts.firstDefined(symbols, function (symbol) { var origin = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; - var info = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, origin, completionKind); + var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target, origin, completionKind); return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source ? { type: "symbol", symbol: symbol, location: location, symbolToOriginInfoMap: symbolToOriginInfoMap, previousToken: previousToken, isJsxInitializer: isJsxInitializer } : undefined; @@ -73076,7 +73472,7 @@ var ts; return { codeActions: undefined, sourceDisplay: undefined }; } var moduleSymbol = symbolOriginInfo.moduleSymbol; - var exportedSymbol = ts.skipAlias(symbol.exportSymbol || symbol, checker); + var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, checker, compilerOptions, allSourceFiles, formatContext, getCanonicalFileName, previousToken, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } @@ -73102,11 +73498,13 @@ var ts; CompletionKind[CompletionKind["None"] = 5] = "None"; })(CompletionKind || (CompletionKind = {})); function getRecommendedCompletion(currentToken, position, sourceFile, checker) { - var ty = getContextualType(currentToken, position, sourceFile, checker); - var symbol = ty && ty.symbol; - return symbol && (symbol.flags & 384 || symbol.flags & 32 && !ts.isAbstractConstructorSymbol(symbol)) - ? getFirstSymbolInChain(symbol, currentToken, checker) - : undefined; + var contextualType = getContextualType(currentToken, position, sourceFile, checker); + return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { + var symbol = type && type.symbol; + return symbol && (symbol.flags & (8 | 384 | 32) && !ts.isAbstractConstructorSymbol(symbol)) + ? getFirstSymbolInChain(symbol, currentToken, checker) + : undefined; + }); } function getContextualType(currentToken, position, sourceFile, checker) { var parent = currentToken.parent; @@ -73115,11 +73513,11 @@ var ts; return getContextualTypeFromParent(currentToken, checker); case 58: switch (parent.kind) { - case 231: + case 232: return checker.getContextualType(parent.initializer); - case 199: + case 200: return checker.getTypeAtLocation(parent.left); - case 261: + case 262: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -73129,9 +73527,9 @@ var ts; case 73: return getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 17: - return ts.isJsxExpression(parent) && parent.parent.kind !== 254 ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 255 ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: - var argInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(currentToken, position, sourceFile); + var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(currentToken, position, sourceFile); return argInfo ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (currentToken.kind === 26 ? 1 : 0)) : isEqualityOperatorKind(currentToken.kind) && ts.isBinaryExpression(parent) && isEqualityOperatorKind(parent.operatorToken.kind) @@ -73142,15 +73540,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 187: + case 188: return checker.getContextualType(parent); - case 199: { + case 200: { 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 265: + case 266: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -73166,9 +73564,9 @@ 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 === 273; }); + return symbol.declarations.some(function (d) { return d.kind === 274; }); } - function getCompletionData(program, log, sourceFile, position, preferences, detailsEntryId) { + function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position, false); @@ -73195,11 +73593,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 277) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 278) { currentToken = ts.getTokenAtPosition(sourceFile, position, true); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 297 || + (currentToken.parent.kind !== 298 || currentToken.parent.name !== currentToken))) { insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); } @@ -73238,14 +73636,15 @@ var ts; if (contextToken.kind === 23) { isRightOfDot = true; switch (parent.kind) { - case 184: + case 185: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; break; - case 145: + case 146: node = parent.left; break; - case 178: + case 179: + case 210: node = parent; break; default: @@ -73253,44 +73652,44 @@ var ts; } } else if (sourceFile.languageVariant === 1) { - if (parent && parent.kind === 184) { + if (parent && parent.kind === 185) { contextToken = parent; parent = parent.parent; } if (currentToken.parent === location) { switch (currentToken.kind) { case 29: - if (currentToken.parent.kind === 254 || currentToken.parent.kind === 256) { + if (currentToken.parent.kind === 255 || currentToken.parent.kind === 257) { location = currentToken; } break; case 41: - if (currentToken.parent.kind === 255) { + if (currentToken.parent.kind === 256) { location = currentToken; } break; } } switch (parent.kind) { - case 257: + case 258: if (contextToken.kind === 41) { isStartingCloseTag = true; location = contextToken; } break; - case 199: + case 200: if (!(parent.left.flags & 32768)) { break; } - case 255: - case 254: case 256: + case 255: + case 257: if (contextToken.kind === 27) { isRightOfOpenTag = true; location = contextToken; } break; - case 261: + case 262: switch (previousToken.kind) { case 58: isJsxInitializer = true; @@ -73337,12 +73736,14 @@ var ts; return { kind: 0, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 292: - case 297: case 293: + case 298: case 294: - case 296: + case 295: + case 297: return true; + default: + return false; } } function getTypeScriptMemberSymbols() { @@ -73368,26 +73769,31 @@ var ts; symbols.push(symbol_2); } } - if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 273 && d.kind !== 238 && d.kind !== 237; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 274 && d.kind !== 239 && d.kind !== 238; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; } } } + if (ts.isMetaProperty(node) && (node.keywordToken === 94 || node.keywordToken === 91)) { + var completion = (node.keywordToken === 94) ? "target" : "meta"; + symbols.push(typeChecker.createSymbol(4, ts.escapeLeadingUnderscores(completion))); + return; + } if (!isTypeLocation) { addTypeProperties(typeChecker.getTypeAtLocation(node)); } } function addTypeProperties(type) { isNewIdentifierLocation = hasIndexSignature(type); - if (ts.isSourceFileJavaScript(sourceFile)) { + if (isUncheckedFile) { symbols.push.apply(symbols, getPropertiesForCompletion(type, typeChecker, true)); } else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 178 ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 179 ? node : node.parent, type, symbol)) { addPropertySymbol(symbol); } } @@ -73396,7 +73802,7 @@ var ts; function addPropertySymbol(symbol) { var symbolSymbol = ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - var leftName = name.kind === 146 ? getLeftMostName(name.expression) : undefined; + var leftName = name.kind === 147 ? getLeftMostName(name.expression) : undefined; return leftName && typeChecker.getSymbolAtLocation(leftName); }); if (symbolSymbol) { @@ -73453,7 +73859,7 @@ var ts; isInSnippetScope = isSnippetScope(scopeNode); var symbolMeanings = 67901928 | 67216319 | 1920 | 2097152; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 273) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 274) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker, true); _i < _a.length; _i++) { @@ -73477,16 +73883,16 @@ var ts; return false; if (ts.programContainsEs6Modules(program)) return true; - if (ts.isSourceFileJavaScript(sourceFile)) + if (isUncheckedFile) return false; return ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions()); } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 273: - case 201: - case 264: - case 212: + case 274: + case 202: + case 265: + case 213: return true; default: return ts.isStatement(scopeNode); @@ -73519,22 +73925,22 @@ var ts; function isContextTokenValueLocation(contextToken) { return contextToken && contextToken.kind === 103 && - (contextToken.parent.kind === 164 || ts.isTypeOfExpression(contextToken.parent)); + (contextToken.parent.kind === 165 || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 56: - return parentKind === 151 || - parentKind === 150 || - parentKind === 148 || - parentKind === 231 || + return parentKind === 152 || + parentKind === 151 || + parentKind === 149 || + parentKind === 232 || ts.isFunctionLikeKind(parentKind); case 58: - return parentKind === 236; + return parentKind === 237; case 118: - return parentKind === 207; + return parentKind === 208; } } return false; @@ -73549,16 +73955,22 @@ var ts; var exportedSymbols = typeChecker.getExportsOfModule(symbol); return exportedSymbols.some(symbolCanBeReferencedAtTypeLocation); } + return false; } function getSymbolsFromOtherSourceFileExports(symbols, tokenText, target) { var tokenTextLowerCase = tokenText.toLowerCase(); + var seenResolvedModules = ts.createMap(); ts.codefix.forEachExternalModuleToImportFrom(typeChecker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { return; } + var resolvedModuleSymbol = typeChecker.resolveExternalModuleSymbol(moduleSymbol); + if (!ts.addToSeen(seenResolvedModules, ts.getSymbolId(resolvedModuleSymbol))) { + return; + } for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.getMergedSymbol(symbol.parent) !== typeChecker.resolveExternalModuleSymbol(moduleSymbol) + if (typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.parent.parent.moduleSpecifier; })) { continue; } @@ -73610,11 +74022,11 @@ var ts; return true; } if (contextToken.kind === 29 && contextToken.parent) { - if (contextToken.parent.kind === 256) { + if (contextToken.parent.kind === 257) { return true; } - if (contextToken.parent.kind === 257 || contextToken.parent.kind === 255) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 254; + if (contextToken.parent.kind === 258 || contextToken.parent.kind === 256) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 255; } } return false; @@ -73624,40 +74036,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 26: - return containingNodeKind === 186 - || containingNodeKind === 154 - || containingNodeKind === 187 - || containingNodeKind === 182 - || containingNodeKind === 199 - || containingNodeKind === 162; + return containingNodeKind === 187 + || containingNodeKind === 155 + || containingNodeKind === 188 + || containingNodeKind === 183 + || containingNodeKind === 200 + || containingNodeKind === 163; case 19: - return containingNodeKind === 186 - || containingNodeKind === 154 - || containingNodeKind === 187 - || containingNodeKind === 190 - || containingNodeKind === 172; + return containingNodeKind === 187 + || containingNodeKind === 155 + || containingNodeKind === 188 + || containingNodeKind === 191 + || containingNodeKind === 173; case 21: - return containingNodeKind === 182 - || containingNodeKind === 159 - || containingNodeKind === 146; + return containingNodeKind === 183 + || containingNodeKind === 160 + || containingNodeKind === 147; case 129: case 130: return true; case 23: - return containingNodeKind === 238; + return containingNodeKind === 239; case 17: - return containingNodeKind === 234; + return containingNodeKind === 235; case 58: - return containingNodeKind === 231 - || containingNodeKind === 199; + return containingNodeKind === 232 + || containingNodeKind === 200; case 14: - return containingNodeKind === 201; + return containingNodeKind === 202; case 15: - return containingNodeKind === 210; + return containingNodeKind === 211; case 114: case 112: case 113: - return containingNodeKind === 151; + return containingNodeKind === 152; } switch (keywordForNode(previousToken)) { case 114: @@ -73669,20 +74081,8 @@ var ts; return false; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 9 - || contextToken.kind === 12 - || ts.isTemplateLiteralKind(contextToken.kind)) { - var start_5 = contextToken.getStart(); - var end = contextToken.getEnd(); - if (start_5 < position && position < end) { - return true; - } - if (position === end) { - return !!contextToken.isUnterminated - || contextToken.kind === 12; - } - } - return false; + return (ts.isRegularExpressionLiteral(contextToken) || ts.isStringTextContainingNode(contextToken)) && (ts.rangeContainsPositionExclusive(ts.createTextRangeFromSpan(ts.createTextSpanFromNode(contextToken)), position) || + position === contextToken.end && (!!contextToken.isUnterminated || ts.isRegularExpressionLiteral(contextToken))); } function tryGetObjectLikeCompletionSymbols() { var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); @@ -73691,7 +74091,7 @@ var ts; completionKind = 0; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 183) { + if (objectLikeContainer.kind === 184) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2; @@ -73700,17 +74100,17 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 179); + ts.Debug.assert(objectLikeContainer.kind === 180); isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (!ts.isVariableLike(rootDeclaration)) return ts.Debug.fail("Root declaration is not variable-like."); - var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 221; - if (!canGetType && rootDeclaration.kind === 148) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 222; + if (!canGetType && rootDeclaration.kind === 149) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 153 || rootDeclaration.parent.kind === 156) { + else if (rootDeclaration.parent.kind === 154 || rootDeclaration.parent.kind === 157) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -73732,7 +74132,7 @@ var ts; ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) return 0; - var moduleSpecifier = (namedImportsOrExports.kind === 246 ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 247 ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); if (!moduleSpecifierSymbol) return 2; @@ -73753,7 +74153,7 @@ var ts; if (!ts.isClassLike(decl)) return 1; var classElement = contextToken.parent; - var classElementModifierFlags = ts.isClassElement(classElement) && ts.getModifierFlags(classElement); + var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(classElement) : 0; if (contextToken.kind === 71 && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": @@ -73793,13 +74193,14 @@ var ts; } function tryGetConstructorLikeCompletionContainer(contextToken) { if (contextToken) { + var parent = contextToken.parent; switch (contextToken.kind) { case 19: case 26: - return ts.isConstructorDeclaration(contextToken.parent) && contextToken.parent; + return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { - return contextToken.parent.parent; + return parent.parent; } } } @@ -73816,6 +74217,7 @@ var ts; return true; } prev_1 = node; + return false; }); return container && container; } @@ -73827,29 +74229,29 @@ var ts; case 28: case 41: case 71: - case 184: - case 262: - case 261: + case 185: case 263: - if (parent && (parent.kind === 255 || parent.kind === 256)) { + case 262: + case 264: + if (parent && (parent.kind === 256 || parent.kind === 257)) { return parent; } - else if (parent.kind === 261) { + else if (parent.kind === 262) { return parent.parent.parent; } break; case 9: - if (parent && ((parent.kind === 261) || (parent.kind === 263))) { + if (parent && ((parent.kind === 262) || (parent.kind === 264))) { return parent.parent.parent; } break; case 18: if (parent && - parent.kind === 264 && - parent.parent && parent.parent.kind === 261) { + parent.kind === 265 && + parent.parent && parent.parent.kind === 262) { return parent.parent.parent.parent; } - if (parent && parent.kind === 263) { + if (parent && parent.kind === 264) { return parent.parent.parent; } break; @@ -73858,51 +74260,51 @@ var ts; return undefined; } function isSolelyIdentifierDefinitionLocation(contextToken) { - var containingNodeKind = contextToken.parent.kind; + var parent = contextToken.parent; + var containingNodeKind = parent.kind; switch (contextToken.kind) { case 26: - return containingNodeKind === 231 || - containingNodeKind === 232 || - containingNodeKind === 213 || - containingNodeKind === 237 || + return containingNodeKind === 232 || + containingNodeKind === 233 || + containingNodeKind === 214 || + containingNodeKind === 238 || isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 235 || - containingNodeKind === 180 || containingNodeKind === 236 || - (ts.isClassLike(contextToken.parent) && - contextToken.parent.typeParameters && - contextToken.parent.typeParameters.end >= contextToken.pos); + containingNodeKind === 181 || + containingNodeKind === 237 || + (ts.isClassLike(parent) && + !!parent.typeParameters && + parent.typeParameters.end >= contextToken.pos); case 23: - return containingNodeKind === 180; - case 56: return containingNodeKind === 181; + case 56: + return containingNodeKind === 182; case 21: - return containingNodeKind === 180; + return containingNodeKind === 181; case 19: - return containingNodeKind === 268 || + return containingNodeKind === 269 || isFunctionLikeButNotConstructor(containingNodeKind); case 17: - return containingNodeKind === 237; + return containingNodeKind === 238; case 27: - return containingNodeKind === 234 || - containingNodeKind === 204 || - containingNodeKind === 235 || + return containingNodeKind === 235 || + containingNodeKind === 205 || containingNodeKind === 236 || + containingNodeKind === 237 || ts.isFunctionLikeKind(containingNodeKind); case 115: - return containingNodeKind === 151 && !ts.isClassLike(contextToken.parent.parent); + return containingNodeKind === 152 && !ts.isClassLike(parent.parent); case 24: - return containingNodeKind === 148 || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 180); + return containingNodeKind === 149 || + (!!parent.parent && parent.parent.kind === 181); case 114: case 112: case 113: - return containingNodeKind === 148 && !ts.isConstructorDeclaration(contextToken.parent.parent); + return containingNodeKind === 149 && !ts.isConstructorDeclaration(parent.parent); case 118: - return containingNodeKind === 247 || - containingNodeKind === 251 || - containingNodeKind === 245; + return containingNodeKind === 248 || + containingNodeKind === 252 || + containingNodeKind === 246; case 125: case 136: if (isFromObjectTypeDeclaration(contextToken)) { @@ -73953,7 +74355,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 154; + return ts.isFunctionLikeKind(kind) && kind !== 155; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8) { @@ -73969,19 +74371,19 @@ var ts; var existingMemberNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 269 && - m.kind !== 270 && - m.kind !== 181 && - m.kind !== 153 && - m.kind !== 155 && - m.kind !== 156) { + if (m.kind !== 270 && + m.kind !== 271 && + m.kind !== 182 && + m.kind !== 154 && + m.kind !== 156 && + m.kind !== 157) { continue; } if (isCurrentlyEditingNode(m)) { continue; } var existingName = void 0; - if (m.kind === 181 && m.propertyName) { + if (ts.isBindingElement(m) && m.propertyName) { if (m.propertyName.kind === 71) { existingName = m.propertyName.escapedText; } @@ -73998,10 +74400,10 @@ var ts; var existingMemberNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; - if (m.kind !== 151 && - m.kind !== 153 && - m.kind !== 155 && - m.kind !== 156) { + if (m.kind !== 152 && + m.kind !== 154 && + m.kind !== 156 && + m.kind !== 157) { continue; } if (isCurrentlyEditingNode(m)) { @@ -74031,7 +74433,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 261) { + if (attr.kind === 262) { seenNames.set(attr.name.escapedText, true); } } @@ -74069,7 +74471,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 72; i <= 144; i++) { + for (var i = 72; i <= 145; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword", @@ -74162,13 +74564,13 @@ var ts; return ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); } var filteredTypes = isForAccess ? type.types : type.types.filter(function (memberType) { - return !(memberType.flags & 16382 || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker)); + return !(memberType.flags & 32764 || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker)); }); return ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(filteredTypes), "getAllPossiblePropertiesOfTypes() should all be defined"); } function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { switch (location.kind) { - case 298: + case 299: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -74211,7 +74613,7 @@ var ts; case "`": return isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": - return contextToken.kind === 27 && contextToken.parent.kind !== 199; + return contextToken.kind === 27 && contextToken.parent.kind !== 200; case "/": return ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) @@ -74224,8 +74626,8 @@ var ts; switch (node.kind) { case 9: case 13: - case 201: - case 188: + case 202: + case 189: return true; default: return false; @@ -74268,7 +74670,7 @@ var ts; if (!sourceFilesSet.has(fileName)) { ts.Debug.assert(program.redirectTargetsSet.has(fileName)); var redirectTarget_1 = program.getSourceFile(fileName); - var redirect = ts.find(sourceFilesToSearch, function (f) { return f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget_1; }); + var redirect = ts.find(sourceFilesToSearch, function (f) { return !!f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget_1; }); fileName = redirect.fileName; ts.Debug.assert(sourceFilesSet.has(fileName)); } @@ -74314,6 +74716,8 @@ var ts; return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); case 120: return highlightSpans(getAsyncAndAwaitOccurrences(node)); + case 116: + return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) ? highlightSpans(getModifierOccurrences(node.kind, node.parent)) @@ -74336,7 +74740,7 @@ var ts; return [node]; } else if (ts.isTryStatement(node)) { - return ts.concatenate(node.catchClause ? aggregateOwnedThrowStatements(node.catchClause) : node.tryBlock && aggregateOwnedThrowStatements(node.tryBlock), aggregateOwnedThrowStatements(node.finallyBlock)); + return ts.concatenate(node.catchClause ? aggregateOwnedThrowStatements(node.catchClause) : node.tryBlock && aggregateOwnedThrowStatements(node.tryBlock), node.finallyBlock && aggregateOwnedThrowStatements(node.finallyBlock)); } return ts.isFunctionLike(node) ? undefined : flatMapChildren(node, aggregateOwnedThrowStatements); } @@ -74344,7 +74748,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 273) { + if (ts.isFunctionBlock(parent) || parent.kind === 274) { return parent; } if (ts.isTryStatement(parent) && parent.tryBlock === child && parent.catchClause) { @@ -74369,23 +74773,23 @@ var ts; } function ownsBreakOrContinueStatement(owner, statement) { var actualOwner = getBreakOrContinueOwner(statement); - return actualOwner && actualOwner === owner; + return !!actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 226: - if (statement.kind === 222) { + case 227: + if (statement.kind === 223) { return false; } - case 219: case 220: case 221: + case 222: + case 219: case 218: - case 217: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: - return (ts.isFunctionLike(node) && "quit"); + return ts.isFunctionLike(node) && "quit"; } }); } @@ -74402,24 +74806,23 @@ var ts; function getNodesToSearchForModifier(declaration, modifierFlag) { var container = declaration.parent; switch (container.kind) { - case 239: - case 273: - case 212: - case 265: + case 240: + case 274: + case 213: case 266: + case 267: if (modifierFlag & 128 && ts.isClassDeclaration(declaration)) { return declaration.members.concat([declaration]); } else { return container.statements; } + case 155: case 154: - case 153: - case 233: { - return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - } case 234: - case 204: + return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); + case 235: + case 205: var nodes = container.members; if (modifierFlag & 28) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); @@ -74449,7 +74852,7 @@ var ts; function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 88, 106, 81)) { - if (loopNode.kind === 217) { + if (loopNode.kind === 218) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 106)) { @@ -74469,13 +74872,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 219: case 220: case 221: - case 217: + case 222: case 218: + case 219: return getLoopBreakContinueOccurrences(owner); - case 226: + case 227: return getSwitchCaseDefaultOccurrences(owner); } } @@ -74547,15 +74950,34 @@ var ts; pushKeywordIf(keywords, modifier, 120); }); } - ts.forEachChild(func, aggregate); + ts.forEachChild(func, function (child) { + traverseWithoutCrossingFunction(child, function (node) { + if (ts.isAwaitExpression(node)) { + pushKeywordIf(keywords, node.getFirstToken(), 121); + } + }); + }); return keywords; - function aggregate(node) { - if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 121); - } - if (!ts.isFunctionLike(node) && !ts.isClassLike(node) && !ts.isInterfaceDeclaration(node) && !ts.isModuleDeclaration(node) && !ts.isTypeAliasDeclaration(node) && !ts.isTypeNode(node)) { - ts.forEachChild(node, aggregate); - } + } + function getYieldOccurrences(node) { + var func = ts.getContainingFunction(node); + if (!func) { + return undefined; + } + var keywords = []; + ts.forEachChild(func, function (child) { + traverseWithoutCrossingFunction(child, function (node) { + if (ts.isYieldExpression(node)) { + pushKeywordIf(keywords, node.getFirstToken(), 116); + } + }); + }); + return keywords; + } + function traverseWithoutCrossingFunction(node, cb) { + cb(node); + if (!ts.isFunctionLike(node) && !ts.isClassLike(node) && !ts.isInterfaceDeclaration(node) && !ts.isModuleDeclaration(node) && !ts.isTypeAliasDeclaration(node) && !ts.isTypeNode(node)) { + ts.forEachChild(node, function (child) { return traverseWithoutCrossingFunction(child, cb); }); } } function getIfElseOccurrences(ifStatement, sourceFile) { @@ -74614,6 +75036,10 @@ var ts; var ts; (function (ts) { function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { + return createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory); + } + ts.createDocumentRegistry = createDocumentRegistry; + function createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory, externalCache) { if (currentDirectory === void 0) { currentDirectory = ""; } var buckets = ts.createMap(); var getCanonicalFileName = ts.createGetCanonicalFileName(!!useCaseSensitiveFileNames); @@ -74634,8 +75060,7 @@ var ts; entries.forEach(function (entry, name) { sourceFiles.push({ name: name, - refCount: entry.languageServiceRefCount, - references: entry.owners.slice(0) + refCount: entry.languageServiceRefCount }); }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); @@ -74666,23 +75091,40 @@ var ts; var bucket = getBucketForCompilationSettings(key, true); var entry = bucket.get(path); var scriptTarget = scriptKind === 6 ? 100 : compilationSettings.target; + if (!entry && externalCache) { + var sourceFile = externalCache.getDocument(key, path); + if (sourceFile) { + ts.Debug.assert(acquiring); + entry = { + sourceFile: sourceFile, + languageServiceRefCount: 0 + }; + bucket.set(path, entry); + } + } if (!entry) { var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, false, scriptKind); + if (externalCache) { + externalCache.setDocument(key, path, sourceFile); + } entry = { sourceFile: sourceFile, languageServiceRefCount: 1, - owners: [] }; bucket.set(path, entry); } else { if (entry.sourceFile.version !== version) { entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); + if (externalCache) { + externalCache.setDocument(key, path, entry.sourceFile); + } } if (acquiring) { entry.languageServiceRefCount++; } } + ts.Debug.assert(entry.languageServiceRefCount !== 0); return entry.sourceFile; } function releaseDocument(fileName, compilationSettings) { @@ -74700,6 +75142,13 @@ var ts; bucket.delete(path); } } + function getLanguageServiceRefCounts(path) { + return ts.arrayFrom(buckets.entries(), function (_a) { + var key = _a[0], bucket = _a[1]; + var entry = bucket.get(path); + return [key, entry && entry.languageServiceRefCount]; + }); + } return { acquireDocument: acquireDocument, acquireDocumentWithKey: acquireDocumentWithKey, @@ -74707,11 +75156,12 @@ var ts; updateDocumentWithKey: updateDocumentWithKey, releaseDocument: releaseDocument, releaseDocumentWithKey: releaseDocumentWithKey, + getLanguageServiceRefCounts: getLanguageServiceRefCounts, reportStats: reportStats, getKeyForCompilationSettings: getKeyForCompilationSettings }; } - ts.createDocumentRegistry = createDocumentRegistry; + ts.createDocumentRegistryInternal = createDocumentRegistryInternal; })(ts || (ts = {})); var ts; (function (ts) { @@ -74767,10 +75217,10 @@ var ts; } cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 186: + case 187: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 && parent.kind === 231) { + if (exportKind === 2 && parent.kind === 232) { var name = parent.name; if (name.kind === 71) { directImports.push(name); @@ -74782,12 +75232,12 @@ var ts; break; case 71: break; - case 242: + case 243: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1)); break; - case 243: + case 244: var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 245) { + if (namedBindings && namedBindings.kind === 246) { handleNamespaceImport(direct, namedBindings.name); } else if (ts.isDefaultImport(direct)) { @@ -74801,7 +75251,7 @@ var ts; directImports.push(direct); } break; - case 249: + case 250: if (!direct.exportClause) { handleDirectImports(getContainingModuleSymbol(direct, checker)); } @@ -74809,7 +75259,7 @@ var ts; directImports.push(direct); } break; - case 178: + case 179: directImports.push(direct); break; default: @@ -74824,7 +75274,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 273 || sourceFileLike.kind === 238); + ts.Debug.assert(sourceFileLike.kind === 274 || sourceFileLike.kind === 239); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -74873,7 +75323,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 242) { + if (decl.kind === 243) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -74883,7 +75333,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 178) { + if (decl.kind === 179) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -74897,7 +75347,7 @@ var ts; if (decl.moduleSpecifier.kind !== 9) { return; } - if (decl.kind === 249) { + if (decl.kind === 250) { searchForNamedImport(decl.exportClause); return; } @@ -74906,7 +75356,7 @@ var ts; return; } var namedBindings = importClause.namedBindings; - if (namedBindings && namedBindings.kind === 245) { + if (namedBindings && namedBindings.kind === 246) { handleNamespaceImportLike(namedBindings.name); return; } @@ -74946,7 +75396,7 @@ var ts; } } else { - var localSymbol = element.kind === 251 && element.propertyName + var localSymbol = element.kind === 252 && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -74959,7 +75409,7 @@ var ts; } function findNamespaceReExports(sourceFileLike, name, checker) { var namespaceImportSymbol = checker.getSymbolAtLocation(name); - return forEachPossibleImportOrExportStatement(sourceFileLike, function (statement) { + return !!forEachPossibleImportOrExportStatement(sourceFileLike, function (statement) { if (!ts.isExportDeclaration(statement)) return; var exportClause = statement.exportClause, moduleSpecifier = statement.moduleSpecifier; @@ -74973,7 +75423,7 @@ var ts; for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { var referencingFile = sourceFiles_5[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 273) { + if (searchSourceFile.kind === 274) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -75018,7 +75468,7 @@ var ts; return map; } function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 273 ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 274 ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -75032,15 +75482,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 249: - case 243: { + case 250: + case 244: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 242: { + case 243: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -75055,10 +75505,11 @@ var ts; return comingFromExport ? getExport() : getExport() || getImport(); function getExport() { var parent = node.parent; + var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 184) { - return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(parent.parent) - ? getSpecialPropertyExport(parent.parent, false) + if (parent.kind === 185) { + return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) + ? getSpecialPropertyExport(grandParent, false) : undefined; } else { @@ -75082,14 +75533,14 @@ var ts; else if (ts.isExportAssignment(parent)) { return getExportAssignmentExport(parent); } - else if (ts.isExportAssignment(parent.parent)) { - return getExportAssignmentExport(parent.parent); + else if (ts.isExportAssignment(grandParent)) { + return getExportAssignmentExport(grandParent); } else if (ts.isBinaryExpression(parent)) { return getSpecialPropertyExport(parent, true); } - else if (ts.isBinaryExpression(parent.parent)) { - return getSpecialPropertyExport(parent.parent, true); + else if (ts.isBinaryExpression(grandParent)) { + return getSpecialPropertyExport(grandParent, true); } else if (ts.isJSDocTypedefTag(parent)) { return exportInfo(symbol, 0); @@ -75155,13 +75606,16 @@ var ts; else if (ts.isBinaryExpression(decl)) { return ts.Debug.assertDefined(decl.right.symbol); } + else if (ts.isSourceFile(decl)) { + return ts.Debug.assertDefined(decl.symbol); + } return ts.Debug.fail(); } function getExportNode(parent, node) { - if (parent.kind === 231) { + if (parent.kind === 232) { var p = parent; return p.name !== node ? undefined : - p.parent.kind === 268 ? undefined : p.parent.parent.kind === 213 ? p.parent.parent : undefined; + p.parent.kind === 269 ? undefined : p.parent.parent.kind === 214 ? p.parent.parent : undefined; } else { return parent; @@ -75170,14 +75624,14 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 242: + case 243: return parent.name === node && isExternalModuleImportEquals(parent) ? { isNamedImport: false } : undefined; - case 247: + case 248: return parent.propertyName ? undefined : { isNamedImport: true }; - case 244: case 245: + case 246: ts.Debug.assert(parent.name === node); return { isNamedImport: false }; default: @@ -75207,21 +75661,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 186) { + if (node.kind === 187) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 273) { + if (parent.kind === 274) { return parent; } - ts.Debug.assert(parent.kind === 239); + ts.Debug.assert(parent.kind === 240); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 238 && node.name.kind === 9; + return node.kind === 239 && node.name.kind === 9; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 253 && eq.moduleReference.expression.kind === 9; + return eq.moduleReference.kind === 254 && eq.moduleReference.expression.kind === 9; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -75230,7 +75684,7 @@ var ts; var FindAllReferences; (function (FindAllReferences) { function nodeEntry(node, isInString) { - return { type: "node", node: node, isInString: isInString }; + return { type: "node", node: node.name || node, isInString: isInString }; } FindAllReferences.nodeEntry = nodeEntry; function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position) { @@ -75254,11 +75708,11 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 273) { + if (node.kind === 274) { return undefined; } var checker = program.getTypeChecker(); - if (node.parent.kind === 270) { + if (node.parent.kind === 271) { var result_5 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_5.push(nodeEntry(node)); }); return result_5; @@ -75359,13 +75813,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 183) { + else if (node.kind === 184) { return { kind: "interface", displayParts: [ts.punctuationPart(19), ts.textPart("object literal"), ts.punctuationPart(20)] }; } - else if (node.kind === 204) { + else if (node.kind === 205) { return { kind: "local class", displayParts: [ts.punctuationPart(19), ts.textPart("anonymous local class"), ts.punctuationPart(20)] @@ -75430,19 +75884,20 @@ var ts; } var moduleReferences = ts.emptyArray; var moduleSourceFile = isModuleSymbol(symbol); + var referencedNode = node; if (moduleSourceFile) { var exportEquals = symbol.exports.get("export="); moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet); if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName)) return moduleReferences; symbol = ts.skipAlias(exportEquals, checker); - node = undefined; + referencedNode = undefined; } - return ts.concatenate(moduleReferences, getReferencedSymbolsForSymbol(symbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options)); + return ts.concatenate(moduleReferences, getReferencedSymbolsForSymbol(symbol, referencedNode, sourceFiles, sourceFilesSet, checker, cancellationToken, options)); } Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; function isModuleSymbol(symbol) { - return symbol.flags & 1536 && ts.find(symbol.declarations, ts.isSourceFile); + return symbol.flags & 1536 ? ts.find(symbol.declarations, ts.isSourceFile) : undefined; } function getReferencedSymbolsForModule(program, symbol, excludeImportTypeOfExportEquals, sourceFiles, sourceFilesSet) { ts.Debug.assert(!!symbol.valueDeclaration); @@ -75468,9 +75923,9 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 273: + case 274: break; - case 238: + case 239: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push({ type: "node", node: decl.name }); } @@ -75510,7 +75965,7 @@ var ts; searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 }, state); } else { - var search = state.createSearch(node, symbol, undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.implementations) : [symbol] }); + var search = state.createSearch(node, symbol, undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, !!options.implementations) : [symbol] }); var scope = getSymbolScope(symbol); if (scope) { getReferencesInContainer(scope, scope.getSourceFile(), search, state, !(ts.isSourceFile(scope) && !ts.contains(sourceFiles, scope))); @@ -75583,13 +76038,13 @@ var ts; State.prototype.getImportSearches = function (exportSymbol, exportInfo) { if (!this.importTracker) this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); - return this.importTracker(exportSymbol, exportInfo, this.options.isForRename); + return this.importTracker(exportSymbol, exportInfo, !!this.options.isForRename); }; State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { if (searchOptions === void 0) { searchOptions = {}; } var _a = searchOptions.text, text = _a === void 0 ? ts.stripQuotes(ts.unescapeLeadingUnderscores((ts.getLocalSymbolForExportDefault(symbol) || symbol).escapedName)) : _a, _b = searchOptions.allSearchSymbols, allSearchSymbols = _b === void 0 ? [symbol] : _b; var escapedText = ts.escapeLeadingUnderscores(text); - var parents = this.options.implementations && location && getParentSymbolsOfPropertyAccess(location, symbol, this.checker); + var parents = this.options.implementations && location ? getParentSymbolsOfPropertyAccess(location, symbol, this.checker) : undefined; return { symbol: symbol, comingFrom: comingFrom, text: text, escapedText: escapedText, parents: parents, allSearchSymbols: allSearchSymbols, includes: function (sym) { return ts.contains(allSearchSymbols, sym); } }; }; State.prototype.referenceAdder = function (searchSymbol) { @@ -75675,13 +76130,14 @@ var ts; } } function getPropertySymbolOfDestructuringAssignment(location, checker) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - checker.getPropertySymbolOfDestructuringAssignment(location); + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) + ? checker.getPropertySymbolOfDestructuringAssignment(location) + : undefined; } function getObjectBindingElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 181); + var bindingElement = ts.getDeclarationOfKind(symbol, 182); if (bindingElement && - bindingElement.parent.kind === 179 && + bindingElement.parent.kind === 180 && ts.isIdentifier(bindingElement.name) && !bindingElement.propertyName) { return bindingElement; @@ -75693,7 +76149,7 @@ var ts; } function getSymbolScope(symbol) { var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 191 || valueDeclaration.kind === 204)) { + if (valueDeclaration && (valueDeclaration.kind === 192 || valueDeclaration.kind === 205)) { return valueDeclaration; } if (!declarations) { @@ -75702,7 +76158,7 @@ var ts; if (flags & (4 | 8192)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 234); + return ts.getAncestor(privateDeclaration, 235); } return undefined; } @@ -75714,13 +76170,13 @@ var ts; return undefined; } var scope; - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; var container = ts.getContainerNode(declaration); if (scope && scope !== container) { return undefined; } - if (!container || container.kind === 273 && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 274 && !ts.isExternalOrCommonJsModule(container)) { return undefined; } scope = container; @@ -75728,19 +76184,28 @@ var ts; return exposedByParent ? scope.getSourceFile() : scope; } function isSymbolReferencedInFile(definition, checker, sourceFile) { - var symbol = checker.getSymbolAtLocation(definition); - if (!symbol) - return true; - return getPossibleSymbolReferenceNodes(sourceFile, symbol.name).some(function (token) { - if (!ts.isIdentifier(token) || token === definition || token.escapedText !== definition.escapedText) - return false; - var referenceSymbol = checker.getSymbolAtLocation(token); - return referenceSymbol === symbol - || checker.getShorthandAssignmentValueSymbol(token.parent) === symbol - || ts.isExportSpecifier(token.parent) && getLocalSymbolForExportSpecifier(token, referenceSymbol, token.parent, checker) === symbol; - }); + return eachSymbolReferenceInFile(definition, checker, sourceFile, function () { return true; }) || false; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; + function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { + var symbol = checker.getSymbolAtLocation(definition); + if (!symbol) + return undefined; + for (var _i = 0, _a = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _i < _a.length; _i++) { + var token = _a[_i]; + if (!ts.isIdentifier(token) || token === definition || token.escapedText !== definition.escapedText) + continue; + var referenceSymbol = checker.getSymbolAtLocation(token); + if (referenceSymbol === symbol + || checker.getShorthandAssignmentValueSymbol(token.parent) === symbol + || ts.isExportSpecifier(token.parent) && getLocalSymbolForExportSpecifier(token, referenceSymbol, token.parent, checker) === symbol) { + var res = cb(token); + if (res) + return res; + } + } + } + Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile; function getPossibleSymbolReferenceNodes(sourceFile, symbolName, container) { if (container === void 0) { container = sourceFile; } return getPossibleSymbolReferencePositions(sourceFile, symbolName, container).map(function (pos) { return ts.getTouchingPropertyName(sourceFile, pos, true); }); @@ -75890,7 +76355,8 @@ var ts; if (!(referenceLocation === propertyName && state.options.isForRename)) { var exportKind = referenceLocation.originalKeywordKind === 79 ? 1 : 0; var exportInfo = FindAllReferences.getExportInfo(referenceSymbol, exportKind, state.checker); - ts.Debug.assert(!!exportInfo); + if (!exportInfo) + return ts.Debug.fail(); searchForImportsOfExport(referenceLocation, referenceSymbol, exportInfo, state); } if (search.comingFrom !== 1 && exportDeclaration.moduleSpecifier && !propertyName) { @@ -75988,12 +76454,12 @@ var ts; for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { var decl = _a[_i]; var ctrKeyword = ts.findChildOfKind(decl, 123, sourceFile); - ts.Debug.assert(decl.kind === 154 && !!ctrKeyword); + ts.Debug.assert(decl.kind === 155 && !!ctrKeyword); addNode(ctrKeyword); } classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 153) { + if (decl && decl.kind === 154) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 99, function (thisKeyword) { @@ -76006,14 +76472,13 @@ var ts; }); } function findSuperConstructorAccesses(cls, addNode) { - var symbol = cls.symbol; - var ctr = symbol.members.get("__constructor"); + var ctr = cls.symbol.members.get("__constructor"); if (!ctr) { return; } for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 154); + ts.Debug.assert(decl.kind === 155); var body = decl.body; if (body) { forEachDescendantOfKind(body, 97, function (node) { @@ -76026,13 +76491,13 @@ var ts; } function addImplementationReferences(refNode, addReference, state) { if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - addReference(refNode.parent); + addReference(refNode); return; } if (refNode.kind !== 71) { return; } - if (refNode.parent.kind === 270) { + if (refNode.parent.kind === 271) { getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } var containingClass = getContainingClassIfInHeritageClause(refNode); @@ -76048,7 +76513,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 212) { + if (body.kind === 213) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -76073,13 +76538,13 @@ var ts; } function isImplementationExpression(node) { switch (node.kind) { - case 190: - return isImplementationExpression(node.expression); - case 192: case 191: + return isImplementationExpression(node.expression); + case 193: + case 192: + case 184: + case 205: case 183: - case 204: - case 182: return true; default: return false; @@ -76111,13 +76576,13 @@ var ts; } var staticFlag = 32; switch (searchSpaceNode.kind) { - case 151: - case 150: - case 153: case 152: + case 151: case 154: + case 153: case 155: case 156: + case 157: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; @@ -76138,30 +76603,30 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 32; switch (searchSpaceNode.kind) { + case 154: case 153: - case 152: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } + case 152: case 151: - case 150: - case 154: case 155: case 156: + case 157: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; break; - case 273: + case 274: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 233: - case 191: + case 234: + case 192: break; default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 273 ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 274 ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -76169,17 +76634,17 @@ var ts; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 191: - case 233: - return searchSpaceNode.symbol === container.symbol; - case 153: - case 152: - return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 204: + case 192: case 234: + return searchSpaceNode.symbol === container.symbol; + case 154: + case 153: + return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; + case 205: + case 235: return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag; - case 273: - return container.kind === 273 && !ts.isExternalModule(container); + case 274: + return container.kind === 274 && !ts.isExternalModule(container); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -76234,24 +76699,11 @@ var ts; return ts.firstDefined(checker.getRootSymbols(sym), function (rootSymbol) { return cbSymbol(sym, rootSymbol) || (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64) && allowBaseTypes(rootSymbol) - ? getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base); }) + ? ts.getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base); }) : undefined); }); } } - function getPropertySymbolsFromBaseTypes(symbol, propertyName, checker, cb) { - var seen = ts.createMap(); - return recur(symbol); - function recur(symbol) { - if (!(symbol.flags & (32 | 64)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) - return; - return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { - var type = checker.getTypeAtLocation(typeReference); - var propertySymbol = type && type.symbol && checker.getPropertyOfType(type, propertyName); - return propertySymbol && (ts.firstDefined(checker.getRootSymbols(propertySymbol), cb) || recur(type.symbol)); - }); }); - } - } function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { var checker = state.checker; return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, function (sym, rootSymbol, baseSymbol) { return search.includes(baseSymbol || rootSymbol || sym) @@ -76274,8 +76726,8 @@ var ts; var lastIterationMeaning = void 0; do { lastIterationMeaning = meaning; - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var declaration = declarations_10[_i]; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; var declarationMeaning = ts.getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -76328,6 +76780,179 @@ var ts; })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); var ts; +(function (ts) { + function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, preferences) { + var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); + var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + var oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName); + var newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName); + return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { + updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); + updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences); + }); + } + ts.getEditsForFileRename = getEditsForFileRename; + function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName) { + var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); + return function (path) { + var canonicalPath = getCanonicalFileName(path); + if (canonicalPath === canonicalOldPath) + return newFileOrDirPath; + var suffix = ts.tryRemoveDirectoryPrefix(canonicalPath, canonicalOldPath); + return suffix === undefined ? undefined : newFileOrDirPath + "/" + suffix; + }; + } + function updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { + var configFile = program.getCompilerOptions().configFile; + if (!configFile) + return; + var configDir = ts.getDirectoryPath(configFile.fileName); + var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(configFile); + if (!jsonObjectLiteral) + return; + forEachProperty(jsonObjectLiteral, function (property, propertyName) { + switch (propertyName) { + case "files": + case "include": + case "exclude": { + var foundExactMatch = updatePaths(property); + if (!foundExactMatch && propertyName === "include" && ts.isArrayLiteralExpression(property.initializer)) { + var includes = ts.mapDefined(property.initializer.elements, function (e) { return ts.isStringLiteral(e) ? e.text : undefined; }); + var matchers = ts.getFileMatcherPatterns(configDir, [], includes, useCaseSensitiveFileNames, currentDirectory); + if (!ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { + changeTracker.insertNodeAfter(configFile, ts.last(property.initializer.elements), ts.createStringLiteral(relativePath(newFileOrDirPath))); + } + } + break; + } + case "compilerOptions": + forEachProperty(property.initializer, function (property, propertyName) { + var option = ts.getOptionFromName(propertyName); + if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) { + updatePaths(property); + } + else if (propertyName === "paths") { + forEachProperty(property.initializer, function (pathsProperty) { + if (!ts.isArrayLiteralExpression(pathsProperty.initializer)) + return; + for (var _i = 0, _a = pathsProperty.initializer.elements; _i < _a.length; _i++) { + var e = _a[_i]; + tryUpdateString(e); + } + }); + } + }); + break; + } + }); + function updatePaths(property) { + var elements = ts.isArrayLiteralExpression(property.initializer) ? property.initializer.elements : [property.initializer]; + var foundExactMatch = false; + for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) { + var element = elements_5[_i]; + foundExactMatch = tryUpdateString(element) || foundExactMatch; + } + return foundExactMatch; + } + function tryUpdateString(element) { + if (!ts.isStringLiteral(element)) + return false; + var elementFileName = combinePathsSafe(configDir, element.text); + var updated = oldToNew(elementFileName); + if (updated !== undefined) { + changeTracker.replaceRangeWithText(configFile, createStringRange(element, configFile), relativePath(updated)); + return true; + } + return false; + } + function relativePath(path) { + return ts.getRelativePathFromDirectory(configDir, path, !useCaseSensitiveFileNames); + } + } + function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences) { + var _loop_14 = function (sourceFile) { + var newImportFromPath = oldToNew(sourceFile.fileName) || sourceFile.fileName; + var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); + var oldFromNew = newToOld(sourceFile.fileName); + var oldImportFromPath = oldFromNew || sourceFile.fileName; + var oldImportFromDirectory = ts.getDirectoryPath(oldImportFromPath); + updateImportsWorker(sourceFile, changeTracker, function (referenceText) { + if (!ts.pathIsRelative(referenceText)) + return undefined; + var oldAbsolute = combinePathsSafe(oldImportFromDirectory, referenceText); + var newAbsolute = oldToNew(oldAbsolute); + return newAbsolute === undefined ? undefined : ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(newImportFromDirectory, newAbsolute, getCanonicalFileName)); + }, function (importLiteral) { + var toImport = oldFromNew !== undefined + ? getSourceFileToImportFromResolved(ts.resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host), oldToNew, program) + : getSourceFileToImport(importLiteral, sourceFile, program, host, oldToNew); + return toImport === undefined ? undefined : ts.moduleSpecifiers.getModuleSpecifier(program, sourceFile, newImportFromPath, toImport, host, preferences); + }); + }; + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + _loop_14(sourceFile); + } + } + function combineNormal(pathA, pathB) { + return ts.normalizePath(ts.combinePaths(pathA, pathB)); + } + function combinePathsSafe(pathA, pathB) { + return ts.ensurePathIsNonModuleName(combineNormal(pathA, pathB)); + } + function getSourceFileToImport(importLiteral, importingSourceFile, program, host, oldToNew) { + var symbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); + if (symbol) { + if (symbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + return undefined; + var oldFileName = ts.find(symbol.declarations, ts.isSourceFile).fileName; + return oldToNew(oldFileName) || oldFileName; + } + else { + var resolved = host.resolveModuleNames + ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName) + : program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName); + return getSourceFileToImportFromResolved(resolved, oldToNew, program); + } + } + function getSourceFileToImportFromResolved(resolved, oldToNew, program) { + return resolved && ((resolved.resolvedModule && getIfInProgram(resolved.resolvedModule.resolvedFileName)) || ts.firstDefined(resolved.failedLookupLocations, getIfInProgram)); + function getIfInProgram(oldLocation) { + var newLocation = oldToNew(oldLocation); + return program.getSourceFile(oldLocation) || newLocation !== undefined && program.getSourceFile(newLocation) + ? newLocation || oldLocation + : undefined; + } + } + function updateImportsWorker(sourceFile, changeTracker, updateRef, updateImport) { + for (var _i = 0, _a = sourceFile.referencedFiles; _i < _a.length; _i++) { + var ref = _a[_i]; + var updated = updateRef(ref.fileName); + if (updated !== undefined && updated !== sourceFile.text.slice(ref.pos, ref.end)) + changeTracker.replaceRangeWithText(sourceFile, ref, updated); + } + for (var _b = 0, _c = sourceFile.imports; _b < _c.length; _b++) { + var importStringLiteral = _c[_b]; + var updated = updateImport(importStringLiteral); + if (updated !== undefined && updated !== importStringLiteral.text) + changeTracker.replaceRangeWithText(sourceFile, createStringRange(importStringLiteral, sourceFile), updated); + } + } + function createStringRange(node, sourceFile) { + return ts.createTextRange(node.getStart(sourceFile) + 1, node.end - 1); + } + function forEachProperty(objectLiteral, cb) { + if (!ts.isObjectLiteralExpression(objectLiteral)) + return; + for (var _i = 0, _a = objectLiteral.properties; _i < _a.length; _i++) { + var property = _a[_i]; + if (ts.isPropertyAssignment(property) && ts.isStringLiteral(property.name)) { + cb(property, property.name.text); + } + } + } +})(ts || (ts = {})); +var ts; (function (ts) { var GoToDefinition; (function (GoToDefinition) { @@ -76340,6 +76965,7 @@ var ts; if (node === sourceFile) { return undefined; } + var parent = node.parent; if (ts.isJumpStatementTarget(node)) { var label = ts.getTargetLabel(node.parent, node.text); return label ? [createDefinitionInfoFromName(label, "label", node.text, undefined)] : undefined; @@ -76353,17 +76979,17 @@ var ts; if (calledDeclaration) { var sigInfo = createDefinitionFromSignatureDeclaration(typeChecker, calledDeclaration); return typeChecker.getRootSymbols(symbol).some(function (s) { return calledDeclaration.symbol === s || calledDeclaration.symbol.parent === s; }) || - symbol.declarations.some(function (d) { return ts.isVariableDeclaration(d) && d.initializer && ts.isRequireCall(d.initializer, false); }) + symbol.declarations.some(function (d) { return ts.isVariableDeclaration(d) && !!d.initializer && ts.isRequireCall(d.initializer, false); }) ? [sigInfo] : [sigInfo].concat(getDefinitionFromSymbol(typeChecker, symbol, node)); } - if (node.parent.kind === 270) { + if (node.parent.kind === 271) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } - if (ts.isPropertyName(node) && ts.isBindingElement(node.parent) && ts.isObjectBindingPattern(node.parent.parent) && - (node === (node.parent.propertyName || node.parent.name))) { - var type = typeChecker.getTypeAtLocation(node.parent.parent); + if (ts.isPropertyName(node) && ts.isBindingElement(parent) && ts.isObjectBindingPattern(parent.parent) && + (node === (parent.propertyName || parent.name))) { + var type = typeChecker.getTypeAtLocation(parent.parent); if (type) { var propSymbols = ts.getPropertySymbolsFromType(type, node); if (propSymbols) { @@ -76405,7 +77031,7 @@ var ts; if (!type) { return undefined; } - if (type.isUnion() && !(type.flags & 16)) { + if (type.isUnion() && !(type.flags & 32)) { return ts.flatMap(type.types, function (t) { return t.symbol && getDefinitionFromSymbol(typeChecker, t.symbol, node); }); } return type.symbol && getDefinitionFromSymbol(typeChecker, type.symbol, node); @@ -76452,11 +77078,11 @@ var ts; return true; } switch (declaration.kind) { - case 244: - case 242: + case 245: + case 243: return true; - case 247: - return declaration.parent.kind === 246; + case 248: + return declaration.parent.kind === 247; default: return false; } @@ -76516,13 +77142,13 @@ var ts; kind: "script", name: name, containerName: undefined, - containerKind: undefined + containerKind: undefined, }; } function getAncestorCallLikeExpression(node) { var target = climbPastManyPropertyAccesses(node); var callLike = target.parent; - return callLike && ts.isCallLikeExpression(callLike) && ts.getInvokedExpression(callLike) === target && callLike; + return callLike && ts.isCallLikeExpression(callLike) && ts.getInvokedExpression(callLike) === target ? callLike : undefined; } function climbPastManyPropertyAccesses(node) { return ts.isRightSideOfPropertyAccess(node) ? climbPastManyPropertyAccesses(node.parent) : node; @@ -76602,11 +77228,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { + case 293: + case 298: + return [declaration]; case 292: case 297: - return [declaration]; - case 291: - case 296: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -76626,16 +77252,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 289: + case 290: return withNode(tag.class); - case 295: - return withList(tag.typeParameters); - case 294: - return withNode(tag.typeExpression); case 296: - case 291: + return withList(tag.typeParameters); + case 295: + return withNode(tag.typeExpression); case 297: case 292: + case 298: + case 293: var name = tag.name; return name ? withNode(name) : comment; default: @@ -76737,7 +77363,7 @@ var ts; return undefined; } var tokenAtPos = ts.getTokenAtPosition(sourceFile, position, false); - var tokenStart = tokenAtPos.getStart(); + var tokenStart = tokenAtPos.getStart(sourceFile); if (!tokenAtPos || tokenStart < position) { return undefined; } @@ -76746,7 +77372,7 @@ var ts; return undefined; } var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters; - if (commentOwner.getStart() < position) { + if (commentOwner.getStart(sourceFile) < position) { return undefined; } if (!parameters || parameters.length === 0) { @@ -76756,44 +77382,40 @@ var ts; var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); - var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); - var docParams = ""; - for (var i = 0; i < parameters.length; i++) { - var currentName = parameters[i].name; - var paramName = currentName.kind === 71 ? currentName.escapedText : "param" + i; - if (isJavaScriptFile) { - docParams += indentationStr + " * @param {any} " + paramName + newLine; - } - else { - docParams += indentationStr + " * @param " + paramName + newLine; - } - } var preamble = "/**" + newLine + indentationStr + " * "; var result = preamble + newLine + - docParams + + parameterDocComments(parameters, ts.hasJavaScriptFileExtension(sourceFile.fileName), indentationStr, newLine) + indentationStr + " */" + (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; + function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { + return parameters.map(function (_a, i) { + var name = _a.name, dotDotDotToken = _a.dotDotDotToken; + var paramName = name.kind === 71 ? name.text : "param" + i; + var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; + return indentationStr + " * @param " + type + paramName + newLine; + }).join(""); + } function getCommentOwnerInfo(tokenAtPos) { for (var commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 233: - case 153: + case 234: case 154: - case 152: + case 155: + case 153: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 234: case 235: - case 150: - case 237: - case 272: case 236: + case 151: + case 238: + case 273: + case 237: return { commentOwner: commentOwner }; - case 213: { + case 214: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -76801,11 +77423,11 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 273: + case 274: return undefined; - case 238: - return commentOwner.parent.kind === 238 ? undefined : { commentOwner: commentOwner }; - case 199: { + case 239: + return commentOwner.parent.kind === 239 ? undefined : { commentOwner: commentOwner }; + case 200: { var be = commentOwner; if (ts.getSpecialPropertyAssignmentKind(be) === 0) { return undefined; @@ -76817,16 +77439,16 @@ var ts; } } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 190) { + while (rightHandSide.kind === 191) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 191: case 192: + case 193: return rightHandSide.parameters; - case 204: { + case 205: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); - return ctr && ctr.parameters; + return ctr ? ctr.parameters : ts.emptyArray; } } return ts.emptyArray; @@ -76983,7 +77605,8 @@ var ts; addInferredTypings(module_1, "Inferred typings from unresolved imports"); } packageNameToTypingLocation.forEach(function (typing, name) { - if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && isTypingUpToDate(typing, typesRegistry.get(name))) { + var registryEntry = typesRegistry.get(name); + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && registryEntry !== undefined && isTypingUpToDate(typing, registryEntry)) { inferredTypings.set(name, typing.typingLocation); } }); @@ -77134,7 +77757,7 @@ var ts; case 0: return ts.Debug.fail(); default: - ts.Debug.assertNever(result); + throw ts.Debug.assertNever(result); } } JsTyping.renderPackageNameValidationFailure = renderPackageNameValidationFailure; @@ -77149,7 +77772,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_14 = function (sourceFile) { + var _loop_15 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { return "continue"; @@ -77160,7 +77783,7 @@ var ts; }; for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { var sourceFile = sourceFiles_7[_i]; - _loop_14(sourceFile); + _loop_15(sourceFile); } rawItems.sort(compareNavigateToItems); if (maxResultCount !== undefined) { @@ -77174,8 +77797,8 @@ var ts; if (!match) { return; } - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_i]; if (!shouldKeepItem(declaration, checker)) continue; if (patternMatcher.patternContainsDots) { @@ -77191,9 +77814,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 244: - case 247: - case 242: + case 245: + case 248: + case 243: var importer = checker.getSymbolAtLocation(declaration.name); var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -77207,7 +77830,7 @@ var ts; containers.unshift(ts.getTextOfIdentifierOrLiteral(name)); return true; } - else if (name && name.kind === 146) { + else if (name && name.kind === 147) { return tryAddComputedPropertyName(name.expression, containers, true); } else { @@ -77233,15 +77856,15 @@ var ts; function getContainers(declaration) { var containers = []; var name = ts.getNameOfDeclaration(declaration); - if (name.kind === 146 && !tryAddComputedPropertyName(name.expression, containers, false)) { + if (name.kind === 147 && !tryAddComputedPropertyName(name.expression, containers, false)) { return undefined; } - declaration = ts.getContainerNode(declaration); - while (declaration) { - if (!tryAddSingleDeclarationName(declaration, containers)) { + var container = ts.getContainerNode(declaration); + while (container) { + if (!tryAddSingleDeclarationName(container, containers)) { return undefined; } - declaration = ts.getContainerNode(declaration); + container = ts.getContainerNode(container); } return containers; } @@ -77368,7 +77991,7 @@ var ts; return; } switch (node.kind) { - case 154: + case 155: var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { @@ -77378,28 +78001,28 @@ var ts; } } break; - case 153: - case 155: + case 154: case 156: - case 152: + case 157: + case 153: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; + case 152: case 151: - case 150: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 244: + case 245: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 245) { + if (namedBindings.kind === 246) { addLeafNode(namedBindings); } else { @@ -77410,8 +78033,8 @@ var ts; } } break; - case 181: - case 231: + case 182: + case 232: var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -77430,12 +78053,12 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; + case 193: + case 234: case 192: - case 233: - case 191: addNodeWithRecursiveChild(node, node.body); break; - case 237: + case 238: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -77445,9 +78068,9 @@ var ts; } endNode(); break; - case 234: - case 204: case 235: + case 205: + case 236: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -77455,18 +78078,18 @@ var ts; } endNode(); break; - case 238: + case 239: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 251: - case 242: - case 159: - case 157: + case 252: + case 243: + case 160: case 158: - case 236: + case 159: + case 237: addLeafNode(node); break; - case 199: { + case 200: { var special = ts.getSpecialPropertyAssignmentKind(node); switch (special) { case 1: @@ -77541,19 +78164,19 @@ var ts; return false; } switch (a.kind) { - case 151: - case 153: - case 155: + case 152: + case 154: case 156: + case 157: return ts.hasModifier(a, 32) === ts.hasModifier(b, 32); - case 238: + case 239: return areSameModule(a, b); default: return true; } } function areSameModule(a, b) { - return a.body.kind === b.body.kind && (a.body.kind !== 238 || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 239 || areSameModule(a.body, b.body)); } function merge(target, source) { var _a; @@ -77576,7 +78199,7 @@ var ts; || ts.compareValues(navigationBarNodeKind(child1), navigationBarNodeKind(child2)); } function tryGetName(node) { - if (node.kind === 238) { + if (node.kind === 239) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -77584,16 +78207,16 @@ var ts; return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); } switch (node.kind) { - case 191: case 192: - case 204: + case 193: + case 205: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 238) { + if (node.kind === 239) { return getModuleName(node); } var name = ts.getNameOfDeclaration(node); @@ -77604,27 +78227,27 @@ var ts; } } switch (node.kind) { - case 273: + case 274: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 192: - case 233: - case 191: + case 193: case 234: - case 204: + case 192: + case 235: + case 205: if (ts.getModifierFlags(node) & 512) { return "default"; } return getFunctionOrClassName(node); - case 154: + case 155: return "constructor"; - case 158: - return "new()"; - case 157: - return "()"; case 159: + return "new()"; + case 158: + return "()"; + case 160: return "[]"; default: return ""; @@ -77647,25 +78270,25 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 234: - case 204: - case 237: case 235: + case 205: case 238: - case 273: case 236: - case 296: - case 291: + case 239: + case 274: + case 237: + case 297: + case 292: return true; - case 154: - case 153: case 155: + case 154: case 156: - case 231: + case 157: + case 232: return hasSomeImportantChild(item); + case 193: + case 234: case 192: - case 233: - case 191: return isTopLevelFunctionDeclaration(item); default: return false; @@ -77675,19 +78298,19 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 239: - case 273: - case 153: + case 240: + case 274: case 154: + case 155: return true; default: return hasSomeImportantChild(item); } } function hasSomeImportantChild(item) { - return ts.forEach(item.children, function (child) { + return ts.some(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 231 && childKind !== 181; + return childKind !== 232 && childKind !== 182; }); } } @@ -77741,23 +78364,23 @@ var ts; } var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 238) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 239) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 238 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 239 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 146; + return !member.name || member.name.kind === 147; } function getNodeSpan(node) { - return node.kind === 273 ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 274 ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 231) { + if (node.parent && node.parent.kind === 232) { node = node.parent; } return ts.getNodeModifiers(node); @@ -77766,14 +78389,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 231) { + else if (node.parent.kind === 232) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 199 && + else if (node.parent.kind === 200 && node.parent.operatorToken.kind === 58) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 269 && node.parent.name) { + else if (node.parent.kind === 270 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -77785,9 +78408,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { + case 193: case 192: - case 191: - case 204: + case 205: return true; default: return false; @@ -77848,12 +78471,12 @@ var ts; OrganizeImports.organizeImports = organizeImports; function getModuleBlock(moduleDecl) { var body = moduleDecl.body; - return body && !ts.isIdentifier(body) && (ts.isModuleBlock(body) ? body : getModuleBlock(body)); + return body && !ts.isIdentifier(body) ? (ts.isModuleBlock(body) ? body : getModuleBlock(body)) : undefined; } function removeUnusedImports(oldImports, sourceFile, program) { var typeChecker = program.getTypeChecker(); var jsxNamespace = typeChecker.getJsxNamespace(); - var jsxContext = sourceFile.languageVariant === 1 && program.getCompilerOptions().jsx; + var jsxElementsPresent = !!(sourceFile.transformFlags & 4); var usedImports = []; for (var _i = 0, oldImports_1 = oldImports; _i < oldImports_1.length; _i++) { var importDecl = oldImports_1[_i]; @@ -77887,7 +78510,7 @@ var ts; } return usedImports; function isDeclarationUsed(identifier) { - return jsxContext && (identifier.text === jsxNamespace) || ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile); + return jsxElementsPresent && (identifier.text === jsxNamespace) || ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile); } } function getExternalModuleName(specifier) { @@ -78037,70 +78660,6 @@ var ts; })(OrganizeImports = ts.OrganizeImports || (ts.OrganizeImports = {})); })(ts || (ts = {})); var ts; -(function (ts) { - function getEditsForFileRename(program, oldFilePath, newFilePath, host, formatContext) { - var pathUpdater = getPathUpdater(oldFilePath, newFilePath, host); - return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { - updateTsconfigFiles(program, changeTracker, oldFilePath, newFilePath); - for (var _i = 0, _a = getImportsToUpdate(program, oldFilePath, host); _i < _a.length; _i++) { - var _b = _a[_i], sourceFile = _b.sourceFile, toUpdate = _b.toUpdate; - var newPath = pathUpdater(isRef(toUpdate) ? toUpdate.fileName : toUpdate.text); - if (newPath !== undefined) { - var range = isRef(toUpdate) ? toUpdate : createStringRange(toUpdate, sourceFile); - changeTracker.replaceRangeWithText(sourceFile, range, isRef(toUpdate) ? newPath : ts.removeFileExtension(newPath)); - } - } - }); - } - ts.getEditsForFileRename = getEditsForFileRename; - function updateTsconfigFiles(program, changeTracker, oldFilePath, newFilePath) { - var configFile = program.getCompilerOptions().configFile; - var oldFile = ts.getTsConfigPropArrayElementValue(configFile, "files", oldFilePath); - if (oldFile) { - changeTracker.replaceRangeWithText(configFile, createStringRange(oldFile, configFile), newFilePath); - } - } - function isRef(toUpdate) { - return "fileName" in toUpdate; - } - function getImportsToUpdate(program, oldFilePath, host) { - var checker = program.getTypeChecker(); - var result = []; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { - var ref = _c[_b]; - if (!program.getSourceFileFromReference(sourceFile, ref) && ts.resolveTripleslashReference(ref.fileName, sourceFile.fileName) === oldFilePath) { - result.push({ sourceFile: sourceFile, toUpdate: ref }); - } - } - for (var _d = 0, _e = sourceFile.imports; _d < _e.length; _d++) { - var importStringLiteral = _e[_d]; - if (checker.getSymbolAtLocation(importStringLiteral)) - continue; - var resolved = host.resolveModuleNames - ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importStringLiteral.text, sourceFile.fileName) - : program.getResolvedModuleWithFailedLookupLocationsFromCache(importStringLiteral.text, sourceFile.fileName); - if (resolved && ts.contains(resolved.failedLookupLocations, oldFilePath)) { - result.push({ sourceFile: sourceFile, toUpdate: importStringLiteral }); - } - } - } - return result; - } - function getPathUpdater(oldFilePath, newFilePath, host) { - var rel = ts.getRelativePathFromFile(oldFilePath, newFilePath, ts.createGetCanonicalFileName(ts.hostUsesCaseSensitiveFileNames(host))); - return function (oldPath) { - if (!ts.pathIsRelative(oldPath)) - return; - return ts.ensurePathIsNonModuleName(ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(oldPath), rel))); - }; - } - function createStringRange(node, sourceFile) { - return ts.createTextRange(node.getStart(sourceFile) + 1, node.end - 1); - } -})(ts || (ts = {})); -var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { @@ -78221,21 +78780,21 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 212: + case 213: if (ts.isFunctionBlock(n)) { - return spanForNode(n.parent, n.parent.kind !== 192); + return spanForNode(n.parent, n.parent.kind !== 193); } switch (n.parent.kind) { - case 217: - case 220: - case 221: - case 219: - case 216: case 218: - case 225: - case 268: + case 221: + case 222: + case 220: + case 217: + case 219: + case 226: + case 269: return spanForNode(n.parent); - case 229: + case 230: var tryStatement = n.parent; if (tryStatement.tryBlock === n) { return spanForNode(n.parent); @@ -78246,16 +78805,16 @@ var ts; default: return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code"); } - case 239: - return spanForNode(n.parent); - case 234: - case 235: - case 237: case 240: + return spanForNode(n.parent); + case 235: + case 236: + case 238: + case 241: return spanForNode(n); - case 183: + case 184: return spanForObjectOrArrayLiteral(n); - case 182: + case 183: return spanForObjectOrArrayLiteral(n, 21); } function spanForObjectOrArrayLiteral(node, open) { @@ -78312,7 +78871,7 @@ var ts; } ts.createPatternMatcher = createPatternMatcher; function getFullMatch(candidateContainers, candidate, dotSeparatedSegments, stringToWordSpans) { - var candidateMatch = matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments), stringToWordSpans); + var candidateMatch = matchSegment(candidate, ts.last(dotSeparatedSegments), stringToWordSpans); if (!candidateMatch) { return undefined; } @@ -78460,13 +79019,13 @@ var ts; } function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_15 = function (start) { + var _loop_16 = 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_4 = _loop_15(start); + var state_4 = _loop_16(start); if (typeof state_4 === "object") return state_4.value; } @@ -78697,7 +79256,7 @@ var ts; else { if (token === 71 || ts.isKeyword(token)) { token = nextToken(); - if (token === 142) { + if (token === 143) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -78723,7 +79282,7 @@ var ts; } if (token === 18) { token = nextToken(); - if (token === 142) { + if (token === 143) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -78737,7 +79296,7 @@ var ts; token = nextToken(); if (token === 71 || ts.isKeyword(token)) { token = nextToken(); - if (token === 142) { + if (token === 143) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -78763,7 +79322,7 @@ var ts; } if (token === 18) { token = nextToken(); - if (token === 142) { + if (token === 143) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -78773,7 +79332,7 @@ var ts; } else if (token === 39) { token = nextToken(); - if (token === 142) { + if (token === 143) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -78871,7 +79430,7 @@ var ts; importedFiles.push(decl.ref); } } - return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: pragmaContext.hasNoDefaultLib, ambientExternalModules: undefined }; + return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: !!pragmaContext.hasNoDefaultLib, ambientExternalModules: undefined }; } else { var ambientModuleNames = void 0; @@ -78889,7 +79448,7 @@ var ts; } } } - return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: pragmaContext.hasNoDefaultLib, ambientExternalModules: ambientModuleNames }; + return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: !!pragmaContext.hasNoDefaultLib, ambientExternalModules: ambientModuleNames }; } } ts.preProcessFile = preProcessFile; @@ -78917,32 +79476,26 @@ var ts; Rename.getRenameInfo = getRenameInfo; function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { var symbol = typeChecker.getSymbolAtLocation(node); - if (symbol) { - var declarations = symbol.declarations; - if (declarations && declarations.length > 0) { - if (declarations.some(isDefinedInLibraryFile)) { - return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); - } - if (ts.isIdentifier(node) && node.originalKeywordKind === 79 && symbol.parent.flags & 1536) { - return undefined; - } - if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) - return undefined; - var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteral(node) && node.parent.kind === 146) - ? 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(symbol), node, sourceFile); - } + if (!symbol) + return; + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) + return; + if (declarations.some(isDefinedInLibraryFile)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } - else if (ts.isStringLiteral(node)) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); - } - return getRenameInfoSuccess(node.text, node.text, "var", "", node, sourceFile); + if (ts.isIdentifier(node) && node.originalKeywordKind === 79 && symbol.parent.flags & 1536) { + return undefined; } + if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) + return undefined; + var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteral(node) && node.parent.kind === 147) + ? 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(symbol), node, sourceFile); } function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { return { @@ -78999,7 +79552,12 @@ var ts; ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; ArgumentListKind[ArgumentListKind["JSXAttributesArguments"] = 3] = "JSXAttributesArguments"; - })(ArgumentListKind = SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); + })(ArgumentListKind || (ArgumentListKind = {})); + var InvocationKind; + (function (InvocationKind) { + InvocationKind[InvocationKind["Call"] = 0] = "Call"; + InvocationKind[InvocationKind["TypeArgs"] = 1] = "TypeArgs"; + })(InvocationKind || (InvocationKind = {})); function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); var startingToken = ts.findTokenOnLeftOfPosition(sourceFile, position); @@ -79010,63 +79568,83 @@ var ts; if (!argumentInfo) return undefined; cancellationToken.throwIfCancellationRequested(); - var call = argumentInfo.invocation; - var candidates = []; - var resolvedSignature = typeChecker.getResolvedSignature(call, candidates, argumentInfo.argumentCount); + var candidateInfo = getCandidateInfo(argumentInfo, typeChecker); cancellationToken.throwIfCancellationRequested(); - if (!candidates.length) { + if (!candidateInfo) { if (ts.isSourceFileJavaScript(sourceFile)) { return createJavaScriptSignatureHelpItems(argumentInfo, program, cancellationToken); } return undefined; } - return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo, typeChecker); }); + return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker); }); } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; - function createJavaScriptSignatureHelpItems(argumentInfo, program, cancellationToken) { - if (argumentInfo.invocation.kind !== 186) { - return undefined; + function getCandidateInfo(argumentInfo, checker) { + var invocation = argumentInfo.invocation; + if (invocation.kind === 0) { + var candidates = []; + var resolvedSignature = checker.getResolvedSignature(invocation.node, candidates, argumentInfo.argumentCount); + return candidates.length === 0 ? undefined : { candidates: candidates, resolvedSignature: resolvedSignature }; } - var callExpression = argumentInfo.invocation; - var expression = callExpression.expression; + else { + var type = checker.getTypeAtLocation(invocation.called); + var signatures = ts.isNewExpression(invocation.called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); + var candidates = signatures.filter(function (candidate) { return !!candidate.typeParameters && candidate.typeParameters.length >= argumentInfo.argumentCount; }); + return candidates.length === 0 ? undefined : { candidates: candidates, resolvedSignature: ts.first(candidates) }; + } + } + function createJavaScriptSignatureHelpItems(argumentInfo, program, cancellationToken) { + var expression = getExpressionFromInvocation(argumentInfo.invocation); var name = ts.isIdentifier(expression) ? expression : ts.isPropertyAccessExpression(expression) ? expression.name : undefined; if (!name || !name.escapedText) { return undefined; } var typeChecker = program.getTypeChecker(); - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; + var _loop_17 = function (sourceFile) { var nameToDeclarations = sourceFile.getNamedDeclarations(); var declarations = nameToDeclarations.get(name.text); if (declarations) { - var _loop_16 = function (declaration) { + var _loop_18 = function (declaration) { var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); if (type) { var callSignatures_1 = type.getCallSignatures(); if (callSignatures_1 && callSignatures_1.length) { - return { value: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(callSignatures_1, callSignatures_1[0], argumentInfo, typeChecker); }) }; + return { value: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(callSignatures_1, callSignatures_1[0], argumentInfo, sourceFile, typeChecker); }) }; } } } }; - for (var _b = 0, declarations_12 = declarations; _b < declarations_12.length; _b++) { - var declaration = declarations_12[_b]; - var state_5 = _loop_16(declaration); - if (typeof state_5 === "object") - return state_5.value; + for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { + var declaration = declarations_13[_i]; + var state_6 = _loop_18(declaration); + if (typeof state_6 === "object") + return state_6; } } + }; + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + var state_5 = _loop_17(sourceFile); + if (typeof state_5 === "object") + return state_5.value; } } + function getArgumentInfoForCompletions(node, position, sourceFile) { + var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile); + return !info || info.kind === 0 || info.invocation.kind === 1 ? undefined + : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex }; + } + SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions; function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (ts.isCallOrNewExpression(node.parent)) { - var invocation = node.parent; + var parent = node.parent; + if (ts.isCallOrNewExpression(parent)) { + var invocation = parent; var list = void 0; var argumentIndex = void 0; if (node.kind === 27 || node.kind === 19) { - list = getChildListThatStartsWithOpenerToken(invocation, node, sourceFile); + list = getChildListThatStartsWithOpenerToken(parent, node, sourceFile); ts.Debug.assert(list !== undefined); argumentIndex = 0; } @@ -79076,52 +79654,58 @@ var ts; return undefined; argumentIndex = getArgumentIndex(list, node); } - var kind = invocation.typeArguments && invocation.typeArguments.pos === list.pos ? 0 : 1; + var kind = parent.typeArguments && parent.typeArguments.pos === list.pos ? 0 : 1; var argumentCount = getArgumentCount(list); if (argumentIndex !== 0) { ts.Debug.assertLessThan(argumentIndex, argumentCount); } var argumentsSpan = getApplicableSpanForArguments(list, sourceFile); - return { kind: kind, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; + return { kind: kind, invocation: { kind: 0, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } - else if (node.kind === 13 && node.parent.kind === 188) { - if (ts.isInsideTemplateLiteral(node, position)) { - return getArgumentListInfoForTemplate(node.parent, 0, sourceFile); + else if (ts.isNoSubstitutionTemplateLiteral(node) && ts.isTaggedTemplateExpression(parent)) { + if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { + return getArgumentListInfoForTemplate(parent, 0, sourceFile); } } - else if (node.kind === 14 && node.parent.parent.kind === 188) { - var templateExpression = node.parent; + else if (ts.isTemplateHead(node) && parent.parent.kind === 189) { + var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 201); - var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; + ts.Debug.assert(templateExpression.kind === 202); + var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 210 && node.parent.parent.parent.kind === 188) { - var templateSpan = node.parent; - var templateExpression = templateSpan.parent; - var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 201); - if (node.kind === 16 && !ts.isInsideTemplateLiteral(node, position)) { + else if (ts.isTemplateSpan(parent) && ts.isTaggedTemplateExpression(parent.parent.parent)) { + var templateSpan = parent; + var tagExpression = parent.parent.parent; + if (ts.isTemplateTail(node) && !ts.isInsideTemplateLiteral(node, position, sourceFile)) { return undefined; } - var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); - var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); + var spanIndex = templateSpan.parent.templateSpans.indexOf(templateSpan); + var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position, sourceFile); return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent && ts.isJsxOpeningLikeElement(node.parent)) { - var attributeSpanStart = node.parent.attributes.getFullStart(); - var attributeSpanEnd = ts.skipTrivia(sourceFile.text, node.parent.attributes.getEnd(), false); + else if (ts.isJsxOpeningLikeElement(parent)) { + var attributeSpanStart = parent.attributes.pos; + var attributeSpanEnd = ts.skipTrivia(sourceFile.text, parent.attributes.end, false); return { kind: 3, - invocation: node.parent, + invocation: { kind: 0, node: parent }, argumentsSpan: ts.createTextSpan(attributeSpanStart, attributeSpanEnd - attributeSpanStart), argumentIndex: 0, argumentCount: 1 }; } + else { + var typeArgInfo = ts.isPossiblyTypeArgumentPosition(node, sourceFile); + if (typeArgInfo) { + var called = typeArgInfo.called, nTypeArguments = typeArgInfo.nTypeArguments; + var invocation = { kind: 1, called: called }; + var argumentsSpan = ts.createTextSpanFromBounds(called.getStart(sourceFile), node.end); + return { kind: 0, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: nTypeArguments, argumentCount: nTypeArguments + 1 }; + } + } return undefined; } - SignatureHelp.getImmediatelyContainingArgumentInfo = getImmediatelyContainingArgumentInfo; function getArgumentIndex(argumentsList, node) { var argumentIndex = 0; for (var _i = 0, _a = argumentsList.getChildren(); _i < _a.length; _i++) { @@ -79138,15 +79722,15 @@ var ts; function getArgumentCount(argumentsList) { var listChildren = argumentsList.getChildren(); var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 26; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 26) { + if (listChildren.length > 0 && ts.last(listChildren).kind === 26) { argumentCount++; } return argumentCount; } - function getArgumentIndexForTemplatePiece(spanIndex, node, position) { + function getArgumentIndexForTemplatePiece(spanIndex, node, position, sourceFile) { ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); - if (ts.isTemplateLiteralKind(node.kind)) { - if (ts.isInsideTemplateLiteral(node, position)) { + if (ts.isTemplateLiteralToken(node)) { + if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { return 0; } return spanIndex + 2; @@ -79160,7 +79744,7 @@ var ts; } return { kind: 2, - invocation: tagExpression, + invocation: { kind: 0, node: tagExpression }, argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile), argumentIndex: argumentIndex, argumentCount: argumentCount @@ -79175,8 +79759,8 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 201) { - var lastSpan = ts.lastOrUndefined(template.templateSpans); + if (template.kind === 202) { + var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); } @@ -79184,36 +79768,38 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 273; n = n.parent) { - if (ts.isFunctionBlock(n)) { - return undefined; - } - if (n.pos < n.parent.pos || n.end > n.parent.end) { - ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); - } + var _loop_19 = function (n) { + ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.showSyntaxKind(n) + ", parent: " + ts.Debug.showSyntaxKind(n.parent); }); var argumentInfo = getImmediatelyContainingArgumentInfo(n, position, sourceFile); if (argumentInfo) { - return argumentInfo; + return { value: argumentInfo }; } + }; + for (var n = node; !ts.isBlock(n) && !ts.isSourceFile(n); n = n.parent) { + var state_7 = _loop_19(n); + if (typeof state_7 === "object") + return state_7.value; } return undefined; } - SignatureHelp.getContainingArgumentInfo = getContainingArgumentInfo; function getChildListThatStartsWithOpenerToken(parent, openerToken, sourceFile) { var children = parent.getChildren(sourceFile); var indexOfOpenerToken = children.indexOf(openerToken); ts.Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1); return children[indexOfOpenerToken + 1]; } + function getExpressionFromInvocation(invocation) { + return invocation.kind === 0 ? ts.getInvokedExpression(invocation.node) : invocation.called; + } var signatureHelpNodeBuilderFlags = 8192 | 3112960; - function createSignatureHelpItems(candidates, resolvedSignature, argumentListInfo, typeChecker) { + function createSignatureHelpItems(candidates, resolvedSignature, argumentListInfo, sourceFile, typeChecker) { var argumentCount = argumentListInfo.argumentCount, applicableSpan = argumentListInfo.argumentsSpan, invocation = argumentListInfo.invocation, argumentIndex = argumentListInfo.argumentIndex; var isTypeParameterList = argumentListInfo.kind === 0; - var callTarget = ts.getInvokedExpression(invocation); - var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); + var enclosingDeclaration = invocation.kind === 0 ? invocation.node : invocation.called; + var callTargetSymbol = typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)); var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, undefined, undefined); var printer = ts.createPrinter({ removeComments: true }); - var items = ts.map(candidates, function (candidateSignature) { + var items = candidates.map(function (candidateSignature) { var signatureHelpParameters; var prefixDisplayParts = []; var suffixDisplayParts = []; @@ -79228,9 +79814,9 @@ var ts; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : ts.emptyArray; suffixDisplayParts.push(ts.punctuationPart(29)); var parameterParts = ts.mapToDisplayParts(function (writer) { - var thisParameter = candidateSignature.thisParameter ? [typeChecker.symbolToParameterDeclaration(candidateSignature.thisParameter, invocation, signatureHelpNodeBuilderFlags)] : []; - var params = ts.createNodeArray(thisParameter.concat(ts.map(candidateSignature.parameters, function (param) { return typeChecker.symbolToParameterDeclaration(param, invocation, signatureHelpNodeBuilderFlags); }))); - printer.writeList(1296, params, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var thisParameter = candidateSignature.thisParameter ? [typeChecker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; + var params = ts.createNodeArray(thisParameter.concat(candidateSignature.parameters.map(function (param) { return typeChecker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); + printer.writeList(1296, params, sourceFile, writer); }); ts.addRange(suffixDisplayParts, parameterParts); } @@ -79238,8 +79824,8 @@ var ts; isVariadic = candidateSignature.hasRestParameter; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { - var args = ts.createNodeArray(ts.map(candidateSignature.typeParameters, function (p) { return typeChecker.typeParameterToDeclaration(p, invocation); })); - printer.writeList(26896, args, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var args = ts.createNodeArray(candidateSignature.typeParameters.map(function (p) { return typeChecker.typeParameterToDeclaration(p, enclosingDeclaration); })); + printer.writeList(26896, args, sourceFile, writer); } }); ts.addRange(prefixDisplayParts, typeParameterParts); @@ -79252,10 +79838,10 @@ var ts; writer.writeSpace(" "); var predicate = typeChecker.getTypePredicateOfSignature(candidateSignature); if (predicate) { - typeChecker.writeTypePredicate(predicate, invocation, undefined, writer); + typeChecker.writeTypePredicate(predicate, enclosingDeclaration, undefined, writer); } else { - typeChecker.writeType(typeChecker.getReturnTypeOfSignature(candidateSignature), invocation, undefined, writer); + typeChecker.writeType(typeChecker.getReturnTypeOfSignature(candidateSignature), enclosingDeclaration, undefined, writer); } }); ts.addRange(suffixDisplayParts, returnTypeParts); @@ -79277,8 +79863,8 @@ var ts; return { items: items, applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; function createSignatureHelpParameterForParameter(parameter) { var displayParts = ts.mapToDisplayParts(function (writer) { - var param = typeChecker.symbolToParameterDeclaration(parameter, invocation, signatureHelpNodeBuilderFlags); - printer.writeNode(4, param, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var param = typeChecker.symbolToParameterDeclaration(parameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); + printer.writeNode(4, param, sourceFile, writer); }); return { name: parameter.name, @@ -79289,8 +79875,8 @@ var ts; } function createSignatureHelpParameterForTypeParameter(typeParameter) { var displayParts = ts.mapToDisplayParts(function (writer) { - var param = typeChecker.typeParameterToDeclaration(typeParameter, invocation); - printer.writeNode(4, param, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var param = typeChecker.typeParameterToDeclaration(typeParameter, enclosingDeclaration); + printer.writeNode(4, param, sourceFile, writer); }); return { name: typeParameter.symbol.name, @@ -79304,9 +79890,8 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function computeSuggestionDiagnostics(sourceFile, program) { - program.getSemanticDiagnostics(sourceFile); - var checker = program.getDiagnosticsProducingTypeChecker(); + function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) { + program.getSemanticDiagnostics(sourceFile, cancellationToken); var diags = []; if (sourceFile.commonJsModuleIndicator && (ts.programContainsEs6Modules(program) || ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) && @@ -79314,40 +79899,10 @@ var ts; diags.push(ts.createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module)); } var isJsFile = ts.isSourceFileJavaScript(sourceFile); - function check(node) { - switch (node.kind) { - case 233: - case 191: - if (isJsFile) { - var symbol = node.symbol; - if (symbol.members && (symbol.members.size > 0)) { - diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); - } - } - break; - } - if (!isJsFile && ts.codefix.parameterShouldGetTypeFromJSDoc(node)) { - diags.push(ts.createDiagnosticForNode(node.name || node, ts.Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types)); - } - node.forEachChild(check); - } check(sourceFile); - if (!isJsFile) { - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (ts.isVariableStatement(statement) && - statement.declarationList.flags & 2 && - statement.declarationList.declarations.length === 1) { - var init = statement.declarationList.declarations[0].initializer; - if (init && ts.isRequireCall(init, true)) { - diags.push(ts.createDiagnosticForNode(init, ts.Diagnostics.require_call_may_be_converted_to_an_import)); - } - } - } - } if (ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())) { - for (var _b = 0, _c = sourceFile.imports; _b < _c.length; _b++) { - var moduleSpecifier = _c[_b]; + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var moduleSpecifier = _a[_i]; var importNode = ts.importFromModuleSpecifier(moduleSpecifier); var name = importNameForConvertToDefaultImport(importNode); if (!name) @@ -79359,17 +79914,55 @@ var ts; } } } - return diags.concat(checker.getSuggestionDiagnostics(sourceFile)).sort(function (d1, d2) { return d1.start - d2.start; }); + ts.addRange(diags, sourceFile.bindSuggestionDiagnostics); + ts.addRange(diags, program.getSuggestionDiagnostics(sourceFile, cancellationToken)); + return diags.sort(function (d1, d2) { return d1.start - d2.start; }); + function check(node) { + if (isJsFile) { + switch (node.kind) { + case 192: + var decl = ts.getDeclarationOfJSInitializer(node); + if (decl) { + var symbol_3 = decl.symbol; + if (symbol_3 && (symbol_3.exports && symbol_3.exports.size || symbol_3.members && symbol_3.members.size)) { + diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); + break; + } + } + case 234: + var symbol = node.symbol; + if (symbol.members && (symbol.members.size > 0)) { + diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); + } + break; + } + } + else { + if (ts.isVariableStatement(node) && + node.parent === sourceFile && + node.declarationList.flags & 2 && + node.declarationList.declarations.length === 1) { + var init = node.declarationList.declarations[0].initializer; + if (init && ts.isRequireCall(init, true)) { + diags.push(ts.createDiagnosticForNode(init, ts.Diagnostics.require_call_may_be_converted_to_an_import)); + } + } + if (ts.codefix.parameterShouldGetTypeFromJSDoc(node)) { + diags.push(ts.createDiagnosticForNode(node.name || node, ts.Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types)); + } + } + node.forEachChild(check); + } } ts.computeSuggestionDiagnostics = computeSuggestionDiagnostics; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 213: + case 214: return statement.declarationList.declarations.some(function (decl) { return ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), true); }); - case 215: { + case 216: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, true); @@ -79386,12 +79979,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 243: + case 244: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings.kind === 245 && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 246 && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 242: + case 243: return node.name; default: return undefined; @@ -79412,7 +80005,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32) { - return ts.getDeclarationOfKind(symbol, 204) ? + return ts.getDeclarationOfKind(symbol, 205) ? "local class" : "class"; } if (flags & 384) @@ -79492,11 +80085,11 @@ var ts; return unionPropertyKind; } switch (location.parent && location.parent.kind) { - case 256: - case 254: + case 257: case 255: + case 256: return location.kind === 71 ? "property" : "JSX attribute"; - case 261: + case 262: return "JSX attribute"; default: return "property"; @@ -79521,7 +80114,7 @@ var ts; var tags; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - var hasAddedSymbolInfo; + var hasAddedSymbolInfo = false; var isThisExpression = location.kind === 99 && ts.isExpression(location); var type; var printer; @@ -79533,7 +80126,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 184) { + if (location.parent && location.parent.kind === 185) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; @@ -79552,7 +80145,7 @@ var ts; if (callExpressionLike) { var candidateSignatures = []; signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); - var useConstructSignatures = callExpressionLike.kind === 187 || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97); + var useConstructSignatures = callExpressionLike.kind === 188 || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -79602,25 +80195,25 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304)) || - (location.kind === 123 && location.parent.kind === 154)) { + (location.kind === 123 && location.parent.kind === 155)) { var functionDeclaration_1 = location.parent; var locationIsSymbolDeclaration = ts.find(symbol.declarations, function (declaration) { return declaration === (location.kind === 123 ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 154 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 155 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 154) { + if (functionDeclaration_1.kind === 155) { symbolKind = "constructor"; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 157 && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 158 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -79630,7 +80223,7 @@ var ts; } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 204)) { + if (ts.getDeclarationOfKind(symbol, 205)) { pushSymbolKind("local class"); } else { @@ -79670,7 +80263,7 @@ var ts; } if (symbolFlags & 1536) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 238); + var declaration = ts.getDeclarationOfKind(symbol, 239); var isNamespace = declaration && declaration.name && declaration.name.kind === 71; displayParts.push(ts.keywordPart(isNamespace ? 130 : 129)); displayParts.push(ts.spacePart()); @@ -79689,23 +80282,24 @@ var ts; writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var decl = ts.getDeclarationOfKind(symbol, 147); - ts.Debug.assert(decl !== undefined); + var decl = ts.getDeclarationOfKind(symbol, 148); + if (decl === undefined) + return ts.Debug.fail(); var declaration = decl.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 158) { + if (declaration.kind === 159) { displayParts.push(ts.keywordPart(94)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 157 && declaration.name) { + else if (declaration.kind !== 158 && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } - else if (declaration.kind === 236) { + else if (declaration.kind === 237) { addInPrefix(); displayParts.push(ts.keywordPart(139)); displayParts.push(ts.spacePart()); @@ -79719,7 +80313,7 @@ var ts; symbolKind = "enum member"; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 272) { + if (declaration.kind === 273) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -79749,17 +80343,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 241: + case 242: displayParts.push(ts.keywordPart(84)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(130)); break; - case 248: + case 249: displayParts.push(ts.keywordPart(84)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 58 : 79)); break; - case 251: + case 252: displayParts.push(ts.keywordPart(84)); break; default: @@ -79768,7 +80362,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 242) { + if (declaration.kind === 243) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -79841,10 +80435,10 @@ var ts; documentation = symbol.getDocumentationComment(typeChecker); tags = symbol.getJsDocTags(); if (documentation.length === 0 && symbolFlags & 4) { - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 273; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 274; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 199) { + if (!declaration.parent || declaration.parent.kind !== 200) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -79927,6 +80521,7 @@ var ts; } } function addSignatureDisplayParts(signature, allSignatures, flags) { + if (flags === void 0) { flags = 0; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); @@ -79954,14 +80549,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 191) { + if (declaration.kind === 192) { return true; } - if (declaration.kind !== 231 && declaration.kind !== 233) { + if (declaration.kind !== 232 && declaration.kind !== 234) { return false; } for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { - if (parent.kind === 273 || parent.kind === 239) { + if (parent.kind === 274 || parent.kind === 240) { return false; } } @@ -80029,7 +80624,8 @@ var ts; ts.addRange(diagnostics, program.getOptionsDiagnostics()); } program.emit(undefined, undefined, undefined, undefined, transpileOptions.transformers); - ts.Debug.assert(outputText !== undefined, "Output generation failed"); + if (outputText === undefined) + return ts.Debug.fail("Output generation failed"); return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; } ts.transpileModule = transpileModule; @@ -80045,7 +80641,7 @@ var ts; return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.cloneCompilerOptions(options); - var _loop_17 = function (opt) { + var _loop_20 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -80061,7 +80657,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_17(opt); + _loop_20(opt); } return options; } @@ -80195,7 +80791,7 @@ var ts; lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - wasNewLine = trailingTrivia && ts.lastOrUndefined(trailingTrivia).kind === 4; + wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4; } else { scanner.scan(); @@ -80233,10 +80829,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 261: - case 256: + case 262: case 257: - case 255: + case 258: + case 256: return ts.isKeyword(node.kind) || node.kind === 71; } } @@ -80395,7 +80991,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0; token <= 144; token++) { + for (var token = 0; token <= 145; token++) { allTokens.push(token); } function anyTokenExcept() { @@ -80407,9 +81003,9 @@ var ts; } var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3])); - var keywords = tokenRangeFromRange(72, 144); + var keywords = tokenRangeFromRange(72, 145); var binaryOperators = tokenRangeFromRange(27, 70); - var binaryKeywordOperators = [92, 93, 144, 118, 127]; + var binaryKeywordOperators = [92, 93, 145, 118, 127]; var unaryPrefixOperators = [43, 44, 52, 51]; var unaryPrefixExpressions = [ 8, 71, 19, 21, @@ -80497,11 +81093,11 @@ var ts; 136, 115, 139, - 142, + 143, 128, 126, ], anyToken, [isNonJsxSameLineTokenContext], 2), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [85, 108, 142], [isNonJsxSameLineTokenContext], 2), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [85, 108, 143], [isNonJsxSameLineTokenContext], 2), rule("SpaceAfterModuleName", 9, 17, [isModuleDeclContext], 2), rule("SpaceBeforeArrow", anyToken, 36, [isNonJsxSameLineTokenContext], 2), rule("SpaceAfterArrow", 36, anyToken, [isNonJsxSameLineTokenContext], 2), @@ -80634,37 +81230,37 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 219; + return context.contextNode.kind === 220; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 199: case 200: - case 170: - case 207: - case 251: - case 247: - case 160: - case 168: + case 201: + case 171: + case 208: + case 252: + case 248: + case 161: case 169: + case 170: return true; - case 181: - case 236: - case 242: - case 231: - case 148: - case 272: + case 182: + case 237: + case 243: + case 232: + case 149: + case 273: + case 152: case 151: - case 150: return context.currentTokenSpan.kind === 58 || context.nextTokenSpan.kind === 58; - case 220: - case 147: - return context.currentTokenSpan.kind === 92 || context.nextTokenSpan.kind === 92; case 221: - return context.currentTokenSpan.kind === 144 || context.nextTokenSpan.kind === 144; + case 148: + return context.currentTokenSpan.kind === 92 || context.nextTokenSpan.kind === 92; + case 222: + return context.currentTokenSpan.kind === 145 || context.nextTokenSpan.kind === 145; } return false; } @@ -80676,22 +81272,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 151 || - contextKind === 150 || - contextKind === 148 || - contextKind === 231 || + return contextKind === 152 || + contextKind === 151 || + contextKind === 149 || + contextKind === 232 || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 200 || - context.contextNode.kind === 170; + return context.contextNode.kind === 201 || + context.contextNode.kind === 171; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 179 || - context.contextNode.kind === 176 || + return context.contextNode.kind === 180 || + context.contextNode.kind === 177 || isSingleLineBlockContext(context); } function isBeforeMultilineBlockContext(context) { @@ -80714,26 +81310,26 @@ var ts; return true; } switch (node.kind) { - case 212: + case 213: + case 241: + case 184: case 240: - case 183: - case 239: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 233: + case 234: + case 154: case 153: - case 152: - case 155: case 156: case 157: - case 191: - case 154: + case 158: case 192: - case 235: + case 155: + case 193: + case 236: return true; } return false; @@ -80742,39 +81338,39 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 233 || context.contextNode.kind === 191; + return context.contextNode.kind === 234 || context.contextNode.kind === 192; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 234: - case 204: case 235: - case 237: - case 165: + case 205: + case 236: case 238: - case 249: + case 166: + case 239: case 250: - case 243: - case 246: + case 251: + case 244: + case 247: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 234: - case 238: - case 237: - case 268: + case 235: case 239: - case 226: + case 238: + case 269: + case 240: + case 227: return true; - case 212: { + case 213: { var blockParent = context.currentTokenParent.parent; - if (!blockParent || blockParent.kind !== 192 && blockParent.kind !== 191) { + if (!blockParent || blockParent.kind !== 193 && blockParent.kind !== 192) { return true; } } @@ -80783,29 +81379,29 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 216: - case 226: - case 219: + case 217: + case 227: case 220: case 221: + case 222: + case 219: + case 230: case 218: - case 229: - case 217: - case 225: - case 268: + case 226: + case 269: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 183; + return context.contextNode.kind === 184; } function isFunctionCallContext(context) { - return context.contextNode.kind === 186; + return context.contextNode.kind === 187; } function isNewContext(context) { - return context.contextNode.kind === 187; + return context.contextNode.kind === 188; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -80817,35 +81413,35 @@ var ts; return context.nextTokenSpan.kind !== 22; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 192; + return context.contextNode.kind === 193; } function isImportTypeContext(context) { - return context.contextNode.kind === 178; + return context.contextNode.kind === 179; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 254 && context.contextNode.kind !== 258; + return context.contextNode.kind !== 255 && context.contextNode.kind !== 259; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 264 || context.contextNode.kind === 263; + return context.contextNode.kind === 265 || context.contextNode.kind === 264; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 261; + return context.nextTokenParent.kind === 262; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 261; + return context.contextNode.kind === 262; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 255; + return context.contextNode.kind === 256; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); } function isEndOfDecoratorContextOnSameLine(context) { return context.TokensAreOnSameLine() && - context.contextNode.decorators && + !!context.contextNode.decorators && nodeIsInDecoratorContext(context.currentTokenParent) && !nodeIsInDecoratorContext(context.nextTokenParent); } @@ -80853,45 +81449,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 149; + return node.kind === 150; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 232 && + return context.currentTokenParent.kind === 233 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2; } function isModuleDeclContext(context) { - return context.contextNode.kind === 238; + return context.contextNode.kind === 239; } function isObjectTypeContext(context) { - return context.contextNode.kind === 165; + return context.contextNode.kind === 166; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 158; + return context.contextNode.kind === 159; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 27 && token.kind !== 29) { return false; } switch (parent.kind) { - case 161: - case 189: + case 162: + case 190: + case 237: + case 235: + case 205: case 236: case 234: - case 204: - case 235: - case 233: - case 191: case 192: + case 193: + case 154: case 153: - case 152: - case 157: case 158: - case 186: + case 159: case 187: - case 206: + case 188: + case 207: return true; default: return false; @@ -80902,16 +81498,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 189; + return context.contextNode.kind === 190; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 105 && context.currentTokenParent.kind === 195; + return context.currentTokenSpan.kind === 105 && context.currentTokenParent.kind === 196; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 202 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 203 && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 208; + return context.contextNode.kind === 209; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -80959,12 +81555,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 144 && column <= 144, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 145 && column <= 145, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; - var mapRowLength = 144 + 1; + var mapRowLength = 145 + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; @@ -81084,17 +81680,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 234: case 235: + case 236: return ts.rangeContainsRange(parent.members, node); - case 238: - var body = parent.body; - return body && body.kind === 239 && ts.rangeContainsRange(body.statements, node); - case 273: - case 212: case 239: + var body = parent.body; + return !!body && body.kind === 240 && ts.rangeContainsRange(body.statements, node); + case 274: + case 213: + case 240: return ts.rangeContainsRange(parent.statements, node); - case 268: + case 269: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -81264,18 +81860,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 234: return 75; - case 235: return 109; - case 233: return 89; - case 237: return 237; - case 155: return 125; - case 156: return 136; - case 153: + case 235: return 75; + case 236: return 109; + case 234: return 89; + case 238: return 238; + case 156: return 125; + case 157: return 136; + case 154: if (node.asteriskToken) { return 39; } - case 151: - case 148: + case 152: + case 149: return ts.getNameOfDeclaration(node).kind; } } @@ -81315,15 +81911,15 @@ var ts; case 41: case 29: switch (container.kind) { - case 256: case 257: - case 255: + case 258: + case 256: return false; } break; case 21: case 22: - if (container.kind !== 176) { + if (container.kind !== 177) { return false; } break; @@ -81392,7 +81988,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 149 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 150 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); if (child.kind === 10) { @@ -81400,7 +81996,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, true, false); } childContextNode = node; - if (isFirstListItem && parent.kind === 182 && inheritedIndentation === -1) { + if (isFirstListItem && parent.kind === 183 && inheritedIndentation === -1) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -81751,12 +82347,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 154: - case 233: - case 191: - case 153: - case 152: + case 155: + case 234: case 192: + case 154: + case 153: + case 193: if (node.typeParameters === list) { return 27; } @@ -81764,8 +82360,8 @@ var ts; return 19; } break; - case 186: case 187: + case 188: if (node.typeArguments === list) { return 27; } @@ -81773,7 +82369,7 @@ var ts; return 19; } break; - case 161: + case 162: if (node.typeArguments === list) { return 27; } @@ -81867,7 +82463,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 26 && precedingToken.parent.kind !== 199) { + if (precedingToken.kind === 26 && precedingToken.parent.kind !== 200) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -81990,7 +82586,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 273 || !parentAndChildShareLine); + (parent.kind === 274 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -82029,7 +82625,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 216 && parent.elseStatement === child) { + if (parent.kind === 217 && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 82, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -82045,40 +82641,40 @@ var ts; if (node.parent) { var end = node.end; switch (node.parent.kind) { - case 161: + case 162: return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), end); - case 183: + case 184: return node.parent.properties; - case 182: + case 183: return node.parent.elements; - case 233: - case 191: + case 234: case 192: - case 153: - case 152: - case 157: + case 193: case 154: - case 163: - case 158: { + case 153: + case 158: + case 155: + case 164: + case 159: { var start = node.getStart(sourceFile); return getListIfStartEndIsInListRange(node.parent.typeParameters, start, end) || getListIfStartEndIsInListRange(node.parent.parameters, start, end); } - case 234: + case 235: return getListIfStartEndIsInListRange(node.parent.typeParameters, node.getStart(sourceFile), end); - case 187: - case 186: { + case 188: + case 187: { var start = node.getStart(sourceFile); return getListIfStartEndIsInListRange(node.parent.typeArguments, start, end) || getListIfStartEndIsInListRange(node.parent.arguments, start, end); } - case 232: + case 233: return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), end); - case 246: - case 250: + case 247: + case 251: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - case 179: case 180: + case 181: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); } } @@ -82116,10 +82712,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 186: case 187: - case 184: + case 188: case 185: + case 186: node = node.expression; break; default: @@ -82171,107 +82767,104 @@ var ts; return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; } SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; - function nodeContentIsAlwaysIndented(kind) { - switch (kind) { - case 215: - case 234: - case 204: - case 235: - case 237: - case 236: - case 182: - case 212: - case 239: - case 183: - case 165: - case 176: - case 167: - case 240: - case 266: - case 265: - case 190: - case 184: - case 186: - case 187: - case 213: - case 231: - case 248: - case 224: - case 200: - case 180: - case 179: - case 256: - case 259: - case 255: - case 264: - case 152: - case 157: - case 158: - case 148: - case 162: - case 163: - case 172: - case 188: - case 196: - case 250: - case 246: - case 251: - case 247: - case 269: - case 151: - return true; - } - return false; - } function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 231: - case 269: + case 216: + case 235: + case 205: + case 236: + case 238: + case 237: case 183: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 183) { + case 213: + case 240: + case 184: + case 166: + case 177: + case 168: + case 241: + case 267: + case 266: + case 191: + case 185: + case 187: + case 188: + case 214: + case 249: + case 225: + case 201: + case 181: + case 180: + case 257: + case 260: + case 256: + case 265: + case 153: + case 158: + case 159: + case 149: + case 163: + case 164: + case 173: + case 189: + case 197: + case 251: + case 247: + case 252: + case 248: + case 152: + return true; + case 232: + case 270: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 184) { return rangeIsOnOneLine(sourceFile, child); } - break; - case 217: + return true; case 218: - case 220: - case 221: case 219: - case 216: - case 233: - case 191: - case 153: + case 221: + case 222: + case 220: + case 217: + case 234: case 192: case 154: + case 193: case 155: case 156: - return childKind !== 212; - case 249: - return childKind !== 250; - case 243: - return childKind !== 244 || - (!!child.namedBindings && child.namedBindings.kind !== 246); - case 254: - return childKind !== 257; - case 258: - return childKind !== 260; + case 157: + return childKind !== 213; + case 250: + return childKind !== 251; + case 244: + return childKind !== 245 || + (!!child.namedBindings && child.namedBindings.kind !== 247); + case 255: + return childKind !== 258; + case 259: + return childKind !== 261; + case 170: + case 169: + if (childKind === 166) { + return false; + } } return indentByDefault; } SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 224: - case 228: { - if (parent.kind !== 212) { + case 225: + case 229: { + if (parent.kind !== 213) { return true; } var grandParent = parent.parent; - return !(grandParent && grandParent.kind === 191 || grandParent.kind === 233); + return !(grandParent && grandParent.kind === 192 || grandParent.kind === 234); } - case 222: case 223: + case 224: return true; default: return false; @@ -82279,7 +82872,7 @@ var ts; } function shouldIndentChildNode(settings, parent, child, sourceFile, isNextChild) { if (isNextChild === void 0) { isNextChild = false; } - return (nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(settings, parent, child, sourceFile, false)) + return nodeWillIndentChild(settings, parent, child, sourceFile, false) && !(isNextChild && child && isControlFlowEndingStatement(child.kind, parent)); } SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; @@ -82378,7 +82971,7 @@ var ts; : end; } function isSeparator(node, candidate) { - return candidate && node.parent && (candidate.kind === 26 || (candidate.kind === 25 && node.parent.kind === 183)); + return !!candidate && !!node.parent && (candidate.kind === 26 || (candidate.kind === 25 && node.parent.kind === 184)); } function spaces(count) { var s = ""; @@ -82422,6 +83015,12 @@ var ts; this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); return this; }; + ChangeTracker.prototype.deleteNodeRangeExcludingEnd = function (sourceFile, startNode, afterEndNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); + var endPosition = afterEndNode === undefined ? sourceFile.text.length : getAdjustedStartPosition(sourceFile, afterEndNode, options, Position.FullStart); + this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + }; ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { var containingList = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); if (!containingList) { @@ -82527,7 +83126,7 @@ var ts; } } else { - endNode = node.kind !== 231 && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 232 && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -82627,7 +83226,7 @@ var ts; else if (ts.isStatement(node) || ts.isClassOrTypeElement(node)) { return { suffix: this.newLineCharacter }; } - else if (ts.isVariableDeclaration(node)) { + else if (ts.isVariableDeclaration(node) || ts.isStringLiteral(node)) { return { prefix: ", " }; } else if (ts.isPropertyAssignment(node)) { @@ -82640,7 +83239,7 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 192) { + if (node.kind === 193) { var arrow = ts.findChildOfKind(node, 36, sourceFile); var lparen = ts.findChildOfKind(node, 19, sourceFile); if (lparen) { @@ -82651,13 +83250,13 @@ var ts; this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function " + name + "("); this.replaceRange(sourceFile, arrow, ts.createToken(20)); } - if (node.body.kind !== 212) { + if (node.body.kind !== 213) { this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(17), ts.createToken(96)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(25), ts.createToken(18)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 191 ? 89 : 75, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 192 ? 89 : 75, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -82754,7 +83353,7 @@ var ts; var changes = changesToText.getTextChangesFromChanges(this.changes, this.newLineCharacter, this.formatContext, validate); for (var _i = 0, _a = this.newFiles; _i < _a.length; _i++) { var _b = _a[_i], oldFile = _b.oldFile, fileName = _b.fileName, statements = _b.statements; - changes.push(changesToText.newFileChanges(oldFile, fileName, statements, this.newLineCharacter)); + changes.push(changesToText.newFileChanges(oldFile, fileName, statements, this.newLineCharacter, this.formatContext)); } return changes; }; @@ -82776,13 +83375,13 @@ var ts; return ts.group(changes, function (c) { return c.sourceFile.path; }).map(function (changesInFile) { var sourceFile = changesInFile[0].sourceFile; var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); }); - var _loop_18 = function (i) { + var _loop_21 = 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); }); }; for (var i = 0; i < normalized.length - 1; i++) { - _loop_18(i); + _loop_21(i); } var textChanges = normalized.map(function (c) { return ts.createTextChange(ts.createTextSpanFromRange(c.range), computeNewText(c, sourceFile, newLineCharacter, formatContext, validate)); @@ -82791,8 +83390,11 @@ var ts; }); } changesToText.getTextChangesFromChanges = getTextChangesFromChanges; - function newFileChanges(oldFile, fileName, statements, newLineCharacter) { - var text = statements.map(function (s) { return getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + function newFileChanges(oldFile, fileName, statements, newLineCharacter, formatContext) { + var nonFormattedText = statements.map(function (s) { return getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + var sourceFile = ts.createSourceFile(fileName, nonFormattedText, 6); + var changes = ts.formatting.formatDocument(sourceFile, formatContext); + var text = applyChanges(nonFormattedText, changes); return { fileName: fileName, textChanges: [ts.createTextChange(ts.createTextSpan(0, 0), text)], isNewFile: true }; } changesToText.newFileChanges = newFileChanges; @@ -83030,7 +83632,7 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 146 + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 147 || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); } })(textChanges = ts.textChanges || (ts.textChanges = {})); @@ -83099,8 +83701,8 @@ var ts; } codefix.codeFixAll = codeFixAll; function eachDiagnostic(_a, errorCodes, cb) { - var program = _a.program, sourceFile = _a.sourceFile; - for (var _i = 0, _b = program.getSemanticDiagnostics(sourceFile).concat(ts.computeSuggestionDiagnostics(sourceFile, program)); _i < _b.length; _i++) { + var program = _a.program, sourceFile = _a.sourceFile, cancellationToken = _a.cancellationToken; + for (var _i = 0, _b = program.getSemanticDiagnostics(sourceFile, cancellationToken).concat(ts.computeSuggestionDiagnostics(sourceFile, program, cancellationToken)); _i < _b.length; _i++) { var diag = _b[_i]; if (ts.contains(errorCodes, diag.code)) { cb(diag); @@ -83229,26 +83831,26 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 231 || - node.kind === 150 || - node.kind === 151; + node.kind === 232 || + node.kind === 151 || + node.kind === 152; } function transformJSDocType(node) { switch (node.kind) { - case 278: case 279: - return ts.createTypeReferenceNode("any", ts.emptyArray); - case 282: - return transformJSDocOptionalType(node); - case 281: - return transformJSDocType(node.type); case 280: - return transformJSDocNullableType(node); - case 284: - return transformJSDocVariadicType(node); + return ts.createTypeReferenceNode("any", ts.emptyArray); case 283: + return transformJSDocOptionalType(node); + case 282: + return transformJSDocType(node.type); + case 281: + return transformJSDocNullableType(node); + case 285: + return transformJSDocVariadicType(node); + case 284: return transformJSDocFunctionType(node); - case 161: + case 162: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, undefined); @@ -83270,7 +83872,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 284 && index === node.parent.parameters.length - 1; + var isRest = node.type.kind === 285 && index === node.parent.parameters.length - 1; var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(24) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -83339,12 +83941,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 233: + case 234: precedingNode = ctorDeclaration; deleteNode(ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 231: + case 232: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -83407,25 +84009,25 @@ var ts; if (!shouldConvertDeclaration(memberDeclaration, assignmentBinaryExpression.right)) { return; } - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 215 + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 216 ? assignmentBinaryExpression.parent : assignmentBinaryExpression; deleteNode(nodeToDelete); if (!assignmentBinaryExpression.right) { return ts.createProperty([], modifiers, symbol.name, undefined, undefined, undefined); } switch (assignmentBinaryExpression.right.kind) { - case 191: { + case 192: { var functionExpression = assignmentBinaryExpression.right; var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 120)); var method = ts.createMethod(undefined, fullModifiers, undefined, memberDeclaration.name, undefined, undefined, functionExpression.parameters, undefined, functionExpression.body); copyComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 192: { + case 193: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; - if (arrowFunctionBody.kind === 212) { + if (arrowFunctionBody.kind === 213) { bodyBlock = arrowFunctionBody; } else { @@ -83449,13 +84051,13 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 191) { + if (!initializer || initializer.kind !== 192) { return undefined; } if (node.name.kind !== 71) { return undefined; } - var memberElements = createClassElementsFromSymbol(initializer.symbol); + var memberElements = createClassElementsFromSymbol(node.symbol); if (initializer.body) { memberElements.unshift(ts.createConstructor(undefined, undefined, initializer.parameters, initializer.body)); } @@ -83497,20 +84099,20 @@ var ts; codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module.code], getCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program; + var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { - var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, program.getCompilerOptions().target); + var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, program.getCompilerOptions().target, preferences); if (moduleExportsChangedToDefault) { for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var importingFile = _a[_i]; - fixImportOfModuleExports(importingFile, sourceFile, changes); + fixImportOfModuleExports(importingFile, sourceFile, changes, preferences); } } }); return [codefix.createCodeFixActionNoFixId("convertToEs6Module", changes, ts.Diagnostics.Convert_to_ES6_module)]; }, }); - function fixImportOfModuleExports(importingFile, exportingFile, changes) { + function fixImportOfModuleExports(importingFile, exportingFile, changes, preferences) { for (var _i = 0, _a = importingFile.imports; _i < _a.length; _i++) { var moduleSpecifier = _a[_i]; var imported = ts.getResolvedModule(importingFile, moduleSpecifier.text); @@ -83519,10 +84121,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 242: - changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, undefined, moduleSpecifier)); + case 243: + changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, undefined, moduleSpecifier, preferences)); break; - case 186: + case 187: if (ts.isRequireCall(importNode, false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -83530,14 +84132,14 @@ var ts; } } } - function convertFileToEs6Module(sourceFile, checker, changes, target) { + function convertFileToEs6Module(sourceFile, checker, changes, target, preferences) { var identifiers = { original: collectFreeIdentifiers(sourceFile), additional: ts.createMap() }; var exports = collectExportRenames(sourceFile, checker, identifiers); convertExportsAccesses(sourceFile, exports, changes); var moduleExportsChangedToDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - var moduleExportsChanged = convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports); + var moduleExportsChanged = convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, preferences); moduleExportsChangedToDefault = moduleExportsChangedToDefault || moduleExportsChanged; } return moduleExportsChangedToDefault; @@ -83571,21 +84173,21 @@ var ts; node.forEachChild(recur); }); } - function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports) { + function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, preferences) { switch (statement.kind) { - case 213: - convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target); + case 214: + convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, preferences); return false; - case 215: { + case 216: { var expression = statement.expression; switch (expression.kind) { - case 186: { + case 187: { if (ts.isRequireCall(expression, true)) { - changes.replaceNode(sourceFile, statement, ts.makeImport(undefined, undefined, expression.arguments[0])); + changes.replaceNode(sourceFile, statement, ts.makeImport(undefined, undefined, expression.arguments[0], preferences)); } return false; } - case 199: { + case 200: { var operatorToken = expression.operatorToken; return operatorToken.kind === 58 && convertAssignment(sourceFile, checker, expression, changes, exports); } @@ -83595,7 +84197,7 @@ var ts; return false; } } - function convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target) { + function convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, preferences) { var declarationList = statement.declarationList; var foundImport = false; var newNodes = ts.flatMap(declarationList.declarations, function (decl) { @@ -83607,11 +84209,11 @@ var ts; } else if (ts.isRequireCall(initializer, true)) { foundImport = true; - return convertSingleImport(sourceFile, name, initializer.arguments[0], changes, checker, identifiers, target); + return convertSingleImport(sourceFile, name, initializer.arguments[0], changes, checker, identifiers, target, preferences); } else if (ts.isPropertyAccessExpression(initializer) && ts.isRequireCall(initializer.expression, true)) { foundImport = true; - return convertPropertyAccessImport(name, initializer.name.text, initializer.expression.arguments[0], identifiers); + return convertPropertyAccessImport(name, initializer.name.text, initializer.expression.arguments[0], identifiers, preferences); } } return ts.createVariableStatement(undefined, ts.createVariableDeclarationList([decl], declarationList.flags)); @@ -83620,20 +84222,20 @@ var ts; changes.replaceNodeWithNodes(sourceFile, statement, newNodes); } } - function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers) { + function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, preferences) { switch (name.kind) { - case 179: - case 180: { + case 180: + case 181: { var tmp = makeUniqueName(propertyName, identifiers); return [ - makeSingleImport(tmp, propertyName, moduleSpecifier), + makeSingleImport(tmp, propertyName, moduleSpecifier, preferences), makeConst(undefined, name, ts.createIdentifier(tmp)), ]; } case 71: - return [makeSingleImport(name.text, propertyName, moduleSpecifier)]; + return [makeSingleImport(name.text, propertyName, moduleSpecifier, preferences)]; default: - ts.Debug.assertNever(name); + return ts.Debug.assertNever(name); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -83667,14 +84269,14 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 155: case 156: - case 270: + case 157: case 271: + case 272: return undefined; - case 269: + case 270: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 153: + case 154: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(84)], prop); default: ts.Debug.assertNever(prop); @@ -83730,15 +84332,15 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported) { var modifiers = [ts.createToken(84)]; switch (exported.kind) { - case 191: { + case 192: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { return exportConst(); } } - case 192: + case 193: return functionExpressionToDeclaration(name, modifiers, exported); - case 204: + case 205: return classExpressionToDeclaration(name, modifiers, exported); default: return exportConst(); @@ -83747,32 +84349,32 @@ var ts; return makeConst(modifiers, ts.createIdentifier(name), exported); } } - function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target) { + function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, preferences) { switch (name.kind) { - case 179: { + case 180: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); }); if (importSpecifiers) { - return [ts.makeImport(undefined, importSpecifiers, moduleSpecifier)]; + return [ts.makeImport(undefined, importSpecifiers, moduleSpecifier, preferences)]; } } - case 180: { + case 181: { var tmp = makeUniqueName(codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, target), identifiers); return [ - ts.makeImport(ts.createIdentifier(tmp), undefined, moduleSpecifier), + ts.makeImport(ts.createIdentifier(tmp), undefined, moduleSpecifier, preferences), makeConst(undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } case 71: - return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers); + return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, preferences); default: - ts.Debug.assertNever(name); + return ts.Debug.assertNever(name); } } - function convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers) { + function convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, preferences) { var nameSymbol = checker.getSymbolAtLocation(name); var namedBindingsNames = ts.createMap(); var needDefaultImport = false; @@ -83803,7 +84405,7 @@ var ts; if (!namedBindings) { needDefaultImport = true; } - return [ts.makeImport(needDefaultImport ? ts.getSynthesizedDeepClone(name) : undefined, namedBindings, moduleSpecifier)]; + return [ts.makeImport(needDefaultImport ? ts.getSynthesizedDeepClone(name) : undefined, namedBindings, moduleSpecifier, preferences)]; } function makeUniqueName(name, identifiers) { while (identifiers.original.has(name) || identifiers.additional.has(name)) { @@ -83814,20 +84416,22 @@ var ts; } function collectFreeIdentifiers(file) { var map = ts.createMultiMap(); - file.forEachChild(function recur(node) { - if (ts.isIdentifier(node) && isFreeIdentifier(node)) { - map.add(node.text, node); - } - node.forEachChild(recur); - }); + forEachFreeIdentifier(file, function (id) { return map.add(id.text, id); }); return map; } + function forEachFreeIdentifier(node, cb) { + if (ts.isIdentifier(node) && isFreeIdentifier(node)) + cb(node); + node.forEachChild(function (child) { return forEachFreeIdentifier(child, cb); }); + } function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 184: + case 185: return parent.name !== node; - case 181: + case 182: + return parent.propertyName !== node; + case 248: return parent.propertyName !== node; default: return true; @@ -83839,10 +84443,10 @@ var ts; function classExpressionToDeclaration(name, additionalModifiers, cls) { return ts.createClassDeclaration(ts.getSynthesizedDeepClones(cls.decorators), ts.concatenate(additionalModifiers, ts.getSynthesizedDeepClones(cls.modifiers)), name, ts.getSynthesizedDeepClones(cls.typeParameters), ts.getSynthesizedDeepClones(cls.heritageClauses), ts.getSynthesizedDeepClones(cls.members)); } - function makeSingleImport(localName, propertyName, moduleSpecifier) { + function makeSingleImport(localName, propertyName, moduleSpecifier, preferences) { return propertyName === "default" - ? ts.makeImport(ts.createIdentifier(localName), undefined, moduleSpecifier) - : ts.makeImport(undefined, [makeImportSpecifier(propertyName, localName)], moduleSpecifier); + ? ts.makeImport(ts.createIdentifier(localName), undefined, moduleSpecifier, preferences) + : ts.makeImport(undefined, [makeImportSpecifier(propertyName, localName)], moduleSpecifier, preferences); } function makeImportSpecifier(propertyName, name) { return ts.createImportSpecifier(propertyName !== undefined && propertyName !== name ? ts.createIdentifier(propertyName) : undefined, ts.createIdentifier(name)); @@ -83926,10 +84530,14 @@ var ts; function getClass(sourceFile, pos) { return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos, false))); } + function symbolPointsToNonPrivateMember(symbol) { + return !(ts.getModifierFlags(symbol.valueDeclaration) & 8); + } function addMissingDeclarations(checker, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) { + var maybeHeritageClauseSymbol = getHeritageClauseSymbolTable(classDeclaration, checker); var implementedType = checker.getTypeAtLocation(implementedTypeNode); var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); - var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8); }); + var nonPrivateAndNotExistedInHeritageClauseMembers = implementedTypeSymbols.filter(ts.and(symbolPointsToNonPrivateMember, function (symbol) { return !maybeHeritageClauseSymbol.has(symbol.escapedName); })); var classType = checker.getTypeAtLocation(classDeclaration); if (!classType.getNumberIndexType()) { createMissingIndexSignatureDeclaration(implementedType, 1); @@ -83937,7 +84545,7 @@ var ts; if (!classType.getStringIndexType()) { createMissingIndexSignatureDeclaration(implementedType, 0); } - codefix.createMissingMemberNodes(classDeclaration, nonPrivateMembers, checker, preferences, function (member) { return changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member); }); + codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, checker, preferences, function (member) { return changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member); }); function createMissingIndexSignatureDeclaration(type, kind) { var indexInfoOfKind = checker.getIndexInfoOfType(type, kind); if (indexInfoOfKind) { @@ -83945,6 +84553,14 @@ var ts; } } } + function getHeritageClauseSymbolTable(classDeclaration, checker) { + var heritageClauseNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + if (!heritageClauseNode) + return ts.createSymbolTable(); + var heritageClauseType = checker.getTypeAtLocation(heritageClauseNode); + var heritageClauseTypeSymbols = checker.getPropertiesOfType(heritageClauseType); + return ts.createSymbolTable(heritageClauseTypeSymbols.filter(symbolPointsToNonPrivateMember)); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; @@ -83960,7 +84576,9 @@ var ts; ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code, ], - getCodeActions: getImportCodeActions, + getCodeActions: function (context) { return context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ? getActionsForUMDImport(context) + : getActionsForNonUMDImport(context); }, fixIds: [], getAllCodeActions: ts.notImplemented, }); @@ -83977,7 +84595,6 @@ var ts; program: program, checker: checker, compilerOptions: program.getCompilerOptions(), - cachedImportDeclarations: [], getCanonicalFileName: ts.createGetCanonicalFileName(ts.hostUsesCaseSensitiveFileNames(context.host)), symbolName: symbolName, symbolToken: symbolToken, @@ -84021,46 +84638,57 @@ var ts; return result; } function getCodeActionsForImport_separateExistingAndNew(exportInfos, context, useExisting, addNew) { - var existingImports = ts.flatMap(exportInfos, function (info) { - return getImportDeclarations(info, context.checker, context.sourceFile, context.cachedImportDeclarations); - }); - if (context.symbolToken && ts.isIdentifier(context.symbolToken)) { - for (var _i = 0, existingImports_1 = existingImports; _i < existingImports_1.length; _i++) { - var declaration = existingImports_1[_i].declaration; - var namespace = getNamespaceImportName(declaration); - if (namespace) { - var moduleSymbol = context.checker.getAliasedSymbol(context.checker.getSymbolAtLocation(namespace)); - if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(context.symbolName))) { - useExisting.push(getCodeActionForUseExistingNamespaceImport(namespace.text, context, context.symbolToken)); - } + var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, context.checker, context.sourceFile); }); + ts.append(useExisting, tryUseExistingNamespaceImport(existingImports, context, context.symbolToken, context.checker)); + var addToExisting = tryAddToExistingImport(existingImports, context); + if (addToExisting) { + useExisting.push(addToExisting); + } + else { + getCodeActionsForAddImport(exportInfos, context, existingImports, addNew); + } + } + function tryUseExistingNamespaceImport(existingImports, context, symbolToken, checker) { + return !symbolToken || !ts.isIdentifier(symbolToken) ? undefined : ts.firstDefined(existingImports, function (_a) { + var declaration = _a.declaration; + var namespace = getNamespaceImportName(declaration); + if (namespace) { + var moduleSymbol = namespace && checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)); + if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(context.symbolName))) { + return getCodeActionForUseExistingNamespaceImport(namespace.text, context, symbolToken); } } - } - getCodeActionsForAddImport(exportInfos, context, existingImports, useExisting, addNew); + }); + } + function tryAddToExistingImport(existingImports, context) { + return ts.firstDefined(existingImports, function (_a) { + var declaration = _a.declaration, importKind = _a.importKind; + if (declaration.kind === 244 && declaration.importClause) { + var changes = tryUpdateExistingImport(context, declaration.importClause, importKind); + if (changes) { + var moduleSpecifierWithoutQuotes = ts.stripQuotes(declaration.moduleSpecifier.getText()); + return createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [context.symbolName, moduleSpecifierWithoutQuotes], changes); + } + } + }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 243) { + if (declaration.kind === 244) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 245 ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 246 ? namedBindings.name : undefined; } else { return declaration.name; } } - function getImportDeclarations(_a, checker, _b, cachedImportDeclarations) { + function getExistingImportDeclarations(_a, checker, _b) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind; var imports = _b.imports; - if (cachedImportDeclarations === void 0) { cachedImportDeclarations = []; } - var moduleSymbolId = ts.getUniqueSymbolId(moduleSymbol, checker); - var cached = cachedImportDeclarations[moduleSymbolId]; - if (!cached) { - cached = cachedImportDeclarations[moduleSymbolId] = ts.mapDefined(imports, function (moduleSpecifier) { - var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 243 || i.kind === 242) - && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; - }); - } - return cached; + return ts.mapDefined(imports, function (moduleSpecifier) { + var i = ts.importFromModuleSpecifier(moduleSpecifier); + return (i.kind === 244 || i.kind === 243) + && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; + }); } function getCodeActionForNewImport(context, _a) { var moduleSpecifier = _a.moduleSpecifier, importKind = _a.importKind; @@ -84111,21 +84739,7 @@ var ts; }); return ts.flatten(choicesForEachExportingModule.sort(function (a, b) { return ts.first(a).moduleSpecifier.length - ts.first(b).moduleSpecifier.length; })); } - function getCodeActionsForAddImport(exportInfos, ctx, existingImports, useExisting, addNew) { - var fromExistingImport = ts.firstDefined(existingImports, function (_a) { - var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 243 && declaration.importClause) { - var changes = tryUpdateExistingImport(ctx, ts.isImportClause(declaration.importClause) && declaration.importClause || undefined, importKind); - if (changes) { - var moduleSpecifierWithoutQuotes = ts.stripQuotes(declaration.moduleSpecifier.getText()); - return createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [ctx.symbolName, moduleSpecifierWithoutQuotes], changes); - } - } - }); - if (fromExistingImport) { - useExisting.push(fromExistingImport); - return; - } + function getCodeActionsForAddImport(exportInfos, ctx, existingImports, addNew) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); var newImportInfos = existingDeclaration ? [existingDeclaration] @@ -84137,9 +84751,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 243 + var expression = declaration.kind === 244 ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 253 + : declaration.moduleReference.kind === 254 ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -84147,7 +84761,7 @@ var ts; function tryUpdateExistingImport(context, importClause, importKind) { var symbolName = context.symbolName, sourceFile = context.sourceFile; var name = importClause.name; - var namedBindings = (importClause.kind !== 242 && importClause).namedBindings; + var namedBindings = (importClause.kind !== 243 && importClause).namedBindings; switch (importKind) { case 1: return name ? undefined : ChangeTracker.with(context, function (t) { @@ -84155,10 +84769,10 @@ var ts; }); case 0: { var newImportSpecifier_1 = ts.createImportSpecifier(undefined, ts.createIdentifier(symbolName)); - if (namedBindings && namedBindings.kind === 246 && namedBindings.elements.length !== 0) { + if (namedBindings && namedBindings.kind === 247 && namedBindings.elements.length !== 0) { return ChangeTracker.with(context, function (t) { return t.insertNodeInListAfter(sourceFile, namedBindings.elements[namedBindings.elements.length - 1], newImportSpecifier_1); }); } - if (!namedBindings || namedBindings.kind === 246 && namedBindings.elements.length === 0) { + if (!namedBindings || namedBindings.kind === 247 && namedBindings.elements.length === 0) { return ChangeTracker.with(context, function (t) { return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamedImports([newImportSpecifier_1]))); }); @@ -84182,11 +84796,6 @@ var ts; }); return createCodeAction(ts.Diagnostics.Change_0_to_1, [symbolName, namespacePrefix + "." + symbolName], changes); } - function getImportCodeActions(context) { - return context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code - ? getActionsForUMDImport(context) - : getActionsForNonUMDImport(context); - } function getActionsForUMDImport(context) { var token = ts.getTokenAtPosition(context.sourceFile, context.span.start, false); var checker = context.program.getTypeChecker(); @@ -84197,7 +84806,7 @@ var ts; if (!ts.isUMDExportSymbol(umdSymbol)) { var parent = token.parent; var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(parent); - if ((ts.isJsxOpeningLikeElement && parent.tagName === token) || parent.kind === 259) { + if ((ts.isJsxOpeningLikeElement && parent.tagName === token) || parent.kind === 260) { umdSymbol = checker.resolveName(checker.getJsxNamespace(parent), isNodeOpeningLikeElement ? parent.tagName : parent, 67216319, false); } } @@ -84240,7 +84849,14 @@ var ts; if (!symbolName) return undefined; ts.Debug.assert(symbolName !== "default"); - var currentTokenMeaning = ts.getMeaningFromLocation(symbolToken); + var addToExistingDeclaration = []; + var addNewDeclaration = []; + getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).forEach(function (exportInfos) { + getCodeActionsForImport_separateExistingAndNew(exportInfos, convertToImportCodeFixContext(context, symbolToken, symbolName), addToExistingDeclaration, addNewDeclaration); + }); + return addToExistingDeclaration.concat(addNewDeclaration); + } + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { var originalSymbolToExportInfos = ts.createMultiMap(); function addSymbol(moduleSymbol, exportedSymbol, importKind) { originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind }); @@ -84261,7 +84877,7 @@ var ts; addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0); } function getEscapedNameForExportDefault(symbol) { - return ts.firstDefined(symbol.declarations, function (declaration) { + return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { if (ts.isExportAssignment(declaration)) { if (ts.isIdentifier(declaration.expression)) { return declaration.expression.escapedText; @@ -84269,19 +84885,12 @@ var ts; } else if (ts.isExportSpecifier(declaration)) { ts.Debug.assert(declaration.name.escapedText === "default"); - if (declaration.propertyName) { - return declaration.propertyName.escapedText; - } + return declaration.propertyName && declaration.propertyName.escapedText; } }); } }); - var addToExistingDeclaration = []; - var addNewDeclaration = []; - originalSymbolToExportInfos.forEach(function (exportInfos) { - getCodeActionsForImport_separateExistingAndNew(exportInfos, convertToImportCodeFixContext(context, symbolToken, symbolName), addToExistingDeclaration, addNewDeclaration); - }); - return addToExistingDeclaration.concat(addNewDeclaration); + return originalSymbolToExportInfos; } function checkSymbolHasMeaning(_a, meaning) { var declarations = _a.declarations; @@ -84303,7 +84912,7 @@ var ts; for (var _b = 0, allSourceFiles_1 = allSourceFiles; _b < allSourceFiles_1.length; _b++) { var sourceFile = allSourceFiles_1[_b]; if (ts.isExternalOrCommonJsModule(sourceFile)) { - cb(sourceFile.symbol, sourceFile); + cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile); } } } @@ -84505,7 +85114,7 @@ var ts; } function addMissingMemberInJs(changeTracker, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 204) { + if (classDeclaration.kind === 205) { return; } var className = classDeclaration.name.getText(); @@ -84531,7 +85140,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 199) { + if (token.parent.parent.kind === 200) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); @@ -84576,7 +85185,13 @@ var ts; } function addMethodDeclaration(changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(callExpression, token.text, inJs, makeStatic, preferences); - changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); + var containingMethodDeclaration = ts.getAncestor(callExpression, 154); + if (containingMethodDeclaration && containingMethodDeclaration.parent === classDeclaration) { + changeTracker.insertNodeAfter(classDeclarationSourceFile, containingMethodDeclaration, methodDeclaration); + } + else { + changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); + } } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -84817,7 +85432,9 @@ var ts; }, fixIds: [fixId], getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - doChange(changes, context.sourceFile, getInfo(diag.file, diag.start, diag.code)); + var info = getInfo(diag.file, diag.start, diag.code); + if (info) + doChange(changes, context.sourceFile, info); }); }, }); function getInfo(sourceFile, pos, diagCode) { @@ -84846,23 +85463,30 @@ var ts; ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code, ts.Diagnostics.All_imports_in_import_declaration_are_unused.code, ts.Diagnostics.All_destructured_elements_are_unused.code, + ts.Diagnostics.All_variables_are_unused.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var errorCode = context.errorCode, sourceFile = context.sourceFile; - var importDecl = tryGetFullImport(sourceFile, context.span.start); + var errorCode = context.errorCode, sourceFile = context.sourceFile, program = context.program; + var checker = program.getTypeChecker(); + var startToken = ts.getTokenAtPosition(sourceFile, context.span.start, false); + var importDecl = tryGetFullImport(startToken); if (importDecl) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.deleteNode(sourceFile, importDecl); }); return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Remove_import_from_0, ts.showModuleSpecifier(importDecl)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } - var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, context.span.start, undefined); }); + var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, startToken, undefined, checker, false); }); if (delDestructure.length) { return [codefix.createCodeFixAction(fixName, delDestructure, ts.Diagnostics.Remove_destructuring, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } + var delVar = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullVariableStatement(t, sourceFile, startToken, undefined); }); + if (delVar.length) { + return [codefix.createCodeFixAction(fixName, delVar, ts.Diagnostics.Remove_variable_statement, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; + } var token = getToken(sourceFile, ts.textSpanEnd(context.span)); var result = []; - var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, undefined); }); + var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, undefined, checker, false); }); if (deletion.length) { result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, token.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)); } @@ -84874,9 +85498,11 @@ var ts; }, fixIds: [fixIdPrefix, fixIdDelete], getAllCodeActions: function (context) { - var deleted = new NodeSet(); + var deleted = new ts.NodeSet(); + var sourceFile = context.sourceFile, program = context.program; + var checker = program.getTypeChecker(); return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var sourceFile = context.sourceFile; + var startToken = ts.getTokenAtPosition(sourceFile, diag.start, false); var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file); switch (context.fixId) { case fixIdPrefix: @@ -84887,14 +85513,13 @@ var ts; case fixIdDelete: if (deleted.some(function (d) { return ts.rangeContainsPosition(d, diag.start); })) break; - var importDecl = tryGetFullImport(diag.file, diag.start); + var importDecl = tryGetFullImport(startToken); if (importDecl) { changes.deleteNode(sourceFile, importDecl); } - else { - if (!tryDeleteFullDestructure(changes, sourceFile, diag.start, deleted)) { - tryDeleteDeclaration(changes, sourceFile, token, deleted); - } + else if (!tryDeleteFullDestructure(changes, sourceFile, startToken, deleted, checker, true) && + !tryDeleteFullVariableStatement(changes, sourceFile, startToken, deleted)) { + tryDeleteDeclaration(changes, sourceFile, token, deleted, checker, true); } break; default: @@ -84903,25 +85528,25 @@ var ts; }); }, }); - function tryGetFullImport(sourceFile, pos) { - var startToken = ts.getTokenAtPosition(sourceFile, pos, false); + function tryGetFullImport(startToken) { return startToken.kind === 91 ? ts.tryCast(startToken.parent, ts.isImportDeclaration) : undefined; } - function tryDeleteFullDestructure(changes, sourceFile, pos, deletedAncestors) { - var startToken = ts.getTokenAtPosition(sourceFile, pos, false); + function tryDeleteFullDestructure(changes, sourceFile, startToken, deletedAncestors, checker, isFixAll) { if (startToken.kind !== 17 || !ts.isObjectBindingPattern(startToken.parent)) return false; - var decl = startToken.parent.parent; + var decl = ts.cast(startToken.parent, ts.isObjectBindingPattern).parent; switch (decl.kind) { - case 231: + case 232: tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors); break; - case 148: + case 149: + if (!mayDeleteParameter(decl, checker, isFixAll)) + break; if (deletedAncestors) deletedAncestors.add(decl); changes.deleteNodeInList(sourceFile, decl); break; - case 181: + case 182: if (deletedAncestors) deletedAncestors.add(decl); changes.deleteNode(sourceFile, decl); @@ -84931,6 +85556,16 @@ var ts; } return true; } + function tryDeleteFullVariableStatement(changes, sourceFile, startToken, deletedAncestors) { + var declarationList = ts.tryCast(startToken.parent, ts.isVariableDeclarationList); + if (declarationList && declarationList.getChildren(sourceFile)[0] === startToken) { + if (deletedAncestors) + deletedAncestors.add(declarationList); + changes.deleteNode(sourceFile, declarationList.parent.kind === 214 ? declarationList.parent : declarationList); + return true; + } + return false; + } function getToken(sourceFile, pos) { var token = ts.findPrecedingToken(pos, sourceFile, undefined, true); return token.kind === 22 ? ts.findPrecedingToken(pos - 1, sourceFile) : token; @@ -84942,26 +85577,26 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 148: + case 149: return true; - case 231: { + case 232: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { + case 222: case 221: - case 220: return true; } } } return false; } - function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors) { + function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { switch (token.kind) { case 71: - tryDeleteIdentifier(changes, sourceFile, token, deletedAncestors); + tryDeleteIdentifier(changes, sourceFile, token, deletedAncestors, checker, isFixAll); break; - case 151: - case 245: + case 152: + case 246: if (deletedAncestors) deletedAncestors.add(token.parent); changes.deleteNode(sourceFile, token.parent); @@ -84982,13 +85617,13 @@ var ts; changes.deleteNode(sourceFile, token.parent.parent); } } - function tryDeleteIdentifier(changes, sourceFile, identifier, deletedAncestors) { + function tryDeleteIdentifier(changes, sourceFile, identifier, deletedAncestors, checker, isFixAll) { var parent = identifier.parent; switch (parent.kind) { - case 231: + case 232: tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors); break; - case 147: + case 148: var typeParameters = ts.getEffectiveTypeParameterDeclarations(parent.parent); if (typeParameters.length === 1) { var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end; @@ -85002,11 +85637,10 @@ var ts; changes.deleteNodeInList(sourceFile, parent); } break; - case 148: - var oldFunction = parent.parent; - if (ts.isSetAccessor(oldFunction)) { + case 149: + if (!mayDeleteParameter(parent, checker, isFixAll)) break; - } + var oldFunction = parent.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) { var newFunction = ts.updateArrowFunction(oldFunction, oldFunction.modifiers, oldFunction.typeParameters, undefined, oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); ts.suppressLeadingAndTrailingTrivia(newFunction); @@ -85016,13 +85650,13 @@ var ts; changes.deleteNodeInList(sourceFile, parent); } break; - case 181: { + case 182: { var pattern = parent.parent; switch (pattern.kind) { - case 180: + case 181: changes.deleteNode(sourceFile, parent); break; - case 179: + case 180: changes.deleteNodeInList(sourceFile, parent); break; default: @@ -85030,11 +85664,11 @@ var ts; } break; } - case 242: - var importEquals = ts.getAncestor(identifier, 242); + case 243: + var importEquals = ts.getAncestor(identifier, 243); changes.deleteNode(sourceFile, importEquals); break; - case 247: + case 248: var namedImports = parent.parent; if (namedImports.elements.length === 1) { tryDeleteNamedImportBinding(changes, sourceFile, namedImports); @@ -85043,10 +85677,10 @@ var ts; changes.deleteNodeInList(sourceFile, parent); } break; - case 244: + case 245: var importClause = parent; if (!importClause.namedBindings) { - changes.deleteNode(sourceFile, ts.getAncestor(importClause, 243)); + changes.deleteNode(sourceFile, ts.getAncestor(importClause, 244)); } else { var start = importClause.name.getStart(sourceFile); @@ -85060,7 +85694,7 @@ var ts; } } break; - case 245: + case 246: tryDeleteNamedImportBinding(changes, sourceFile, parent); break; default: @@ -85076,13 +85710,13 @@ var ts; } } else { - var importDecl = ts.getAncestor(namedBindings, 243); + var importDecl = ts.getAncestor(namedBindings, 244); changes.deleteNode(sourceFile, importDecl); } } function tryDeleteVariableDeclaration(changes, sourceFile, varDecl, deletedAncestors) { switch (varDecl.parent.parent.kind) { - case 219: { + case 220: { var forStatement = varDecl.parent.parent; var forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { @@ -85097,16 +85731,16 @@ var ts; } break; } - case 221: + case 222: var forOfStatement = varDecl.parent.parent; - ts.Debug.assert(forOfStatement.initializer.kind === 232); + ts.Debug.assert(forOfStatement.initializer.kind === 233); var forOfInitializer = forOfStatement.initializer; if (deletedAncestors) deletedAncestors.add(forOfInitializer.declarations[0]); changes.replaceNode(sourceFile, forOfInitializer.declarations[0], ts.createObjectLiteral()); break; - case 220: - case 229: + case 221: + case 230: break; default: var variableStatement = varDecl.parent.parent; @@ -85122,18 +85756,30 @@ var ts; } } } - var NodeSet = (function () { - function NodeSet() { - this.map = ts.createMap(); + function mayDeleteParameter(p, checker, isFixAll) { + var parent = p.parent; + switch (parent.kind) { + case 154: + var symbol = checker.getSymbolAtLocation(parent.name); + if (ts.isMemberSymbolInBaseType(symbol, checker)) + return false; + case 155: + case 234: + case 192: + case 193: { + var parameters = parent.parameters; + var index = parameters.indexOf(p); + ts.Debug.assert(index !== -1); + return isFixAll + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 71 && !p.symbol.isReferenced; }) + : index === parameters.length - 1; + } + case 157: + return false; + default: + return ts.Debug.failBadSyntaxKind(parent); } - NodeSet.prototype.add = function (node) { - this.map.set(String(ts.getNodeId(node)), node); - }; - NodeSet.prototype.some = function (pred) { - return ts.forEachEntry(this.map, pred) || false; - }; - return NodeSet; - }()); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; @@ -85157,7 +85803,7 @@ var ts; ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; switch (container.kind) { - case 216: + case 217: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { changes.deleteNodeRange(sourceFile, ts.first(statement.parent.statements), ts.last(statement.parent.statements)); @@ -85167,8 +85813,8 @@ var ts; } break; } - case 218: case 219: + case 220: changes.deleteNode(sourceFile, container); break; default: @@ -85186,13 +85832,15 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 235: case 236: - return true; - case 238: - return ts.getModuleInstanceState(s) !== 1; case 237: + return true; + case 239: + return ts.getModuleInstanceState(s) !== 1; + case 238: return ts.hasModifier(s, 2048); + default: + return false; } } function sliceAfter(arr, value) { @@ -85249,8 +85897,8 @@ 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 === 280) { - actions.push(fix(checker.getNullableType(type, 4096), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + if (typeNode.kind === 281) { + actions.push(fix(checker.getNullableType(type, 8192), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -85267,7 +85915,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 280 && fixId === fixIdNullable ? checker.getNullableType(type, 4096) : type; + var fixedType = typeNode.kind === 281 && fixId === fixIdNullable ? checker.getNullableType(type, 8192) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -85282,22 +85930,22 @@ var ts; } function isTypeContainer(node) { switch (node.kind) { - case 207: - case 157: + case 208: case 158: - case 233: - case 155: case 159: - case 176: - case 153: - case 152: - case 148: - case 151: - case 150: + case 234: case 156: - case 236: - case 189: - case 231: + case 160: + case 177: + case 154: + case 153: + case 149: + case 152: + case 151: + case 157: + case 237: + case 190: + case 232: return true; default: return false; @@ -85350,20 +85998,20 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 153: + case 154: insertBefore = containingFunction.name; break; - case 233: - case 191: + case 234: + case 192: insertBefore = ts.findChildOfKind(containingFunction, 89, sourceFile); break; - case 192: + case 193: insertBefore = ts.findChildOfKind(containingFunction, 19, sourceFile) || ts.first(containingFunction.parameters); break; default: return; } - return { + return insertBefore && { insertBefore: insertBefore, returnType: getReturnType(containingFunction) }; @@ -85453,15 +86101,15 @@ var ts; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216); switch (declaration.kind) { - case 155: case 156: - case 150: + case 157: case 151: + case 152: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration); out(ts.createProperty(undefined, modifiers, name, optional ? ts.createToken(55) : undefined, typeNode, undefined)); break; - case 152: case 153: + case 154: var signatures = checker.getSignaturesOfType(type, 0); if (!ts.some(signatures)) { break; @@ -85493,7 +86141,7 @@ var ts; } } function signatureToMethodDeclaration(checker, signature, enclosingDeclaration, modifiers, name, optional, body) { - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 153, enclosingDeclaration, 256); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 154, enclosingDeclaration, 256); if (!signatureDeclaration) { return undefined; } @@ -85670,11 +86318,11 @@ var ts; } function isApplicableFunctionForInference(declaration) { switch (declaration.kind) { - case 233: - case 153: + case 234: case 154: + case 155: return true; - case 191: + case 192: return !!declaration.name; } return false; @@ -85730,11 +86378,11 @@ var ts; } function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { switch (containingFunction.kind) { + case 155: + case 192: + case 234: case 154: - case 191: - case 233: - case 153: - var isConstructor = containingFunction.kind === 154; + var isConstructor = containingFunction.kind === 155; var searchToken = isConstructor ? ts.findChildOfKind(containingFunction, 123, sourceFile) : containingFunction.name; @@ -85768,7 +86416,7 @@ var ts; cancellationToken.throwIfCancellationRequested(); inferTypeFromContext(reference, checker, usageContext); } - var isConstructor = declaration.kind === 154; + var isConstructor = declaration.kind === 155; var callContexts = isConstructor ? usageContext.constructContexts : usageContext.callContexts; return callContexts && declaration.parameters.map(function (parameter, parameterIndex) { var types = []; @@ -85800,21 +86448,21 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 198: + case 199: usageContext.isNumber = true; break; - case 197: + case 198: inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); break; - case 199: + case 200: inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); break; - case 265: case 266: + case 267: inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); break; - case 186: case 187: + case 188: if (node.parent.expression === node) { inferTypeFromCallExpressionContext(node.parent, checker, usageContext); } @@ -85822,13 +86470,13 @@ var ts; inferTypeFromContextualType(node, checker, usageContext); } break; - case 184: + case 185: inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); break; - case 185: + case 186: inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); break; - case 231: { + case 232: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { @@ -85888,7 +86536,7 @@ var ts; case 29: case 31: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 272) { + if (operandType.flags & 544) { addCandidateType(usageContext, operandType); } else { @@ -85898,13 +86546,13 @@ var ts; case 59: case 37: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 272) { + if (otherOperandType.flags & 544) { addCandidateType(usageContext, otherOperandType); } - else if (otherOperandType.flags & 84) { + else if (otherOperandType.flags & 168) { usageContext.isNumber = true; } - else if (otherOperandType.flags & 34) { + else if (otherOperandType.flags & 68) { usageContext.isString = true; } else { @@ -85925,7 +86573,7 @@ var ts; break; case 54: if (node === parent.left && - (node.parent.parent.kind === 231 || ts.isAssignmentExpression(node.parent.parent, true))) { + (node.parent.parent.kind === 232 || ts.isAssignmentExpression(node.parent.parent, true))) { addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); } break; @@ -85950,7 +86598,7 @@ var ts; } } inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 186) { + if (parent.kind === 187) { (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); } else { @@ -85975,7 +86623,7 @@ var ts; var indexType = checker.getTypeAtLocation(parent); var indexUsageContext = {}; inferTypeFromContext(parent, checker, indexUsageContext); - if (indexType.flags & 84) { + if (indexType.flags & 168) { usageContext.numberIndexContext = indexUsageContext; } else { @@ -86073,12 +86721,12 @@ var ts; return checker.createSignature(undefined, undefined, undefined, parameters, returnType, undefined, callContext.argumentTypes.length, false, false); } function addCandidateType(context, type) { - if (type && !(type.flags & 1) && !(type.flags & 16384)) { + if (type && !(type.flags & 1) && !(type.flags & 32768)) { (context.candidateTypes || (context.candidateTypes = [])).push(type); } } function hasCallContext(usageContext) { - return usageContext && usageContext.callContexts; + return !!usageContext && !!usageContext.callContexts; } })(InferFromReference || (InferFromReference = {})); })(codefix = ts.codefix || (ts.codefix = {})); @@ -86105,7 +86753,7 @@ var ts; var namespace = ts.getNamespaceDeclarationNode(node); var opts = context.program.getCompilerOptions(); var variations = []; - variations.push(createAction(context, sourceFile, node, ts.makeImport(namespace.name, undefined, node.moduleSpecifier))); + variations.push(createAction(context, sourceFile, node, ts.makeImport(namespace.name, undefined, node.moduleSpecifier, context.preferences))); if (ts.getEmitModuleKind(opts) === ts.ModuleKind.CommonJS) { variations.push(createAction(context, sourceFile, node, ts.createImportEqualsDeclaration(undefined, undefined, namespace.name, ts.createExternalModuleReference(node.moduleSpecifier)))); } @@ -86124,7 +86772,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 186 : 187; + var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 187 : 188; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start, false), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; @@ -86211,8 +86859,9 @@ var ts; } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { var undefinedTypeNode = ts.createKeywordTypeNode(140); - var types = ts.isUnionTypeNode(propertyDeclaration.type) ? propertyDeclaration.type.types.concat(undefinedTypeNode) : [propertyDeclaration.type, undefinedTypeNode]; - changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration.type, ts.createUnionTypeNode(types)); + var type = propertyDeclaration.type; + var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; + changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.createUnionTypeNode(types)); } function getActionForAddMissingInitializer(context, propertyDeclaration) { var checker = context.program.getTypeChecker(); @@ -86230,13 +86879,13 @@ var ts; return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); } function getDefaultValueFromType(checker, type) { - if (type.flags & 2) { + if (type.flags & 4) { return ts.createLiteral(""); } - else if (type.flags & 4) { + else if (type.flags & 8) { return ts.createNumericLiteral("0"); } - else if (type.flags & 8) { + else if (type.flags & 16) { return ts.createFalse(); } else if (type.isLiteral()) { @@ -86262,50 +86911,69 @@ var ts; (function (ts) { var moduleSpecifiers; (function (moduleSpecifiers) { - function getModuleSpecifiers(moduleSymbol, program, importingSourceFile, host, preferences) { + function getModuleSpecifier(program, fromSourceFile, fromSourceFileName, toFileName, host, preferences) { + var info = getInfo(program.getCompilerOptions(), fromSourceFile, fromSourceFileName, host); var compilerOptions = program.getCompilerOptions(); - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); - var addJsExtension = usesJsExtensionOnImports(importingSourceFile); - var getCanonicalFileName = ts.hostGetCanonicalFileName(host); - var sourceDirectory = ts.getDirectoryPath(importingSourceFile.fileName); - return getAllModulePaths(program, moduleSymbol.valueDeclaration.getSourceFile()).map(function (moduleFileName) { - var global = tryGetModuleNameFromAmbientModule(moduleSymbol) - || tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) - || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) - || rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); - if (global) { - return [global]; - } - var relativePath = removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); - if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { - return [relativePath]; - } - var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName); - if (!relativeToBaseUrl) { - return [relativePath]; - } - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, moduleResolutionKind, addJsExtension); - if (paths) { - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - if (fromPaths) { - return [fromPaths]; - } - } - if (preferences.importModuleSpecifierPreference === "non-relative") { - return [importRelativeToBaseUrl]; - } - if (preferences.importModuleSpecifierPreference !== undefined) - ts.Debug.assertNever(preferences.importModuleSpecifierPreference); - if (isPathRelativeToParent(relativeToBaseUrl)) { - return [relativePath]; - } - var pathFromSourceToBaseUrl = ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, baseUrl, getCanonicalFileName)); - var relativeFirst = getRelativePathNParents(relativePath) < getRelativePathNParents(pathFromSourceToBaseUrl); - return relativeFirst ? [relativePath, importRelativeToBaseUrl] : [importRelativeToBaseUrl, relativePath]; + return getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || + ts.first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); + } + moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; + function getModuleSpecifiers(moduleSymbol, program, importingSourceFile, host, preferences) { + var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); + if (ambient) + return [[ambient]]; + var compilerOptions = program.getCompilerOptions(); + var info = getInfo(compilerOptions, importingSourceFile, importingSourceFile.fileName, host); + var modulePaths = getAllModulePaths(program, moduleSymbol.valueDeclaration.getSourceFile()); + var global = ts.mapDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }); + return global.length ? global.map(function (g) { return [g]; }) : modulePaths.map(function (moduleFileName) { + return getLocalModuleSpecifiers(moduleFileName, info, compilerOptions, preferences); }); } moduleSpecifiers.getModuleSpecifiers = getModuleSpecifiers; + function getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host) { + var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); + var addJsExtension = usesJsExtensionOnImports(importingSourceFile); + var getCanonicalFileName = ts.hostGetCanonicalFileName(host); + var sourceDirectory = ts.getDirectoryPath(importingSourceFileName); + return { moduleResolutionKind: moduleResolutionKind, addJsExtension: addJsExtension, getCanonicalFileName: getCanonicalFileName, sourceDirectory: sourceDirectory }; + } + function getGlobalModuleSpecifier(moduleFileName, _a, host, compilerOptions) { + var addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; + return tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) + || compilerOptions.rootDirs && tryGetModuleNameFromRootDirs(compilerOptions.rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); + } + function getLocalModuleSpecifiers(moduleFileName, _a, compilerOptions, preferences) { + var moduleResolutionKind = _a.moduleResolutionKind, addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var relativePath = removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); + if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { + return [relativePath]; + } + var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName); + if (!relativeToBaseUrl) { + return [relativePath]; + } + var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, moduleResolutionKind, addJsExtension); + if (paths) { + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); + if (fromPaths) { + return [fromPaths]; + } + } + if (preferences.importModuleSpecifierPreference === "non-relative") { + return [importRelativeToBaseUrl]; + } + if (preferences.importModuleSpecifierPreference !== undefined) + ts.Debug.assertNever(preferences.importModuleSpecifierPreference); + if (isPathRelativeToParent(relativeToBaseUrl)) { + return [relativePath]; + } + var pathFromSourceToBaseUrl = ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, baseUrl, getCanonicalFileName)); + var relativeFirst = getRelativePathNParents(relativePath) < getRelativePathNParents(pathFromSourceToBaseUrl); + return relativeFirst ? [relativePath, importRelativeToBaseUrl] : [importRelativeToBaseUrl, relativePath]; + } function usesJsExtensionOnImports(_a) { var imports = _a.imports; return ts.firstDefined(imports, function (_a) { @@ -86390,8 +87058,9 @@ var ts; return undefined; } var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); - moduleSpecifier = getNodeResolvablePath(moduleSpecifier); - return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier); + if (!ts.startsWith(sourceDirectory, moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex))) + return undefined; + return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); function getDirectoryOrExtensionlessFileName(path) { var packageRootPath = path.substring(0, parts.packageRootIndex); var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); @@ -86413,15 +87082,6 @@ var ts; } return fullModulePathWithoutExtension; } - function getNodeResolvablePath(path) { - var basePath = path.substring(0, parts.topLevelNodeModulesIndex); - if (sourceDirectory.indexOf(basePath) === 0) { - return path.substring(parts.topLevelPackageNameIndex + 1); - } - else { - return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, path, getCanonicalFileName)); - } - } } function getNodeModulePathParts(fullPath) { var topLevelNodeModulesIndex = 0; @@ -86538,14 +87198,14 @@ var ts; var info = getInfo(sourceFile, start); if (!info) return undefined; - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info, context.preferences); }); return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_default_import, fixId, ts.Diagnostics.Convert_all_to_default_imports)]; }, fixIds: [fixId], getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { var info = getInfo(diag.file, diag.start); if (info) - doChange(changes, diag.file, info); + doChange(changes, diag.file, info, context.preferences); }); }, }); function getInfo(sourceFile, pos) { @@ -86561,8 +87221,8 @@ var ts; return { importNode: importNode, name: name, moduleSpecifier: importNode.moduleSpecifier }; } } - function doChange(changes, sourceFile, info) { - changes.replaceNode(sourceFile, info.importNode, ts.makeImport(info.name, undefined, info.moduleSpecifier)); + function doChange(changes, sourceFile, info, preferences) { + changes.replaceNode(sourceFile, info.importNode, ts.makeImport(info.name, undefined, info.moduleSpecifier, preferences)); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -86589,7 +87249,7 @@ var ts; function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos, false); ts.Debug.assert(token.kind === 91); - ts.Debug.assert(token.parent.kind === 178); + ts.Debug.assert(token.parent.kind === 179); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -86599,6 +87259,182 @@ var ts; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixIdAddMissingTypeof = "fixConvertToMappedObjectType"; + var fixId = fixIdAddMissingTypeof; + var errorCodes = [ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span; + var info = getInfo(sourceFile, span.start); + if (!info) + return undefined; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info); }); + var name = ts.idText(info.container.name); + return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Convert_0_to_mapped_object_type, name], fixId, [ts.Diagnostics.Convert_0_to_mapped_object_type, name])]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var info = getInfo(diag.file, diag.start); + if (info) + doChange(changes, diag.file, info); + }); } + }); + function getInfo(sourceFile, pos) { + var token = ts.getTokenAtPosition(sourceFile, pos, false); + var indexSignature = ts.cast(token.parent.parent, ts.isIndexSignatureDeclaration); + if (ts.isClassDeclaration(indexSignature.parent)) + return undefined; + var container = ts.isInterfaceDeclaration(indexSignature.parent) ? indexSignature.parent : ts.cast(indexSignature.parent.parent, ts.isTypeAliasDeclaration); + return { indexSignature: indexSignature, container: container }; + } + function createTypeAliasFromInterface(declaration, type) { + return ts.createTypeAliasDeclaration(declaration.decorators, declaration.modifiers, declaration.name, declaration.typeParameters, type); + } + function doChange(changes, sourceFile, _a) { + var indexSignature = _a.indexSignature, container = _a.container; + var members = ts.isInterfaceDeclaration(container) ? container.members : container.type.members; + var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); + var parameter = ts.first(indexSignature.parameters); + var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(132) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ + mappedIntersectionType + ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); + changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var refactor; + (function (refactor) { + var generateGetAccessorAndSetAccessor; + (function (generateGetAccessorAndSetAccessor) { + var refactorName = "Convert import"; + var actionNameNamespaceToNamed = "Convert namespace import to named imports"; + var actionNameNamedToNamespace = "Convert named imports to namespace import"; + refactor.registerRefactor(refactorName, { + getAvailableActions: function (context) { + var i = getImportToConvert(context); + if (!i) + return undefined; + var description = i.kind === 246 ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 246 ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; + }, + getEditsForAction: function (context, actionName) { + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + } + }); + function getImportToConvert(context) { + var file = context.file; + var span = ts.getRefactorContextSpan(context); + var token = ts.getTokenAtPosition(file, span.start, false); + var importDecl = ts.getParentNodeInSpan(token, file, span); + if (!importDecl || !ts.isImportDeclaration(importDecl)) + return undefined; + var importClause = importDecl.importClause; + return importClause && importClause.namedBindings; + } + function doChange(sourceFile, program, changes, toConvert) { + var checker = program.getTypeChecker(); + if (toConvert.kind === 246) { + doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); + } + else { + doChangeNamedToNamespace(sourceFile, checker, changes, toConvert); + } + } + function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { + var usedAsNamespaceOrDefault = false; + var nodesToReplace = []; + var conflictingNames = ts.createMap(); + ts.FindAllReferences.Core.eachSymbolReferenceInFile(toConvert.name, checker, sourceFile, function (id) { + if (!ts.isPropertyAccessExpression(id.parent)) { + usedAsNamespaceOrDefault = true; + } + else { + var parent = ts.cast(id.parent, ts.isPropertyAccessExpression); + var exportName = parent.name.text; + if (checker.resolveName(exportName, id, 67108863, true)) { + conflictingNames.set(exportName, true); + } + ts.Debug.assert(parent.expression === id); + nodesToReplace.push(parent); + } + }); + var exportNameToImportName = ts.createMap(); + for (var _i = 0, nodesToReplace_1 = nodesToReplace; _i < nodesToReplace_1.length; _i++) { + var propertyAccess = nodesToReplace_1[_i]; + var exportName = propertyAccess.name.text; + var importName = exportNameToImportName.get(exportName); + if (importName === undefined) { + exportNameToImportName.set(exportName, importName = conflictingNames.has(exportName) ? ts.getUniqueName(exportName, sourceFile) : exportName); + } + changes.replaceNode(sourceFile, propertyAccess, ts.createIdentifier(importName)); + } + var importSpecifiers = []; + exportNameToImportName.forEach(function (name, propertyName) { + importSpecifiers.push(ts.createImportSpecifier(name === propertyName ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name))); + }); + var importDecl = toConvert.parent.parent; + if (usedAsNamespaceOrDefault && !allowSyntheticDefaultImports) { + changes.insertNodeAfter(sourceFile, importDecl, updateImport(importDecl, undefined, importSpecifiers)); + } + else { + changes.replaceNode(sourceFile, importDecl, updateImport(importDecl, usedAsNamespaceOrDefault ? ts.createIdentifier(toConvert.name.text) : undefined, importSpecifiers)); + } + } + function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) { + var importDecl = toConvert.parent.parent; + var moduleSpecifier = importDecl.moduleSpecifier; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 6) : "module"; + var namespaceNameConflicts = toConvert.elements.some(function (element) { + return ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { + return !!checker.resolveName(preferredName, id, 67108863, true); + }) || false; + }); + var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; + var neededNamedImports = []; + var _loop_22 = function (element) { + var propertyName = (element.propertyName || element.name).text; + ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { + var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); + if (ts.isShorthandPropertyAssignment(id.parent)) { + changes.replaceNode(sourceFile, id.parent, ts.createPropertyAssignment(id.text, access)); + } + else if (ts.isExportSpecifier(id.parent) && !id.parent.propertyName) { + if (!neededNamedImports.some(function (n) { return n.name === element.name; })) { + neededNamedImports.push(ts.createImportSpecifier(element.propertyName && ts.createIdentifier(element.propertyName.text), ts.createIdentifier(element.name.text))); + } + } + else { + changes.replaceNode(sourceFile, id, access); + } + }); + }; + for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { + var element = _a[_i]; + _loop_22(element); + } + changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); + if (neededNamedImports.length) { + changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, undefined, neededNamedImports)); + } + } + function updateImport(old, defaultImportName, elements) { + return ts.createImportDeclaration(undefined, undefined, ts.createImportClause(defaultImportName, elements && elements.length ? ts.createNamedImports(elements) : undefined), old.moduleSpecifier); + } + })(generateGetAccessorAndSetAccessor = refactor.generateGetAccessorAndSetAccessor || (refactor.generateGetAccessorAndSetAccessor = {})); + })(refactor = ts.refactor || (ts.refactor = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var refactor; (function (refactor) { @@ -86723,8 +87559,8 @@ var ts; if (length === 0) { return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractEmpty)] }; } - var start = getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, false), sourceFile, span); - var end = getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); + var start = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, false), sourceFile, span); + var end = ts.getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); var declarations = []; var rangeFacts = RangeFacts.None; if (!start || !end) { @@ -86738,7 +87574,8 @@ var ts; return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } var statements = []; - for (var _i = 0, _a = start.parent.statements; _i < _a.length; _i++) { + var start2 = start; + for (var _i = 0, _a = start2.parent.statements; _i < _a.length; _i++) { var statement = _a[_i]; if (statement === start || statements.length) { var errors_1 = checkNode(statement); @@ -86801,20 +87638,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 151) { + if (current.kind === 152) { if (ts.hasModifier(current, 32)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 148) { + else if (current.kind === 149) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 154) { + if (ctorOrMethod.kind === 155) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 153) { + else if (current.kind === 154) { if (ts.hasModifier(current, 32)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -86852,7 +87689,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 231) ? node.parent.parent : node; + var declaringNode = (node.kind === 232) ? node.parent.parent : node; if (ts.hasModifier(declaringNode, 1)) { (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; @@ -86860,11 +87697,11 @@ var ts; declarations.push(node.symbol); } switch (node.kind) { - case 243: + case 244: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; case 97: - if (node.parent.kind === 186) { + if (node.parent.kind === 187) { var containingClass_1 = ts.getContainingClass(node); if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractSuper)); @@ -86876,10 +87713,10 @@ var ts; } break; } - if (!node || ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { + if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 233: case 234: + case 235: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); } @@ -86889,18 +87726,18 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 216: + case 217: permittedJumps = 0; break; - case 229: + case 230: permittedJumps = 0; break; - case 212: - if (node.parent && node.parent.kind === 229 && node.parent.finallyBlock === node) { + case 213: + if (node.parent && node.parent.kind === 230 && node.parent.finallyBlock === node) { permittedJumps = 4; } break; - case 265: + case 266: permittedJumps |= 1; break; default: @@ -86910,11 +87747,11 @@ var ts; break; } switch (node.kind) { - case 173: + case 174: case 99: rangeFacts |= RangeFacts.UsesThis; break; - case 227: + case 228: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); @@ -86922,8 +87759,8 @@ var ts; seenLabels.pop(); break; } + case 224: case 223: - case 222: { var label = node.label; if (label) { @@ -86932,19 +87769,19 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 223 ? 1 : 2))) { + if (!(permittedJumps & (node.kind === 224 ? 1 : 2))) { (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 196: + case 197: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 202: + case 203: rangeFacts |= RangeFacts.IsGenerator; break; - case 224: + case 225: if (permittedJumps & 4) { rangeFacts |= RangeFacts.HasReturn; } @@ -86987,12 +87824,12 @@ var ts; var scopes = []; while (true) { current = current.parent; - if (current.kind === 148) { + if (current.kind === 149) { current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } if (isScope(current)) { scopes.push(current); - if (current.kind === 273) { + if (current.kind === 274) { return scopes; } } @@ -87075,32 +87912,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 154: + case 155: return "constructor"; - case 191: - case 233: + case 192: + case 234: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 192: + case 193: return "arrow function"; - case 153: + case 154: return "method '" + scope.name.getText(); - case 155: - return "'get " + scope.name.getText() + "'"; case 156: + return "'get " + scope.name.getText() + "'"; + case 157: return "'set " + scope.name.getText() + "'"; default: - ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 234 + return scope.kind === 235 ? 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 === 239 + return scope.kind === 240 ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 : 1; } @@ -87113,7 +87950,7 @@ var ts; var usagesInScope = _a.usages, typeParameterUsages = _a.typeParameterUsages, substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); var file = scope.getSourceFile(); - var functionNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newMethod" : "newFunction", file.text); + var functionNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newMethod" : "newFunction", file); var isJS = ts.isInJavaScriptFile(scope); var functionName = ts.createIdentifier(functionNameText); var returnType; @@ -87279,7 +88116,7 @@ var ts; var substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); var file = scope.getSourceFile(); - var localNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file.text); + var localNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file); var isJS = ts.isInJavaScriptFile(scope); var variableType = isJS || !checker.isContextSensitive(node) ? undefined @@ -87312,7 +88149,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 215 && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 216 && scope === ts.findAncestor(node, isScope)) { var newVariableStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([newVariableDeclaration], 2)); changeTracker.replaceNode(context.file, node.parent, newVariableStatement); } @@ -87325,7 +88162,7 @@ var ts; else { changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, false); } - if (node.parent.kind === 215) { + if (node.parent.kind === 216) { changeTracker.deleteNode(context.file, node.parent, ts.textChanges.useNonAdjustedPositions); } else { @@ -87407,7 +88244,7 @@ var ts; return { body: ts.createBlock(statements, true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 224 && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 225 && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -87482,7 +88319,8 @@ var ts; } prevMember = member; } - ts.Debug.assert(prevMember !== undefined); + if (prevMember === undefined) + return ts.Debug.fail(); return prevMember; } function getNodeToInsertConstantBefore(node, scope) { @@ -87507,13 +88345,9 @@ var ts; ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent)); return curr.parent.parent; } - ts.Debug.assert(prevStatement !== undefined); - return prevStatement; - } - if (curr === scope) { - ts.Debug.fail("Didn't encounter a block-like before encountering scope"); - break; + return ts.Debug.assertDefined(prevStatement); } + ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } } function getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes) { @@ -87560,14 +88394,14 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (2048 | 16384)) { + else if (checker.getTypeAtLocation(expression).flags & (4096 | 32768)) { expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } for (var _i = 0, scopes_1 = scopes; _i < scopes_1.length; _i++) { var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 233 + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 234 ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -87619,7 +88453,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_19 = function (i) { + var _loop_23 = function (i) { var scopeUsages = usagesPerScope[i]; if (i > 0 && (scopeUsages.usages.size > 0 || scopeUsages.typeParameterUsages.size > 0)) { var errorNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range; @@ -87655,7 +88489,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_19(i); + _loop_23(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -87828,46 +88662,33 @@ var ts; : ts.createPropertyAccess(prefix, symbol.name); } } - function getParentNodeInSpan(node, file, span) { - if (!node) - return undefined; - while (node.parent) { - if (ts.isSourceFile(node.parent) || !spanContainsNode(span, node.parent, file)) { - return node; - } - node = node.parent; - } - } - function spanContainsNode(span, node, file) { - return ts.textSpanContainsPosition(span, node.getStart(file)) && - node.getEnd() <= ts.textSpanEnd(span); - } function isExtractableExpression(node) { - switch (node.parent.kind) { - case 272: + var parent = node.parent; + switch (parent.kind) { + case 273: return false; } switch (node.kind) { case 9: - return node.parent.kind !== 243 && - node.parent.kind !== 247; - case 203: - case 179: - case 181: + return parent.kind !== 244 && + parent.kind !== 248; + case 204: + case 180: + case 182: return false; case 71: - return node.parent.kind !== 181 && - node.parent.kind !== 247 && - node.parent.kind !== 251; + return parent.kind !== 182 && + parent.kind !== 248 && + parent.kind !== 252; } return true; } function isBlockLike(node) { switch (node.kind) { - case 212: - case 273: - case 239: - case 265: + case 213: + case 274: + case 240: + case 266: return true; default: return false; @@ -87941,7 +88762,7 @@ var ts; var renameLocation = renameLocationOffset + ts.getRenameLocation(edits, renameFilename, nameNeedRename.text, ts.isParameter(declaration)); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; } - function isConvertableName(name) { + function isConvertibleName(name) { return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { @@ -87967,17 +88788,17 @@ var ts; var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); var meaning = 28 | 32 | 64; if (!declaration || !ts.rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition) - || !isConvertableName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) + || !isConvertibleName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) return undefined; var name = declaration.name.text; var startWithUnderscore = startsWithUnderscore(name); - var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file.text), declaration.name); - var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file.text) : name, declaration.name); + var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file), declaration.name); + var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file) : name, declaration.name); return { isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 148 ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 149 ? declaration.parent.parent : declaration.parent, originalName: declaration.name, declaration: declaration, fieldName: fieldName, @@ -88025,7 +88846,9 @@ var ts; if (!constructor.body) return; var file = context.file, program = context.program, cancellationToken = context.cancellationToken; - var referenceEntries = ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(originalName.parent.pos, originalName, program, [file], cancellationToken), function (entry) { return ((entry.type === "node" && ts.rangeContainsRange(constructor, entry.node) && ts.isIdentifier(entry.node) && ts.isWriteAccess(entry.node)) ? entry.node : undefined); }); + var referenceEntries = ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(originalName.parent.pos, originalName, program, [file], cancellationToken), function (entry) { + return (entry.type === "node" && ts.rangeContainsRange(constructor, entry.node) && ts.isIdentifier(entry.node) && ts.isWriteAccess(entry.node)) ? entry.node : undefined; + }); ts.forEach(referenceEntries, function (entry) { var parent = entry.parent; var accessorName = ts.createIdentifier(fieldName.text); @@ -88047,7 +88870,7 @@ var ts; var refactorName = "Move to a new file"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { - if (!context.preferences.allowTextChangesInNewFiles || getFirstAndLastStatementToMove(context) === undefined) + if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined) return undefined; var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Move_to_a_new_file); return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; @@ -88055,55 +88878,63 @@ var ts; getEditsForAction: function (context, actionName) { ts.Debug.assert(actionName === refactorName); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); - function getFirstAndLastStatementToMove(context) { + function getRangeToMove(context) { var file = context.file; var range = ts.createTextRangeFromSpan(ts.getRefactorContextSpan(context)); var statements = file.statements; var startNodeIndex = ts.findIndex(statements, function (s) { return s.end > range.pos; }); if (startNodeIndex === -1) return undefined; - if (range.pos > statements[startNodeIndex].getStart(file)) + var startStatement = statements[startNodeIndex]; + if (ts.isNamedDeclaration(startStatement) && startStatement.name && ts.rangeContainsRange(startStatement.name, range)) { + return { toMove: [statements[startNodeIndex]], afterLast: statements[startNodeIndex + 1] }; + } + if (range.pos > startStatement.getStart(file)) return undefined; var afterEndNodeIndex = ts.findIndex(statements, function (s) { return s.end > range.end; }, startNodeIndex); if (afterEndNodeIndex !== -1 && (afterEndNodeIndex === 0 || statements[afterEndNodeIndex].getStart(file) < range.end)) return undefined; - return { first: startNodeIndex, afterLast: afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex }; + return { + toMove: statements.slice(startNodeIndex, afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex), + afterLast: afterEndNodeIndex === -1 ? undefined : statements[afterEndNodeIndex], + }; } - function doChange(oldFile, program, toMove, changes, host) { + function doChange(oldFile, program, toMove, changes, host, preferences) { var checker = program.getTypeChecker(); var usage = getUsageInfo(oldFile, toMove.all, checker); var currentDirectory = ts.getDirectoryPath(oldFile.fileName); var extension = ts.extensionFromPath(oldFile.fileName); var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host); var newFileNameWithExtension = newModuleName + extension; - changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatements(oldFile, usage, changes, toMove, program, newModuleName)); + changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences)); addNewFileToTsconfig(program, changes, oldFile.fileName, newFileNameWithExtension, ts.hostGetCanonicalFileName(host)); } function getStatementsToMove(context) { - var statements = context.file.statements; - var _a = getFirstAndLastStatementToMove(context), first = _a.first, afterLast = _a.afterLast; + var rangeToMove = getRangeToMove(context); + if (rangeToMove === undefined) + return undefined; var all = []; var ranges = []; - var rangeToMove = statements.slice(first, afterLast); - ts.getRangesWhere(rangeToMove, function (s) { return !isPureImport(s); }, function (start, afterEnd) { - for (var i = start; i < afterEnd; i++) - all.push(rangeToMove[i]); - ranges.push({ first: rangeToMove[start], last: rangeToMove[afterEnd - 1] }); + var toMove = rangeToMove.toMove, afterLast = rangeToMove.afterLast; + ts.getRangesWhere(toMove, function (s) { return !isPureImport(s); }, function (start, afterEndIndex) { + for (var i = start; i < afterEndIndex; i++) + all.push(toMove[i]); + ranges.push({ first: toMove[start], afterLast: afterLast }); }); - return { all: all, ranges: ranges }; + return all.length === 0 ? undefined : { all: all, ranges: ranges }; } function isPureImport(node) { switch (node.kind) { - case 243: + case 244: return true; - case 242: + case 243: return !ts.hasModifier(node, 1); - case 213: - return node.declarationList.declarations.every(function (d) { return d.initializer && ts.isRequireCall(d.initializer, true); }); + case 214: + return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, true); }); default: return false; } @@ -88122,26 +88953,26 @@ var ts; changes.insertNodeInListAfter(cfg, ts.last(filesProp.initializer.elements), ts.createLiteral(newFilePath), filesProp.initializer.elements); } } - function getNewStatements(oldFile, usage, changes, toMove, program, newModuleName) { + function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences) { var checker = program.getTypeChecker(); if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) { deleteMovedStatements(oldFile, toMove.ranges, changes); return toMove.all; } var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator; - var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax); + var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax, preferences); if (importsFromNewFile) { changes.insertNodeBefore(oldFile, oldFile.statements[0], importsFromNewFile, true); } deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); deleteMovedStatements(oldFile, toMove.ranges, changes); updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName); - return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); + return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, preferences).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); } function deleteMovedStatements(sourceFile, moved, changes) { for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) { - var _a = moved_1[_i], first_1 = _a.first, last_3 = _a.last; - changes.deleteNodeRange(sourceFile, first_1, last_3); + var _a = moved_1[_i], first_1 = _a.first, afterLast = _a.afterLast; + changes.deleteNodeRangeExcludingEnd(sourceFile, first_1, afterLast); } } function deleteUnusedOldImports(oldFile, toMove, changes, toDelete, checker) { @@ -88154,11 +88985,13 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_20 = function (sourceFile) { + var _loop_24 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_21 = function (statement) { + var _loop_25 = function (statement) { forEachImportInStatement(statement, function (importNode) { + if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) + return; var shouldMove = function (name) { var symbol = ts.isBindingElement(name.parent) ? ts.getPropertySymbolFromBindingElement(checker, name.parent) @@ -88170,21 +89003,72 @@ var ts; var newImportDeclaration = filterImport(importNode, ts.createLiteral(newModuleSpecifier), shouldMove); if (newImportDeclaration) changes.insertNodeAfter(sourceFile, statement, newImportDeclaration); + var ns = getNamespaceLikeImport(importNode); + if (ns) + updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, ns, importNode); }); }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_21(statement); + _loop_25(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_20(sourceFile); + _loop_24(sourceFile); + } + } + function getNamespaceLikeImport(node) { + switch (node.kind) { + case 244: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 246 ? + node.importClause.namedBindings.name : undefined; + case 243: + return node.name; + case 232: + return ts.tryCast(node.name, ts.isIdentifier); + default: + return ts.Debug.assertNever(node); + } + } + function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { + var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 6); + var needUniqueName = false; + var toChange = []; + ts.FindAllReferences.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, function (ref) { + if (!ts.isPropertyAccessExpression(ref.parent)) + return; + needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863, true); + if (movedSymbols.has(checker.getSymbolAtLocation(ref.parent.name))) { + toChange.push(ref); + } + }); + if (toChange.length) { + var newNamespaceName = needUniqueName ? ts.getUniqueName(preferredNewNamespaceName, sourceFile) : preferredNewNamespaceName; + for (var _i = 0, toChange_1 = toChange; _i < toChange_1.length; _i++) { + var ref = toChange_1[_i]; + changes.replaceNode(sourceFile, ref, ts.createIdentifier(newNamespaceName)); + } + changes.insertNodeAfter(sourceFile, oldImportNode, updateNamespaceLikeImportNode(oldImportNode, newModuleName, newModuleSpecifier)); + } + } + function updateNamespaceLikeImportNode(node, newNamespaceName, newModuleSpecifier) { + var newNamespaceId = ts.createIdentifier(newNamespaceName); + var newModuleString = ts.createLiteral(newModuleSpecifier); + switch (node.kind) { + case 244: + return ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); + case 243: + return ts.createImportEqualsDeclaration(undefined, undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); + case 232: + return ts.createVariableDeclaration(newNamespaceId, undefined, createRequireCall(newModuleString)); + default: + return ts.Debug.assertNever(node); } } function moduleSpecifierFromImport(i) { - return (i.kind === 243 ? i.moduleSpecifier - : i.kind === 242 ? i.moduleReference.expression + return (i.kind === 244 ? i.moduleSpecifier + : i.kind === 243 ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -88206,7 +89090,7 @@ var ts; } } } - function createOldFileImportsFromNewFile(newFileNeedExport, newFileNameWithExtension, useEs6Imports) { + function createOldFileImportsFromNewFile(newFileNeedExport, newFileNameWithExtension, useEs6Imports, preferences) { var defaultImport; var imports = []; newFileNeedExport.forEach(function (symbol) { @@ -88217,13 +89101,13 @@ var ts; imports.push(symbol.name); } }); - return makeImportOrRequire(defaultImport, imports, newFileNameWithExtension, useEs6Imports); + return makeImportOrRequire(defaultImport, imports, newFileNameWithExtension, useEs6Imports, preferences); } - function makeImportOrRequire(defaultImport, imports, path, useEs6Imports) { + function makeImportOrRequire(defaultImport, imports, path, useEs6Imports, preferences) { path = ts.ensurePathIsNonModuleName(path); if (useEs6Imports) { var specifiers = imports.map(function (i) { return ts.createImportSpecifier(undefined, ts.createIdentifier(i)); }); - return ts.makeImportIfNecessary(defaultImport, specifiers, path); + return ts.makeImportIfNecessary(defaultImport, specifiers, path, preferences); } else { ts.Debug.assert(!defaultImport); @@ -88254,15 +89138,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 243: + case 244: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 242: + case 243: if (isUnused(importDecl.name)) { changes.deleteNode(sourceFile, importDecl); } break; - case 231: + case 232: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -88275,7 +89159,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 245 ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 246 ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.deleteNode(sourceFile, importDecl); } @@ -88287,7 +89171,7 @@ var ts; if (namedBindingsUnused) { changes.deleteNode(sourceFile, namedBindings); } - else if (namedBindings.kind === 246) { + else if (namedBindings.kind === 247) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -88305,9 +89189,9 @@ var ts; changes.deleteNode(sourceFile, name); } break; - case 180: + case 181: break; - case 179: + case 180: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.deleteNode(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -88322,7 +89206,7 @@ var ts; break; } } - function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax) { + function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, preferences) { var copiedOldImports = []; for (var _i = 0, _a = oldFile.statements; _i < _a.length; _i++) { var oldStatement = _a[_i]; @@ -88353,7 +89237,7 @@ var ts; } } }); - ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEs6ModuleSyntax)); + ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEs6ModuleSyntax, preferences)); return copiedOldImports; } function makeUniqueModuleName(moduleName, extension, inDirectory, host) { @@ -88388,7 +89272,7 @@ var ts; if (isInImport(decl)) { oldImportsNeededByNewFile.add(symbol); } - else if (isTopLevelDeclaration(decl) && !movedSymbols.has(symbol)) { + else if (isTopLevelDeclaration(decl) && sourceFileOfTopLevelDeclaration(decl) === oldFile && !movedSymbols.has(symbol)) { newFileImportsFromOldFile.add(symbol); } } @@ -88410,13 +89294,13 @@ var ts; } function isInImport(decl) { switch (decl.kind) { - case 242: - case 247: - case 244: + case 243: + case 248: + case 245: return true; - case 231: + case 232: return isVariableDeclarationInImport(decl); - case 181: + case 182: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -88428,7 +89312,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 243: { + case 244: { var clause = i.importClause; if (!clause) return undefined; @@ -88438,9 +89322,9 @@ var ts; ? ts.createImportDeclaration(undefined, undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 242: + case 243: return keep(i.name) ? i : undefined; - case 231: { + case 232: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -88449,7 +89333,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 245) { + if (namedBindings.kind === 246) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -88461,9 +89345,9 @@ var ts; switch (name.kind) { case 71: return keep(name) ? name : undefined; - case 180: + case 181: return name; - case 179: { + case 180: { var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.createObjectBindingPattern(newElements) : undefined; } @@ -88508,7 +89392,10 @@ var ts; return SymbolSet; }()); function isTopLevelDeclaration(node) { - return isNonVariableTopLevelDeclaration(node) || ts.isVariableDeclaration(node) && ts.isSourceFile(node.parent.parent.parent); + return isNonVariableTopLevelDeclaration(node) && ts.isSourceFile(node.parent) || ts.isVariableDeclaration(node) && ts.isSourceFile(node.parent.parent.parent); + } + function sourceFileOfTopLevelDeclaration(node) { + return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { ts.Debug.assert(ts.isSourceFile(node.parent)); @@ -88516,13 +89403,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 233: case 234: + case 235: + case 239: case 238: case 237: case 236: - case 235: - case 242: + case 243: return true; default: return false; @@ -88530,17 +89417,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 233: case 234: + case 235: + case 239: case 238: case 237: case 236: - case 235: - case 242: + case 243: return cb(statement); - case 213: + case 214: return ts.forEach(statement.declarationList.declarations, cb); - case 215: { + case 216: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getSpecialPropertyAssignmentKind(expression) === 1 ? cb(statement) @@ -88549,7 +89436,7 @@ var ts; } } function nameOfTopLevelDeclaration(d) { - return d.kind === 215 ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); + return d.kind === 216 ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); } function getTopLevelDeclarationStatement(d) { return ts.isVariableDeclaration(d) ? d.parent.parent : d; @@ -88581,23 +89468,23 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.createModifier(84)], d.modifiers); switch (d.kind) { - case 233: - return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); case 234: - return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 213: - return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 238: - return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 237: - return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 236: - return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); + return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); case 235: + return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); + case 214: + return ts.updateVariableStatement(d, modifiers, d.declarationList); + case 239: + return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); + case 238: + return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); + case 237: + return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); + case 236: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 242: + case 243: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 215: + case 216: return ts.Debug.fail(); default: return ts.Debug.assertNever(d); @@ -88608,21 +89495,21 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 233: case 234: + case 235: return [decl.name.text]; - case 213: + case 214: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); + case 239: case 238: case 237: case 236: - case 235: - case 242: - return undefined; - case 215: + case 243: + return ts.emptyArray; + case 216: return ts.Debug.fail(); default: - ts.Debug.assertNever(decl); + return ts.Debug.assertNever(decl); } } function createExportAssignment(name) { @@ -88813,7 +89700,7 @@ var ts; var value = 0; for (; moreDigits; state.decodingIndex++) { if (createErrorIfCondition(state.decodingIndex >= state.encodedText.length, "Error in decoding base64VLQFormatDecode, past the mapping string")) { - return; + return undefined; } var currentByte = base64FormatDecode(state.encodedText.charAt(state.decodingIndex)); moreDigits = (currentByte & 32) !== 0; @@ -88917,8 +89804,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 277 || kid.kind > 297; }); - return child.kind < 145 ? + var child = ts.find(children, function (kid) { return kid.kind < 278 || kid.kind > 298; }); + return child.kind < 146 ? child : child.getFirstToken(sourceFile); }; @@ -88929,7 +89816,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 145 ? child : child.getLastToken(sourceFile); + return child.kind < 146 ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -88982,7 +89869,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(298, nodes.pos, nodes.end, parent); + var list = createNode(299, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -89159,25 +90046,25 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 131072); - }; - TypeObject.prototype.isIntersection = function () { return !!(this.flags & 262144); }; + TypeObject.prototype.isIntersection = function () { + return !!(this.flags & 524288); + }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 393216); + return !!(this.flags & 786432); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 224); + return !!(this.flags & 448); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 32); - }; - TypeObject.prototype.isNumberLiteral = function () { return !!(this.flags & 64); }; + TypeObject.prototype.isNumberLiteral = function () { + return !!(this.flags & 128); + }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 32768); + return !!(this.flags & 65536); }; TypeObject.prototype.isClassOrInterface = function () { return !!(ts.getObjectFlags(this) & 3); @@ -89222,8 +90109,8 @@ var ts; return ts.emptyArray; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); if (doc.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { - var declaration = declarations_13[_i]; + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; var inheritedDocs = findInheritedJSDocComments(declaration, declaration.symbol.name, checker); if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc); @@ -89299,10 +90186,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 233: - case 191: + case 234: + case 192: + case 154: case 153: - case 152: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -89319,29 +90206,29 @@ var ts; } ts.forEachChild(node, visit); break; - case 234: - case 204: case 235: + case 205: case 236: case 237: case 238: - case 242: - case 251: - case 247: - case 244: + case 239: + case 243: + case 252: + case 248: case 245: - case 155: + case 246: case 156: - case 165: + case 157: + case 166: addDeclaration(node); ts.forEachChild(node, visit); break; - case 148: + case 149: if (!ts.hasModifier(node, 92)) { break; } - case 231: - case 181: { + case 232: + case 182: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -89351,24 +90238,24 @@ var ts; visit(decl.initializer); } } - case 272: + case 273: + case 152: case 151: - case 150: addDeclaration(node); break; - case 249: + case 250: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 243: + case 244: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 245) { + if (importClause.namedBindings.kind === 246) { addDeclaration(importClause.namedBindings); } else { @@ -89377,7 +90264,7 @@ var ts; } } break; - case 199: + case 200: if (ts.getSpecialPropertyAssignmentKind(node) !== 0) { addDeclaration(node); } @@ -89515,11 +90402,11 @@ var ts; }; HostCache.prototype.getVersion = function (path) { var file = this.getHostFileInformation(path); - return file && file.version; + return (file && file.version); }; HostCache.prototype.getScriptSnapshot = function (path) { var file = this.getHostFileInformation(path); - return file && file.scriptSnapshot; + return (file && file.scriptSnapshot); }; return HostCache; }()); @@ -89606,7 +90493,7 @@ var ts; this.cancellationToken = cancellationToken; } CancellationTokenObject.prototype.isCancellationRequested = function () { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + return !!this.cancellationToken && this.cancellationToken.isCancellationRequested(); }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { @@ -89710,7 +90597,7 @@ var ts; var hostCache = new HostCache(host, getCanonicalFileName); var rootFileNames = hostCache.getRootFileNames(); var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; - if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (path) { return hostCache.getVersion(path); }, fileExists, hasInvalidatedResolution, host.hasChangedAutomaticTypeDirectiveNames)) { + if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (path) { return hostCache.getVersion(path); }, fileExists, hasInvalidatedResolution, !!host.hasChangedAutomaticTypeDirectiveNames)) { return; } var newSettings = hostCache.compilationSettings(); @@ -89773,7 +90660,7 @@ var ts; var entry = hostCache.getEntryByPath(path); return entry ? !ts.isString(entry) : - (host.fileExists && host.fileExists(fileName)); + (!!host.fileExists && host.fileExists(fileName)); } function onReleaseOldSourceFile(oldSourceFile, oldOptions) { var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); @@ -89834,7 +90721,7 @@ var ts; } function getSuggestionDiagnostics(fileName) { synchronizeHostData(); - return ts.computeSuggestionDiagnostics(getValidSourceFile(fileName), program); + return ts.computeSuggestionDiagnostics(getValidSourceFile(fileName), program, cancellationToken); } function getCompilerOptionsDiagnostics() { synchronizeHostData(); @@ -89849,7 +90736,7 @@ var ts; function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { if (preferences === void 0) { preferences = ts.defaultPreferences; } synchronizeHostData(); - return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, formattingOptions && ts.formatting.getFormatContext(formattingOptions), getCanonicalFileName, preferences, cancellationToken); + return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions)), getCanonicalFileName, preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); @@ -89870,10 +90757,10 @@ var ts; if (ts.isLabelName(node)) { return undefined; } - case 184: - case 145: + case 185: + case 146: case 99: - case 173: + case 174: case 97: var type_4 = typeChecker.getTypeAtLocation(node); return type_4 && { @@ -90084,18 +90971,9 @@ var ts; } function getReferences(fileName, position, options) { synchronizeHostData(); - var sourceFiles = []; - if (options && options.isForRename) { - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - if (!program.isSourceFileDefaultLibrary(sourceFile)) { - sourceFiles.push(sourceFile); - } - } - } - else { - sourceFiles = program.getSourceFiles().slice(); - } + var sourceFiles = options && options.isForRename + ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) + : program.getSourceFiles(); return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); } function findReferences(fileName, position) { @@ -90103,11 +90981,13 @@ var ts; return ts.FindAllReferences.findReferencedSymbols(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position); } function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { + if (excludeDtsFiles === void 0) { excludeDtsFiles = false; } synchronizeHostData(); var sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); } function getEmitOutput(fileName, emitOnlyDtsFiles) { + if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); @@ -90121,29 +91001,26 @@ var ts; function getNonBoundSourceFile(fileName) { return syntaxTreeCache.getCurrentSourceFile(fileName); } - function getSourceFile(fileName) { - return getNonBoundSourceFile(fileName); - } function getNameOrDottedNameSpan(fileName, startPos, _endPos) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var node = ts.getTouchingPropertyName(sourceFile, startPos, false); if (node === sourceFile) { - return; + return undefined; } switch (node.kind) { - case 184: - case 145: + case 185: + case 146: case 9: case 86: case 101: case 95: case 97: case 99: - case 173: + case 174: case 71: break; default: - return; + return undefined; } var nodeForStartPos = node; while (true) { @@ -90151,7 +91028,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 238 && + if (nodeForStartPos.parent.parent.kind === 239 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -90278,8 +91155,9 @@ var ts; var formatContext = ts.formatting.getFormatContext(formatOptions); return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); } - function getEditsForFileRename(oldFilePath, newFilePath, formatOptions) { - return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions)); + function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { + if (preferences === void 0) { preferences = ts.defaultPreferences; } + return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions), preferences); } function applyCodeActionCommand(fileName, actionOrUndefined) { var action = typeof fileName === "string" ? actionOrUndefined : fileName; @@ -90292,7 +91170,7 @@ var ts; ? host.installPackage({ fileName: ts.toPath(action.file, currentDirectory, getCanonicalFileName), packageName: action.packageName }) : Promise.reject("Host does not implement `installPackage`"); default: - ts.Debug.fail(); + return ts.Debug.fail(); } } function getDocCommentTemplateAtPosition(fileName, position) { @@ -90320,6 +91198,17 @@ var ts; } return true; } + function getJsxClosingTagAtPosition(fileName, position) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var token = ts.findPrecedingToken(position, sourceFile); + if (!token) + return undefined; + var element = token.kind === 29 && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + : ts.isJsxText(token) ? token.parent : undefined; + if (element && !ts.tagNamesAreEquivalent(element.openingElement.tagName, element.closingElement.tagName)) { + return { newText: "" }; + } + } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); @@ -90349,7 +91238,8 @@ var ts; descriptor = descriptors[i]; } } - ts.Debug.assert(descriptor !== undefined); + if (descriptor === undefined) + return ts.Debug.fail(); if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { continue; } @@ -90452,6 +91342,7 @@ var ts; getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, + getJsxClosingTagAtPosition: getJsxClosingTagAtPosition, getSpanOfEnclosingComment: getSpanOfEnclosingComment, getCodeFixesAtPosition: getCodeFixesAtPosition, getCombinedCodeFix: getCombinedCodeFix, @@ -90460,7 +91351,6 @@ var ts; getEditsForFileRename: getEditsForFileRename, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, - getSourceFile: getSourceFile, getProgram: getProgram, getApplicableRefactors: getApplicableRefactors, getEditsForRefactor: getEditsForRefactor, @@ -90493,7 +91383,7 @@ var ts; } function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 253 || + node.parent.kind === 254 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -90501,12 +91391,12 @@ var ts; switch (node.kind) { case 9: case 8: - if (node.parent.kind === 146) { + if (node.parent.kind === 147) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } case 71: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 183 || node.parent.parent.kind === 262) && + (node.parent.parent.kind === 184 || node.parent.parent.kind === 263) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -90523,7 +91413,7 @@ var ts; if (name && type) { var result_7 = []; var symbol = type.getProperty(name); - if (type.flags & 131072) { + if (type.flags & 262144) { ts.forEach(type.types, function (t) { var symbol = t.getProperty(name); if (symbol) { @@ -90543,7 +91433,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 185 && + node.parent.kind === 186 && node.parent.argumentExpression === node; } function getDefaultLibFilePath(options) { @@ -90566,10 +91456,11 @@ var ts; var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position, false); var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line; if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) { - tokenAtLocation = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); - if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) { + var preceding = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); + if (!preceding || sourceFile.getLineAndCharacterOfPosition(preceding.getEnd()).line !== lineOfPosition) { return undefined; } + tokenAtLocation = preceding; } if (tokenAtLocation.flags & 4194304) { return undefined; @@ -90601,90 +91492,91 @@ var ts; } function spanInNode(node) { if (node) { + var parent = node.parent; switch (node.kind) { - case 213: + case 214: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 231: - case 151: - case 150: - return spanInVariableDeclaration(node); - case 148: - return spanInParameterDeclaration(node); - case 233: - case 153: + case 232: case 152: - case 155: - case 156: + case 151: + return spanInVariableDeclaration(node); + case 149: + return spanInParameterDeclaration(node); + case 234: case 154: - case 191: + case 153: + case 156: + case 157: + case 155: case 192: + case 193: return spanInFunctionDeclaration(node); - case 212: + case 213: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 239: + case 240: return spanInBlock(node); - case 268: + case 269: return spanInBlock(node.block); - case 215: - return textSpan(node.expression); - case 224: - return textSpan(node.getChildAt(0), node.expression); - case 218: - return textSpanEndingAtNextToken(node, node.expression); - case 217: - return spanInNode(node.statement); - case 230: - return textSpan(node.getChildAt(0)); case 216: - return textSpanEndingAtNextToken(node, node.expression); - case 227: - return spanInNode(node.statement); - case 223: - case 222: - return textSpan(node.getChildAt(0), node.label); + return textSpan(node.expression); + case 225: + return textSpan(node.getChildAt(0), node.expression); case 219: - return spanInForStatement(node); - case 220: return textSpanEndingAtNextToken(node, node.expression); - case 221: - return spanInInitializerOfForLike(node); - case 226: + case 218: + return spanInNode(node.statement); + case 231: + return textSpan(node.getChildAt(0)); + case 217: return textSpanEndingAtNextToken(node, node.expression); - case 265: - case 266: - return spanInNode(node.statements[0]); - case 229: - return spanInBlock(node.tryBlock); case 228: + return spanInNode(node.statement); + case 224: + case 223: + return textSpan(node.getChildAt(0), node.label); + case 220: + return spanInForStatement(node); + case 221: + return textSpanEndingAtNextToken(node, node.expression); + case 222: + return spanInInitializerOfForLike(node); + case 227: + return textSpanEndingAtNextToken(node, node.expression); + case 266: + case 267: + return spanInNode(node.statements[0]); + case 230: + return spanInBlock(node.tryBlock); + case 229: return textSpan(node, node.expression); - case 248: - return textSpan(node, node.expression); - case 242: - return textSpan(node, node.moduleReference); - case 243: - return textSpan(node, node.moduleSpecifier); case 249: + return textSpan(node, node.expression); + case 243: + return textSpan(node, node.moduleReference); + case 244: return textSpan(node, node.moduleSpecifier); - case 238: + case 250: + return textSpan(node, node.moduleSpecifier); + case 239: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 234: - case 237: - case 272: - case 181: - return textSpan(node); - case 225: - return spanInNode(node.statement); - case 149: - return spanInNodeArray(node.parent.decorators); - case 179: - case 180: - return spanInBindingPattern(node); case 235: + case 238: + case 273: + case 182: + return textSpan(node); + case 226: + return spanInNode(node.statement); + case 150: + return spanInNodeArray(parent.decorators); + case 180: + case 181: + return spanInBindingPattern(node); case 236: + case 237: return undefined; case 25: case 1: @@ -90712,20 +91604,20 @@ var ts; case 74: case 87: return spanInNextNode(node); - case 144: + case 145: return spanInOfKeyword(node); default: if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); } if ((node.kind === 71 || - node.kind === 203 || - node.kind === 269 || - node.kind === 270) && - ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + node.kind === 204 || + node.kind === 270 || + node.kind === 271) && + ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 199) { + if (node.kind === 200) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); @@ -90738,20 +91630,20 @@ var ts; } } if (ts.isExpressionNode(node)) { - switch (node.parent.kind) { - case 217: + switch (parent.kind) { + case 218: return spanInPreviousNode(node); - case 149: + case 150: return spanInNode(node.parent); - case 219: - case 221: + case 220: + case 222: return textSpan(node); - case 199: + case 200: if (node.parent.operatorToken.kind === 26) { return textSpan(node); } break; - case 192: + case 193: if (node.parent.body === node) { return textSpan(node); } @@ -90759,26 +91651,26 @@ var ts; } } switch (node.parent.kind) { - case 269: + case 270: if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 189: + case 190: if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 231: - case 148: { + case 232: + case 149: { var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { return spanInPreviousNode(node); } break; } - case 199: { + case 200: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { return spanInPreviousNode(node); @@ -90802,15 +91694,16 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 220) { + if (variableDeclaration.parent.parent.kind === 221) { return spanInNode(variableDeclaration.parent.parent); } + var parent = variableDeclaration.parent; if (ts.isBindingPattern(variableDeclaration.name)) { return spanInBindingPattern(variableDeclaration.name); } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 221) { + parent.parent.kind === 222) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -90843,7 +91736,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 234 && functionDeclaration.kind !== 154); + (functionDeclaration.parent.kind === 235 && functionDeclaration.kind !== 155); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -90863,22 +91756,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 238: + case 239: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 218: - case 216: - case 220: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 219: + case 217: case 221: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 220: + case 222: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 232) { + if (forLikeStatement.initializer.kind === 233) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -90900,60 +91793,60 @@ var ts; } } function spanInBindingPattern(bindingPattern) { - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 205 ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 206 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 181) { + if (bindingPattern.parent.kind === 182) { return textSpan(bindingPattern.parent); } return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 180 && node.kind !== 179); - var elements = node.kind === 182 ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 205 ? element : undefined; }); + ts.Debug.assert(node.kind !== 181 && node.kind !== 180); + var elements = node.kind === 183 ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 206 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 199 ? node.parent : node); + return textSpan(node.parent.kind === 200 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 237: + case 238: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 234: + case 235: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 240: + case 241: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 239: + case 240: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 237: - case 234: + case 238: + case 235: return textSpan(node); - case 212: + case 213: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 268: + case 269: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 240: + case 241: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 179: + case 180: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -90966,7 +91859,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 180: + case 181: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -90978,33 +91871,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 217 || - node.parent.kind === 186 || - node.parent.kind === 187) { + if (node.parent.kind === 218 || + node.parent.kind === 187 || + node.parent.kind === 188) { return spanInPreviousNode(node); } - if (node.parent.kind === 190) { + if (node.parent.kind === 191) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 191: - case 233: case 192: - case 153: - case 152: - case 155: - case 156: + case 234: + case 193: case 154: - case 218: - case 217: + case 153: + case 156: + case 157: + case 155: case 219: - case 221: - case 186: + case 218: + case 220: + case 222: case 187: - case 190: + case 188: + case 191: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -91012,26 +91905,26 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 269 || - node.parent.kind === 148) { + node.parent.kind === 270 || + node.parent.kind === 149) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 189) { + if (node.parent.kind === 190) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 217) { + if (node.parent.kind === 218) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 221) { + if (node.parent.kind === 222) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -91292,7 +92185,8 @@ var ts; start: diagnostic.start, length: diagnostic.length, category: ts.diagnosticCategoryName(diagnostic), - code: diagnostic.code + code: diagnostic.code, + reportsUnnecessary: diagnostic.reportsUnnecessary, }; } var LanguageServiceShimObject = (function (_super) { @@ -91533,9 +92427,11 @@ var ts; } ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { var _this = this; + if (syntacticClassifierAbsent === void 0) { syntacticClassifierAbsent = false; } return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); }; ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { + if (classifyKeywordsInGenerics === void 0) { classifyKeywordsInGenerics = false; } var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); var result = ""; for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { @@ -91884,7 +92780,7 @@ var ts; function ThrottledOperations(host, logger) { this.host = host; this.pendingTimeouts = ts.createMap(); - this.logger = logger.hasLevel(server.LogLevel.verbose) && logger; + this.logger = logger.hasLevel(server.LogLevel.verbose) ? logger : undefined; } ThrottledOperations.prototype.schedule = function (operationId, delay, cb) { var pendingTimeout = this.pendingTimeouts.get(operationId); @@ -91982,6 +92878,7 @@ var ts; (function (protocol) { var CommandTypes; (function (CommandTypes) { + CommandTypes["JsxClosingTag"] = "jsxClosingTag"; CommandTypes["Brace"] = "brace"; CommandTypes["BraceFull"] = "brace-full"; CommandTypes["BraceCompletion"] = "braceCompletion"; @@ -92485,15 +93382,15 @@ var ts; } var set = ts.createMap(); var unique = 0; - for (var _i = 0, arr1_1 = arr1; _i < arr1_1.length; _i++) { - var v = arr1_1[_i]; + for (var _i = 0, _a = arr1; _i < _a.length; _i++) { + var v = _a[_i]; if (set.get(v) !== true) { set.set(v, true); unique++; } } - for (var _a = 0, arr2_1 = arr2; _a < arr2_1.length; _a++) { - var v = arr2_1[_a]; + for (var _b = 0, _c = arr2; _b < _c.length; _b++) { + var v = _c[_b]; var isSet = set.get(v); if (isSet === undefined) { return false; @@ -92756,11 +93653,11 @@ var ts; }; Project.prototype.getScriptKind = function (fileName) { var info = this.getOrCreateScriptInfoAndAttachToProject(fileName); - return info && info.scriptKind; + return (info && info.scriptKind); }; Project.prototype.getScriptVersion = function (filename) { var info = this.getOrCreateScriptInfoAndAttachToProject(filename); - return info && info.getLatestVersion(); + return (info && info.getLatestVersion()); }; Project.prototype.getScriptSnapshot = function (filename) { var scriptInfo = this.getOrCreateScriptInfoAndAttachToProject(filename); @@ -92993,9 +93890,7 @@ var ts; } return ts.map(this.program.getSourceFiles(), function (sourceFile) { var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.path); - if (!scriptInfo) { - ts.Debug.fail("scriptInfo for a file '" + sourceFile.fileName + "' Path: '" + sourceFile.path + "' is missing."); - } + ts.Debug.assert(!!scriptInfo, "getScriptInfo", function () { return "scriptInfo for a file '" + sourceFile.fileName + "' Path: '" + sourceFile.path + "' is missing."; }); return scriptInfo; }); }; @@ -93065,6 +93960,7 @@ var ts; if (info && (info.isScriptOpen() || !requireOpen)) { return this.containsScriptInfo(info); } + return false; }; Project.prototype.isRoot = function (info) { return this.rootFilesMap && this.rootFilesMap.get(info.path) === info; @@ -93342,7 +94238,7 @@ var ts; } var searchPaths = [ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations); if (this.projectService.globalPlugins) { - var _loop_22 = function (globalPluginName) { + var _loop_26 = function (globalPluginName) { if (!globalPluginName) return "continue"; if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; })) @@ -93353,7 +94249,7 @@ var ts; var this_1 = this; for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) { var globalPluginName = _a[_i]; - _loop_22(globalPluginName); + _loop_26(globalPluginName); } } }; @@ -93756,7 +94652,7 @@ var ts; var externalFilePropertyReader = { getFileName: function (x) { return x.fileName; }, getScriptKind: function (x) { return tryConvertScriptKindName(x.scriptKind); }, - hasMixedContent: function (x) { return x.hasMixedContent; }, + hasMixedContent: function (x) { return !!x.hasMixedContent; }, }; function findProjectByName(projectName, projects) { for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { @@ -93828,10 +94724,11 @@ var ts; if (this.host.realpath) { this.realpathToScriptInfos = ts.createMultiMap(); } - this.currentDirectory = this.host.getCurrentDirectory(); + this.currentDirectory = server.toNormalizedPath(this.host.getCurrentDirectory()); this.toCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); - this.globalCacheLocationDirectoryPath = this.typingsInstaller.globalTypingsCacheLocation && - ts.ensureTrailingDirectorySeparator(this.toPath(this.typingsInstaller.globalTypingsCacheLocation)); + this.globalCacheLocationDirectoryPath = this.typingsInstaller.globalTypingsCacheLocation + ? ts.ensureTrailingDirectorySeparator(this.toPath(this.typingsInstaller.globalTypingsCacheLocation)) + : undefined; this.throttledOperations = new server.ThrottledOperations(this.host, this.logger); if (this.typesMapLocation) { this.loadTypesMap(); @@ -93847,7 +94744,7 @@ var ts; hostInfo: "Unknown host", extraFileExtensions: [] }; - this.documentRegistry = ts.createDocumentRegistry(this.host.useCaseSensitiveFileNames, this.currentDirectory); + this.documentRegistry = ts.createDocumentRegistryInternal(this.host.useCaseSensitiveFileNames, this.currentDirectory, this); var watchLogLevel = this.logger.hasLevel(server.LogLevel.verbose) ? ts.WatchLogLevel.Verbose : this.logger.loggingEnabled() ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None; var log = watchLogLevel !== ts.WatchLogLevel.None ? (function (s) { return _this.logger.info(s); }) : ts.noop; @@ -93862,6 +94759,14 @@ var ts; ProjectService.prototype.getNormalizedAbsolutePath = function (fileName) { return ts.getNormalizedAbsolutePath(fileName, this.host.getCurrentDirectory()); }; + ProjectService.prototype.setDocument = function (key, path, sourceFile) { + var info = ts.Debug.assertDefined(this.getScriptInfoForPath(path)); + info.cacheSourceFile = { key: key, sourceFile: sourceFile }; + }; + ProjectService.prototype.getDocument = function (key, path) { + var info = this.getScriptInfoForPath(path); + return info && info.cacheSourceFile && info.cacheSourceFile.key === key ? info.cacheSourceFile.sourceFile : undefined; + }; ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { this.ensureProjectStructuresUptoDate(); }; @@ -94016,7 +94921,7 @@ var ts; } return scriptInfo.getDefaultProject(); } - return scriptInfo && !scriptInfo.isOrphan() && scriptInfo.getDefaultProject(); + return scriptInfo && !scriptInfo.isOrphan() ? scriptInfo.getDefaultProject() : undefined; }; ProjectService.prototype.getScriptInfoEnsuringProjectsUptoDate = function (uncheckedFileName) { this.ensureProjectStructuresUptoDate(); @@ -94140,7 +95045,7 @@ var ts; } project.updateGraph(); if (!this.useSingleInferredProject && !project.projectRootPath) { - var _loop_23 = function (inferredProject) { + var _loop_27 = function (inferredProject) { if (inferredProject === project || inferredProject.isOrphan()) { return "continue"; } @@ -94152,7 +95057,7 @@ var ts; }; for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var inferredProject = _a[_i]; - _loop_23(inferredProject); + _loop_27(inferredProject); } } return project; @@ -94528,7 +95433,7 @@ var ts; if (!(project instanceof server.ConfiguredProject)) { return "other"; } - var configFilePath = project instanceof server.ConfiguredProject && project.getConfigFilePath(); + var configFilePath = project instanceof server.ConfiguredProject ? project.getConfigFilePath() : undefined; return server.getBaseConfigFileName(configFilePath) || "other"; } function convertTypeAcquisition(_a) { @@ -94735,7 +95640,7 @@ var ts; return projects; function combineProjects(toAddInfo) { if (toAddInfo !== info) { - var _loop_24 = function (project) { + var _loop_28 = function (project) { if (project.languageServiceEnabled && !project.isOrphan() && !project.getCompilerOptions().preserveSymlinks && @@ -94751,7 +95656,7 @@ var ts; }; for (var _i = 0, _a = toAddInfo.containingProjects; _i < _a.length; _i++) { var project = _a[_i]; - _loop_24(project); + _loop_28(project); } } } @@ -94794,7 +95699,7 @@ var ts; if (!openedByClient && !isDynamic && !(hostToQueryFileExistsOn || this.host).fileExists(fileName)) { return; } - info = new server.ScriptInfo(this.host, fileName, scriptKind, hasMixedContent, path); + info = new server.ScriptInfo(this.host, fileName, scriptKind, !!hasMixedContent, path); this.filenameToScriptInfo.set(info.path, info); if (!openedByClient) { this.watchClosedScriptInfo(info); @@ -94996,13 +95901,13 @@ var ts; this.printProjects(); }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_25 = function (proj) { - var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); + var _loop_29 = function (proj) { + var knownProject = ts.find(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName(); }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_25(proj); + _loop_29(proj); } }; ProjectService.prototype.synchronizeProjectList = function (knownProjects) { @@ -95093,7 +95998,8 @@ var ts; }; ProjectService.prototype.applySafeList = function (proj) { var _this = this; - var rootFiles = proj.rootFiles, typeAcquisition = proj.typeAcquisition; + var rootFiles = proj.rootFiles; + var typeAcquisition = proj.typeAcquisition; ts.Debug.assert(!!typeAcquisition, "proj.typeAcquisition should be set by now"); if (typeAcquisition.enable === false) { return []; @@ -95102,7 +96008,7 @@ var ts; var excludeRules = []; var normalizedNames = rootFiles.map(function (f) { return ts.normalizeSlashes(f.fileName); }); var excludedFiles = []; - var _loop_26 = function (name) { + var _loop_30 = function (name) { var rule = this_2.safelist[name]; for (var _i = 0, normalizedNames_1 = normalizedNames; _i < normalizedNames_1.length; _i++) { var root = normalizedNames_1[_i]; @@ -95117,7 +96023,7 @@ var ts; } } if (rule.exclude) { - var _loop_28 = function (exclude) { + var _loop_32 = function (exclude) { var processedRule = root.replace(rule.match, function () { var groups = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -95140,7 +96046,7 @@ var ts; }; for (var _c = 0, _d = rule.exclude; _c < _d.length; _c++) { var exclude = _d[_c]; - _loop_28(exclude); + _loop_32(exclude); } } else { @@ -95155,11 +96061,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_26(name); + _loop_30(name); } var excludeRegexes = excludeRules.map(function (e) { return new RegExp(e, "i"); }); var filesToKeep = []; - var _loop_27 = function (i) { + var _loop_31 = function (i) { if (excludeRegexes.some(function (re) { return re.test(normalizedNames[i]); })) { excludedFiles.push(normalizedNames[i]); } @@ -95193,7 +96099,7 @@ var ts; }; var this_3 = this; for (var i = 0; i < proj.rootFiles.length; i++) { - _loop_27(i); + _loop_31(i); } proj.rootFiles = filesToKeep; return excludedFiles; @@ -95364,8 +96270,8 @@ var ts; return { line: lineAndCharacter.line + 1, offset: lineAndCharacter.character + 1 }; } function formatConfigFileDiag(diag, includeFileName) { - var start = diag.file && convertToLocation(ts.getLineAndCharacterOfPosition(diag.file, diag.start)); - var end = diag.file && convertToLocation(ts.getLineAndCharacterOfPosition(diag.file, diag.start + diag.length)); + var start = (diag.file && convertToLocation(ts.getLineAndCharacterOfPosition(diag.file, diag.start))); + var end = (diag.file && convertToLocation(ts.getLineAndCharacterOfPosition(diag.file, diag.start + diag.length))); var text = ts.flattenDiagnosticMessageText(diag.messageText, "\n"); var code = diag.code, source = diag.source; var category = ts.diagnosticCategoryName(diag); @@ -95743,6 +96649,9 @@ var ts; _this.projectService.reloadProjects(); return _this.notRequired(); }, + _a[server.CommandNames.JsxClosingTag] = function (request) { + return _this.requiredResponse(_this.getJsxClosingTag(request.arguments)); + }, _a[server.CommandNames.GetCodeFixes] = function (request) { return _this.requiredResponse(_this.getCodeFixes(request.arguments, true)); }, @@ -95791,6 +96700,7 @@ var ts; this.logger = opts.logger; this.canUseEvents = opts.canUseEvents; this.suppressDiagnosticEvents = opts.suppressDiagnosticEvents; + this.noGetErrOnBackgroundUpdate = opts.noGetErrOnBackgroundUpdate; var throttleWaitMilliseconds = opts.throttleWaitMilliseconds; this.eventHandler = this.canUseEvents ? opts.eventHandler || (function (event) { return _this.defaultEventHandler(event); }) @@ -95862,7 +96772,7 @@ var ts; var _this = this; this.projectService.logger.info("got projects updated in background, updating diagnostics for " + openFiles); if (openFiles.length) { - if (!this.suppressDiagnosticEvents) { + if (!this.suppressDiagnosticEvents && !this.noGetErrOnBackgroundUpdate) { var checkList_1 = this.createCheckList(openFiles); this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, checkList_1, 100, true); }); } @@ -96004,20 +96914,20 @@ var ts; return project.getLanguageService().getEncodedSemanticClassifications(file, args); }; Session.prototype.getProject = function (projectFileName) { - return projectFileName && this.projectService.findProject(projectFileName); + return projectFileName === undefined ? undefined : this.projectService.findProject(projectFileName); }; Session.prototype.getConfigFileAndProject = function (args) { var project = this.getProject(args.projectFileName); var file = server.toNormalizedPath(args.file); return { - configFile: project && project.hasConfigFile(file) && file, + configFile: project && project.hasConfigFile(file) ? file : undefined, project: project }; }; Session.prototype.getConfigFileDiagnostics = function (configFile, project, includeLinePosition) { var projectErrors = project.getAllProjectErrors(); var optionsErrors = project.getLanguageService().getCompilerOptionsDiagnostics(); - var diagnosticsForConfigFile = ts.filter(ts.concatenate(projectErrors, optionsErrors), function (diagnostic) { return diagnostic.file && diagnostic.file.fileName === configFile; }); + var diagnosticsForConfigFile = ts.filter(ts.concatenate(projectErrors, optionsErrors), function (diagnostic) { return !!diagnostic.file && diagnostic.file.fileName === configFile; }); return includeLinePosition ? this.convertToDiagnosticsWithLinePositionFromDiagnosticFile(diagnosticsForConfigFile) : ts.map(diagnosticsForConfigFile, function (diagnostic) { return formatConfigFileDiag(diagnostic, false); }); @@ -96030,8 +96940,8 @@ var ts; length: d.length, category: ts.diagnosticCategoryName(d), code: d.code, - startLocation: d.file && convertToLocation(ts.getLineAndCharacterOfPosition(d.file, d.start)), - endLocation: d.file && convertToLocation(ts.getLineAndCharacterOfPosition(d.file, d.start + d.length)) + startLocation: (d.file && convertToLocation(ts.getLineAndCharacterOfPosition(d.file, d.start))), + endLocation: (d.file && convertToLocation(ts.getLineAndCharacterOfPosition(d.file, d.start + d.length))) }); }); }; Session.prototype.getCompilerOptionsDiagnostics = function (args) { @@ -96167,21 +97077,27 @@ var ts; if (configFile) { return server.emptyArray; } - return this.getDiagnosticsWorker(args, false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); + return this.getDiagnosticsWorker(args, false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, !!args.includeLinePosition); }; Session.prototype.getSemanticDiagnosticsSync = function (args) { var _a = this.getConfigFileAndProject(args), configFile = _a.configFile, project = _a.project; if (configFile) { - return this.getConfigFileDiagnostics(configFile, project, args.includeLinePosition); + return this.getConfigFileDiagnostics(configFile, project, !!args.includeLinePosition); } - return this.getDiagnosticsWorker(args, true, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); + return this.getDiagnosticsWorker(args, true, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, !!args.includeLinePosition); }; Session.prototype.getSuggestionDiagnosticsSync = function (args) { var configFile = this.getConfigFileAndProject(args).configFile; if (configFile) { return server.emptyArray; } - return this.getDiagnosticsWorker(args, true, function (project, file) { return project.getLanguageService().getSuggestionDiagnostics(file); }, args.includeLinePosition); + return this.getDiagnosticsWorker(args, true, function (project, file) { return project.getLanguageService().getSuggestionDiagnostics(file); }, !!args.includeLinePosition); + }; + Session.prototype.getJsxClosingTag = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var position = this.getPositionInFile(args, file); + var tag = project.getLanguageService().getJsxClosingTagAtPosition(file, position); + return tag === undefined ? undefined : { newText: tag.newText, caretOffset: 0 }; }; Session.prototype.getDocumentHighlights = function (args, simplifiedResult) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; @@ -96354,13 +97270,10 @@ var ts; var position = this.getPosition(args, scriptInfo); if (simplifiedResult) { var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); - if (!nameInfo) { - return undefined; - } - var displayString = ts.displayPartsToString(nameInfo.displayParts); - var nameSpan = nameInfo.textSpan; - var nameColStart = scriptInfo.positionToLineOffset(nameSpan.start).offset; - var nameText = scriptInfo.getSnapshot().getText(nameSpan.start, ts.textSpanEnd(nameSpan)); + var displayString = nameInfo ? ts.displayPartsToString(nameInfo.displayParts) : ""; + var nameSpan = nameInfo && nameInfo.textSpan; + var nameColStart = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0; + var nameText = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, ts.textSpanEnd(nameSpan)) : ""; var refs = combineProjectOutput(file, function (path) { return _this.projectService.getScriptInfoForPath(path).fileName; }, projects, function (project, file) { var references = project.getLanguageService().getReferencesAtPosition(file, position); if (!references) { @@ -96701,7 +97614,7 @@ var ts; }; Session.prototype.reload = function (args, reqSeq) { var file = server.toNormalizedPath(args.file); - var tempFileName = args.tmpfile && server.toNormalizedPath(args.tmpfile); + var tempFileName = args.tmpfile === undefined ? undefined : server.toNormalizedPath(args.tmpfile); var info = this.projectService.getScriptInfoForNormalizedPath(file); if (info) { this.changeSeq++; @@ -96904,7 +97817,7 @@ var ts; }; Session.prototype.getEditsForFileRename = function (args, simplifiedResult) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var changes = project.getLanguageService().getEditsForFileRename(args.oldFilePath, args.newFilePath, this.getFormatOptions(file)); + var changes = project.getLanguageService().getEditsForFileRename(args.oldFilePath, args.newFilePath, this.getFormatOptions(file), this.getPreferences(file)); return simplifiedResult ? this.mapTextChangesToCodeEdits(project, changes) : changes; }; Session.prototype.getCodeFixes = function (args, simplifiedResult) { @@ -97573,6 +98486,7 @@ var ts; this.load(LineIndex.linesFromText(newText).lines); return this; } + return undefined; } else { var checkText = void 0; @@ -97912,8 +98826,7 @@ var ts; return ts.combinePaths(ts.combinePaths(cacheLocation, "typescript"), ts.versionMajorMinor); } default: - ts.Debug.fail("unsupported platform '" + process.platform + "'"); - return; + return ts.Debug.fail("unsupported platform '" + process.platform + "'"); } } function getNonWindowsCacheLocation(platformIsDarwin) { @@ -98262,6 +99175,7 @@ var ts; canUseEvents: true, suppressDiagnosticEvents: suppressDiagnosticEvents, syntaxOnly: syntaxOnly, + noGetErrOnBackgroundUpdate: noGetErrOnBackgroundUpdate, globalPlugins: globalPlugins, pluginProbeLocations: pluginProbeLocations, allowLocalPluginLoads: allowLocalPluginLoads, @@ -98283,7 +99197,7 @@ var ts; return _this; } IOSession.prototype.event = function (body, eventName) { - ts.Debug.assert(this.constructed, "Should only call `IOSession.prototype.event` on an initialized IOSession"); + ts.Debug.assert(!!this.constructed, "Should only call `IOSession.prototype.event` on an initialized IOSession"); if (this.canUseEvents && this.eventPort) { if (!this.eventSocket) { if (this.logger.hasLevel(server.LogLevel.verbose)) { @@ -98590,8 +99504,8 @@ var ts; var eventPort; { var str = server.findArgument("--eventPort"); - var v = str && parseInt(str); - if (!isNaN(v)) { + var v = str === undefined ? undefined : parseInt(str); + if (v !== undefined && !isNaN(v)) { eventPort = v; } } @@ -98619,6 +99533,7 @@ var ts; var suppressDiagnosticEvents = server.hasArgument("--suppressDiagnosticEvents"); var syntaxOnly = server.hasArgument("--syntaxOnly"); var telemetryEnabled = server.hasArgument(server.Arguments.EnableTelemetry); + var noGetErrOnBackgroundUpdate = server.hasArgument("--noGetErrOnBackgroundUpdate"); logger.info("Starting TS Server"); logger.info("Version: " + ts.version); logger.info("Arguments: " + process.argv.join(" ")); diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index cbf39a2a48f..76a5d890fa7 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -204,169 +204,170 @@ declare namespace ts { TypeKeyword = 139, UndefinedKeyword = 140, UniqueKeyword = 141, - FromKeyword = 142, - GlobalKeyword = 143, - OfKeyword = 144, - QualifiedName = 145, - ComputedPropertyName = 146, - TypeParameter = 147, - Parameter = 148, - Decorator = 149, - PropertySignature = 150, - PropertyDeclaration = 151, - MethodSignature = 152, - MethodDeclaration = 153, - Constructor = 154, - GetAccessor = 155, - SetAccessor = 156, - CallSignature = 157, - ConstructSignature = 158, - IndexSignature = 159, - TypePredicate = 160, - TypeReference = 161, - FunctionType = 162, - ConstructorType = 163, - TypeQuery = 164, - TypeLiteral = 165, - ArrayType = 166, - TupleType = 167, - UnionType = 168, - IntersectionType = 169, - ConditionalType = 170, - InferType = 171, - ParenthesizedType = 172, - ThisType = 173, - TypeOperator = 174, - IndexedAccessType = 175, - MappedType = 176, - LiteralType = 177, - ImportType = 178, - ObjectBindingPattern = 179, - ArrayBindingPattern = 180, - BindingElement = 181, - ArrayLiteralExpression = 182, - ObjectLiteralExpression = 183, - PropertyAccessExpression = 184, - ElementAccessExpression = 185, - CallExpression = 186, - NewExpression = 187, - TaggedTemplateExpression = 188, - TypeAssertionExpression = 189, - ParenthesizedExpression = 190, - FunctionExpression = 191, - ArrowFunction = 192, - DeleteExpression = 193, - TypeOfExpression = 194, - VoidExpression = 195, - AwaitExpression = 196, - PrefixUnaryExpression = 197, - PostfixUnaryExpression = 198, - BinaryExpression = 199, - ConditionalExpression = 200, - TemplateExpression = 201, - YieldExpression = 202, - SpreadElement = 203, - ClassExpression = 204, - OmittedExpression = 205, - ExpressionWithTypeArguments = 206, - AsExpression = 207, - NonNullExpression = 208, - MetaProperty = 209, - TemplateSpan = 210, - SemicolonClassElement = 211, - Block = 212, - VariableStatement = 213, - EmptyStatement = 214, - ExpressionStatement = 215, - IfStatement = 216, - DoStatement = 217, - WhileStatement = 218, - ForStatement = 219, - ForInStatement = 220, - ForOfStatement = 221, - ContinueStatement = 222, - BreakStatement = 223, - ReturnStatement = 224, - WithStatement = 225, - SwitchStatement = 226, - LabeledStatement = 227, - ThrowStatement = 228, - TryStatement = 229, - DebuggerStatement = 230, - VariableDeclaration = 231, - VariableDeclarationList = 232, - FunctionDeclaration = 233, - ClassDeclaration = 234, - InterfaceDeclaration = 235, - TypeAliasDeclaration = 236, - EnumDeclaration = 237, - ModuleDeclaration = 238, - ModuleBlock = 239, - CaseBlock = 240, - NamespaceExportDeclaration = 241, - ImportEqualsDeclaration = 242, - ImportDeclaration = 243, - ImportClause = 244, - NamespaceImport = 245, - NamedImports = 246, - ImportSpecifier = 247, - ExportAssignment = 248, - ExportDeclaration = 249, - NamedExports = 250, - ExportSpecifier = 251, - MissingDeclaration = 252, - ExternalModuleReference = 253, - JsxElement = 254, - JsxSelfClosingElement = 255, - JsxOpeningElement = 256, - JsxClosingElement = 257, - JsxFragment = 258, - JsxOpeningFragment = 259, - JsxClosingFragment = 260, - JsxAttribute = 261, - JsxAttributes = 262, - JsxSpreadAttribute = 263, - JsxExpression = 264, - CaseClause = 265, - DefaultClause = 266, - HeritageClause = 267, - CatchClause = 268, - PropertyAssignment = 269, - ShorthandPropertyAssignment = 270, - SpreadAssignment = 271, - EnumMember = 272, - SourceFile = 273, - Bundle = 274, - UnparsedSource = 275, - InputFiles = 276, - JSDocTypeExpression = 277, - JSDocAllType = 278, - JSDocUnknownType = 279, - JSDocNullableType = 280, - JSDocNonNullableType = 281, - JSDocOptionalType = 282, - JSDocFunctionType = 283, - JSDocVariadicType = 284, - JSDocComment = 285, - JSDocTypeLiteral = 286, - JSDocSignature = 287, - JSDocTag = 288, - JSDocAugmentsTag = 289, - JSDocClassTag = 290, - JSDocCallbackTag = 291, - JSDocParameterTag = 292, - JSDocReturnTag = 293, - JSDocTypeTag = 294, - JSDocTemplateTag = 295, - JSDocTypedefTag = 296, - JSDocPropertyTag = 297, - SyntaxList = 298, - NotEmittedStatement = 299, - PartiallyEmittedExpression = 300, - CommaListExpression = 301, - MergeDeclarationMarker = 302, - EndOfDeclarationMarker = 303, - Count = 304, + UnknownKeyword = 142, + FromKeyword = 143, + GlobalKeyword = 144, + OfKeyword = 145, + QualifiedName = 146, + ComputedPropertyName = 147, + TypeParameter = 148, + Parameter = 149, + Decorator = 150, + PropertySignature = 151, + PropertyDeclaration = 152, + MethodSignature = 153, + MethodDeclaration = 154, + Constructor = 155, + GetAccessor = 156, + SetAccessor = 157, + CallSignature = 158, + ConstructSignature = 159, + IndexSignature = 160, + TypePredicate = 161, + TypeReference = 162, + FunctionType = 163, + ConstructorType = 164, + TypeQuery = 165, + TypeLiteral = 166, + ArrayType = 167, + TupleType = 168, + UnionType = 169, + IntersectionType = 170, + ConditionalType = 171, + InferType = 172, + ParenthesizedType = 173, + ThisType = 174, + TypeOperator = 175, + IndexedAccessType = 176, + MappedType = 177, + LiteralType = 178, + ImportType = 179, + ObjectBindingPattern = 180, + ArrayBindingPattern = 181, + BindingElement = 182, + ArrayLiteralExpression = 183, + ObjectLiteralExpression = 184, + PropertyAccessExpression = 185, + ElementAccessExpression = 186, + CallExpression = 187, + NewExpression = 188, + TaggedTemplateExpression = 189, + TypeAssertionExpression = 190, + ParenthesizedExpression = 191, + FunctionExpression = 192, + ArrowFunction = 193, + DeleteExpression = 194, + TypeOfExpression = 195, + VoidExpression = 196, + AwaitExpression = 197, + PrefixUnaryExpression = 198, + PostfixUnaryExpression = 199, + BinaryExpression = 200, + ConditionalExpression = 201, + TemplateExpression = 202, + YieldExpression = 203, + SpreadElement = 204, + ClassExpression = 205, + OmittedExpression = 206, + ExpressionWithTypeArguments = 207, + AsExpression = 208, + NonNullExpression = 209, + MetaProperty = 210, + TemplateSpan = 211, + SemicolonClassElement = 212, + Block = 213, + VariableStatement = 214, + EmptyStatement = 215, + ExpressionStatement = 216, + IfStatement = 217, + DoStatement = 218, + WhileStatement = 219, + ForStatement = 220, + ForInStatement = 221, + ForOfStatement = 222, + ContinueStatement = 223, + BreakStatement = 224, + ReturnStatement = 225, + WithStatement = 226, + SwitchStatement = 227, + LabeledStatement = 228, + ThrowStatement = 229, + TryStatement = 230, + DebuggerStatement = 231, + VariableDeclaration = 232, + VariableDeclarationList = 233, + FunctionDeclaration = 234, + ClassDeclaration = 235, + InterfaceDeclaration = 236, + TypeAliasDeclaration = 237, + EnumDeclaration = 238, + ModuleDeclaration = 239, + ModuleBlock = 240, + CaseBlock = 241, + NamespaceExportDeclaration = 242, + ImportEqualsDeclaration = 243, + ImportDeclaration = 244, + ImportClause = 245, + NamespaceImport = 246, + NamedImports = 247, + ImportSpecifier = 248, + ExportAssignment = 249, + ExportDeclaration = 250, + NamedExports = 251, + ExportSpecifier = 252, + MissingDeclaration = 253, + ExternalModuleReference = 254, + JsxElement = 255, + JsxSelfClosingElement = 256, + JsxOpeningElement = 257, + JsxClosingElement = 258, + JsxFragment = 259, + JsxOpeningFragment = 260, + JsxClosingFragment = 261, + JsxAttribute = 262, + JsxAttributes = 263, + JsxSpreadAttribute = 264, + JsxExpression = 265, + CaseClause = 266, + DefaultClause = 267, + HeritageClause = 268, + CatchClause = 269, + PropertyAssignment = 270, + ShorthandPropertyAssignment = 271, + SpreadAssignment = 272, + EnumMember = 273, + SourceFile = 274, + Bundle = 275, + UnparsedSource = 276, + InputFiles = 277, + JSDocTypeExpression = 278, + JSDocAllType = 279, + JSDocUnknownType = 280, + JSDocNullableType = 281, + JSDocNonNullableType = 282, + JSDocOptionalType = 283, + JSDocFunctionType = 284, + JSDocVariadicType = 285, + JSDocComment = 286, + JSDocTypeLiteral = 287, + JSDocSignature = 288, + JSDocTag = 289, + JSDocAugmentsTag = 290, + JSDocClassTag = 291, + JSDocCallbackTag = 292, + JSDocParameterTag = 293, + JSDocReturnTag = 294, + JSDocTypeTag = 295, + JSDocTemplateTag = 296, + JSDocTypedefTag = 297, + JSDocPropertyTag = 298, + SyntaxList = 299, + NotEmittedStatement = 300, + PartiallyEmittedExpression = 301, + CommaListExpression = 302, + MergeDeclarationMarker = 303, + EndOfDeclarationMarker = 304, + Count = 305, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -374,15 +375,15 @@ declare namespace ts { FirstReservedWord = 72, LastReservedWord = 107, FirstKeyword = 72, - LastKeyword = 144, + LastKeyword = 145, FirstFutureReservedWord = 108, LastFutureReservedWord = 116, - FirstTypeNode = 160, - LastTypeNode = 178, + FirstTypeNode = 161, + LastTypeNode = 179, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, - LastToken = 144, + LastToken = 145, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -391,11 +392,11 @@ declare namespace ts { LastTemplateToken = 16, FirstBinaryOperator = 27, LastBinaryOperator = 70, - FirstNode = 145, - FirstJSDocNode = 277, - LastJSDocNode = 297, - FirstJSDocTagNode = 288, - LastJSDocTagNode = 297 + FirstNode = 146, + FirstJSDocNode = 278, + LastJSDocNode = 298, + FirstJSDocTagNode = 289, + LastJSDocTagNode = 298 } enum NodeFlags { None = 0, @@ -460,7 +461,7 @@ declare namespace ts { flags: NodeFlags; decorators?: NodeArray; modifiers?: ModifiersArray; - parent?: Node; + parent: Node; } interface JSDocContainer { } @@ -525,12 +526,12 @@ declare namespace ts { } interface Decorator extends Node { kind: SyntaxKind.Decorator; - parent?: NamedDeclaration; + parent: NamedDeclaration; expression: LeftHandSideExpression; } interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; - parent?: DeclarationWithTypeParameters | InferTypeNode; + parent: DeclarationWithTypeParameters | InferTypeNode; name: Identifier; constraint?: TypeNode; default?: TypeNode; @@ -541,7 +542,7 @@ declare namespace ts { name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; - type: TypeNode | undefined; + type?: TypeNode; } type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { @@ -553,7 +554,7 @@ declare namespace ts { type BindingName = Identifier | BindingPattern; interface VariableDeclaration extends NamedDeclaration { kind: SyntaxKind.VariableDeclaration; - parent?: VariableDeclarationList | CatchClause; + parent: VariableDeclarationList | CatchClause; name: BindingName; exclamationToken?: ExclamationToken; type?: TypeNode; @@ -561,12 +562,12 @@ declare namespace ts { } interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; - parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement; + parent: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; - parent?: SignatureDeclaration; + parent: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; name: BindingName; questionToken?: QuestionToken; @@ -575,7 +576,7 @@ declare namespace ts { } interface BindingElement extends NamedDeclaration { kind: SyntaxKind.BindingElement; - parent?: BindingPattern; + parent: BindingPattern; propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; name: BindingName; @@ -628,12 +629,12 @@ declare namespace ts { } interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; - parent?: VariableDeclaration | ParameterDeclaration | BindingElement; + parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; - parent?: VariableDeclaration | ParameterDeclaration | BindingElement; + parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; @@ -662,47 +663,47 @@ declare namespace ts { } interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; - parent?: ObjectTypeDeclaration; + parent: ObjectTypeDeclaration; name: PropertyName; } interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; - parent?: ClassLikeDeclaration | ObjectLiteralExpression; + parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; - parent?: ClassLikeDeclaration; + parent: ClassLikeDeclaration; body?: FunctionBody; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; - parent?: ClassLikeDeclaration; + parent: ClassLikeDeclaration; } interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; - parent?: ClassLikeDeclaration | ObjectLiteralExpression; + parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; - parent?: ClassLikeDeclaration | ObjectLiteralExpression; + parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; - parent?: ObjectTypeDeclaration; + parent: ObjectTypeDeclaration; } interface TypeNode extends Node { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; @@ -730,7 +731,7 @@ declare namespace ts { } interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; - parent?: SignatureDeclaration; + parent: SignatureDeclaration; parameterName: Identifier | ThisTypeNode; type: TypeNode; } @@ -959,15 +960,15 @@ declare namespace ts { } interface TemplateHead extends LiteralLikeNode { kind: SyntaxKind.TemplateHead; - parent?: TemplateExpression; + parent: TemplateExpression; } interface TemplateMiddle extends LiteralLikeNode { kind: SyntaxKind.TemplateMiddle; - parent?: TemplateSpan; + parent: TemplateSpan; } interface TemplateTail extends LiteralLikeNode { kind: SyntaxKind.TemplateTail; - parent?: TemplateSpan; + parent: TemplateSpan; } type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; interface TemplateExpression extends PrimaryExpression { @@ -977,7 +978,7 @@ declare namespace ts { } interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; - parent?: TemplateExpression; + parent: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } @@ -991,7 +992,7 @@ declare namespace ts { } interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; - parent?: ArrayLiteralExpression | CallExpression | NewExpression; + parent: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; } /** @@ -1044,7 +1045,7 @@ declare namespace ts { } interface ExpressionWithTypeArguments extends NodeWithTypeArguments { kind: SyntaxKind.ExpressionWithTypeArguments; - parent?: HeritageClause; + parent: HeritageClause; expression: LeftHandSideExpression; } interface NewExpression extends PrimaryExpression, Declaration { @@ -1090,11 +1091,11 @@ declare namespace ts { type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; interface JsxAttributes extends ObjectLiteralExpressionBase { - parent?: JsxOpeningLikeElement; + parent: JsxOpeningLikeElement; } interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; - parent?: JsxElement; + parent: JsxElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; @@ -1113,38 +1114,38 @@ declare namespace ts { } interface JsxOpeningFragment extends Expression { kind: SyntaxKind.JsxOpeningFragment; - parent?: JsxFragment; + parent: JsxFragment; } interface JsxClosingFragment extends Expression { kind: SyntaxKind.JsxClosingFragment; - parent?: JsxFragment; + parent: JsxFragment; } interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; - parent?: JsxAttributes; + parent: JsxAttributes; name: Identifier; initializer?: StringLiteral | JsxExpression; } interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; - parent?: JsxAttributes; + parent: JsxAttributes; expression: Expression; } interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; - parent?: JsxElement; + parent: JsxElement; tagName: JsxTagNameExpression; } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; - parent?: JsxElement | JsxAttributeLike; + parent: JsxElement | JsxAttributeLike; dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { kind: SyntaxKind.JsxText; containsOnlyWhiteSpaces: boolean; - parent?: JsxElement; + parent: JsxElement; } type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; interface Statement extends Node { @@ -1245,18 +1246,18 @@ declare namespace ts { } interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; - parent?: SwitchStatement; + parent: SwitchStatement; clauses: NodeArray; } interface CaseClause extends Node { kind: SyntaxKind.CaseClause; - parent?: CaseBlock; + parent: CaseBlock; expression: Expression; statements: NodeArray; } interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; - parent?: CaseBlock; + parent: CaseBlock; statements: NodeArray; } type CaseOrDefaultClause = CaseClause | DefaultClause; @@ -1267,7 +1268,7 @@ declare namespace ts { } interface ThrowStatement extends Statement { kind: SyntaxKind.ThrowStatement; - expression: Expression; + expression?: Expression; } interface TryStatement extends Statement { kind: SyntaxKind.TryStatement; @@ -1277,7 +1278,7 @@ declare namespace ts { } interface CatchClause extends Node { kind: SyntaxKind.CatchClause; - parent?: TryStatement; + parent: TryStatement; variableDeclaration?: VariableDeclaration; block: Block; } @@ -1317,7 +1318,7 @@ declare namespace ts { } interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; - parent?: InterfaceDeclaration | ClassLikeDeclaration; + parent: InterfaceDeclaration | ClassLikeDeclaration; token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; types: NodeArray; } @@ -1329,7 +1330,7 @@ declare namespace ts { } interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; - parent?: EnumDeclaration; + parent: EnumDeclaration; name: PropertyName; initializer?: Expression; } @@ -1342,7 +1343,7 @@ declare namespace ts { type ModuleBody = NamespaceBody | JSDocNamespaceBody; interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; - parent?: ModuleBody | SourceFile; + parent: ModuleBody | SourceFile; name: ModuleName; body?: ModuleBody | JSDocNamespaceDeclaration; } @@ -1354,11 +1355,11 @@ declare namespace ts { type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: JSDocNamespaceBody; + body?: JSDocNamespaceBody; } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; - parent?: ModuleDeclaration; + parent: ModuleDeclaration; statements: NodeArray; } type ModuleReference = EntityName | ExternalModuleReference; @@ -1369,18 +1370,18 @@ declare namespace ts { */ interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; - parent?: SourceFile | ModuleBlock; + parent: SourceFile | ModuleBlock; name: Identifier; moduleReference: ModuleReference; } interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; - parent?: ImportEqualsDeclaration; - expression?: Expression; + parent: ImportEqualsDeclaration; + expression: Expression; } interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; - parent?: SourceFile | ModuleBlock; + parent: SourceFile | ModuleBlock; importClause?: ImportClause; /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier: Expression; @@ -1388,13 +1389,13 @@ declare namespace ts { type NamedImportBindings = NamespaceImport | NamedImports; interface ImportClause extends NamedDeclaration { kind: SyntaxKind.ImportClause; - parent?: ImportDeclaration; + parent: ImportDeclaration; name?: Identifier; namedBindings?: NamedImportBindings; } interface NamespaceImport extends NamedDeclaration { kind: SyntaxKind.NamespaceImport; - parent?: ImportClause; + parent: ImportClause; name: Identifier; } interface NamespaceExportDeclaration extends DeclarationStatement { @@ -1403,7 +1404,7 @@ declare namespace ts { } interface ExportDeclaration extends DeclarationStatement { kind: SyntaxKind.ExportDeclaration; - parent?: SourceFile | ModuleBlock; + parent: SourceFile | ModuleBlock; /** Will not be assigned in the case of `export * from "foo";` */ exportClause?: NamedExports; /** If this is not a StringLiteral it will be a grammar error. */ @@ -1411,24 +1412,24 @@ declare namespace ts { } interface NamedImports extends Node { kind: SyntaxKind.NamedImports; - parent?: ImportClause; + parent: ImportClause; elements: NodeArray; } interface NamedExports extends Node { kind: SyntaxKind.NamedExports; - parent?: ExportDeclaration; + parent: ExportDeclaration; elements: NodeArray; } type NamedImportsOrExports = NamedImports | NamedExports; interface ImportSpecifier extends NamedDeclaration { kind: SyntaxKind.ImportSpecifier; - parent?: NamedImports; + parent: NamedImports; propertyName?: Identifier; name: Identifier; } interface ExportSpecifier extends NamedDeclaration { kind: SyntaxKind.ExportSpecifier; - parent?: NamedExports; + parent: NamedExports; propertyName?: Identifier; name: Identifier; } @@ -1439,7 +1440,7 @@ declare namespace ts { */ interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; - parent?: SourceFile; + parent: SourceFile; isExportEquals?: boolean; expression: Expression; } @@ -1494,15 +1495,15 @@ declare namespace ts { type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; interface JSDoc extends Node { kind: SyntaxKind.JSDocComment; - parent?: HasJSDoc; - tags: NodeArray | undefined; - comment: string | undefined; + parent: HasJSDoc; + tags?: NodeArray; + comment?: string; } interface JSDocTag extends Node { parent: JSDoc | JSDocTypeLiteral; atToken: AtToken; tagName: Identifier; - comment: string | undefined; + comment?: string; } interface JSDocUnknownTag extends JSDocTag { kind: SyntaxKind.JSDocTag; @@ -1526,11 +1527,11 @@ declare namespace ts { } interface JSDocReturnTag extends JSDocTag { kind: SyntaxKind.JSDocReturnTag; - typeExpression: JSDocTypeExpression; + typeExpression?: JSDocTypeExpression; } interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; - typeExpression: JSDocTypeExpression; + typeExpression?: JSDocTypeExpression; } interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { parent: JSDoc; @@ -1608,7 +1609,7 @@ declare namespace ts { container?: FunctionExpression | ArrowFunction | MethodDeclaration; } interface FlowLabel extends FlowNodeBase { - antecedents: FlowNode[]; + antecedents: FlowNode[] | undefined; } interface FlowAssignment extends FlowNodeBase { node: Expression | VariableDeclaration | BindingElement; @@ -1635,7 +1636,7 @@ declare namespace ts { } interface AmdDependency { path: string; - name: string; + name?: string; } interface SourceFile extends Declaration { kind: SyntaxKind.SourceFile; @@ -1644,7 +1645,7 @@ declare namespace ts { fileName: string; text: string; amdDependencies: ReadonlyArray; - moduleName: string; + moduleName?: string; referencedFiles: ReadonlyArray; typeReferenceDirectives: ReadonlyArray; languageVariant: LanguageVariant; @@ -1704,7 +1705,7 @@ declare namespace ts { fileExists(path: string): boolean; readFile(path: string): string | undefined; } - type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray) => void; + type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles?: ReadonlyArray) => void; class OperationCanceledException { } interface CancellationToken { @@ -1734,9 +1735,10 @@ declare namespace ts { emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + /** The first time this is called, it will return global diagnostics (no location). */ getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; getConfigFileParsingDiagnostics(): ReadonlyArray; /** * Gets a type checker that can be used to semantically analyze source files in the program. @@ -1793,7 +1795,7 @@ declare namespace ts { emitSkipped: boolean; /** Contains declaration emit diagnostics */ diagnostics: ReadonlyArray; - emittedFiles: string[]; + emittedFiles?: string[]; } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; @@ -1810,7 +1812,7 @@ declare namespace ts { getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; /** Note that the resulting nodes cannot be checked. */ - typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode; + typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): (SignatureDeclaration & { typeArguments?: NodeArray; @@ -1846,7 +1848,7 @@ declare namespace ts { */ getExportSymbolOfSymbol(symbol: Symbol): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined; - getTypeAtLocation(node: Node): Type; + getTypeAtLocation(node: Node): Type | undefined; getTypeFromTypeNode(node: TypeNode): Type; signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; @@ -1863,9 +1865,10 @@ declare namespace ts { getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. + * returns undefined if the node is not valid. * @param argumentCount Apparent number of arguments, passed in case of a possibly incomplete call. This should come from an ArgumentListInfo. See `signatureHelp.ts`. */ - getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature; + getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined; getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined; isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined; isUndefinedSymbol(symbol: Symbol): boolean; @@ -2069,8 +2072,8 @@ declare namespace ts { interface Symbol { flags: SymbolFlags; escapedName: __String; - declarations?: Declaration[]; - valueDeclaration?: Declaration; + declarations: Declaration[]; + valueDeclaration: Declaration; members?: SymbolTable; exports?: SymbolTable; globalExports?: SymbolTable; @@ -2126,61 +2129,62 @@ declare namespace ts { type SymbolTable = UnderscoreEscapedMap; enum TypeFlags { Any = 1, - String = 2, - Number = 4, - Boolean = 8, - Enum = 16, - StringLiteral = 32, - NumberLiteral = 64, - BooleanLiteral = 128, - EnumLiteral = 256, - ESSymbol = 512, - UniqueESSymbol = 1024, - Void = 2048, - Undefined = 4096, - Null = 8192, - Never = 16384, - TypeParameter = 32768, - Object = 65536, - Union = 131072, - Intersection = 262144, - Index = 524288, - IndexedAccess = 1048576, - Conditional = 2097152, - Substitution = 4194304, - NonPrimitive = 134217728, - Literal = 224, - Unit = 13536, - StringOrNumberLiteral = 96, - PossiblyFalsy = 14574, - StringLike = 34, - NumberLike = 84, - BooleanLike = 136, - EnumLike = 272, - ESSymbolLike = 1536, - VoidLike = 6144, - UnionOrIntersection = 393216, - StructuredType = 458752, - TypeVariable = 1081344, - InstantiableNonPrimitive = 7372800, - InstantiablePrimitive = 524288, - Instantiable = 7897088, - StructuredOrInstantiable = 8355840, - Narrowable = 142575359, - NotUnionOrUnit = 134283777 + Unknown = 2, + String = 4, + Number = 8, + Boolean = 16, + Enum = 32, + StringLiteral = 64, + NumberLiteral = 128, + BooleanLiteral = 256, + EnumLiteral = 512, + ESSymbol = 1024, + UniqueESSymbol = 2048, + Void = 4096, + Undefined = 8192, + Null = 16384, + Never = 32768, + TypeParameter = 65536, + Object = 131072, + Union = 262144, + Intersection = 524288, + Index = 1048576, + IndexedAccess = 2097152, + Conditional = 4194304, + Substitution = 8388608, + NonPrimitive = 16777216, + Literal = 448, + Unit = 27072, + StringOrNumberLiteral = 192, + PossiblyFalsy = 29148, + StringLike = 68, + NumberLike = 168, + BooleanLike = 272, + EnumLike = 544, + ESSymbolLike = 3072, + VoidLike = 12288, + UnionOrIntersection = 786432, + StructuredType = 917504, + TypeVariable = 2162688, + InstantiableNonPrimitive = 14745600, + InstantiablePrimitive = 1048576, + Instantiable = 15794176, + StructuredOrInstantiable = 16711680, + Narrowable = 33492479, + NotUnionOrUnit = 16909315 } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { flags: TypeFlags; - symbol?: Symbol; + symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; aliasTypeArguments?: Type[]; } interface LiteralType extends Type { value: string | number; - freshType?: LiteralType; - regularType?: LiteralType; + freshType: LiteralType; + regularType: LiteralType; } interface UniqueESSymbolType extends Type { symbol: Symbol; @@ -2215,18 +2219,18 @@ declare namespace ts { } /** Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). */ interface InterfaceType extends ObjectType { - typeParameters: TypeParameter[]; - outerTypeParameters: TypeParameter[]; - localTypeParameters: TypeParameter[]; - thisType: TypeParameter; + typeParameters: TypeParameter[] | undefined; + outerTypeParameters: TypeParameter[] | undefined; + localTypeParameters: TypeParameter[] | undefined; + thisType: TypeParameter | undefined; } type BaseType = ObjectType | IntersectionType; interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; - declaredStringIndexInfo: IndexInfo; - declaredNumberIndexInfo: IndexInfo; + declaredStringIndexInfo?: IndexInfo; + declaredNumberIndexInfo?: IndexInfo; } /** * Type references (ObjectFlags.Reference). When a class or interface has type parameters or @@ -2277,11 +2281,11 @@ declare namespace ts { trueType: Type; falseType: Type; isDistributive: boolean; - inferTypeParameters: TypeParameter[]; + inferTypeParameters?: TypeParameter[]; outerTypeParameters?: TypeParameter[]; instantiations?: Map; - aliasSymbol: Symbol; - aliasTypeArguments: Type[]; + aliasSymbol?: Symbol; + aliasTypeArguments?: Type[]; } interface ConditionalType extends InstantiableType { root: ConditionalRoot; @@ -2359,6 +2363,11 @@ declare namespace ts { code: number; source?: string; } + interface DiagnosticWithLocation extends Diagnostic { + file: SourceFile; + start: number; + length: number; + } enum DiagnosticCategory { Warning = 0, Error = 1, @@ -2624,7 +2633,7 @@ declare namespace ts { packageId?: PackageId; } interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { - readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective; + readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; readonly failedLookupLocations: ReadonlyArray; } interface CompilerHost extends ModuleResolutionHost { @@ -2644,8 +2653,8 @@ declare namespace ts { /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): (ResolvedTypeReferenceDirective | undefined)[]; - getEnvironmentVariable?(name: string): string; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; } interface SourceMapRange extends TextRange { @@ -2657,6 +2666,7 @@ declare namespace ts { skipTrivia?: (pos: number) => number; } enum EmitFlags { + None = 0, SingleLine = 1, AdviseOnEmitNode = 2, NoSubstitution = 4, @@ -2710,7 +2720,7 @@ declare namespace ts { /** Resumes a suspended lexical environment, usually before visiting a function body. */ resumeLexicalEnvironment(): void; /** Ends a lexical environment, returning any declarations. */ - endLexicalEnvironment(): Statement[]; + endLexicalEnvironment(): Statement[] | undefined; /** Hoists a function declaration to the containing scope. */ hoistFunctionDeclaration(node: FunctionDeclaration): void; /** Hoists a variable declaration to the containing scope. */ @@ -2754,7 +2764,7 @@ declare namespace ts { /** Gets the transformed source files. */ transformed: T[]; /** Gets diagnostics for the transformation. */ - diagnostics?: Diagnostic[]; + diagnostics?: DiagnosticWithLocation[]; /** * Gets a substitute for a node, if one is available; otherwise, returns the original node. * @@ -2841,7 +2851,7 @@ declare namespace ts { * }); * ``` */ - onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + onEmitNode?(hint: EmitHint, node: Node | undefined, emitCallback: (hint: EmitHint, node: Node | undefined) => void): void; /** * 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, @@ -2954,13 +2964,13 @@ declare namespace ts { } } declare namespace ts { - const versionMajorMinor = "2.9"; + const versionMajorMinor = "3.0"; /** The version of the TypeScript compiler release */ const version: string; } declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): Diagnostic[]; + function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): T[]; } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; @@ -3014,7 +3024,7 @@ declare namespace ts { interface FileWatcher { close(): void; } - function getNodeMajorVersion(): number; + function getNodeMajorVersion(): number | undefined; let sys: System; } declare namespace ts { @@ -3041,8 +3051,8 @@ declare namespace ts { scanJSDocToken(): JsDocSyntaxKind; scan(): SyntaxKind; getText(): string; - setText(text: string, start?: number, length?: number): void; - setOnError(onError: ErrorCallback): void; + setText(text: string | undefined, start?: number, length?: number): void; + setOnError(onError: ErrorCallback | undefined): void; setScriptTarget(scriptTarget: ScriptTarget): void; setLanguageVariant(variant: LanguageVariant): void; setTextPos(textPos: number): void; @@ -3062,15 +3072,15 @@ declare namespace ts { function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; - function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; - function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; + function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined; + function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined; function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; /** Optionally, get the shebang */ function getShebang(text: string): string | undefined; - function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; - function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; - function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; + function isIdentifierStart(ch: number, languageVersion: ScriptTarget | undefined): boolean; + function isIdentifierPart(ch: number, languageVersion: ScriptTarget | undefined): boolean; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, textInitial?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3079,12 +3089,12 @@ declare namespace ts { function textSpanContainsPosition(span: TextSpan, position: number): boolean; function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean; function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean; - function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan; + function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan | undefined; function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean; function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean; function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; - function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan; + function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan | undefined; function createTextSpan(start: number, length: number): TextSpan; function createTextSpanFromBounds(start: number, end: number): TextSpan; function textChangeRangeNewSpan(range: TextChangeRange): TextSpan; @@ -3100,7 +3110,7 @@ declare namespace ts { * Vn. */ function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; - function getTypeParameterOwner(d: Declaration): Declaration; + function getTypeParameterOwner(d: Declaration): Declaration | undefined; type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration; name: Identifier; @@ -3122,6 +3132,8 @@ declare namespace ts { }, errors?: Push): void; function getOriginalNode(node: Node): Node; function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; + function getOriginalNode(node: Node | undefined): Node | undefined; + function getOriginalNode(node: Node | undefined, nodeTest: (node: Node | undefined) => node is T): T | undefined; /** * Gets a value indicating whether a node originated in the parse tree. * @@ -3142,7 +3154,7 @@ declare namespace ts { * @param nodeTest A callback used to ensure the correct type of parse tree node is returned. * @returns The original parse tree node if found; otherwise, undefined. */ - function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; + function getParseTreeNode(node: Node | undefined, nodeTest?: (node: Node) => node is T): T | undefined; /** * Remove extra underscore from escaped identifier text content. * @@ -3160,7 +3172,7 @@ declare namespace ts { */ function unescapeIdentifier(id: string): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined; - function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; + function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName; /** * Gets the JSDoc parameter tags for the node if present. * @@ -3389,8 +3401,10 @@ declare namespace ts { */ function isToken(n: Node): boolean; function isLiteralExpression(node: Node): node is LiteralExpression; + type TemplateLiteralToken = NoSubstitutionTemplateLiteral | TemplateHead | TemplateMiddle | TemplateTail; + function isTemplateLiteralToken(node: Node): node is TemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail; - function isStringTextContainingNode(node: Node): boolean; + function isStringTextContainingNode(node: Node): node is StringLiteral | TemplateLiteralToken; function isModifier(node: Node): node is Modifier; function isEntityName(node: Node): node is EntityName; function isPropertyName(node: Node): node is PropertyName; @@ -3442,7 +3456,7 @@ declare namespace ts { */ function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; - function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName; + function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; /** * Parse json text into SyntaxTree and return node and parse errors if any * @param fileName @@ -3488,7 +3502,7 @@ declare namespace ts { getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; } interface PerModuleNameCache { - get(directory: string): ResolvedModuleWithFailedLookupLocations; + get(directory: string): ResolvedModuleWithFailedLookupLocations | undefined; set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; @@ -3570,7 +3584,7 @@ declare namespace ts { function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; function createTypeQueryNode(exprName: EntityName): TypeQueryNode; function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; - function createTypeLiteralNode(members: ReadonlyArray): TypeLiteralNode; + function createTypeLiteralNode(members: ReadonlyArray | undefined): TypeLiteralNode; function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; @@ -3609,23 +3623,23 @@ declare namespace ts { function updateArrayLiteral(node: ArrayLiteralExpression, elements: ReadonlyArray): ArrayLiteralExpression; function createObjectLiteral(properties?: ReadonlyArray, multiLine?: boolean): ObjectLiteralExpression; function updateObjectLiteral(node: ObjectLiteralExpression, properties: ReadonlyArray): ObjectLiteralExpression; - function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; + function createPropertyAccess(expression: Expression, name: string | Identifier | undefined): PropertyAccessExpression; function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; + function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): CallExpression; function updateCall(node: CallExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; function createNew(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; function updateNew(node: NewExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray, template: TemplateLiteral): TaggedTemplateExpression; + function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; + function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; @@ -3655,15 +3669,15 @@ declare namespace ts { function createTemplateTail(text: string): TemplateTail; function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral; function createYield(expression?: Expression): YieldExpression; - function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; + function createYield(asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray, members: ReadonlyArray): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray, members: ReadonlyArray): ClassExpression; + function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; function createOmittedExpression(): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: ReadonlyArray, expression: Expression): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray, expression: Expression): ExpressionWithTypeArguments; + function createExpressionWithTypeArguments(typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; function createAsExpression(expression: Expression, type: TypeNode): AsExpression; function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; function createNonNullExpression(expression: Expression): NonNullExpression; @@ -3690,8 +3704,8 @@ declare namespace ts { function updateFor(node: ForStatement, initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement): ForStatement; function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; - function createForOf(awaitModifier: AwaitKeywordToken, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; - function updateForOf(node: ForOfStatement, awaitModifier: AwaitKeywordToken, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function createForOf(awaitModifier: AwaitKeywordToken | undefined, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function updateForOf(node: ForOfStatement, awaitModifier: AwaitKeywordToken | undefined, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; function createContinue(label?: string | Identifier): ContinueStatement; function updateContinue(node: ContinueStatement, label: Identifier | undefined): ContinueStatement; function createBreak(label?: string | Identifier): BreakStatement; @@ -3715,8 +3729,8 @@ declare namespace ts { function updateVariableDeclarationList(node: VariableDeclarationList, declarations: ReadonlyArray): VariableDeclarationList; function createFunctionDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; function updateFunctionDeclaration(node: FunctionDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray, members: ReadonlyArray): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray, members: ReadonlyArray): ClassDeclaration; + function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; function createInterfaceDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; function createTypeAliasDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; @@ -3734,7 +3748,7 @@ declare namespace ts { function createImportEqualsDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; function createImportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression | undefined): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; function createImportClause(name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function updateImportClause(node: ImportClause, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; @@ -3743,7 +3757,7 @@ declare namespace ts { function updateNamedImports(node: NamedImports, elements: ReadonlyArray): NamedImports; function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean, expression: Expression): ExportAssignment; + function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; function updateExportAssignment(node: ExportAssignment, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, expression: Expression): ExportAssignment; function createExportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; function updateExportDeclaration(node: ExportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; @@ -3873,16 +3887,16 @@ declare namespace ts { */ function setCommentRange(node: T, range: TextRange): T; function getSyntheticLeadingComments(node: Node): SynthesizedComment[] | undefined; - function setSyntheticLeadingComments(node: T, comments: SynthesizedComment[]): T; + function setSyntheticLeadingComments(node: T, comments: SynthesizedComment[] | undefined): T; function addSyntheticLeadingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T; function getSyntheticTrailingComments(node: Node): SynthesizedComment[] | undefined; - function setSyntheticTrailingComments(node: T, comments: SynthesizedComment[]): T; + function setSyntheticTrailingComments(node: T, comments: SynthesizedComment[] | undefined): T; function addSyntheticTrailingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T; function moveSyntheticComments(node: T, original: Node): T; /** * Gets the constant value to emit for an expression. */ - function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): string | number; + function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): string | number | undefined; /** * Sets the constant value to emit for an expression. */ @@ -3918,7 +3932,7 @@ declare namespace ts { * @param test A callback to execute to verify the Node is valid. * @param lift An optional callback to execute to lift a NodeArray into a valid Node. */ - function visitNode(node: T, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T; + function visitNode(node: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T; /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. * @@ -3927,7 +3941,7 @@ declare namespace ts { * @param test A callback to execute to verify the Node is valid. * @param lift An optional callback to execute to lift a NodeArray into a valid Node. */ - function visitNode(node: T | undefined, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T | undefined; + function visitNode(node: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T | undefined; /** * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. * @@ -3937,7 +3951,7 @@ declare namespace ts { * @param start An optional value indicating the starting offset at which to start visiting. * @param count An optional value indicating the maximum number of nodes to visit. */ - function visitNodes(nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; + function visitNodes(nodes: NodeArray | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; /** * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. * @@ -3957,7 +3971,7 @@ declare namespace ts { * Starts a new lexical environment and visits a parameter list, suspending the lexical * environment upon completion. */ - function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): NodeArray; + function visitParameterList(nodes: NodeArray | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): NodeArray; /** * Resumes a suspended lexical environment and visits a function body, ending the lexical * environment and merging hoisted declarations upon completion. @@ -4006,8 +4020,19 @@ declare namespace ts { function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; + function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain | undefined, newLine: string): string; function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): ReadonlyArray; + /** + * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' + * that represent a compilation unit. + * + * Creating a program proceeds from a set of root files, expanding the set of inputs by following imports and + * triple-slash-reference-path directives transitively. '@types' and triple-slash-reference-types are also pulled in. + * + * @param createProgramOptions - The options for creating a program. + * @returns A 'Program' object. + */ + function createProgram(createProgramOptions: CreateProgramOptions): Program; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4022,7 +4047,6 @@ declare namespace ts { * @param configFileParsingDiagnostics - error during config file parsing * @returns A 'Program' object. */ - function createProgram(createProgramOptions: CreateProgramOptions): Program; function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; } declare namespace ts { @@ -4148,18 +4172,18 @@ declare namespace ts { * Create the builder to manage semantic diagnostics and cache them */ function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; - function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; /** * Create the builder that can handle the changes in program and iterate through changed files * to emit the those files and manage semantic diagnostics cache as well */ function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; - function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; /** * Creates a builder thats just abstraction over program and can be used with watch */ function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; - function createAbstractBuilder(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; + function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; } declare namespace ts { type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void; @@ -4201,11 +4225,11 @@ declare namespace ts { /** If provided would be used to write log about compilation */ trace?(s: string): void; /** If provided is used to get the environment variable */ - getEnvironmentVariable?(name: string): string; + getEnvironmentVariable?(name: string): string | undefined; /** If provided, used to resolve the module names, otherwise typescript's default module resolution */ resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; /** Used to watch changes in source files, missing files needed to update the program or config file */ watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; /** Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added */ @@ -4355,8 +4379,8 @@ declare namespace ts { getLeadingTriviaWidth(sourceFile?: SourceFile): number; getFullText(sourceFile?: SourceFile): string; getText(sourceFile?: SourceFile): string; - getFirstToken(sourceFile?: SourceFile): Node; - getLastToken(sourceFile?: SourceFile): Node; + getFirstToken(sourceFile?: SourceFile): Node | undefined; + getLastToken(sourceFile?: SourceFile): Node | undefined; forEachChild(cbNode: (node: Node) => T | undefined, cbNodeArray?: (nodes: NodeArray) => T | undefined): T | undefined; } interface Identifier { @@ -4444,7 +4468,7 @@ declare namespace ts { referencedFiles: FileReference[]; typeReferenceDirectives: FileReference[]; importedFiles: FileReference[]; - ambientExternalModules: string[]; + ambientExternalModules?: string[]; isLibFile: boolean; } interface HostCancellationToken { @@ -4477,7 +4501,7 @@ declare namespace ts { fileExists?(path: string): boolean; getTypeRootsVersion?(): number; resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; - getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations; + getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getDirectories?(directoryName: string): string[]; /** @@ -4497,9 +4521,10 @@ declare namespace ts { } interface LanguageService { cleanupSemanticCache(): void; - getSyntacticDiagnostics(fileName: string): Diagnostic[]; + getSyntacticDiagnostics(fileName: string): DiagnosticWithLocation[]; + /** The first time this is called, it will return global diagnostics (no location). */ getSemanticDiagnostics(fileName: string): Diagnostic[]; - getSuggestionDiagnostics(fileName: string): Diagnostic[]; + getSuggestionDiagnostics(fileName: string): DiagnosticWithLocation[]; getCompilerOptionsDiagnostics(): Diagnostic[]; /** * @deprecated Use getEncodedSyntacticClassifications instead. @@ -4511,24 +4536,24 @@ declare namespace ts { getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; - getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): CompletionInfo; - getCompletionEntryDetails(fileName: string, position: number, name: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails; - getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol; - getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; - getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan; - getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan; - getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems; + getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): CompletionInfo | undefined; + getCompletionEntryDetails(fileName: string, position: number, name: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails | undefined; + getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol | undefined; + getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined; + getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined; + getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; + getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; - getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; - getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan; - getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; - getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[]; - getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; - findReferences(fileName: string, position: number): ReferencedSymbol[]; - getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; + getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; + getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; + getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] | undefined; + getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; + findReferences(fileName: string, position: number): ReferencedSymbol[] | undefined; + getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; /** @deprecated */ - getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -4539,9 +4564,14 @@ 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; + getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion | undefined; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan; + /** + * 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. + * Editors should call this after `>` is typed. + */ + getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined; + getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; @@ -4557,11 +4587,14 @@ declare namespace ts { getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined): 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): ReadonlyArray; - getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings): ReadonlyArray; + getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; - getProgram(): Program; + getProgram(): Program | undefined; dispose(): void; } + interface JsxClosingTagInfo { + readonly newText: string; + } interface CombinedCodeFixScope { type: "file"; fileName: string; @@ -4662,7 +4695,7 @@ declare namespace ts { } interface CombinedCodeActions { changes: ReadonlyArray; - commands: ReadonlyArray | undefined; + commands?: ReadonlyArray; } type CodeActionCommand = InstallPackageAction; interface InstallPackageAction { @@ -4712,8 +4745,8 @@ declare namespace ts { */ interface RefactorEditInfo { edits: FileTextChanges[]; - renameFilename: string | undefined; - renameLocation: number | undefined; + renameFilename?: string; + renameLocation?: number; commands?: CodeActionCommand[]; } interface TextInsertion { @@ -4834,7 +4867,7 @@ declare namespace ts { containerName: string; } interface DefinitionInfoAndBoundSpan { - definitions: ReadonlyArray; + definitions?: ReadonlyArray; textSpan: TextSpan; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { @@ -4880,13 +4913,13 @@ declare namespace ts { kind: ScriptElementKind; kindModifiers: string; textSpan: TextSpan; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - tags: JSDocTagInfo[]; + displayParts?: SymbolDisplayPart[]; + documentation?: SymbolDisplayPart[]; + tags?: JSDocTagInfo[]; } interface RenameInfo { canRename: boolean; - localizedErrorMessage: string; + localizedErrorMessage?: string; displayName: string; fullDisplayName: string; kind: ScriptElementKind; @@ -4938,7 +4971,7 @@ declare namespace ts { interface CompletionEntry { name: string; kind: ScriptElementKind; - kindModifiers: string; + kindModifiers?: string; sortText: string; insertText?: string; /** @@ -4956,8 +4989,8 @@ declare namespace ts { kind: ScriptElementKind; kindModifiers: string; displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - tags: JSDocTagInfo[]; + documentation?: SymbolDisplayPart[]; + tags?: JSDocTagInfo[]; codeActions?: CodeAction[]; source?: SymbolDisplayPart[]; } @@ -5270,12 +5303,12 @@ declare namespace ts { /** The version of the language service API */ const servicesVersion = "0.8"; function toEditorSettings(options: EditorOptions | EditorSettings): EditorSettings; - function displayPartsToString(displayParts: SymbolDisplayPart[]): string; + function displayPartsToString(displayParts: SymbolDisplayPart[] | undefined): string; function getDefaultCompilerOptions(): CompilerOptions; function getSupportedCodeFixes(): string[]; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile; let disableIncrementalParsing: boolean; - function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange | undefined, aggressiveChecks?: boolean): SourceFile; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry, syntaxOnly?: boolean): LanguageService; /** * Get the path of the default library files (lib.d.ts) as distributed with the typescript @@ -5433,7 +5466,7 @@ declare namespace ts.server { startGroup(): void; endGroup(): void; msg(s: string, type?: Msg): void; - getLogFileName(): string; + getLogFileName(): string | undefined; } enum Msg { Err = "Err", @@ -5458,7 +5491,7 @@ declare namespace ts.server { function normalizedPathToPath(normalizedPath: NormalizedPath, currentDirectory: string, getCanonicalFileName: (f: string) => string): Path; function asNormalizedPath(fileName: string): NormalizedPath; interface NormalizedPathMap { - get(path: NormalizedPath): T; + get(path: NormalizedPath): T | undefined; set(path: NormalizedPath, value: T): void; contains(path: NormalizedPath): boolean; remove(path: NormalizedPath): void; @@ -5491,6 +5524,7 @@ declare namespace ts.server { */ declare namespace ts.server.protocol { enum CommandTypes { + JsxClosingTag = "jsxClosingTag", Brace = "brace", BraceCompletion = "braceCompletion", GetSpanOfEnclosingComment = "getSpanOfEnclosingComment", @@ -6160,6 +6194,15 @@ declare namespace ts.server.protocol { */ openingBrace: string; } + interface JsxClosingTagRequest extends FileLocationRequest { + readonly command: CommandTypes.JsxClosingTag; + readonly arguments: JsxClosingTagRequestArgs; + } + interface JsxClosingTagRequestArgs extends FileLocationRequestArgs { + } + interface JsxClosingTagResponse extends Response { + readonly body: TextInsertion; + } /** * @deprecated * Get occurrences request; value of command field is @@ -6851,7 +6894,7 @@ declare namespace ts.server.protocol { } interface CompletionEntryIdentifier { name: string; - source: string; + source?: string; } /** * Completion entry details request; value of command field is @@ -6891,7 +6934,7 @@ declare namespace ts.server.protocol { /** * Optional modifiers for the kind (such as 'public'). */ - kindModifiers: string; + kindModifiers?: string; /** * A string that is used for comparing completion items so that they can be ordered. This * is often the same as the name but may be different in certain circumstances. @@ -6948,11 +6991,11 @@ declare namespace ts.server.protocol { /** * Documentation strings for the symbol. */ - documentation: SymbolDisplayPart[]; + documentation?: SymbolDisplayPart[]; /** * JSDoc tags for the symbol. */ - tags: JSDocTagInfo[]; + tags?: JSDocTagInfo[]; /** * The associated code actions for this entry */ @@ -7727,15 +7770,15 @@ declare namespace ts.server { close(fileExists?: boolean): void; getSnapshot(): IScriptSnapshot; private ensureRealPath; - getFormatCodeSettings(): FormatCodeSettings; - getPreferences(): UserPreferences; + getFormatCodeSettings(): FormatCodeSettings | undefined; + getPreferences(): UserPreferences | undefined; attachToProject(project: Project): boolean; isAttached(project: Project): boolean; detachFromProject(project: Project): void; detachAllProjects(): void; getDefaultProject(): Project; registerFileUpdate(): void; - setOptions(formatSettings: FormatCodeSettings, preferences: UserPreferences): void; + setOptions(formatSettings: FormatCodeSettings, preferences: UserPreferences | undefined): void; getLatestVersion(): string; saveTo(fileName: string): void; reloadFromFile(tempFileName?: NormalizedPath): void; @@ -7763,7 +7806,7 @@ declare namespace ts.server { interface ITypingsInstaller { isKnownTypesPackageName(name: string): boolean; installPackage(options: InstallPackageOptionsWithProject): Promise; - enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray): void; + enqueueInstallTypingsRequest(p: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray | undefined): void; attach(projectService: ProjectService): void; onProjectClosed(p: Project): void; readonly globalTypingsCacheLocation: string | undefined; @@ -7856,7 +7899,7 @@ declare namespace ts.server { private getOrCreateScriptInfoAndAttachToProject; getScriptKind(fileName: string): ScriptKind; getScriptVersion(filename: string): string; - getScriptSnapshot(filename: string): IScriptSnapshot; + getScriptSnapshot(filename: string): IScriptSnapshot | undefined; getCancellationToken(): HostCancellationToken; getCurrentDirectory(): string; getDefaultLibFileName(): string; @@ -7865,7 +7908,7 @@ declare namespace ts.server { readFile(fileName: string): string | undefined; fileExists(file: string): boolean; resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModuleFull[]; - getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations; + getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; resolveTypeReferenceDirectives(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; directoryExists(path: string): boolean; getDirectories(path: string): string[]; @@ -7890,7 +7933,7 @@ declare namespace ts.server { abstract getTypeAcquisition(): TypeAcquisition; protected removeLocalTypingsFromTypeAcquisition(newTypeAcquisition: TypeAcquisition): TypeAcquisition; getExternalFiles(): SortedReadonlyArray; - getSourceFile(path: Path): SourceFile; + getSourceFile(path: Path): SourceFile | undefined; close(): void; private detachScriptInfoIfNotRoot; isClosed(): boolean; @@ -7920,7 +7963,7 @@ declare namespace ts.server { private addMissingFileWatcher; private isWatchedMissingFile; getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo | undefined; - getScriptInfo(uncheckedFileName: string): ScriptInfo; + getScriptInfo(uncheckedFileName: string): ScriptInfo | undefined; filesToString(writeProjectFileNames: boolean): string; setCompilerOptions(compilerOptions: CompilerOptions): void; protected removeRoot(info: ScriptInfo): void; @@ -8066,7 +8109,7 @@ declare namespace ts.server { readonly info: OpenFileInfo; } interface ProjectInfoTypeAcquisitionData { - readonly enable: boolean; + readonly enable: boolean | undefined; readonly include: boolean; readonly exclude: boolean; } @@ -8127,7 +8170,6 @@ declare namespace ts.server { syntaxOnly?: boolean; } class ProjectService { - private readonly documentRegistry; /** * Container of all known scripts */ @@ -8152,7 +8194,7 @@ declare namespace ts.server { /** * Open files: with value being project root path, and key being Path of the file that is open */ - readonly openFiles: Map; + readonly openFiles: Map; /** * Map of open files that are opened without complete path but have projectRoot as current directory */ @@ -8176,7 +8218,7 @@ declare namespace ts.server { private safelist; private legacySafelist; private pendingProjectUpdates; - readonly currentDirectory: string; + readonly currentDirectory: NormalizedPath; readonly toCanonicalFileName: (f: string) => string; readonly host: ServerHost; readonly logger: Logger; @@ -8204,8 +8246,8 @@ declare namespace ts.server { private delayUpdateProjectGraphs; setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions, projectRootPath?: string): void; findProject(projectName: string): Project | undefined; - getDefaultProjectForFile(fileName: NormalizedPath, ensureProject: boolean): Project; - getScriptInfoEnsuringProjectsUptoDate(uncheckedFileName: string): ScriptInfo; + getDefaultProjectForFile(fileName: NormalizedPath, ensureProject: boolean): Project | undefined; + getScriptInfoEnsuringProjectsUptoDate(uncheckedFileName: string): ScriptInfo | undefined; /** * Ensures the project structures are upto date * This means, @@ -8289,18 +8331,18 @@ declare namespace ts.server { private getOrCreateSingleInferredProjectIfEnabled; private getOrCreateSingleInferredWithoutProjectRoot; private createInferredProject; - getScriptInfo(uncheckedFileName: string): ScriptInfo; + getScriptInfo(uncheckedFileName: string): ScriptInfo | undefined; private watchClosedScriptInfo; private stopWatchingScriptInfo; getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, hostToQueryFileExistsOn?: { fileExists(path: string): boolean; - }): ScriptInfo; + }): ScriptInfo | undefined; private getOrCreateScriptInfoWorker; /** * This gets the script info for the normalized path. If the path is not rooted disk path then the open script info with project root context is preferred */ - getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; - getScriptInfoForPath(fileName: Path): ScriptInfo; + getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo | undefined; + getScriptInfoForPath(fileName: Path): ScriptInfo | undefined; setHostConfiguration(args: protocol.ConfigureRequestArguments): void; closeLog(): void; /** @@ -8391,6 +8433,7 @@ declare namespace ts.server { suppressDiagnosticEvents?: boolean; syntaxOnly?: boolean; throttleWaitMilliseconds?: number; + noGetErrOnBackgroundUpdate?: boolean; globalPlugins?: ReadonlyArray; pluginProbeLocations?: ReadonlyArray; allowLocalPluginLoads?: boolean; @@ -8410,6 +8453,7 @@ declare namespace ts.server { protected canUseEvents: boolean; private suppressDiagnosticEvents?; private eventHandler; + private readonly noGetErrOnBackgroundUpdate?; constructor(opts: SessionOptions); private sendRequestCompletedEvent; private defaultEventHandler; @@ -8447,6 +8491,7 @@ declare namespace ts.server { private getSyntacticDiagnosticsSync; private getSemanticDiagnosticsSync; private getSuggestionDiagnosticsSync; + private getJsxClosingTag; private getDocumentHighlights; private setCompilerOptionsForInferredProjects; private getProjectInfo; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index ae049cd4143..d03353a3474 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -202,190 +202,191 @@ var ts; SyntaxKind[SyntaxKind["TypeKeyword"] = 139] = "TypeKeyword"; SyntaxKind[SyntaxKind["UndefinedKeyword"] = 140] = "UndefinedKeyword"; SyntaxKind[SyntaxKind["UniqueKeyword"] = 141] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 142] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 143] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 144] = "OfKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 142] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 143] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 144] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 145] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 145] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 146] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 146] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 147] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 147] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 148] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 149] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 148] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 149] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 150] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 150] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 151] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 152] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 153] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 154] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 155] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 156] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 157] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 158] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 159] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 151] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 152] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 153] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 154] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 155] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 156] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 157] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 158] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 159] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 160] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 160] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 161] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 162] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 163] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 164] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 165] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 166] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 167] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 168] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 169] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 170] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 171] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 172] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 173] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 174] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 175] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 176] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 177] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 178] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 161] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 162] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 163] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 164] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 165] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 166] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 167] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 168] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 169] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 170] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 171] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 172] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 173] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 174] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 175] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 176] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 177] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 178] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 179] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 179] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 180] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 181] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 180] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 181] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 182] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 182] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 183] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 184] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 185] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 186] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 187] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 188] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 189] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 190] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 191] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 192] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 193] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 194] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 195] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 196] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 197] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 198] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 199] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 200] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 201] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 202] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 203] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 204] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 205] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 206] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 207] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 208] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 209] = "MetaProperty"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 183] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 184] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 185] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 186] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 187] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 188] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 189] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 190] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 191] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 192] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 193] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 194] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 195] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 196] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 197] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 198] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 199] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 200] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 201] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 202] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 203] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 204] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 205] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 206] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 207] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 208] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 209] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 210] = "MetaProperty"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 210] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 211] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 211] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 212] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 212] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 213] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 214] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 215] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 216] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 217] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 218] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 219] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 220] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 221] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 222] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 223] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 224] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 225] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 226] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 227] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 228] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 229] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 230] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 231] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 232] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 233] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 234] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 235] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 236] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 237] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 238] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 239] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 240] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 241] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 242] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 243] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 244] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 245] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 246] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 247] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 248] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 249] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 250] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 251] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 252] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 213] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 214] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 215] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 216] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 217] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 218] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 219] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 220] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 221] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 222] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 223] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 224] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 225] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 226] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 227] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 228] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 229] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 230] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 231] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 232] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 233] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 234] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 235] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 236] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 237] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 238] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 239] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 240] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 241] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 242] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 243] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 244] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 245] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 246] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 247] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 248] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 249] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 250] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 251] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 252] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 253] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 253] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 254] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 254] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 255] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 256] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 257] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 258] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 259] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 260] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 261] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 262] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 263] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 264] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 255] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 256] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 257] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 258] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 259] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 260] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 261] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 262] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 263] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 264] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 265] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 265] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 266] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 267] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 268] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 266] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 267] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 268] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 269] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 269] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 270] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 271] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 270] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 271] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 272] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 272] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 273] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 273] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 274] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 275] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 276] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 274] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 275] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 276] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 277] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 277] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 278] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 278] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 279] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 279] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 280] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 281] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 282] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 283] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 284] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 285] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 286] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 287] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 288] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 289] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 290] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 291] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 292] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 293] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 294] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 295] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 296] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 297] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 280] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 281] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 282] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 283] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 284] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 285] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 286] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 288] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 289] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 290] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 291] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 292] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 293] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 294] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 295] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 296] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 297] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 298] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 298] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 299] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 299] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 300] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 301] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 302] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 303] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 300] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 301] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 302] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 303] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 304] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 304] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 305] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; @@ -394,15 +395,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 144] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 145] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 160] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 178] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 179] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 144] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 145] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -411,13 +412,13 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 145] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 277] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 297] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 288] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 297] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 278] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 298] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 289] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 298] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 144] = "LastContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -857,89 +858,93 @@ var ts; var TypeFlags; (function (TypeFlags) { TypeFlags[TypeFlags["Any"] = 1] = "Any"; - TypeFlags[TypeFlags["String"] = 2] = "String"; - TypeFlags[TypeFlags["Number"] = 4] = "Number"; - TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; - TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; - TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; - TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; - TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; - TypeFlags[TypeFlags["UniqueESSymbol"] = 1024] = "UniqueESSymbol"; - TypeFlags[TypeFlags["Void"] = 2048] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 4096] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 8192] = "Null"; - TypeFlags[TypeFlags["Never"] = 16384] = "Never"; - TypeFlags[TypeFlags["TypeParameter"] = 32768] = "TypeParameter"; - TypeFlags[TypeFlags["Object"] = 65536] = "Object"; - TypeFlags[TypeFlags["Union"] = 131072] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 262144] = "Intersection"; - TypeFlags[TypeFlags["Index"] = 524288] = "Index"; - TypeFlags[TypeFlags["IndexedAccess"] = 1048576] = "IndexedAccess"; - TypeFlags[TypeFlags["Conditional"] = 2097152] = "Conditional"; - TypeFlags[TypeFlags["Substitution"] = 4194304] = "Substitution"; + TypeFlags[TypeFlags["Unknown"] = 2] = "Unknown"; + TypeFlags[TypeFlags["String"] = 4] = "String"; + TypeFlags[TypeFlags["Number"] = 8] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 16] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 32] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 64] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 128] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 256] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 512] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 1024] = "ESSymbol"; + TypeFlags[TypeFlags["UniqueESSymbol"] = 2048] = "UniqueESSymbol"; + TypeFlags[TypeFlags["Void"] = 4096] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 8192] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 16384] = "Null"; + TypeFlags[TypeFlags["Never"] = 32768] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 65536] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 131072] = "Object"; + TypeFlags[TypeFlags["Union"] = 262144] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 524288] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 1048576] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 2097152] = "IndexedAccess"; + TypeFlags[TypeFlags["Conditional"] = 4194304] = "Conditional"; + TypeFlags[TypeFlags["Substitution"] = 8388608] = "Substitution"; + TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; /* @internal */ - TypeFlags[TypeFlags["FreshLiteral"] = 8388608] = "FreshLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 33554432] = "FreshLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsWideningType"] = 16777216] = "ContainsWideningType"; + TypeFlags[TypeFlags["UnionOfUnitTypes"] = 67108864] = "UnionOfUnitTypes"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 33554432] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 134217728] = "ContainsWideningType"; /* @internal */ - TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 67108864] = "ContainsAnyFunctionType"; - TypeFlags[TypeFlags["NonPrimitive"] = 134217728] = "NonPrimitive"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 268435456] = "ContainsObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["UnionOfUnitTypes"] = 268435456] = "UnionOfUnitTypes"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 536870912] = "ContainsAnyFunctionType"; /* @internal */ - TypeFlags[TypeFlags["GenericMappedType"] = 536870912] = "GenericMappedType"; + TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; /* @internal */ - TypeFlags[TypeFlags["Nullable"] = 12288] = "Nullable"; - TypeFlags[TypeFlags["Literal"] = 224] = "Literal"; - TypeFlags[TypeFlags["Unit"] = 13536] = "Unit"; - TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["Nullable"] = 24576] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 448] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 27072] = "Unit"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 192] = "StringOrNumberLiteral"; /* @internal */ - TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 1120] = "StringOrNumberLiteralOrUnique"; + TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 2240] = "StringOrNumberLiteralOrUnique"; /* @internal */ - TypeFlags[TypeFlags["DefinitelyFalsy"] = 14560] = "DefinitelyFalsy"; - TypeFlags[TypeFlags["PossiblyFalsy"] = 14574] = "PossiblyFalsy"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 29120] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 29148] = "PossiblyFalsy"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 134249103] = "Intrinsic"; + TypeFlags[TypeFlags["Intrinsic"] = 16839967] = "Intrinsic"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 16382] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 84] = "NumberLike"; - TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; - TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; - TypeFlags[TypeFlags["ESSymbolLike"] = 1536] = "ESSymbolLike"; - TypeFlags[TypeFlags["VoidLike"] = 6144] = "VoidLike"; + TypeFlags[TypeFlags["Primitive"] = 32764] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 68] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 168] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 272] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 544] = "EnumLike"; + TypeFlags[TypeFlags["ESSymbolLike"] = 3072] = "ESSymbolLike"; + TypeFlags[TypeFlags["VoidLike"] = 12288] = "VoidLike"; /* @internal */ - TypeFlags[TypeFlags["DisjointDomains"] = 134233854] = "DisjointDomains"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 393216] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 458752] = "StructuredType"; - TypeFlags[TypeFlags["TypeVariable"] = 1081344] = "TypeVariable"; - TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 7372800] = "InstantiableNonPrimitive"; - TypeFlags[TypeFlags["InstantiablePrimitive"] = 524288] = "InstantiablePrimitive"; - TypeFlags[TypeFlags["Instantiable"] = 7897088] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 8355840] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["DisjointDomains"] = 16809468] = "DisjointDomains"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 786432] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 917504] = "StructuredType"; + TypeFlags[TypeFlags["TypeVariable"] = 2162688] = "TypeVariable"; + TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 14745600] = "InstantiableNonPrimitive"; + TypeFlags[TypeFlags["InstantiablePrimitive"] = 1048576] = "InstantiablePrimitive"; + TypeFlags[TypeFlags["Instantiable"] = 15794176] = "Instantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 16711680] = "StructuredOrInstantiable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 142575359] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 134283777] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["Narrowable"] = 33492479] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 16909315] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["NotUnit"] = 8374815] = "NotUnit"; + TypeFlags[TypeFlags["NotUnit"] = 16749629] = "NotUnit"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 50331648] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 402653184] = "RequiresWidening"; /* @internal */ - TypeFlags[TypeFlags["PropagatingFlags"] = 117440512] = "PropagatingFlags"; + TypeFlags[TypeFlags["PropagatingFlags"] = 939524096] = "PropagatingFlags"; // The following flags are used for different purposes during union and intersection type construction /* @internal */ - TypeFlags[TypeFlags["NonWideningType"] = 16777216] = "NonWideningType"; + TypeFlags[TypeFlags["NonWideningType"] = 134217728] = "NonWideningType"; /* @internal */ - TypeFlags[TypeFlags["Wildcard"] = 33554432] = "Wildcard"; + TypeFlags[TypeFlags["Wildcard"] = 268435456] = "Wildcard"; /* @internal */ - TypeFlags[TypeFlags["EmptyObject"] = 67108864] = "EmptyObject"; + TypeFlags[TypeFlags["EmptyObject"] = 536870912] = "EmptyObject"; /* @internal */ - TypeFlags[TypeFlags["ConstructionFlags"] = 117440512] = "ConstructionFlags"; + TypeFlags[TypeFlags["ConstructionFlags"] = 939524096] = "ConstructionFlags"; + // The following flag is used for different purposes by maybeTypeOfKind + /* @internal */ + TypeFlags[TypeFlags["GenericMappedType"] = 134217728] = "GenericMappedType"; })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); var ObjectFlags; (function (ObjectFlags) { @@ -1325,6 +1330,7 @@ var ts; })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); var EmitFlags; (function (EmitFlags) { + EmitFlags[EmitFlags["None"] = 0] = "None"; EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine"; EmitFlags[EmitFlags["AdviseOnEmitNode"] = 2] = "AdviseOnEmitNode"; EmitFlags[EmitFlags["NoSubstitution"] = 4] = "NoSubstitution"; @@ -1633,7 +1639,7 @@ var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "2.9"; + ts.versionMajorMinor = "3.0"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); @@ -1781,6 +1787,10 @@ var ts; return array ? array.length : 0; } ts.length = length; + function hasEntries(map) { + return !!map && !!map.size; + } + ts.hasEntries = hasEntries; /** * Iterates through 'array' by index and performs the callback on each element of array until the callback * returns a truthy value, then returns that value. @@ -1937,7 +1947,7 @@ var ts; return result; } } - Debug.fail(); + return Debug.fail(); } ts.findMap = findMap; function contains(array, value, equalityComparer) { @@ -2055,11 +2065,6 @@ var ts; return array; } ts.sameMap = sameMap; - /** - * Flattens an array containing a mix of array or non-array elements. - * - * @param array The array to flatten. - */ function flatten(array) { var result; if (array) { @@ -2079,12 +2084,6 @@ var ts; return result; } ts.flatten = flatten; - /** - * Maps an array. If the mapped value is an array, it is spread into the result. - * - * @param array The array to map. - * @param mapfn The callback used to map the result into one or more values. - */ function flatMap(array, mapfn) { var result; if (array) { @@ -2207,13 +2206,6 @@ var ts; }; } ts.singleIterator = singleIterator; - /** - * Maps contiguous spans of values with the same key. - * - * @param array The array to map. - * @param keyfn A callback used to select the key for an element. - * @param mapfn A callback used to map a contiguous chunk of values to a single value. - */ function spanMap(array, keyfn, mapfn) { var result; if (array) { @@ -2331,12 +2323,6 @@ var ts; } return result; } - /** - * Deduplicates an unsorted array. - * @param equalityComparer An optional `EqualityComparer` used to determine if two values are duplicates. - * @param comparer An optional `Comparer` used to sort entries before comparison, though the - * result will remain in the original order in `array`. - */ function deduplicate(array, equalityComparer, comparer) { return !array ? undefined : array.length === 0 ? [] : @@ -2345,9 +2331,6 @@ var ts; deduplicateEquality(array, equalityComparer); } ts.deduplicate = deduplicate; - /** - * Deduplicates an array that has already been sorted. - */ function deduplicateSorted(array, comparer) { if (!array) return undefined; @@ -2490,14 +2473,6 @@ var ts; return result; } ts.sum = sum; - /** - * Appends a value to an array, returning the array. - * - * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array - * is created if `value` was appended. - * @param value The value to append to the array. If `value` is `undefined`, nothing is - * appended. - */ function append(to, value) { if (value === undefined) return to; @@ -2514,16 +2489,6 @@ var ts; function toOffset(array, offset) { return offset < 0 ? array.length + offset : offset; } - /** - * Appends a range of value to an array, returning the array. - * - * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array - * is created if `value` was appended. - * @param from The values to append to the array. If `from` is `undefined`, nothing is - * appended. If an element of `from` is `undefined`, that element is not appended. - * @param start The offset in `from` at which to start copying values. - * @param end The offset in `from` at which to stop copying values (non-inclusive). - */ function addRange(to, from, start, end) { if (from === undefined || from.length === 0) return to; @@ -2539,23 +2504,6 @@ var ts; return to; } ts.addRange = addRange; - /** - * Appends a range of value to begin of an array, returning the array. - * - * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array - * is created if `value` was appended. - * @param from The values to append to the array. If `from` is `undefined`, nothing is - * appended. If an element of `from` is `undefined`, that element is not appended. - */ - function prependRange(to, from) { - if (from === undefined || from.length === 0) - return to; - if (to === undefined) - return from.slice(); - to.unshift.apply(to, from); - return to; - } - ts.prependRange = prependRange; /** * @return Whether the value was added. */ @@ -2853,7 +2801,7 @@ var ts; var arg = args_1[_a]; for (var p in arg) { if (hasProperty(arg, p)) { - t[p] = arg[p]; + t[p] = arg[p]; // TODO: GH#23368 } } } @@ -3012,10 +2960,10 @@ var ts; if (value !== undefined && test(value)) return value; if (value && typeof value.kind === "number") { - Debug.fail("Invalid cast. The supplied " + Debug.showSyntaxKind(value) + " did not pass the test '" + Debug.getFunctionName(test) + "'."); + return Debug.fail("Invalid cast. The supplied " + Debug.showSyntaxKind(value) + " did not pass the test '" + Debug.getFunctionName(test) + "'."); } else { - Debug.fail("Invalid cast. The supplied value did not pass the test '" + Debug.getFunctionName(test) + "'."); + return Debug.fail("Invalid cast. The supplied value did not pass the test '" + Debug.getFunctionName(test) + "'."); } } ts.cast = cast; @@ -3101,7 +3049,7 @@ var ts; } ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { - baseIndex = baseIndex || 0; + if (baseIndex === void 0) { baseIndex = 0; } return text.replace(/{(\d+)}/g, function (_match, index) { return Debug.assertDefined(args[+index + baseIndex]); }); } ts.formatStringFromArgs = formatStringFromArgs; @@ -3409,7 +3357,9 @@ var ts; return compareValues(a ? 1 : 0, b ? 1 : 0); } ts.compareBooleans = compareBooleans; - function compareMessageText(text1, text2) { + function compareMessageText(t1, t2) { + var text1 = t1; + var text2 = t2; while (text1 && text2) { // We still have both chains. var string1 = isString(text1) ? text1 : text1.messageText; @@ -3446,6 +3396,14 @@ var ts; return moduleResolution; } ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; + function unreachableCodeIsError(options) { + return options.allowUnreachableCode === false; + } + ts.unreachableCodeIsError = unreachableCodeIsError; + function unusedLabelIsError(options) { + return options.allowUnusedLabels === false; + } + ts.unusedLabelIsError = unusedLabelIsError; function getAreDeclarationMapsEnabled(options) { return !!(options.declaration && options.declarationMap); } @@ -3464,7 +3422,7 @@ var ts; } ts.getEmitDeclarations = getEmitDeclarations; function getStrictOptionValue(compilerOptions, flag) { - return compilerOptions[flag] === undefined ? compilerOptions.strict : compilerOptions[flag]; + return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; } ts.getStrictOptionValue = getStrictOptionValue; function hasZeroOrOneAsteriskCharacter(str) { @@ -3947,6 +3905,23 @@ var ts; return startsWith(str, prefix) ? str.substr(prefix.length) : str; } ts.removePrefix = removePrefix; + function tryRemovePrefix(str, prefix) { + return startsWith(str, prefix) ? str.substring(prefix.length) : undefined; + } + ts.tryRemovePrefix = tryRemovePrefix; + function tryRemoveDirectoryPrefix(path, dirPath) { + var a = tryRemovePrefix(path, dirPath); + if (a === undefined) + return undefined; + switch (a.charCodeAt(0)) { + case 47 /* slash */: + case 92 /* backslash */: + return a.slice(1); + default: + return undefined; + } + } + ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; function endsWith(str, suffix) { var expectedPos = str.length - suffix.length; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; @@ -3956,6 +3931,10 @@ var ts; return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str; } ts.removeSuffix = removeSuffix; + function tryRemoveSuffix(str, suffix) { + return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : undefined; + } + ts.tryRemoveSuffix = tryRemoveSuffix; function stringContains(str, substring) { return str.indexOf(substring) !== -1; } @@ -3989,7 +3968,7 @@ var ts; /** * Matches any single directory segment unless it is the last segment and a .min.js file * Breakdown: - * [^./] # matches everything up to the first . character (excluding directory seperators) + * [^./] # matches everything up to the first . character (excluding directory separators) * (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension */ singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*", @@ -4051,7 +4030,7 @@ var ts; var subpattern = ""; var hasWrittenComponent = false; var components = getNormalizedPathComponents(spec, basePath); - var lastComponent = lastOrUndefined(components); + var lastComponent = last(components); if (usage !== "exclude" && lastComponent === "**") { return undefined; } @@ -4115,6 +4094,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } + /** @param path directory of the tsconfig.json */ function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); @@ -4128,14 +4108,18 @@ var ts; }; } ts.getFileMatcherPatterns = getFileMatcherPatterns; + function getRegexFromPattern(pattern, useCaseSensitiveFileNames) { + return new RegExp(pattern, useCaseSensitiveFileNames ? "" : "i"); + } + ts.getRegexFromPattern = getRegexFromPattern; + /** @param path directory of the tsconfig.json */ function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); - var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); - var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); - var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return getRegexFromPattern(pattern, useCaseSensitiveFileNames); }); + var includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames); + var excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames); // Associate an array of results with each include regex. This keeps results in order of the "include" order. // If there are no "includes", then just put everything in results[0]. var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; @@ -4277,11 +4261,11 @@ var ts; return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */; } function hasJavaScriptFileExtension(fileName) { - return forEach(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + return some(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); } ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; function hasTypeScriptFileExtension(fileName) { - return forEach(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + return some(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); } ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) { @@ -4487,7 +4471,8 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { - assert(value !== undefined && value !== null, message); + if (value === undefined || value === null) + return fail(message); return value; } Debug.assertDefined = assertDefined; @@ -4671,10 +4656,7 @@ var ts; */ function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - if (ext !== undefined) { - return ext; - } - Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : Debug.fail("File " + path + " has unknown extension."); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -5118,6 +5100,7 @@ var ts; return parseInt(version.substring(1, dot)); } ts.getNodeMajorVersion = getNodeMajorVersion; + // TODO: this is used as if it's certainly defined in many places. ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does @@ -5299,6 +5282,7 @@ var ts; return watchDirectoryRecursively(directoryName, callback); } watchDirectory(directoryName, callback); + return undefined; // TODO: GH#18217 }; } function createNonPollingWatchFile() { @@ -5330,7 +5314,7 @@ var ts; var watcher = fsWatchDirectory(dirName, function (_eventName, relativeFileName) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" var fileName = !ts.isString(relativeFileName) - ? undefined + ? undefined // TODO: GH#18217 : ts.getNormalizedAbsolutePath(relativeFileName, dirName); // Some applications save a working file via rename operations var callbacks = fileWatcherCallbacks.get(toCanonicalName(fileName)); @@ -5579,6 +5563,7 @@ var ts; switch (entryKind) { case 0 /* File */: return stat.isFile(); case 1 /* Directory */: return stat.isDirectory(); + default: return false; } } catch (e) { @@ -5770,6 +5755,7 @@ var ts; The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), + Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), @@ -6221,6 +6207,7 @@ var ts; Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2568, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators_2568", "Type '{0}' is not an array type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: diag(2570, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await_2570", "Property '{0}' does not exist on type '{1}'. Did you forget to use 'await'?"), + Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."), JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -6274,7 +6261,7 @@ var ts; _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: diag(2692, ts.DiagnosticCategory.Error, "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible."), _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: diag(2693, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", "'{0}' only refers to a type, but is being used as a value here."), 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."), + 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."), 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."), @@ -6304,6 +6291,7 @@ var ts; Cannot_invoke_an_object_which_is_possibly_undefined: diag(2722, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_undefined_2722", "Cannot invoke an object which is possibly 'undefined'."), Cannot_invoke_an_object_which_is_possibly_null_or_undefined: diag(2723, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_null_or_undefined_2723", "Cannot invoke an object which is possibly 'null' or 'undefined'."), Module_0_has_no_exported_member_1_Did_you_mean_2: diag(2724, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_2_2724", "Module '{0}' has no exported member '{1}'. Did you mean '{2}'?"), + Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."), 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}'."), @@ -6602,6 +6590,7 @@ var ts; _0_is_declared_but_never_used: diag(6196, ts.DiagnosticCategory.Error, "_0_is_declared_but_never_used_6196", "'{0}' is declared but never used.", /*reportsUnnecessary*/ true), Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"), All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", /*reportsUnnecessary*/ true), + All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), 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"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -6629,7 +6618,7 @@ var ts; Function_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: diag(7024, ts.DiagnosticCategory.Error, "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", "Function 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."), Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: diag(7025, ts.DiagnosticCategory.Error, "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type."), JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: diag(7026, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists."), - Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected."), + Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected.", /*reportsUnnecessary*/ true), Unused_label: diag(7028, ts.DiagnosticCategory.Error, "Unused_label_7028", "Unused label.", /*reportsUnnecessary*/ true), Fallthrough_case_in_switch: diag(7029, ts.DiagnosticCategory.Error, "Fallthrough_case_in_switch_7029", "Fallthrough case in switch."), Not_all_code_paths_return_a_value: diag(7030, ts.DiagnosticCategory.Error, "Not_all_code_paths_return_a_value_7030", "Not all code paths return a value."), @@ -6710,6 +6699,7 @@ var ts; Implement_inherited_abstract_class: diag(90007, ts.DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"), Add_0_to_unresolved_variable: diag(90008, ts.DiagnosticCategory.Message, "Add_0_to_unresolved_variable_90008", "Add '{0}.' to unresolved variable"), Remove_destructuring: diag(90009, ts.DiagnosticCategory.Message, "Remove_destructuring_90009", "Remove destructuring"), + Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"), Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""), Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"), Add_0_to_existing_import_declaration_from_1: diag(90015, ts.DiagnosticCategory.Message, "Add_0_to_existing_import_declaration_from_1_90015", "Add '{0}' to existing import declaration from \"{1}\""), @@ -6779,6 +6769,9 @@ var ts; Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing 'typeof'"), Remove_unused_label: diag(95053, ts.DiagnosticCategory.Message, "Remove_unused_label_95053", "Remove unused label"), Remove_all_unused_labels: diag(95054, ts.DiagnosticCategory.Message, "Remove_all_unused_labels_95054", "Remove all unused labels"), + Convert_0_to_mapped_object_type: diag(95055, ts.DiagnosticCategory.Message, "Convert_0_to_mapped_object_type_95055", "Convert '{0}' to mapped object type"), + Convert_namespace_import_to_named_imports: diag(95056, ts.DiagnosticCategory.Message, "Convert_namespace_import_to_named_imports_95056", "Convert namespace import to named imports"), + Convert_named_imports_to_namespace_import: diag(95057, ts.DiagnosticCategory.Message, "Convert_named_imports_to_namespace_import_95057", "Convert named imports to namespace import"), }; })(ts || (ts = {})); var ts; @@ -6817,7 +6810,7 @@ var ts; "false": 86 /* FalseKeyword */, "finally": 87 /* FinallyKeyword */, "for": 88 /* ForKeyword */, - "from": 142 /* FromKeyword */, + "from": 143 /* FromKeyword */, "function": 89 /* FunctionKeyword */, "get": 125 /* GetKeyword */, "if": 90 /* IfKeyword */, @@ -6843,7 +6836,7 @@ var ts; "public": 114 /* PublicKeyword */, "readonly": 132 /* ReadonlyKeyword */, "require": 133 /* RequireKeyword */, - "global": 143 /* GlobalKeyword */, + "global": 144 /* GlobalKeyword */, "return": 96 /* ReturnKeyword */, "set": 136 /* SetKeyword */, "static": 115 /* StaticKeyword */, @@ -6859,6 +6852,7 @@ var ts; "typeof": 103 /* TypeOfKeyword */, "undefined": 140 /* UndefinedKeyword */, "unique": 141 /* UniqueKeyword */, + "unknown": 142 /* UnknownKeyword */, "var": 104 /* VarKeyword */, "void": 105 /* VoidKeyword */, "while": 106 /* WhileKeyword */, @@ -6866,7 +6860,7 @@ var ts; "yield": 116 /* YieldKeyword */, "async": 120 /* AsyncKeyword */, "await": 121 /* AwaitKeyword */, - "of": 144 /* OfKeyword */, + "of": 145 /* OfKeyword */, "{": 17 /* OpenBraceToken */, "}": 18 /* CloseBraceToken */, "(": 19 /* OpenParenToken */, @@ -7485,8 +7479,9 @@ var ts; } ts.isIdentifierText = isIdentifierText; // Creates a scanner over a (possibly unspecified) range of a piece of text. - function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + var text = textInitial; // Current position (end position of text of current token) var pos; // end of text @@ -7942,7 +7937,7 @@ var ts; var isPreviousTokenSeparator = false; while (true) { var ch = text.charCodeAt(pos); - // Numeric seperators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator + // Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator if (ch === 95 /* _ */) { tokenFlags |= 512 /* ContainsSeparator */; if (separatorAllowed) { @@ -8758,7 +8753,7 @@ var ts; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function packageIdIsEqual(a, b) { - return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; + return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; } function packageIdToString(_a) { var name = _a.name, subModuleName = _a.subModuleName, version = _a.version; @@ -8809,7 +8804,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 273 /* SourceFile */) { + while (node && node.kind !== 274 /* SourceFile */) { node = node.parent; } return node; @@ -8817,11 +8812,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 212 /* Block */: - case 240 /* CaseBlock */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 213 /* Block */: + case 241 /* CaseBlock */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: return true; } return false; @@ -8866,11 +8861,11 @@ var ts; } ts.getEndLinePosition = getEndLinePosition; /** - * Returns a value indicating whether a name is unique globally or within the current file + * Returns a value indicating whether a name is unique globally or within the current file. + * Note: This does not consider whether a name appears as a free identifier or not, so at the expression `x.y` this includes both `x` and `y`. */ - function isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) { - return !(hasGlobalName && hasGlobalName(name)) - && !currentSourceFile.identifiers.has(name); + function isFileLevelUniqueName(sourceFile, name, hasGlobalName) { + return !(hasGlobalName && hasGlobalName(name)) && !sourceFile.identifiers.has(name); } ts.isFileLevelUniqueName = isFileLevelUniqueName; // Returns true if this node is missing from the actual source code. A 'missing' node is different @@ -8896,6 +8891,27 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + /** + * Appends a range of value to begin of an array, returning the array. + * + * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array + * is created if `value` was appended. + * @param from The values to append to the array. If `from` is `undefined`, nothing is + * appended. If an element of `from` is `undefined`, that element is not appended. + */ + function prependStatements(to, from) { + if (from === undefined || from.length === 0) + return to; + if (to === undefined) + return from.slice(); + var prologue = to.length && isPrologueDirective(to[0]) && to.shift(); + to.unshift.apply(to, from); + if (prologue) { + to.unshift(prologue); + } + return to; + } + ts.prependStatements = prependStatements; /** * Determine if the given comment is a triple-slash * @@ -8938,7 +8954,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 298 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 299 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -8985,7 +9001,7 @@ var ts; */ function getEmitFlags(node) { var emitNode = node.emitNode; - return emitNode && emitNode.flags; + return emitNode && emitNode.flags || 0; } ts.getEmitFlags = getEmitFlags; function getLiteralText(node, sourceFile) { @@ -9019,7 +9035,7 @@ var ts; case 12 /* RegularExpressionLiteral */: return node.text; } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); } ts.getLiteralText = getLiteralText; function getTextOfConstantValue(value) { @@ -9052,7 +9068,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 231 /* VariableDeclaration */ && node.parent.kind === 268 /* CatchClause */; + return node.kind === 232 /* VariableDeclaration */ && node.parent.kind === 269 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9074,11 +9090,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 === 238 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 239 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 273 /* SourceFile */ || - node.kind === 238 /* ModuleDeclaration */ || + return node.kind === 274 /* SourceFile */ || + node.kind === 239 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -9095,9 +9111,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: return ts.isExternalModule(node.parent); - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9109,53 +9125,53 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 273 /* SourceFile */: - case 240 /* CaseBlock */: - case 268 /* CatchClause */: - case 238 /* ModuleDeclaration */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 274 /* SourceFile */: + case 241 /* CaseBlock */: + case 269 /* CatchClause */: + case 239 /* ModuleDeclaration */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return true; - case 212 /* Block */: + case 213 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block - return parentNode && !ts.isFunctionLike(parentNode); + return !ts.isFunctionLike(parentNode); } return false; } ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 152 /* MethodSignature */: - case 159 /* IndexSignature */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 283 /* JSDocFunctionType */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 295 /* JSDocTemplateTag */: - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 291 /* JSDocCallbackTag */: - case 296 /* JSDocTypedefTag */: - case 287 /* JSDocSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 153 /* MethodSignature */: + case 160 /* IndexSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 284 /* JSDocFunctionType */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 296 /* JSDocTemplateTag */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 292 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 288 /* JSDocSignature */: return true; default: ts.assertTypeIsNever(node); @@ -9165,8 +9181,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9175,15 +9191,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 213 /* VariableStatement */: - case 234 /* ClassDeclaration */: - case 233 /* FunctionDeclaration */: - case 238 /* ModuleDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 214 /* VariableStatement */: + case 235 /* ClassDeclaration */: + case 234 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: return true; default: return false; @@ -9218,8 +9234,8 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return escapeLeadingUnderscores(name.text); - case 146 /* ComputedPropertyName */: - return isStringOrNumericLiteral(name.expression) ? escapeLeadingUnderscores(name.expression.text) : undefined; + case 147 /* ComputedPropertyName */: + return isStringOrNumericLiteral(name.expression) ? escapeLeadingUnderscores(name.expression.text) : undefined; // TODO: GH#18217 Almost all uses of this assume the result to be defined! default: ts.Debug.assertNever(name); } @@ -9229,10 +9245,12 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); + default: + throw ts.Debug.assertNever(name); } } ts.entityNameToString = entityNameToString; @@ -9251,11 +9269,6 @@ var ts; return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3); } ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; - function createDiagnosticForNodeSpan(sourceFile, startNode, endNode, message, arg0, arg1, arg2, arg3) { - var start = ts.skipTrivia(sourceFile.text, startNode.pos); - return ts.createFileDiagnostic(sourceFile, start, endNode.end - start, message, arg0, arg1, arg2, arg3); - } - ts.createDiagnosticForNodeSpan = createDiagnosticForNodeSpan; function createDiagnosticForNodeFromMessageChain(node, messageChain) { var sourceFile = getSourceFileOfNode(node); var span = getErrorSpanForNode(sourceFile, node); @@ -9278,7 +9291,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 212 /* Block */) { + if (node.body && node.body.kind === 213 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9292,7 +9305,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 273 /* SourceFile */: + case 274 /* 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 @@ -9301,25 +9314,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 231 /* VariableDeclaration */: - case 181 /* BindingElement */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 272 /* EnumMember */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 236 /* TypeAliasDeclaration */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 232 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 273 /* EnumMember */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 237 /* TypeAliasDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: errorNode = node.name; break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -9352,7 +9365,7 @@ var ts; } ts.isJsonSourceFile = isJsonSourceFile; function isConstEnumDeclaration(node) { - return node.kind === 237 /* EnumDeclaration */ && isConst(node); + return node.kind === 238 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -9365,21 +9378,21 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 186 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 187 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 186 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 187 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 178 /* ImportType */ && - n.argument.kind === 177 /* LiteralType */ && + return n.kind === 179 /* ImportType */ && + n.argument.kind === 178 /* LiteralType */ && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 215 /* ExpressionStatement */ + return node.kind === 216 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9388,11 +9401,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 148 /* Parameter */ || - node.kind === 147 /* TypeParameter */ || - node.kind === 191 /* FunctionExpression */ || - node.kind === 192 /* ArrowFunction */ || - node.kind === 190 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 149 /* Parameter */ || + node.kind === 148 /* TypeParameter */ || + node.kind === 192 /* FunctionExpression */ || + node.kind === 193 /* ArrowFunction */ || + node.kind === 191 /* ParenthesizedExpression */) ? 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 '/**/' @@ -9408,11 +9421,12 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (160 /* FirstTypeNode */ <= node.kind && node.kind <= 178 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 179 /* LastTypeNode */) { return true; } switch (node.kind) { case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 134 /* NumberKeyword */: case 137 /* StringKeyword */: case 122 /* BooleanKeyword */: @@ -9421,32 +9435,32 @@ var ts; case 131 /* NeverKeyword */: return true; case 105 /* VoidKeyword */: - return node.parent.kind !== 195 /* VoidExpression */; - case 206 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 196 /* VoidExpression */; + case 207 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 147 /* TypeParameter */: - return node.parent.kind === 176 /* MappedType */ || node.parent.kind === 171 /* InferType */; + case 148 /* TypeParameter */: + return node.parent.kind === 177 /* MappedType */ || node.parent.kind === 172 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 71 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 145 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 185 /* 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 === 71 /* Identifier */ || node.kind === 145 /* QualifiedName */ || node.kind === 184 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 185 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 145 /* QualifiedName */: - case 184 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: + case 146 /* QualifiedName */: + case 185 /* PropertyAccessExpression */: + case 99 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 164 /* TypeQuery */) { + if (parent.kind === 165 /* TypeQuery */) { return false; } - if (parent.kind === 178 /* ImportType */) { + if (parent.kind === 179 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9455,41 +9469,42 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (160 /* FirstTypeNode */ <= parent.kind && parent.kind <= 178 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 179 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return node === parent.constraint; - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 148 /* Parameter */: - case 231 /* VariableDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 149 /* Parameter */: + case 232 /* VariableDeclaration */: return node === parent.type; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return node === parent.type; - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: return node === parent.type; - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: return node === parent.type; - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } + } } return false; } @@ -9510,23 +9525,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return visitor(node); - case 240 /* CaseBlock */: - case 212 /* Block */: - case 216 /* IfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 225 /* WithStatement */: - case 226 /* SwitchStatement */: - case 265 /* CaseClause */: - case 266 /* DefaultClause */: - case 227 /* LabeledStatement */: - case 229 /* TryStatement */: - case 268 /* CatchClause */: + case 241 /* CaseBlock */: + case 213 /* Block */: + case 217 /* IfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 226 /* WithStatement */: + case 227 /* SwitchStatement */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: + case 228 /* LabeledStatement */: + case 230 /* TryStatement */: + case 269 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9536,26 +9551,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 237 /* EnumDeclaration */: - case 235 /* InterfaceDeclaration */: - case 238 /* ModuleDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 238 /* EnumDeclaration */: + case 236 /* InterfaceDeclaration */: + case 239 /* ModuleDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 146 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 147 /* 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); @@ -9578,10 +9593,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 166 /* ArrayType */) { + if (node && node.kind === 167 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 161 /* TypeReference */) { + else if (node && node.kind === 162 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9591,12 +9606,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 235 /* InterfaceDeclaration */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 165 /* TypeLiteral */: + case 236 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 166 /* TypeLiteral */: return node.members; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return node.properties; } } @@ -9604,14 +9619,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 181 /* BindingElement */: - case 272 /* EnumMember */: - case 148 /* Parameter */: - case 269 /* PropertyAssignment */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 270 /* ShorthandPropertyAssignment */: - case 231 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 273 /* EnumMember */: + case 149 /* Parameter */: + case 270 /* PropertyAssignment */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 271 /* ShorthandPropertyAssignment */: + case 232 /* VariableDeclaration */: return true; } } @@ -9623,8 +9638,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 232 /* VariableDeclarationList */ - && node.parent.parent.kind === 213 /* VariableStatement */; + return node.parent.kind === 233 /* VariableDeclarationList */ + && node.parent.parent.kind === 214 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9635,13 +9650,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: return true; } return false; @@ -9652,7 +9667,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 227 /* LabeledStatement */) { + if (node.statement.kind !== 228 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9660,17 +9675,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 212 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 213 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 153 /* MethodDeclaration */ && node.parent.kind === 183 /* ObjectLiteralExpression */; + return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 184 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 153 /* MethodDeclaration */ && - (node.parent.kind === 183 /* ObjectLiteralExpression */ || - node.parent.kind === 204 /* ClassExpression */); + return node.kind === 154 /* MethodDeclaration */ && + (node.parent.kind === 184 /* ObjectLiteralExpression */ || + node.parent.kind === 205 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9682,31 +9697,35 @@ var ts; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { - return ts.filter(objectLiteral.properties, function (property) { - if (property.kind === 269 /* PropertyAssignment */) { + return objectLiteral.properties.filter(function (property) { + if (property.kind === 270 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); - return key === propName || (key2 && key2 === propName); + return key === propName || (!!key2 && key2 === propName); } + return false; }); } ts.getPropertyAssignment = getPropertyAssignment; function getTsConfigObjectLiteralExpression(tsConfigSourceFile) { if (tsConfigSourceFile && tsConfigSourceFile.statements.length) { var expression = tsConfigSourceFile.statements[0].expression; - return ts.isObjectLiteralExpression(expression) && expression; + return ts.tryCast(expression, ts.isObjectLiteralExpression); } } ts.getTsConfigObjectLiteralExpression = getTsConfigObjectLiteralExpression; function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) { - var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile); - return jsonObjectLiteral && - ts.firstDefined(getPropertyAssignment(jsonObjectLiteral, propKey), function (property) { - return ts.isArrayLiteralExpression(property.initializer) ? - ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) : - undefined; - }); + return ts.firstDefined(getTsConfigPropArray(tsConfigSourceFile, propKey), function (property) { + return ts.isArrayLiteralExpression(property.initializer) ? + ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) : + undefined; + }); } ts.getTsConfigPropArrayElementValue = getTsConfigPropArrayElementValue; + function getTsConfigPropArray(tsConfigSourceFile, propKey) { + var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile); + return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : ts.emptyArray; + } + ts.getTsConfigPropArray = getTsConfigPropArray; function getContainingFunction(node) { return ts.findAncestor(node.parent, ts.isFunctionLike); } @@ -9716,13 +9735,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { + ts.Debug.assert(node.kind !== 274 /* SourceFile */); while (true) { node = node.parent; if (!node) { - return undefined; + 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 146 /* ComputedPropertyName */: + case 147 /* 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 @@ -9737,9 +9757,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 149 /* Decorator */: + case 150 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 148 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 149 /* 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; @@ -9750,26 +9770,26 @@ var ts; node = node.parent; } break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 238 /* ModuleDeclaration */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 237 /* EnumDeclaration */: - case 273 /* SourceFile */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 239 /* ModuleDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 238 /* EnumDeclaration */: + case 274 /* SourceFile */: return node; } } @@ -9779,9 +9799,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 154 /* Constructor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 155 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: return container; } } @@ -9803,27 +9823,27 @@ var ts; return node; } switch (node.kind) { - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: node = node.parent; break; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return node; - case 149 /* Decorator */: + case 150 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 148 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 149 /* 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; @@ -9839,14 +9859,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 191 /* FunctionExpression */ || func.kind === 192 /* ArrowFunction */) { + if (func.kind === 192 /* FunctionExpression */ || func.kind === 193 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 190 /* ParenthesizedExpression */) { + while (parent.kind === 191 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 186 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 187 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -9857,7 +9877,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 184 /* PropertyAccessExpression */ || kind === 185 /* ElementAccessExpression */) + return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) && node.expression.kind === 97 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -9866,20 +9886,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 184 /* PropertyAccessExpression */ || kind === 185 /* ElementAccessExpression */) + return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) && node.expression.kind === 99 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return node.typeName; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 71 /* Identifier */: - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return node; } return undefined; @@ -9887,10 +9907,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return node.tag; - case 256 /* JsxOpeningElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9899,53 +9919,55 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: // classes are valid targets return true; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 234 /* ClassDeclaration */; - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 153 /* MethodDeclaration */: + return parent.kind === 235 /* ClassDeclaration */; + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 154 /* 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 === 234 /* ClassDeclaration */; - case 148 /* Parameter */: + && parent.kind === 235 /* ClassDeclaration */; + case 149 /* 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 === 154 /* Constructor */ - || parent.kind === 153 /* MethodDeclaration */ - || parent.kind === 156 /* SetAccessor */) - && grandparent.kind === 234 /* ClassDeclaration */; + && (parent.kind === 155 /* Constructor */ + || parent.kind === 154 /* MethodDeclaration */ + || parent.kind === 157 /* SetAccessor */) + && grandparent.kind === 235 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node, parent, grandparent) { return node.decorators !== undefined - && nodeCanBeDecorated(node, parent, grandparent); + && nodeCanBeDecorated(node, parent, grandparent); // TODO: GH#18217 } ts.nodeIsDecorated = nodeIsDecorated; function nodeOrChildIsDecorated(node, parent, grandparent) { - return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent); + return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent); // TODO: GH#18217 } ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 234 /* ClassDeclaration */: - return ts.forEach(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); - case 153 /* MethodDeclaration */: - case 156 /* SetAccessor */: - return ts.forEach(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); + case 235 /* ClassDeclaration */: + return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 + case 154 /* MethodDeclaration */: + case 157 /* SetAccessor */: + return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 + default: + return false; } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 256 /* JsxOpeningElement */ || - parent.kind === 255 /* JsxSelfClosingElement */ || - parent.kind === 257 /* JsxClosingElement */) { + if (parent.kind === 257 /* JsxOpeningElement */ || + parent.kind === 256 /* JsxSelfClosingElement */ || + parent.kind === 258 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -9958,45 +9980,45 @@ var ts; case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 12 /* RegularExpressionLiteral */: - case 182 /* ArrayLiteralExpression */: - case 183 /* ObjectLiteralExpression */: - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 188 /* TaggedTemplateExpression */: - case 207 /* AsExpression */: - case 189 /* TypeAssertionExpression */: - case 208 /* NonNullExpression */: - case 190 /* ParenthesizedExpression */: - case 191 /* FunctionExpression */: - case 204 /* ClassExpression */: - case 192 /* ArrowFunction */: - case 195 /* VoidExpression */: - case 193 /* DeleteExpression */: - case 194 /* TypeOfExpression */: - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: - case 199 /* BinaryExpression */: - case 200 /* ConditionalExpression */: - case 203 /* SpreadElement */: - case 201 /* TemplateExpression */: + case 183 /* ArrayLiteralExpression */: + case 184 /* ObjectLiteralExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 189 /* TaggedTemplateExpression */: + case 208 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 209 /* NonNullExpression */: + case 191 /* ParenthesizedExpression */: + case 192 /* FunctionExpression */: + case 205 /* ClassExpression */: + case 193 /* ArrowFunction */: + case 196 /* VoidExpression */: + case 194 /* DeleteExpression */: + case 195 /* TypeOfExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: + case 200 /* BinaryExpression */: + case 201 /* ConditionalExpression */: + case 204 /* SpreadElement */: + case 202 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: - case 205 /* OmittedExpression */: - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: - case 258 /* JsxFragment */: - case 202 /* YieldExpression */: - case 196 /* AwaitExpression */: - case 209 /* MetaProperty */: + case 206 /* OmittedExpression */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: + case 259 /* JsxFragment */: + case 203 /* YieldExpression */: + case 197 /* AwaitExpression */: + case 210 /* MetaProperty */: return true; - case 145 /* QualifiedName */: - while (node.parent.kind === 145 /* QualifiedName */) { + case 146 /* QualifiedName */: + while (node.parent.kind === 146 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 164 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node); case 71 /* Identifier */: - if (node.parent.kind === 164 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through @@ -10012,47 +10034,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 272 /* EnumMember */: - case 269 /* PropertyAssignment */: - case 181 /* BindingElement */: + case 232 /* VariableDeclaration */: + case 149 /* Parameter */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 273 /* EnumMember */: + case 270 /* PropertyAssignment */: + case 182 /* BindingElement */: return parent.initializer === node; - case 215 /* ExpressionStatement */: - case 216 /* IfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 224 /* ReturnStatement */: - case 225 /* WithStatement */: - case 226 /* SwitchStatement */: - case 265 /* CaseClause */: - case 228 /* ThrowStatement */: + case 216 /* ExpressionStatement */: + case 217 /* IfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 225 /* ReturnStatement */: + case 226 /* WithStatement */: + case 227 /* SwitchStatement */: + case 266 /* CaseClause */: + case 229 /* ThrowStatement */: return parent.expression === node; - case 219 /* ForStatement */: + case 220 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 232 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 233 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 232 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233 /* VariableDeclarationList */) || forInStatement.expression === node; - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: return node === parent.expression; - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return node === parent.expression; - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return node === parent.expression; - case 149 /* Decorator */: - case 264 /* JsxExpression */: - case 263 /* JsxSpreadAttribute */: - case 271 /* SpreadAssignment */: + case 150 /* Decorator */: + case 265 /* JsxExpression */: + case 264 /* JsxSpreadAttribute */: + case 272 /* SpreadAssignment */: return true; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -10060,7 +10082,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 242 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 253 /* ExternalModuleReference */; + return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10069,7 +10091,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 242 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 253 /* ExternalModuleReference */; + return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 254 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -10081,15 +10103,15 @@ var ts; } ts.isSourceFileNotJavaScript = isSourceFileNotJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 65536 /* JavaScriptFile */); + return !!node && !!(node.flags & 65536 /* JavaScriptFile */); } ts.isInJavaScriptFile = isInJavaScriptFile; function isInJsonFile(node) { - return node && !!(node.flags & 16777216 /* JsonFile */); + return !!node && !!(node.flags & 16777216 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return node && !!(node.flags & 2097152 /* JSDoc */); + return !!node && !!(node.flags & 2097152 /* JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -10101,7 +10123,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 186 /* CallExpression */) { + if (callExpression.kind !== 187 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -10123,30 +10145,49 @@ var ts; return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */; } ts.isStringDoubleQuoted = isStringDoubleQuoted; - /** - * Given the symbol of a declaration, find the symbol of its Javascript container-like initializer, - * if it has one. Otherwise just return the original symbol. - * - * Container-like initializer behave like namespaces, so the binder needs to add contained symbols - * to their exports. An example is a function with assignments to `this` inside. - */ - function getJSInitializerSymbol(symbol) { - if (!symbol || !symbol.valueDeclaration) { - return symbol; + function getDeclarationOfJSInitializer(node) { + if (!isInJavaScriptFile(node) || !node.parent) { + return undefined; } - var declaration = symbol.valueDeclaration; - var e = getDeclaredJavascriptInitializer(declaration) || getAssignedJavascriptInitializer(declaration); - return e && e.symbol ? e.symbol : symbol; - } - ts.getJSInitializerSymbol = getJSInitializerSymbol; - /** Get the declaration initializer, when the initializer is container-like (See getJavascriptInitializer) */ - function getDeclaredJavascriptInitializer(node) { - if (node && ts.isVariableDeclaration(node) && node.initializer) { - return getJavascriptInitializer(node.initializer, /*isPrototypeAssignment*/ false) || - ts.isIdentifier(node.name) && getDefaultedJavascriptInitializer(node.name, node.initializer, /*isPrototypeAssignment*/ false); + var name; + var decl; + if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) { + name = node.parent.name; + decl = node.parent; } + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.right === node) { + name = node.parent.left; + decl = name; + } + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 54 /* BarBarToken */) { + if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { + name = node.parent.parent.name; + decl = node.parent.parent; + } + else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.parent.right === node.parent) { + name = node.parent.parent.left; + decl = name; + } + if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { + return undefined; + } + } + if (!name || !getJavascriptInitializer(node, isPrototypeAccess(name))) { + return undefined; + } + return decl; } - ts.getDeclaredJavascriptInitializer = getDeclaredJavascriptInitializer; + ts.getDeclarationOfJSInitializer = getDeclarationOfJSInitializer; + /** Get the initializer, taking into account defaulted Javascript initializers */ + function getEffectiveInitializer(node) { + if (isInJavaScriptFile(node) && node.initializer && + ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 54 /* BarBarToken */ && + node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { + return node.initializer.right; + } + return node.initializer; + } + ts.getEffectiveInitializer = getEffectiveInitializer; /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getJavascriptInitializer). * We treat the right hand side of assignments with container-like initalizers as declarations. @@ -10172,11 +10213,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 191 /* FunctionExpression */ || e.kind === 192 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 192 /* FunctionExpression */ || e.kind === 193 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 191 /* FunctionExpression */ || - initializer.kind === 204 /* ClassExpression */ || - initializer.kind === 192 /* ArrowFunction */) { + if (initializer.kind === 192 /* FunctionExpression */ || + initializer.kind === 205 /* ClassExpression */ || + initializer.kind === 193 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10198,6 +10239,13 @@ var ts; return e; } } + function isDefaultedJavascriptInitializer(node) { + var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ ? node.parent.left : + undefined; + return name && getJavascriptInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); + } + ts.isDefaultedJavascriptInitializer = isDefaultedJavascriptInitializer; /** Given a Javascript initializer, return the outer name. That is, the lhs of the assignment or the declaration name. */ function getOuterNameOfJsInitializer(node) { if (ts.isBinaryExpression(node.parent)) { @@ -10307,7 +10355,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 215 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 216 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10317,14 +10365,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: return node.parent; - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: return node.parent.parent; - case 186 /* CallExpression */: + case 187 /* CallExpression */: return node.parent; - case 177 /* LiteralType */: + case 178 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10334,12 +10382,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: return node.moduleSpecifier; - case 242 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 253 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 178 /* ImportType */: + case 243 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 254 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 179 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10348,11 +10396,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return node; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10360,19 +10408,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 243 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 244 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 148 /* Parameter */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 270 /* ShorthandPropertyAssignment */: - case 269 /* PropertyAssignment */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 149 /* Parameter */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 271 /* ShorthandPropertyAssignment */: + case 270 /* PropertyAssignment */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10380,14 +10428,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 283 /* JSDocFunctionType */ && + return node.kind === 284 /* JSDocFunctionType */ && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 296 /* JSDocTypedefTag */ || node.kind === 291 /* JSDocCallbackTag */; + return node.kind === 297 /* JSDocTypedefTag */ || node.kind === 292 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10397,38 +10445,39 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 58 /* EqualsToken */ && - node.expression.right; + node.expression.operatorToken.kind === 58 /* EqualsToken */ + ? node.expression.right + : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && getSpecialPropertyAssignmentKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 54 /* BarBarToken */ && - node.expression.right.right; + node.expression.right.operatorToken.kind === 54 /* BarBarToken */ + ? node.expression.right.right + : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return node.initializer; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return node.initializer; } } function getSingleVariableOfVariableStatement(node) { - return ts.isVariableStatement(node) && - node.declarationList.declarations.length > 0 && - node.declarationList.declarations[0]; + return ts.isVariableStatement(node) ? ts.firstOrUndefined(node.declarationList.declarations) : undefined; } function getNestedModuleDeclaration(node) { - return node.kind === 238 /* ModuleDeclaration */ && + return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 238 /* ModuleDeclaration */ && - node.body; + node.body.kind === 239 /* ModuleDeclaration */ + ? node.body + : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; @@ -10438,7 +10487,7 @@ var ts; var parent = node.parent; if (!parent) return; - if (parent.kind === 269 /* PropertyAssignment */ || parent.kind === 151 /* PropertyDeclaration */ || getNestedModuleDeclaration(parent)) { + if (parent.kind === 270 /* PropertyAssignment */ || parent.kind === 152 /* PropertyDeclaration */ || getNestedModuleDeclaration(parent)) { getJSDocCommentsAndTagsWorker(parent); } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -10458,11 +10507,11 @@ var ts; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */ || ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */ || - node.kind === 184 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 215 /* ExpressionStatement */) { + node.kind === 185 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 216 /* ExpressionStatement */) { getJSDocCommentsAndTagsWorker(parent); } // Pull parameter comments from declaring function as well - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); } if (isVariableLike(node) && ts.hasInitializer(node) && node.initializer !== hostNode && ts.hasJSDocNodes(node.initializer)) { @@ -10517,12 +10566,12 @@ var ts; ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { var last = ts.lastOrUndefined(s.parameters); - return last && isRestParameter(last); + return !!last && isRestParameter(last); } 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 === 284 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 285 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10535,31 +10584,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 190 /* ParenthesizedExpression */: - case 182 /* ArrayLiteralExpression */: - case 203 /* SpreadElement */: - case 208 /* NonNullExpression */: + case 191 /* ParenthesizedExpression */: + case 183 /* ArrayLiteralExpression */: + case 204 /* SpreadElement */: + case 209 /* NonNullExpression */: node = parent; break; - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10586,22 +10635,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 212 /* Block */: - case 213 /* VariableStatement */: - case 225 /* WithStatement */: - case 216 /* IfStatement */: - case 226 /* SwitchStatement */: - case 240 /* CaseBlock */: - case 265 /* CaseClause */: - case 266 /* DefaultClause */: - case 227 /* LabeledStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 229 /* TryStatement */: - case 268 /* CatchClause */: + case 213 /* Block */: + case 214 /* VariableStatement */: + case 226 /* WithStatement */: + case 217 /* IfStatement */: + case 227 /* SwitchStatement */: + case 241 /* CaseBlock */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: + case 228 /* LabeledStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 230 /* TryStatement */: + case 269 /* CatchClause */: return true; } return false; @@ -10618,15 +10667,15 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 172 /* ParenthesizedType */); + return walkUp(node, 173 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 190 /* ParenthesizedExpression */); + return walkUp(node, 191 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 190 /* ParenthesizedExpression */) { + while (node.kind === 191 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -10634,11 +10683,11 @@ var ts; ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 184 /* PropertyAccessExpression */ && node.kind !== 185 /* ElementAccessExpression */) { + if (node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 193 /* DeleteExpression */; + return node && node.kind === 194 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10660,9 +10709,10 @@ var ts; switch (name.kind) { case 71 /* Identifier */: case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - if (ts.isDeclaration(name.parent)) { - return name.parent.name === name; + case 8 /* NumericLiteral */: { + var parent = name.parent; + if (ts.isDeclaration(parent)) { + return parent.name === name; } else if (ts.isQualifiedName(name.parent)) { var tag = name.parent.parent; @@ -10672,6 +10722,7 @@ var ts; var binExp = name.parent.parent; return ts.isBinaryExpression(binExp) && getSpecialPropertyAssignmentKind(binExp) !== 0 /* None */ && ts.getNameOfDeclaration(binExp) === name; } + } default: return false; } @@ -10679,7 +10730,7 @@ var ts; ts.isAnyDeclarationName = isAnyDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 146 /* ComputedPropertyName */ && + node.parent.kind === 147 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10687,32 +10738,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 272 /* EnumMember */: - case 269 /* PropertyAssignment */: - case 184 /* PropertyAccessExpression */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 273 /* EnumMember */: + case 270 /* PropertyAssignment */: + case 185 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 145 /* QualifiedName */) { + while (parent.kind === 146 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 164 /* TypeQuery */ || parent.kind === 161 /* TypeReference */; + return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; } return false; - case 181 /* BindingElement */: - case 247 /* ImportSpecifier */: + case 182 /* BindingElement */: + case 248 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 251 /* ExportSpecifier */: - case 261 /* JsxAttribute */: + case 252 /* ExportSpecifier */: + case 262 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10728,13 +10779,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 242 /* ImportEqualsDeclaration */ || - node.kind === 241 /* NamespaceExportDeclaration */ || - node.kind === 244 /* ImportClause */ && !!node.name || - node.kind === 245 /* NamespaceImport */ || - node.kind === 247 /* ImportSpecifier */ || - node.kind === 251 /* ExportSpecifier */ || - node.kind === 248 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 243 /* ImportEqualsDeclaration */ || + node.kind === 242 /* NamespaceExportDeclaration */ || + node.kind === 245 /* ImportClause */ && !!node.name || + node.kind === 246 /* NamespaceImport */ || + node.kind === 248 /* ImportSpecifier */ || + node.kind === 252 /* ExportSpecifier */ || + node.kind === 249 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -10795,11 +10846,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 72 /* FirstKeyword */ <= token && token <= 144 /* LastKeyword */; + return 72 /* FirstKeyword */ <= token && token <= 145 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 117 /* FirstContextualKeyword */ <= token && token <= 144 /* LastContextualKeyword */; + return 117 /* FirstContextualKeyword */ <= token && token <= 145 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -10829,14 +10880,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -10850,10 +10901,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -10876,11 +10927,11 @@ var ts; */ function hasDynamicName(declaration) { var name = ts.getNameOfDeclaration(declaration); - return name && isDynamicName(name); + return !!name && isDynamicName(name); } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 146 /* ComputedPropertyName */ && + return name.kind === 147 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -10901,7 +10952,7 @@ var ts; if (name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return escapeLeadingUnderscores(name.text); } - if (name.kind === 146 /* ComputedPropertyName */) { + if (name.kind === 147 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -10954,11 +11005,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 148 /* Parameter */; + return root.kind === 149 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 181 /* BindingElement */) { + while (node.kind === 182 /* BindingElement */) { node = node.parent.parent; } return node; @@ -10966,15 +11017,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 154 /* Constructor */ - || kind === 191 /* FunctionExpression */ - || kind === 233 /* FunctionDeclaration */ - || kind === 192 /* ArrowFunction */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */ - || kind === 238 /* ModuleDeclaration */ - || kind === 273 /* SourceFile */; + return kind === 155 /* Constructor */ + || kind === 192 /* FunctionExpression */ + || kind === 234 /* FunctionDeclaration */ + || kind === 193 /* ArrowFunction */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */ + || kind === 239 /* ModuleDeclaration */ + || kind === 274 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -10993,23 +11044,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 187 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 187 /* NewExpression */: + case 188 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 197 /* PrefixUnaryExpression */: - case 194 /* TypeOfExpression */: - case 195 /* VoidExpression */: - case 193 /* DeleteExpression */: - case 196 /* AwaitExpression */: - case 200 /* ConditionalExpression */: - case 202 /* YieldExpression */: + case 198 /* PrefixUnaryExpression */: + case 195 /* TypeOfExpression */: + case 196 /* VoidExpression */: + case 194 /* DeleteExpression */: + case 197 /* AwaitExpression */: + case 201 /* ConditionalExpression */: + case 203 /* YieldExpression */: return 1 /* Right */; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: switch (operator) { case 40 /* AsteriskAsteriskToken */: case 58 /* EqualsToken */: @@ -11033,15 +11084,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 187 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 199 /* BinaryExpression */) { + if (expression.kind === 200 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 197 /* PrefixUnaryExpression */ || expression.kind === 198 /* PostfixUnaryExpression */) { + else if (expression.kind === 198 /* PrefixUnaryExpression */ || expression.kind === 199 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11051,15 +11102,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: return 0; - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return 1; - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return 2; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return 4; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: switch (operatorKind) { case 26 /* CommaToken */: return 0; @@ -11080,21 +11131,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 197 /* PrefixUnaryExpression */: - case 194 /* TypeOfExpression */: - case 195 /* VoidExpression */: - case 193 /* DeleteExpression */: - case 196 /* AwaitExpression */: + case 198 /* PrefixUnaryExpression */: + case 195 /* TypeOfExpression */: + case 196 /* VoidExpression */: + case 194 /* DeleteExpression */: + case 197 /* AwaitExpression */: return 16; - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return 17; - case 186 /* CallExpression */: + case 187 /* CallExpression */: return 18; - case 187 /* NewExpression */: + case 188 /* NewExpression */: return hasArguments ? 19 : 18; - case 188 /* TaggedTemplateExpression */: - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: + case 189 /* TaggedTemplateExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: return 19; case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: @@ -11104,19 +11155,19 @@ var ts; case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 182 /* ArrayLiteralExpression */: - case 183 /* ObjectLiteralExpression */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 204 /* ClassExpression */: - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: - case 258 /* JsxFragment */: + case 183 /* ArrayLiteralExpression */: + case 184 /* ObjectLiteralExpression */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 205 /* ClassExpression */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: + case 259 /* JsxFragment */: case 12 /* RegularExpressionLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 201 /* TemplateExpression */: - case 190 /* ParenthesizedExpression */: - case 205 /* OmittedExpression */: + case 202 /* TemplateExpression */: + case 191 /* ParenthesizedExpression */: + case 206 /* OmittedExpression */: return 20; default: return -1; @@ -11169,7 +11220,7 @@ var ts; } ts.getBinaryOperatorPrecedence = getBinaryOperatorPrecedence; function createDiagnosticCollection() { - var nonFileDiagnostics = []; + var nonFileDiagnostics = []; // See GH#19873 var filesWithDiagnostics = []; var fileDiagnostics = ts.createMap(); var hasReadNonFileDiagnostics = false; @@ -11187,7 +11238,7 @@ var ts; if (diagnostic.file) { diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { - diagnostics = []; + diagnostics = []; // See GH#19873 fileDiagnostics.set(diagnostic.file.fileName, diagnostics); ts.insertSorted(filesWithDiagnostics, diagnostic.file.fileName, ts.compareStringsCaseSensitive); } @@ -11334,7 +11385,7 @@ var ts; var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + linePos = output.length - s.length + ts.last(lineStartsOfS); } } } @@ -11509,7 +11560,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 71 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 71 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { @@ -11517,16 +11568,17 @@ var ts; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { + // TODO: GH#18217 var firstAccessor; var secondAccessor; var getAccessor; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 155 /* GetAccessor */) { + if (accessor.kind === 156 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 156 /* SetAccessor */) { + else if (accessor.kind === 157 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11535,7 +11587,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 155 /* GetAccessor */ || member.kind === 156 /* SetAccessor */) + if ((member.kind === 156 /* GetAccessor */ || member.kind === 157 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -11546,10 +11598,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 155 /* GetAccessor */ && !getAccessor) { + if (member.kind === 156 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 156 /* SetAccessor */ && !setAccessor) { + if (member.kind === 157 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11596,25 +11648,20 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 285 /* JSDocComment */); - var templateTags = ts.flatMap(ts.filter(node.parent.tags, ts.isJSDocTemplateTag), function (tag) { return tag.typeParameters; }); - var templateTagNodes = templateTags; - templateTagNodes.pos = templateTagNodes.length > 0 ? ts.first(templateTagNodes).pos : node.pos; - templateTagNodes.end = templateTagNodes.length > 0 ? ts.last(templateTagNodes).end : node.end; - templateTagNodes.hasTrailingComma = false; - return templateTagNodes; + ts.Debug.assert(node.parent.kind === 286 /* JSDocComment */); + return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray); } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getJSDocTypeParameterDeclarations(node) { - // template tags are only available when a typedef isn't already using them - var tag = ts.find(ts.getJSDocTags(node), function (tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 285 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); - }); - return (tag && tag.typeParameters) || ts.emptyArray; + return ts.flatMap(ts.getJSDocTags(node), function (tag) { return isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined; }); } 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 === 286 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node * was parsed in a JavaScript file, gets the type annotation from JSDoc. @@ -11713,13 +11760,13 @@ var ts; // All comments look like they could have been part of the copyright header. Make // sure there is at least one blank line between it and the node. If not, it's not // a copyright header. - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.last(detachedComments).end); var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); if (nodeLine >= lastCommentLine + 2) { // Valid detachedComments emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); emitComments(text, lineMap, writer, detachedComments, /*leadingSeparator*/ false, /*trailingSeparator*/ true, newLine, writeComment); - currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.last(detachedComments).end }; } } } @@ -11888,7 +11935,7 @@ var ts; ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 206 /* ExpressionWithTypeArguments */ && + if (ts.isExpressionWithTypeArguments(node) && node.parent.token === 85 /* ExtendsKeyword */ && ts.isClassLike(node.parent.parent)) { return node.parent.parent; @@ -11906,8 +11953,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 183 /* ObjectLiteralExpression */ - || kind === 182 /* ArrayLiteralExpression */; + return kind === 184 /* ObjectLiteralExpression */ + || kind === 183 /* ArrayLiteralExpression */; } return false; } @@ -11917,7 +11964,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 206 /* ExpressionWithTypeArguments */ + return node.kind === 207 /* ExpressionWithTypeArguments */ && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 /* ImplementsKeyword */ @@ -11938,17 +11985,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 145 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 183 /* ObjectLiteralExpression */ && + return expression.kind === 184 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 182 /* ArrayLiteralExpression */ && + return expression.kind === 183 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12062,14 +12109,14 @@ var ts; return output; } function base64encode(host, input) { - if (host.base64encode) { + if (host && host.base64encode) { return host.base64encode(input); } return convertToBase64(input); } ts.base64encode = base64encode; function base64decode(host, input) { - if (host.base64decode) { + if (host && host.base64decode) { return host.base64decode(input); } var length = input.length; @@ -12289,8 +12336,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 237 /* EnumDeclaration */: - case 238 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 239 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12363,21 +12410,21 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 198 /* PostfixUnaryExpression */: - case 197 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0 /* Read */; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : 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 && parent.parent.kind === 215 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && parent.parent.kind === 216 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function compareDataObjects(dst, src) { @@ -12468,7 +12515,7 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 65536 /* Object */ ? type.objectFlags : 0; + return type.flags & 131072 /* Object */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { @@ -12739,9 +12786,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 147 /* TypeParameter */) { + if (d && d.kind === 148 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 235 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236 /* InterfaceDeclaration */) { return current; } } @@ -12749,7 +12796,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 154 /* Constructor */; + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 155 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12767,7 +12814,7 @@ var ts; } ts.isEmptyBindingElement = isEmptyBindingElement; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 181 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 182 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -12775,14 +12822,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 231 /* VariableDeclaration */) { + if (node.kind === 232 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 232 /* VariableDeclarationList */) { + if (node && node.kind === 233 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 213 /* VariableStatement */) { + if (node && node.kind === 214 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -12798,14 +12845,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 231 /* VariableDeclaration */) { + if (node.kind === 232 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 232 /* VariableDeclarationList */) { + if (node && node.kind === 233 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 213 /* VariableStatement */) { + if (node && node.kind === 214 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -12858,7 +12905,7 @@ var ts; // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) ts.localizedDiagnosticMessages = JSON.parse(fileContents); } - catch (e) { + catch (_a) { if (errors) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath)); } @@ -12942,17 +12989,17 @@ var ts; } // Covers remaining cases switch (hostNode.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return expr.name; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -12961,10 +13008,10 @@ var ts; return undefined; case 1 /* EndOfFileToken */: return undefined; - case 190 /* ParenthesizedExpression */: { + case 191 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 227 /* LabeledStatement */: { + case 228 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12987,28 +13034,29 @@ var ts; return !!node.name; // A 'name' property should always be a DeclarationName. } ts.isNamedDeclaration = isNamedDeclaration; + // TODO: GH#18217 This is often used as if it returns a defined result function getNameOfDeclaration(declaration) { if (!declaration) { return undefined; } switch (declaration.kind) { - case 204 /* ClassExpression */: - case 191 /* FunctionExpression */: + case 205 /* ClassExpression */: + case 192 /* FunctionExpression */: if (!declaration.name) { return getAssignedName(declaration); } break; case 71 /* Identifier */: return declaration; - case 297 /* JSDocPropertyTag */: - case 292 /* JSDocParameterTag */: { + case 298 /* JSDocPropertyTag */: + case 293 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 145 /* QualifiedName */) { + if (name.kind === 146 /* QualifiedName */) { return name.right; } break; } - case 199 /* BinaryExpression */: { + case 200 /* BinaryExpression */: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1 /* ExportsProperty */: @@ -13020,11 +13068,11 @@ var ts; return undefined; } } - case 291 /* JSDocCallbackTag */: + case 292 /* JSDocCallbackTag */: return declaration.name; - case 296 /* JSDocTypedefTag */: + case 297 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 248 /* ExportAssignment */: { + case 249 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -13214,637 +13262,637 @@ var ts; ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 145 /* QualifiedName */; + return node.kind === 146 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 146 /* ComputedPropertyName */; + return node.kind === 147 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 147 /* TypeParameter */; + return node.kind === 148 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 148 /* Parameter */; + return node.kind === 149 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 149 /* Decorator */; + return node.kind === 150 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 150 /* PropertySignature */; + return node.kind === 151 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 151 /* PropertyDeclaration */; + return node.kind === 152 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 152 /* MethodSignature */; + return node.kind === 153 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 153 /* MethodDeclaration */; + return node.kind === 154 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 154 /* Constructor */; + return node.kind === 155 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 155 /* GetAccessor */; + return node.kind === 156 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 156 /* SetAccessor */; + return node.kind === 157 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 157 /* CallSignature */; + return node.kind === 158 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 158 /* ConstructSignature */; + return node.kind === 159 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 159 /* IndexSignature */; + return node.kind === 160 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 156 /* SetAccessor */ || node.kind === 155 /* GetAccessor */; + return node.kind === 157 /* SetAccessor */ || node.kind === 156 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 160 /* TypePredicate */; + return node.kind === 161 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 161 /* TypeReference */; + return node.kind === 162 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 162 /* FunctionType */; + return node.kind === 163 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 163 /* ConstructorType */; + return node.kind === 164 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 164 /* TypeQuery */; + return node.kind === 165 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 165 /* TypeLiteral */; + return node.kind === 166 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 166 /* ArrayType */; + return node.kind === 167 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 167 /* TupleType */; + return node.kind === 168 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 168 /* UnionType */; + return node.kind === 169 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 169 /* IntersectionType */; + return node.kind === 170 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 170 /* ConditionalType */; + return node.kind === 171 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 171 /* InferType */; + return node.kind === 172 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 172 /* ParenthesizedType */; + return node.kind === 173 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 173 /* ThisType */; + return node.kind === 174 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 174 /* TypeOperator */; + return node.kind === 175 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 175 /* IndexedAccessType */; + return node.kind === 176 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 176 /* MappedType */; + return node.kind === 177 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 177 /* LiteralType */; + return node.kind === 178 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 178 /* ImportType */; + return node.kind === 179 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 179 /* ObjectBindingPattern */; + return node.kind === 180 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 180 /* ArrayBindingPattern */; + return node.kind === 181 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 181 /* BindingElement */; + return node.kind === 182 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 182 /* ArrayLiteralExpression */; + return node.kind === 183 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 183 /* ObjectLiteralExpression */; + return node.kind === 184 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 184 /* PropertyAccessExpression */; + return node.kind === 185 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 185 /* ElementAccessExpression */; + return node.kind === 186 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 186 /* CallExpression */; + return node.kind === 187 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 187 /* NewExpression */; + return node.kind === 188 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 188 /* TaggedTemplateExpression */; + return node.kind === 189 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 189 /* TypeAssertionExpression */; + return node.kind === 190 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 190 /* ParenthesizedExpression */; + return node.kind === 191 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 300 /* PartiallyEmittedExpression */) { + while (node.kind === 301 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 191 /* FunctionExpression */; + return node.kind === 192 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 192 /* ArrowFunction */; + return node.kind === 193 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 193 /* DeleteExpression */; + return node.kind === 194 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 194 /* TypeOfExpression */; + return node.kind === 195 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 195 /* VoidExpression */; + return node.kind === 196 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 196 /* AwaitExpression */; + return node.kind === 197 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 197 /* PrefixUnaryExpression */; + return node.kind === 198 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 198 /* PostfixUnaryExpression */; + return node.kind === 199 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 199 /* BinaryExpression */; + return node.kind === 200 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 200 /* ConditionalExpression */; + return node.kind === 201 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 201 /* TemplateExpression */; + return node.kind === 202 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 202 /* YieldExpression */; + return node.kind === 203 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 203 /* SpreadElement */; + return node.kind === 204 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 204 /* ClassExpression */; + return node.kind === 205 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 205 /* OmittedExpression */; + return node.kind === 206 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 206 /* ExpressionWithTypeArguments */; + return node.kind === 207 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 207 /* AsExpression */; + return node.kind === 208 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 208 /* NonNullExpression */; + return node.kind === 209 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 209 /* MetaProperty */; + return node.kind === 210 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 210 /* TemplateSpan */; + return node.kind === 211 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 211 /* SemicolonClassElement */; + return node.kind === 212 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 212 /* Block */; + return node.kind === 213 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 213 /* VariableStatement */; + return node.kind === 214 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 214 /* EmptyStatement */; + return node.kind === 215 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 215 /* ExpressionStatement */; + return node.kind === 216 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 216 /* IfStatement */; + return node.kind === 217 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 217 /* DoStatement */; + return node.kind === 218 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 218 /* WhileStatement */; + return node.kind === 219 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 219 /* ForStatement */; + return node.kind === 220 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 220 /* ForInStatement */; + return node.kind === 221 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 221 /* ForOfStatement */; + return node.kind === 222 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 222 /* ContinueStatement */; + return node.kind === 223 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 223 /* BreakStatement */; + return node.kind === 224 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 223 /* BreakStatement */ || node.kind === 222 /* ContinueStatement */; + return node.kind === 224 /* BreakStatement */ || node.kind === 223 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 224 /* ReturnStatement */; + return node.kind === 225 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 225 /* WithStatement */; + return node.kind === 226 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 226 /* SwitchStatement */; + return node.kind === 227 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 227 /* LabeledStatement */; + return node.kind === 228 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 228 /* ThrowStatement */; + return node.kind === 229 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 229 /* TryStatement */; + return node.kind === 230 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 230 /* DebuggerStatement */; + return node.kind === 231 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 231 /* VariableDeclaration */; + return node.kind === 232 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 232 /* VariableDeclarationList */; + return node.kind === 233 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 233 /* FunctionDeclaration */; + return node.kind === 234 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 234 /* ClassDeclaration */; + return node.kind === 235 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 235 /* InterfaceDeclaration */; + return node.kind === 236 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 236 /* TypeAliasDeclaration */; + return node.kind === 237 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 237 /* EnumDeclaration */; + return node.kind === 238 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 238 /* ModuleDeclaration */; + return node.kind === 239 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 239 /* ModuleBlock */; + return node.kind === 240 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 240 /* CaseBlock */; + return node.kind === 241 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 241 /* NamespaceExportDeclaration */; + return node.kind === 242 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 242 /* ImportEqualsDeclaration */; + return node.kind === 243 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 243 /* ImportDeclaration */; + return node.kind === 244 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 244 /* ImportClause */; + return node.kind === 245 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 245 /* NamespaceImport */; + return node.kind === 246 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 246 /* NamedImports */; + return node.kind === 247 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 247 /* ImportSpecifier */; + return node.kind === 248 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 248 /* ExportAssignment */; + return node.kind === 249 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 249 /* ExportDeclaration */; + return node.kind === 250 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 250 /* NamedExports */; + return node.kind === 251 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 251 /* ExportSpecifier */; + return node.kind === 252 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 252 /* MissingDeclaration */; + return node.kind === 253 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 253 /* ExternalModuleReference */; + return node.kind === 254 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 254 /* JsxElement */; + return node.kind === 255 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 255 /* JsxSelfClosingElement */; + return node.kind === 256 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 256 /* JsxOpeningElement */; + return node.kind === 257 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 257 /* JsxClosingElement */; + return node.kind === 258 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 258 /* JsxFragment */; + return node.kind === 259 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 259 /* JsxOpeningFragment */; + return node.kind === 260 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 260 /* JsxClosingFragment */; + return node.kind === 261 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 261 /* JsxAttribute */; + return node.kind === 262 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 262 /* JsxAttributes */; + return node.kind === 263 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 263 /* JsxSpreadAttribute */; + return node.kind === 264 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 264 /* JsxExpression */; + return node.kind === 265 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 265 /* CaseClause */; + return node.kind === 266 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 266 /* DefaultClause */; + return node.kind === 267 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 267 /* HeritageClause */; + return node.kind === 268 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 268 /* CatchClause */; + return node.kind === 269 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 269 /* PropertyAssignment */; + return node.kind === 270 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 270 /* ShorthandPropertyAssignment */; + return node.kind === 271 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 271 /* SpreadAssignment */; + return node.kind === 272 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 272 /* EnumMember */; + return node.kind === 273 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 273 /* SourceFile */; + return node.kind === 274 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 274 /* Bundle */; + return node.kind === 275 /* Bundle */; } ts.isBundle = isBundle; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 277 /* JSDocTypeExpression */; + return node.kind === 278 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 278 /* JSDocAllType */; + return node.kind === 279 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 279 /* JSDocUnknownType */; + return node.kind === 280 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 280 /* JSDocNullableType */; + return node.kind === 281 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 281 /* JSDocNonNullableType */; + return node.kind === 282 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 282 /* JSDocOptionalType */; + return node.kind === 283 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 283 /* JSDocFunctionType */; + return node.kind === 284 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 284 /* JSDocVariadicType */; + return node.kind === 285 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 285 /* JSDocComment */; + return node.kind === 286 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 289 /* JSDocAugmentsTag */; + return node.kind === 290 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 290 /* JSDocClassTag */; + return node.kind === 291 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocParameterTag(node) { - return node.kind === 292 /* JSDocParameterTag */; + return node.kind === 293 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 293 /* JSDocReturnTag */; + return node.kind === 294 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 294 /* JSDocTypeTag */; + return node.kind === 295 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 295 /* JSDocTemplateTag */; + return node.kind === 296 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 296 /* JSDocTypedefTag */; + return node.kind === 297 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 297 /* JSDocPropertyTag */; + return node.kind === 298 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 297 /* JSDocPropertyTag */ || node.kind === 292 /* JSDocParameterTag */; + return node.kind === 298 /* JSDocPropertyTag */ || node.kind === 293 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 286 /* JSDocTypeLiteral */; + return node.kind === 287 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 291 /* JSDocCallbackTag */; + return node.kind === 292 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 287 /* JSDocSignature */; + return node.kind === 288 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -13855,7 +13903,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 298 /* SyntaxList */; + return n.kind === 299 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -13865,7 +13913,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 145 /* FirstNode */; + return kind >= 146 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13874,7 +13922,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 144 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 145 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -13899,6 +13947,10 @@ var ts; return 13 /* FirstTemplateToken */ <= kind && kind <= 16 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isTemplateLiteralToken(node) { + return isTemplateLiteralKind(node.kind); + } + ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; return kind === 15 /* TemplateMiddle */ @@ -13912,7 +13964,6 @@ var ts; // Identifiers /* @internal */ function isGeneratedIdentifier(node) { - // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */; } ts.isGeneratedIdentifier = isGeneratedIdentifier; @@ -13952,7 +14003,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 145 /* QualifiedName */ + return kind === 146 /* QualifiedName */ || kind === 71 /* Identifier */; } ts.isEntityName = isEntityName; @@ -13961,14 +14012,14 @@ var ts; return kind === 71 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 146 /* ComputedPropertyName */; + || kind === 147 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 179 /* ObjectBindingPattern */ - || kind === 180 /* ArrayBindingPattern */; + || kind === 180 /* ObjectBindingPattern */ + || kind === 181 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13983,13 +14034,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return true; default: return false; @@ -13998,14 +14049,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 287 /* JSDocSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 162 /* FunctionType */: - case 283 /* JSDocFunctionType */: - case 163 /* ConstructorType */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 288 /* JSDocSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 163 /* FunctionType */: + case 284 /* JSDocFunctionType */: + case 164 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14020,29 +14071,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 154 /* Constructor */ - || kind === 151 /* PropertyDeclaration */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */ - || kind === 159 /* IndexSignature */ - || kind === 211 /* SemicolonClassElement */; + return kind === 155 /* Constructor */ + || kind === 152 /* PropertyDeclaration */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */ + || kind === 160 /* IndexSignature */ + || kind === 212 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 234 /* ClassDeclaration */ || node.kind === 204 /* ClassExpression */); + return node && (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 155 /* GetAccessor */ || node.kind === 156 /* SetAccessor */); + return node && (node.kind === 156 /* GetAccessor */ || node.kind === 157 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return true; default: return false; @@ -14052,11 +14103,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 158 /* ConstructSignature */ - || kind === 157 /* CallSignature */ - || kind === 150 /* PropertySignature */ - || kind === 152 /* MethodSignature */ - || kind === 159 /* IndexSignature */; + return kind === 159 /* ConstructSignature */ + || kind === 158 /* CallSignature */ + || kind === 151 /* PropertySignature */ + || kind === 153 /* MethodSignature */ + || kind === 160 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14065,18 +14116,19 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 269 /* PropertyAssignment */ - || kind === 270 /* ShorthandPropertyAssignment */ - || kind === 271 /* SpreadAssignment */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */; + return kind === 270 /* PropertyAssignment */ + || kind === 271 /* ShorthandPropertyAssignment */ + || kind === 272 /* SpreadAssignment */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 160 /* FirstTypeNode */ && kind <= 178 /* LastTypeNode */) + return (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) || kind === 119 /* AnyKeyword */ + || kind === 142 /* UnknownKeyword */ || kind === 134 /* NumberKeyword */ || kind === 135 /* ObjectKeyword */ || kind === 122 /* BooleanKeyword */ @@ -14087,14 +14139,14 @@ var ts; || kind === 140 /* UndefinedKeyword */ || kind === 95 /* NullKeyword */ || kind === 131 /* NeverKeyword */ - || kind === 206 /* ExpressionWithTypeArguments */ - || kind === 278 /* JSDocAllType */ - || kind === 279 /* JSDocUnknownType */ - || kind === 280 /* JSDocNullableType */ - || kind === 281 /* JSDocNonNullableType */ - || kind === 282 /* JSDocOptionalType */ - || kind === 283 /* JSDocFunctionType */ - || kind === 284 /* JSDocVariadicType */; + || kind === 207 /* ExpressionWithTypeArguments */ + || kind === 279 /* JSDocAllType */ + || kind === 280 /* JSDocUnknownType */ + || kind === 281 /* JSDocNullableType */ + || kind === 282 /* JSDocNonNullableType */ + || kind === 283 /* JSDocOptionalType */ + || kind === 284 /* JSDocFunctionType */ + || kind === 285 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -14107,8 +14159,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 162 /* FunctionType */: - case 163 /* ConstructorType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: return true; } return false; @@ -14119,8 +14171,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 180 /* ArrayBindingPattern */ - || kind === 179 /* ObjectBindingPattern */; + return kind === 181 /* ArrayBindingPattern */ + || kind === 180 /* ObjectBindingPattern */; } return false; } @@ -14128,15 +14180,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 182 /* ArrayLiteralExpression */ - || kind === 183 /* ObjectLiteralExpression */; + return kind === 183 /* ArrayLiteralExpression */ + || kind === 184 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 181 /* BindingElement */ - || kind === 205 /* OmittedExpression */; + return kind === 182 /* BindingElement */ + || kind === 206 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14145,9 +14197,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: - case 181 /* BindingElement */: + case 232 /* VariableDeclaration */: + case 149 /* Parameter */: + case 182 /* BindingElement */: return true; } return false; @@ -14168,8 +14220,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 179 /* ObjectBindingPattern */: - case 183 /* ObjectLiteralExpression */: + case 180 /* ObjectBindingPattern */: + case 184 /* ObjectLiteralExpression */: return true; } return false; @@ -14181,8 +14233,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180 /* ArrayBindingPattern */: - case 182 /* ArrayLiteralExpression */: + case 181 /* ArrayBindingPattern */: + case 183 /* ArrayLiteralExpression */: return true; } return false; @@ -14191,26 +14243,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 184 /* PropertyAccessExpression */ - || kind === 145 /* QualifiedName */ - || kind === 178 /* ImportType */; + return kind === 185 /* PropertyAccessExpression */ + || kind === 146 /* QualifiedName */ + || kind === 179 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 184 /* PropertyAccessExpression */ - || kind === 145 /* QualifiedName */; + return kind === 185 /* PropertyAccessExpression */ + || kind === 146 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 256 /* JsxOpeningElement */: - case 255 /* JsxSelfClosingElement */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 188 /* TaggedTemplateExpression */: - case 149 /* Decorator */: + case 257 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 189 /* TaggedTemplateExpression */: + case 150 /* Decorator */: return true; default: return false; @@ -14218,12 +14270,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 186 /* CallExpression */ || node.kind === 187 /* NewExpression */; + return node.kind === 187 /* CallExpression */ || node.kind === 188 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 201 /* TemplateExpression */ + return kind === 202 /* TemplateExpression */ || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14234,32 +14286,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: - case 187 /* NewExpression */: - case 186 /* CallExpression */: - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: - case 258 /* JsxFragment */: - case 188 /* TaggedTemplateExpression */: - case 182 /* ArrayLiteralExpression */: - case 190 /* ParenthesizedExpression */: - case 183 /* ObjectLiteralExpression */: - case 204 /* ClassExpression */: - case 191 /* FunctionExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: + case 188 /* NewExpression */: + case 187 /* CallExpression */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: + case 259 /* JsxFragment */: + case 189 /* TaggedTemplateExpression */: + case 183 /* ArrayLiteralExpression */: + case 191 /* ParenthesizedExpression */: + case 184 /* ObjectLiteralExpression */: + case 205 /* ClassExpression */: + case 192 /* FunctionExpression */: case 71 /* Identifier */: case 12 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 99 /* ThisKeyword */: case 101 /* TrueKeyword */: case 97 /* SuperKeyword */: - case 208 /* NonNullExpression */: - case 209 /* MetaProperty */: + case 209 /* NonNullExpression */: + case 210 /* MetaProperty */: case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -14273,13 +14325,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: - case 193 /* DeleteExpression */: - case 194 /* TypeOfExpression */: - case 195 /* VoidExpression */: - case 196 /* AwaitExpression */: - case 189 /* TypeAssertionExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: + case 194 /* DeleteExpression */: + case 195 /* TypeOfExpression */: + case 196 /* VoidExpression */: + case 197 /* AwaitExpression */: + case 190 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -14288,9 +14340,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return true; - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; default: @@ -14309,15 +14361,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 200 /* ConditionalExpression */: - case 202 /* YieldExpression */: - case 192 /* ArrowFunction */: - case 199 /* BinaryExpression */: - case 203 /* SpreadElement */: - case 207 /* AsExpression */: - case 205 /* OmittedExpression */: - case 301 /* CommaListExpression */: - case 300 /* PartiallyEmittedExpression */: + case 201 /* ConditionalExpression */: + case 203 /* YieldExpression */: + case 193 /* ArrowFunction */: + case 200 /* BinaryExpression */: + case 204 /* SpreadElement */: + case 208 /* AsExpression */: + case 206 /* OmittedExpression */: + case 302 /* CommaListExpression */: + case 301 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14325,18 +14377,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 189 /* TypeAssertionExpression */ - || kind === 207 /* AsExpression */; + return kind === 190 /* TypeAssertionExpression */ + || kind === 208 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 300 /* PartiallyEmittedExpression */; + return node.kind === 301 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 299 /* NotEmittedStatement */; + return node.kind === 300 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14347,13 +14399,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: return true; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14361,7 +14413,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 220 /* ForInStatement */ || node.kind === 221 /* ForOfStatement */; + return node.kind === 221 /* ForInStatement */ || node.kind === 222 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14385,113 +14437,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 239 /* ModuleBlock */ - || kind === 238 /* ModuleDeclaration */ + return kind === 240 /* ModuleBlock */ + || kind === 239 /* ModuleDeclaration */ || kind === 71 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 239 /* ModuleBlock */ - || kind === 238 /* ModuleDeclaration */; + return kind === 240 /* ModuleBlock */ + || kind === 239 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 238 /* ModuleDeclaration */; + || kind === 239 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 246 /* NamedImports */ - || kind === 245 /* NamespaceImport */; + return kind === 247 /* NamedImports */ + || kind === 246 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 238 /* ModuleDeclaration */ || node.kind === 237 /* EnumDeclaration */; + return node.kind === 239 /* ModuleDeclaration */ || node.kind === 238 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 192 /* ArrowFunction */ - || kind === 181 /* BindingElement */ - || kind === 234 /* ClassDeclaration */ - || kind === 204 /* ClassExpression */ - || kind === 154 /* Constructor */ - || kind === 237 /* EnumDeclaration */ - || kind === 272 /* EnumMember */ - || kind === 251 /* ExportSpecifier */ - || kind === 233 /* FunctionDeclaration */ - || kind === 191 /* FunctionExpression */ - || kind === 155 /* GetAccessor */ - || kind === 244 /* ImportClause */ - || kind === 242 /* ImportEqualsDeclaration */ - || kind === 247 /* ImportSpecifier */ - || kind === 235 /* InterfaceDeclaration */ - || kind === 261 /* JsxAttribute */ - || kind === 153 /* MethodDeclaration */ - || kind === 152 /* MethodSignature */ - || kind === 238 /* ModuleDeclaration */ - || kind === 241 /* NamespaceExportDeclaration */ - || kind === 245 /* NamespaceImport */ - || kind === 148 /* Parameter */ - || kind === 269 /* PropertyAssignment */ - || kind === 151 /* PropertyDeclaration */ - || kind === 150 /* PropertySignature */ - || kind === 156 /* SetAccessor */ - || kind === 270 /* ShorthandPropertyAssignment */ - || kind === 236 /* TypeAliasDeclaration */ - || kind === 147 /* TypeParameter */ - || kind === 231 /* VariableDeclaration */ - || kind === 296 /* JSDocTypedefTag */ - || kind === 291 /* JSDocCallbackTag */ - || kind === 297 /* JSDocPropertyTag */; + return kind === 193 /* ArrowFunction */ + || kind === 182 /* BindingElement */ + || kind === 235 /* ClassDeclaration */ + || kind === 205 /* ClassExpression */ + || kind === 155 /* Constructor */ + || kind === 238 /* EnumDeclaration */ + || kind === 273 /* EnumMember */ + || kind === 252 /* ExportSpecifier */ + || kind === 234 /* FunctionDeclaration */ + || kind === 192 /* FunctionExpression */ + || kind === 156 /* GetAccessor */ + || kind === 245 /* ImportClause */ + || kind === 243 /* ImportEqualsDeclaration */ + || kind === 248 /* ImportSpecifier */ + || kind === 236 /* InterfaceDeclaration */ + || kind === 262 /* JsxAttribute */ + || kind === 154 /* MethodDeclaration */ + || kind === 153 /* MethodSignature */ + || kind === 239 /* ModuleDeclaration */ + || kind === 242 /* NamespaceExportDeclaration */ + || kind === 246 /* NamespaceImport */ + || kind === 149 /* Parameter */ + || kind === 270 /* PropertyAssignment */ + || kind === 152 /* PropertyDeclaration */ + || kind === 151 /* PropertySignature */ + || kind === 157 /* SetAccessor */ + || kind === 271 /* ShorthandPropertyAssignment */ + || kind === 237 /* TypeAliasDeclaration */ + || kind === 148 /* TypeParameter */ + || kind === 232 /* VariableDeclaration */ + || kind === 297 /* JSDocTypedefTag */ + || kind === 292 /* JSDocCallbackTag */ + || kind === 298 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 233 /* FunctionDeclaration */ - || kind === 252 /* MissingDeclaration */ - || kind === 234 /* ClassDeclaration */ - || kind === 235 /* InterfaceDeclaration */ - || kind === 236 /* TypeAliasDeclaration */ - || kind === 237 /* EnumDeclaration */ - || kind === 238 /* ModuleDeclaration */ - || kind === 243 /* ImportDeclaration */ - || kind === 242 /* ImportEqualsDeclaration */ - || kind === 249 /* ExportDeclaration */ - || kind === 248 /* ExportAssignment */ - || kind === 241 /* NamespaceExportDeclaration */; + return kind === 234 /* FunctionDeclaration */ + || kind === 253 /* MissingDeclaration */ + || kind === 235 /* ClassDeclaration */ + || kind === 236 /* InterfaceDeclaration */ + || kind === 237 /* TypeAliasDeclaration */ + || kind === 238 /* EnumDeclaration */ + || kind === 239 /* ModuleDeclaration */ + || kind === 244 /* ImportDeclaration */ + || kind === 243 /* ImportEqualsDeclaration */ + || kind === 250 /* ExportDeclaration */ + || kind === 249 /* ExportAssignment */ + || kind === 242 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 223 /* BreakStatement */ - || kind === 222 /* ContinueStatement */ - || kind === 230 /* DebuggerStatement */ - || kind === 217 /* DoStatement */ - || kind === 215 /* ExpressionStatement */ - || kind === 214 /* EmptyStatement */ - || kind === 220 /* ForInStatement */ - || kind === 221 /* ForOfStatement */ - || kind === 219 /* ForStatement */ - || kind === 216 /* IfStatement */ - || kind === 227 /* LabeledStatement */ - || kind === 224 /* ReturnStatement */ - || kind === 226 /* SwitchStatement */ - || kind === 228 /* ThrowStatement */ - || kind === 229 /* TryStatement */ - || kind === 213 /* VariableStatement */ - || kind === 218 /* WhileStatement */ - || kind === 225 /* WithStatement */ - || kind === 299 /* NotEmittedStatement */ - || kind === 303 /* EndOfDeclarationMarker */ - || kind === 302 /* MergeDeclarationMarker */; + return kind === 224 /* BreakStatement */ + || kind === 223 /* ContinueStatement */ + || kind === 231 /* DebuggerStatement */ + || kind === 218 /* DoStatement */ + || kind === 216 /* ExpressionStatement */ + || kind === 215 /* EmptyStatement */ + || kind === 221 /* ForInStatement */ + || kind === 222 /* ForOfStatement */ + || kind === 220 /* ForStatement */ + || kind === 217 /* IfStatement */ + || kind === 228 /* LabeledStatement */ + || kind === 225 /* ReturnStatement */ + || kind === 227 /* SwitchStatement */ + || kind === 229 /* ThrowStatement */ + || kind === 230 /* TryStatement */ + || kind === 214 /* VariableStatement */ + || kind === 219 /* WhileStatement */ + || kind === 226 /* WithStatement */ + || kind === 300 /* NotEmittedStatement */ + || kind === 304 /* EndOfDeclarationMarker */ + || kind === 303 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 147 /* TypeParameter */) { - return node.parent.kind !== 295 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); + if (node.kind === 148 /* TypeParameter */) { + return node.parent.kind !== 296 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -14518,10 +14570,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 212 /* Block */) + if (node.kind !== 213 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 229 /* TryStatement */ || node.parent.kind === 268 /* CatchClause */) { + if (node.parent.kind === 230 /* TryStatement */ || node.parent.kind === 269 /* CatchClause */) { return false; } } @@ -14531,8 +14583,8 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 253 /* ExternalModuleReference */ - || kind === 145 /* QualifiedName */ + return kind === 254 /* ExternalModuleReference */ + || kind === 146 /* QualifiedName */ || kind === 71 /* Identifier */; } ts.isModuleReference = isModuleReference; @@ -14542,76 +14594,78 @@ var ts; var kind = node.kind; return kind === 99 /* ThisKeyword */ || kind === 71 /* Identifier */ - || kind === 184 /* PropertyAccessExpression */; + || kind === 185 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 254 /* JsxElement */ - || kind === 264 /* JsxExpression */ - || kind === 255 /* JsxSelfClosingElement */ + return kind === 255 /* JsxElement */ + || kind === 265 /* JsxExpression */ + || kind === 256 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */ - || kind === 258 /* JsxFragment */; + || kind === 259 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 261 /* JsxAttribute */ - || kind === 263 /* JsxSpreadAttribute */; + return kind === 262 /* JsxAttribute */ + || kind === 264 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 264 /* JsxExpression */; + || kind === 265 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 256 /* JsxOpeningElement */ - || kind === 255 /* JsxSelfClosingElement */; + return kind === 257 /* JsxOpeningElement */ + || kind === 256 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 265 /* CaseClause */ - || kind === 266 /* DefaultClause */; + return kind === 266 /* CaseClause */ + || kind === 267 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 277 /* FirstJSDocNode */ && node.kind <= 297 /* LastJSDocNode */; + return node.kind >= 278 /* FirstJSDocNode */ && node.kind <= 298 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 285 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 286 /* JSDocComment */ || 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 >= 288 /* FirstJSDocTagNode */ && node.kind <= 297 /* LastJSDocTagNode */; + return node.kind >= 289 /* FirstJSDocTagNode */ && node.kind <= 298 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 156 /* SetAccessor */; + return node.kind === 157 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 155 /* GetAccessor */; + return node.kind === 156 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ /* @internal */ + // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times function hasJSDocNodes(node) { - return !!node.jsDoc && node.jsDoc.length > 0; + var jsDoc = node.jsDoc; + return !!jsDoc && jsDoc.length > 0; } ts.hasJSDocNodes = hasJSDocNodes; /** True if has type node attached to it. */ @@ -14624,36 +14678,36 @@ var ts; /* @internal */ function couldHaveType(node) { switch (node.kind) { - case 148 /* Parameter */: - case 150 /* PropertySignature */: - case 151 /* PropertyDeclaration */: - case 152 /* MethodSignature */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 160 /* TypePredicate */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 172 /* ParenthesizedType */: - case 174 /* TypeOperator */: - case 176 /* MappedType */: - case 189 /* TypeAssertionExpression */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 207 /* AsExpression */: - case 231 /* VariableDeclaration */: - case 233 /* FunctionDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 277 /* JSDocTypeExpression */: - case 280 /* JSDocNullableType */: - case 281 /* JSDocNonNullableType */: - case 282 /* JSDocOptionalType */: - case 283 /* JSDocFunctionType */: - case 284 /* JSDocVariadicType */: + case 149 /* Parameter */: + case 151 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 153 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 161 /* TypePredicate */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 173 /* ParenthesizedType */: + case 175 /* TypeOperator */: + case 177 /* MappedType */: + case 190 /* TypeAssertionExpression */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 208 /* AsExpression */: + case 232 /* VariableDeclaration */: + case 234 /* FunctionDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 278 /* JSDocTypeExpression */: + case 281 /* JSDocNullableType */: + case 282 /* JSDocNonNullableType */: + case 283 /* JSDocOptionalType */: + case 284 /* JSDocFunctionType */: + case 285 /* JSDocVariadicType */: return true; } return false; @@ -14673,13 +14727,13 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 261 /* JsxAttribute */: - case 263 /* JsxSpreadAttribute */: - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 262 /* JsxAttribute */: + case 264 /* JsxSpreadAttribute */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return true; default: return false; @@ -14688,7 +14742,7 @@ var ts; ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 161 /* TypeReference */ || node.kind === 206 /* ExpressionWithTypeArguments */; + return node.kind === 162 /* TypeReference */ || node.kind === 207 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14722,7 +14776,7 @@ var ts; ts.isStringLiteralLike = isStringLiteralLike; /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 246 /* NamedImports */ || node.kind === 250 /* NamedExports */; + return node.kind === 247 /* NamedImports */ || node.kind === 251 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; })(ts || (ts = {})); @@ -14745,7 +14799,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 273 /* SourceFile */) { + if (kind === 274 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71 /* Identifier */) { @@ -14797,28 +14851,28 @@ 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 <= 144 /* LastToken */) { + if (!node || node.kind <= 145 /* LastToken */) { return; } switch (node.kind) { - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 148 /* Parameter */: + case 149 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -14826,7 +14880,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -14834,51 +14888,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150 /* PropertySignature */: + case 151 /* 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 269 /* PropertyAssignment */: + case 270 /* 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 231 /* VariableDeclaration */: + case 232 /* 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 181 /* BindingElement */: + case 182 /* 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 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* 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 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -14889,304 +14943,304 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 165 /* TypeLiteral */: + case 166 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 167 /* TupleType */: + case 168 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 168 /* UnionType */: - case 169 /* IntersectionType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 171 /* InferType */: + case 172 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 178 /* ImportType */: + case 179 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 172 /* ParenthesizedType */: - case 174 /* TypeOperator */: + case 173 /* ParenthesizedType */: + case 175 /* TypeOperator */: return visitNode(cbNode, node.type); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 176 /* MappedType */: + case 177 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 177 /* LiteralType */: + case 178 /* LiteralType */: return visitNode(cbNode, node.literal); - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 194 /* TypeOfExpression */: + case 195 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 207 /* AsExpression */: + case 208 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return visitNode(cbNode, node.name); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 212 /* Block */: - case 239 /* ModuleBlock */: + case 213 /* Block */: + case 240 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 273 /* SourceFile */: + case 274 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222 /* ContinueStatement */: - case 223 /* BreakStatement */: + case 223 /* ContinueStatement */: + case 224 /* BreakStatement */: return visitNode(cbNode, node.label); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 265 /* CaseClause */: + case 266 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 149 /* Decorator */: + case 150 /* Decorator */: return visitNode(cbNode, node.expression); - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* 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 235 /* InterfaceDeclaration */: + case 236 /* 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 236 /* TypeAliasDeclaration */: + case 237 /* 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 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 272 /* EnumMember */: + case 273 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 246 /* NamedImports */: - case 250 /* NamedExports */: + case 247 /* NamedImports */: + case 251 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 252 /* MissingDeclaration */: + case 253 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 254 /* JsxElement */: + case 255 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 255 /* JsxSelfClosingElement */: - case 256 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 263 /* JsxSpreadAttribute */: + case 264 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 277 /* JSDocTypeExpression */: + case 278 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 281 /* JSDocNonNullableType */: + case 282 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 280 /* JSDocNullableType */: + case 281 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 282 /* JSDocOptionalType */: + case 283 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 285 /* JSDocComment */: + case 286 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 292 /* JSDocParameterTag */: - case 297 /* JSDocPropertyTag */: + case 293 /* JSDocParameterTag */: + case 298 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -15195,17 +15249,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 293 /* JSDocReturnTag */: + case 294 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 294 /* JSDocTypeTag */: + case 295 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 289 /* JSDocAugmentsTag */: + case 290 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 295 /* JSDocTemplateTag */: + case 296 /* JSDocTemplateTag */: return visitNodes(cbNode, cbNodes, node.typeParameters); - case 296 /* JSDocTypedefTag */: + case 297 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 277 /* JSDocTypeExpression */) { + node.typeExpression.kind === 278 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -15213,16 +15267,16 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 291 /* JSDocCallbackTag */: + case 292 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 287 /* JSDocSignature */: + case 288 /* JSDocSignature */: 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 286 /* JSDocTypeLiteral */: + case 287 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -15230,7 +15284,7 @@ var ts; } } return; - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -15278,6 +15332,7 @@ var ts; // becoming detached from any SourceFile). It is recommended that this SourceFile not // be used once 'update' is called on it. function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + if (aggressiveChecks === void 0) { aggressiveChecks = false; } var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. @@ -15403,6 +15458,7 @@ var ts; // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { + if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); if (scriptKind === 6 /* JSON */) { var result_1 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); @@ -15433,6 +15489,7 @@ var ts; initializeState(sourceText, languageVersion, syntaxCursor, 6 /* JSON */); // Set source file so that errors will be reported with this file name sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false); + sourceFile.flags = contextFlags; // Prime the scanner. nextToken(); var pos = getNodePos(); @@ -15441,7 +15498,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(215 /* ExpressionStatement */); + var statement = createNode(216 /* ExpressionStatement */); switch (token()) { case 21 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -15600,10 +15657,11 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(273 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(274 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; + sourceFile.bindSuggestionDiagnostics = undefined; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); sourceFile.languageVariant = getLanguageVariant(scriptKind); @@ -15987,7 +16045,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(146 /* ComputedPropertyName */); + var node = createNode(147 /* ComputedPropertyName */); parseExpected(21 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -16124,7 +16182,7 @@ var ts; case 14 /* JsxChildren */: return true; } - ts.Debug.fail("Non-exhaustive case in 'isListElement'."); + return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { ts.Debug.assert(token() === 17 /* OpenBraceToken */); @@ -16213,6 +16271,8 @@ var ts; return token() === 29 /* GreaterThanToken */ || token() === 41 /* SlashToken */; case 14 /* JsxChildren */: return token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + default: + return false; } } function isVariableDeclaratorListTerminator() { @@ -16399,14 +16459,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 154 /* Constructor */: - case 159 /* IndexSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 151 /* PropertyDeclaration */: - case 211 /* SemicolonClassElement */: + case 155 /* Constructor */: + case 160 /* IndexSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 212 /* SemicolonClassElement */: return true; - case 153 /* MethodDeclaration */: + case 154 /* 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. @@ -16421,8 +16481,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: return true; } } @@ -16431,58 +16491,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 213 /* VariableStatement */: - case 212 /* Block */: - case 216 /* IfStatement */: - case 215 /* ExpressionStatement */: - case 228 /* ThrowStatement */: - case 224 /* ReturnStatement */: - case 226 /* SwitchStatement */: - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 219 /* ForStatement */: - case 218 /* WhileStatement */: - case 225 /* WithStatement */: - case 214 /* EmptyStatement */: - case 229 /* TryStatement */: - case 227 /* LabeledStatement */: - case 217 /* DoStatement */: - case 230 /* DebuggerStatement */: - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 249 /* ExportDeclaration */: - case 248 /* ExportAssignment */: - case 238 /* ModuleDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 234 /* FunctionDeclaration */: + case 214 /* VariableStatement */: + case 213 /* Block */: + case 217 /* IfStatement */: + case 216 /* ExpressionStatement */: + case 229 /* ThrowStatement */: + case 225 /* ReturnStatement */: + case 227 /* SwitchStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 220 /* ForStatement */: + case 219 /* WhileStatement */: + case 226 /* WithStatement */: + case 215 /* EmptyStatement */: + case 230 /* TryStatement */: + case 228 /* LabeledStatement */: + case 218 /* DoStatement */: + case 231 /* DebuggerStatement */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 250 /* ExportDeclaration */: + case 249 /* ExportAssignment */: + case 239 /* ModuleDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 272 /* EnumMember */; + return node.kind === 273 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 158 /* ConstructSignature */: - case 152 /* MethodSignature */: - case 159 /* IndexSignature */: - case 150 /* PropertySignature */: - case 157 /* CallSignature */: + case 159 /* ConstructSignature */: + case 153 /* MethodSignature */: + case 160 /* IndexSignature */: + case 151 /* PropertySignature */: + case 158 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 231 /* VariableDeclaration */) { + if (node.kind !== 232 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -16503,7 +16563,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 148 /* Parameter */) { + if (node.kind !== 149 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -16544,6 +16604,7 @@ var ts; case 22 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; case 13 /* JsxAttributes */: return ts.Diagnostics.Identifier_expected; case 14 /* JsxChildren */: return ts.Diagnostics.Identifier_expected; + default: return undefined; // TODO: GH#18217 `default: Debug.assertNever(context);` } } // Parses a comma-delimited list of elements @@ -16632,7 +16693,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(145 /* QualifiedName */, entity.pos); + var node = createNode(146 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -16669,19 +16730,19 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(201 /* TemplateExpression */); + var template = createNode(202 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); var list = []; var listPos = getNodePos(); do { list.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(list).literal.kind === 15 /* TemplateMiddle */); + } while (ts.last(list).literal.kind === 15 /* TemplateMiddle */); template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { - var span = createNode(210 /* TemplateSpan */); + var span = createNode(211 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18 /* CloseBraceToken */) { @@ -16732,7 +16793,7 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(161 /* TypeReference */); + var node = createNode(162 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token() === 27 /* LessThanToken */) { node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */); @@ -16741,20 +16802,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(160 /* TypePredicate */, lhs.pos); + var node = createNode(161 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(173 /* ThisType */); + var node = createNode(174 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(278 /* JSDocAllType */); + var result = createNode(279 /* JSDocAllType */); if (postFixEquals) { - return createJSDocPostfixType(282 /* JSDocOptionalType */, result); + return createJSDocPostfixType(283 /* JSDocOptionalType */, result); } else { nextToken(); @@ -16762,7 +16823,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(281 /* JSDocNonNullableType */); + var result = createNode(282 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -16786,28 +16847,28 @@ var ts; token() === 29 /* GreaterThanToken */ || token() === 58 /* EqualsToken */ || token() === 49 /* BarToken */) { - var result = createNode(279 /* JSDocUnknownType */, pos); + var result = createNode(280 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(280 /* JSDocNullableType */, pos); + var result = createNode(281 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(283 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(284 /* JSDocFunctionType */); nextToken(); fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(161 /* TypeReference */); + var node = createNode(162 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(148 /* Parameter */); + var parameter = createNode(149 /* Parameter */); if (token() === 99 /* ThisKeyword */ || token() === 94 /* NewKeyword */) { parameter.name = parseIdentifierName(); parseExpected(56 /* ColonToken */); @@ -16819,23 +16880,23 @@ var ts; var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); var type = parseType(); if (dotdotdot) { - var variadic = createNode(284 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(285 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58 /* EqualsToken */) { - return createJSDocPostfixType(282 /* JSDocOptionalType */, type); + return createJSDocPostfixType(283 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(164 /* TypeQuery */); + var node = createNode(165 /* TypeQuery */); parseExpected(103 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(147 /* TypeParameter */); + var node = createNode(148 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(85 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -16880,7 +16941,7 @@ var ts; isStartOfType(/*inStartOfParameter*/ true); } function parseParameter() { - var node = createNodeWithJSDoc(148 /* Parameter */); + var node = createNodeWithJSDoc(149 /* Parameter */); if (token() === 99 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); @@ -16915,7 +16976,7 @@ var ts; if (!(flags & 32 /* JSDoc */)) { signature.typeParameters = parseTypeParameters(); } - signature.parameters = parseParameterList(flags); + signature.parameters = parseParameterList(flags); // TODO: GH#18217 if (shouldParseReturnType(returnToken, !!(flags & 4 /* Type */))) { signature.type = parseTypeOrTypePredicate(); return signature.type !== undefined; @@ -16983,7 +17044,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 158 /* ConstructSignature */) { + if (kind === 159 /* ConstructSignature */) { parseExpected(94 /* NewKeyword */); } fillSignature(56 /* ColonToken */, 4 /* Type */, node); @@ -17044,7 +17105,7 @@ var ts; return token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 22 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 159 /* IndexSignature */; + node.kind = 160 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -17054,13 +17115,13 @@ var ts; node.name = parsePropertyName(); node.questionToken = parseOptionalToken(55 /* QuestionToken */); if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - node.kind = 152 /* MethodSignature */; + node.kind = 153 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] fillSignature(56 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 150 /* PropertySignature */; + node.kind = 151 /* PropertySignature */; node.type = parseTypeAnnotation(); if (token() === 58 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt @@ -17077,7 +17138,7 @@ var ts; if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { return true; } - var idToken; + var idToken = false; // Eat up all modifiers, but hold on to the last one in case it is actually an identifier while (ts.isModifierKind(token())) { idToken = true; @@ -17106,10 +17167,10 @@ var ts; } function parseTypeMember() { if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - return parseSignatureMember(157 /* CallSignature */); + return parseSignatureMember(158 /* CallSignature */); } if (token() === 94 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(158 /* ConstructSignature */); + return parseSignatureMember(159 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -17135,7 +17196,7 @@ var ts; return false; } function parseTypeLiteral() { - var node = createNode(165 /* TypeLiteral */); + var node = createNode(166 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -17161,14 +17222,14 @@ var ts; return token() === 21 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 92 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(147 /* TypeParameter */); + var node = createNode(148 /* TypeParameter */); node.name = parseIdentifier(); parseExpected(92 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(176 /* MappedType */); + var node = createNode(177 /* MappedType */); parseExpected(17 /* OpenBraceToken */); if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -17191,23 +17252,23 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(167 /* TupleType */); + var node = createNode(168 /* TupleType */); node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(172 /* ParenthesizedType */); + var node = createNode(173 /* ParenthesizedType */); parseExpected(19 /* OpenParenToken */); node.type = parseType(); if (!node.type) { - return undefined; + return undefined; // TODO: GH#18217 } parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 163 /* ConstructorType */) { + if (kind === 164 /* ConstructorType */) { parseExpected(94 /* NewKeyword */); } if (!fillSignature(36 /* EqualsGreaterThanToken */, 4 /* Type */ | (sourceFile.languageVariant === 1 /* JSX */ ? 8 /* RequireCompleteParameterList */ : 0), node)) { @@ -17223,10 +17284,10 @@ var ts; return token() === 23 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(177 /* LiteralType */); + var node = createNode(178 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(197 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(198 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 38 /* MinusToken */; nextToken(); } @@ -17247,7 +17308,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(178 /* ImportType */); + var node = createNode(179 /* ImportType */); if (parseOptional(103 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -17267,6 +17328,7 @@ var ts; function parseNonArrayType() { switch (token()) { case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 137 /* StringKeyword */: case 134 /* NumberKeyword */: case 138 /* SymbolKeyword */: @@ -17323,6 +17385,7 @@ var ts; function isStartOfType(inStartOfParameter) { switch (token()) { case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 137 /* StringKeyword */: case 134 /* NumberKeyword */: case 122 /* BooleanKeyword */: @@ -17371,26 +17434,26 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51 /* ExclamationToken */: - type = createJSDocPostfixType(281 /* JSDocNonNullableType */, type); + type = createJSDocPostfixType(282 /* JSDocNonNullableType */, type); break; case 55 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createJSDocPostfixType(280 /* JSDocNullableType */, type); + type = createJSDocPostfixType(281 /* JSDocNullableType */, type); break; case 21 /* OpenBracketToken */: parseExpected(21 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(175 /* IndexedAccessType */, type.pos); + var node = createNode(176 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(166 /* ArrayType */, type.pos); + var node = createNode(167 /* ArrayType */, type.pos); node.elementType = type; parseExpected(22 /* CloseBracketToken */); type = finishNode(node); @@ -17409,16 +17472,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(174 /* TypeOperator */); + var node = createNode(175 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(171 /* InferType */); + var node = createNode(172 /* InferType */); parseExpected(126 /* InferKeyword */); - var typeParameter = createNode(147 /* TypeParameter */); + var typeParameter = createNode(148 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -17449,10 +17512,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(169 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(170 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(168 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(169 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); } function isStartOfFunctionType() { if (token() === 27 /* LessThanToken */) { @@ -17509,7 +17572,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(160 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(161 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -17532,14 +17595,14 @@ var ts; } function parseTypeWorker(noConditionalTypes) { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(162 /* FunctionType */); + return parseFunctionOrConstructorType(163 /* FunctionType */); // TODO: GH#18217 } if (token() === 94 /* NewKeyword */) { - return parseFunctionOrConstructorType(163 /* ConstructorType */); + return parseFunctionOrConstructorType(164 /* ConstructorType */); } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(170 /* ConditionalType */, type.pos); + var node = createNode(171 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -17732,7 +17795,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(202 /* YieldExpression */); + var node = createNode(203 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -17754,13 +17817,13 @@ var ts; ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(192 /* ArrowFunction */, asyncModifier.pos); + node = createNode(193 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(192 /* ArrowFunction */, identifier.pos); + node = createNode(193 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(148 /* Parameter */, identifier.pos); + var parameter = createNode(149 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); @@ -17956,7 +18019,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(192 /* ArrowFunction */); + var node = createNodeWithJSDoc(193 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -18024,7 +18087,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(200 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(201 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -18039,7 +18102,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 92 /* InKeyword */ || t === 144 /* OfKeyword */; + return t === 92 /* InKeyword */ || t === 145 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -18104,39 +18167,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(199 /* BinaryExpression */, left.pos); + var node = createNode(200 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(207 /* AsExpression */, left.pos); + var node = createNode(208 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(197 /* PrefixUnaryExpression */); + var node = createNode(198 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(193 /* DeleteExpression */); + var node = createNode(194 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(194 /* TypeOfExpression */); + var node = createNode(195 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(195 /* VoidExpression */); + var node = createNode(196 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18152,7 +18215,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(196 /* AwaitExpression */); + var node = createNode(197 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18196,7 +18259,7 @@ var ts; if (token() === 40 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 189 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 190 /* 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 { @@ -18293,7 +18356,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(197 /* PrefixUnaryExpression */); + var node = createNode(198 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -18306,7 +18369,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(198 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(199 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -18362,7 +18425,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(209 /* MetaProperty */, fullStart); + var node = createNode(210 /* MetaProperty */, fullStart); node.keywordToken = 91 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -18437,33 +18500,17 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(184 /* PropertyAccessExpression */, expression.pos); + var node = createNode(185 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(23 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } - function tagNamesAreEquivalent(lhs, rhs) { - if (lhs.kind !== rhs.kind) { - return false; - } - if (lhs.kind === 71 /* Identifier */) { - return lhs.escapedText === rhs.escapedText; - } - if (lhs.kind === 99 /* ThisKeyword */) { - return true; - } - // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only - // take forms of JsxTagNameExpression which includes an identifier, "this" expression, or another propertyAccessExpression - // it is safe to case the expression property as such. See parseJsxElementName for how we parse tag name in Jsx element - return lhs.name.escapedText === rhs.name.escapedText && - tagNamesAreEquivalent(lhs.expression, rhs.expression); - } function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 256 /* JsxOpeningElement */) { - var node = createNode(254 /* JsxElement */, opening.pos); + if (opening.kind === 257 /* JsxOpeningElement */) { + var node = createNode(255 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -18472,15 +18519,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 259 /* JsxOpeningFragment */) { - var node = createNode(258 /* JsxFragment */, opening.pos); + else if (opening.kind === 260 /* JsxOpeningFragment */) { + var node = createNode(259 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 255 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 256 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -18495,11 +18542,11 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(199 /* BinaryExpression */, result.pos); + var badNode = createNode(200 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(26 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); + badNode.operatorToken = createMissingNode(26 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); // TODO: GH#18217 badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -18553,7 +18600,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(262 /* JsxAttributes */); + var jsxAttributes = createNode(263 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -18562,7 +18609,7 @@ var ts; parseExpected(27 /* LessThanToken */); if (token() === 29 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(259 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(260 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -18574,7 +18621,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(256 /* JsxOpeningElement */, fullStart); + node = createNode(257 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -18586,7 +18633,7 @@ var ts; parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(255 /* JsxSelfClosingElement */, fullStart); + node = createNode(256 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -18603,7 +18650,7 @@ var ts; var expression = token() === 99 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(184 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18611,7 +18658,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(264 /* JsxExpression */); + var node = createNode(265 /* JsxExpression */); if (!parseExpected(17 /* OpenBraceToken */)) { return undefined; } @@ -18633,7 +18680,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(261 /* JsxAttribute */); + var node = createNode(262 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 58 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -18648,7 +18695,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(263 /* JsxSpreadAttribute */); + var node = createNode(264 /* JsxSpreadAttribute */); parseExpected(17 /* OpenBraceToken */); parseExpected(24 /* DotDotDotToken */); node.expression = parseExpression(); @@ -18656,7 +18703,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(257 /* JsxClosingElement */); + var node = createNode(258 /* JsxClosingElement */); parseExpected(28 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -18669,7 +18716,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(260 /* JsxClosingFragment */); + var node = createNode(261 /* JsxClosingFragment */); parseExpected(28 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -18684,7 +18731,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(189 /* TypeAssertionExpression */); + var node = createNode(190 /* TypeAssertionExpression */); parseExpected(27 /* LessThanToken */); node.type = parseType(); parseExpected(29 /* GreaterThanToken */); @@ -18695,7 +18742,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(184 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18703,14 +18750,14 @@ var ts; } if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(208 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(209 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(21 /* OpenBracketToken */)) { - var indexedAccess = createNode(185 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(186 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; if (token() === 22 /* CloseBracketToken */) { indexedAccess.argumentExpression = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -18737,7 +18784,7 @@ var ts; return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(188 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(189 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ @@ -18761,7 +18808,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(186 /* CallExpression */, expression.pos); + var callExpr = createNode(187 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -18769,7 +18816,7 @@ var ts; continue; } else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(186 /* CallExpression */, expression.pos); + var callExpr = createNode(187 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -18881,28 +18928,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(190 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(191 /* ParenthesizedExpression */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(203 /* SpreadElement */); + var node = createNode(204 /* SpreadElement */); parseExpected(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(205 /* OmittedExpression */) : + token() === 26 /* CommaToken */ ? createNode(206 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(182 /* ArrayLiteralExpression */); + var node = createNode(183 /* ArrayLiteralExpression */); parseExpected(21 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -18914,17 +18961,17 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 271 /* SpreadAssignment */; + node.kind = 272 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 155 /* GetAccessor */); + return parseAccessorDeclaration(node, 156 /* GetAccessor */); } if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* SetAccessor */); + return parseAccessorDeclaration(node, 157 /* SetAccessor */); } var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -18941,7 +18988,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */); if (isShorthandPropertyAssignment) { - node.kind = 270 /* ShorthandPropertyAssignment */; + node.kind = 271 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(58 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -18949,14 +18996,14 @@ var ts; } } else { - node.kind = 269 /* PropertyAssignment */; + node.kind = 270 /* PropertyAssignment */; parseExpected(56 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(183 /* ObjectLiteralExpression */); + var node = createNode(184 /* ObjectLiteralExpression */); parseExpected(17 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -18975,7 +19022,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(191 /* FunctionExpression */); + var node = createNodeWithJSDoc(192 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); @@ -19000,7 +19047,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94 /* NewKeyword */); if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(209 /* MetaProperty */, fullStart); + var node_2 = createNode(210 /* MetaProperty */, fullStart); node_2.keywordToken = 94 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -19017,7 +19064,7 @@ var ts; } break; } - var node = createNode(187 /* NewExpression */, fullStart); + var node = createNode(188 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19 /* OpenParenToken */) { @@ -19027,7 +19074,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(212 /* Block */); + var node = createNode(213 /* Block */); if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19060,12 +19107,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(214 /* EmptyStatement */); + var node = createNode(215 /* EmptyStatement */); parseExpected(25 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(216 /* IfStatement */); + var node = createNode(217 /* IfStatement */); parseExpected(90 /* IfKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19075,7 +19122,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(217 /* DoStatement */); + var node = createNode(218 /* DoStatement */); parseExpected(81 /* DoKeyword */); node.statement = parseStatement(); parseExpected(106 /* WhileKeyword */); @@ -19090,7 +19137,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(218 /* WhileStatement */); + var node = createNode(219 /* WhileStatement */); parseExpected(106 /* WhileKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19113,8 +19160,8 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(144 /* OfKeyword */) : parseOptional(144 /* OfKeyword */)) { - var forOfStatement = createNode(221 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { + var forOfStatement = createNode(222 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -19122,14 +19169,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(220 /* ForInStatement */, pos); + var forInStatement = createNode(221 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(219 /* ForStatement */, pos); + var forStatement = createNode(220 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(25 /* SemicolonToken */); if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { @@ -19147,7 +19194,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 223 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 224 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -19155,7 +19202,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(224 /* ReturnStatement */); + var node = createNode(225 /* ReturnStatement */); parseExpected(96 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -19164,7 +19211,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(225 /* WithStatement */); + var node = createNode(226 /* WithStatement */); parseExpected(107 /* WithKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19173,7 +19220,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(265 /* CaseClause */); + var node = createNode(266 /* CaseClause */); parseExpected(73 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(56 /* ColonToken */); @@ -19181,7 +19228,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(266 /* DefaultClause */); + var node = createNode(267 /* DefaultClause */); parseExpected(79 /* DefaultKeyword */); parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -19191,12 +19238,12 @@ var ts; return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(226 /* SwitchStatement */); + var node = createNode(227 /* SwitchStatement */); parseExpected(98 /* SwitchKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(240 /* CaseBlock */); + var caseBlock = createNode(241 /* CaseBlock */); parseExpected(17 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(18 /* CloseBraceToken */); @@ -19211,7 +19258,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(228 /* ThrowStatement */); + var node = createNode(229 /* ThrowStatement */); parseExpected(100 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -19219,7 +19266,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(229 /* TryStatement */); + var node = createNode(230 /* TryStatement */); parseExpected(102 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -19232,7 +19279,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(268 /* CatchClause */); + var result = createNode(269 /* CatchClause */); parseExpected(74 /* CatchKeyword */); if (parseOptional(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -19246,7 +19293,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(230 /* DebuggerStatement */); + var node = createNode(231 /* DebuggerStatement */); parseExpected(78 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -19258,12 +19305,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 227 /* LabeledStatement */; + node.kind = 228 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 215 /* ExpressionStatement */; + node.kind = 216 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -19335,7 +19382,7 @@ var ts; return false; } continue; - case 143 /* GlobalKeyword */: + case 144 /* GlobalKeyword */: nextToken(); return token() === 17 /* OpenBraceToken */ || token() === 71 /* Identifier */ || token() === 84 /* ExportKeyword */; case 91 /* ImportKeyword */: @@ -19399,7 +19446,7 @@ var ts; case 129 /* ModuleKeyword */: case 130 /* NamespaceKeyword */: case 139 /* TypeKeyword */: - case 143 /* GlobalKeyword */: + case 144 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 114 /* PublicKeyword */: @@ -19430,16 +19477,16 @@ var ts; case 17 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(231 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); case 110 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(231 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); } break; case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(233 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(234 /* FunctionDeclaration */)); case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(234 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(235 /* ClassDeclaration */)); case 90 /* IfKeyword */: return parseIfStatement(); case 81 /* DoKeyword */: @@ -19449,9 +19496,9 @@ var ts; case 88 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(222 /* ContinueStatement */); + return parseBreakOrContinueStatement(223 /* ContinueStatement */); case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(223 /* BreakStatement */); + return parseBreakOrContinueStatement(224 /* BreakStatement */); case 96 /* ReturnKeyword */: return parseReturnStatement(); case 107 /* WithKeyword */: @@ -19485,7 +19532,7 @@ var ts; case 117 /* AbstractKeyword */: case 115 /* StaticKeyword */: case 132 /* ReadonlyKeyword */: - case 143 /* GlobalKeyword */: + case 144 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -19527,7 +19574,7 @@ var ts; return parseTypeAliasDeclaration(node); case 83 /* EnumKeyword */: return parseEnumDeclaration(node); - case 143 /* GlobalKeyword */: + case 144 /* GlobalKeyword */: case 129 /* ModuleKeyword */: case 130 /* NamespaceKeyword */: return parseModuleDeclaration(node); @@ -19548,12 +19595,13 @@ var ts; if (node.decorators || node.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(252 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(253 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; return finishNode(missing); } + return undefined; // TODO: GH#18217 } } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { @@ -19570,16 +19618,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 26 /* CommaToken */) { - return createNode(205 /* OmittedExpression */); + return createNode(206 /* OmittedExpression */); } - var node = createNode(181 /* BindingElement */); + var node = createNode(182 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(181 /* BindingElement */); + var node = createNode(182 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -19595,14 +19643,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(179 /* ObjectBindingPattern */); + var node = createNode(180 /* ObjectBindingPattern */); parseExpected(17 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(180 /* ArrayBindingPattern */); + var node = createNode(181 /* ArrayBindingPattern */); parseExpected(21 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(22 /* CloseBracketToken */); @@ -19624,7 +19672,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(231 /* VariableDeclaration */); + var node = createNode(232 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 /* Identifier */ && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -19637,7 +19685,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(232 /* VariableDeclarationList */); + var node = createNode(233 /* VariableDeclarationList */); switch (token()) { case 104 /* VarKeyword */: break; @@ -19660,7 +19708,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 144 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 145 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -19675,13 +19723,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 213 /* VariableStatement */; + node.kind = 214 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 233 /* FunctionDeclaration */; + node.kind = 234 /* FunctionDeclaration */; parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -19692,14 +19740,14 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(node) { - node.kind = 154 /* Constructor */; + node.kind = 155 /* Constructor */; parseExpected(123 /* ConstructorKeyword */); fillSignature(56 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 153 /* MethodDeclaration */; + node.kind = 154 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; @@ -19708,7 +19756,7 @@ var ts; return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 151 /* PropertyDeclaration */; + node.kind = 152 /* PropertyDeclaration */; if (!node.questionToken && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } @@ -19813,7 +19861,7 @@ var ts; if (!parseOptional(57 /* AtToken */)) { break; } - var decorator = createNode(149 /* Decorator */, decoratorStart); + var decorator = createNode(150 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -19863,7 +19911,7 @@ var ts; } function parseClassElement() { if (token() === 25 /* SemicolonToken */) { - var result = createNode(211 /* SemicolonClassElement */); + var result = createNode(212 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -19871,10 +19919,10 @@ var ts; node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 155 /* GetAccessor */); + return parseAccessorDeclaration(node, 156 /* GetAccessor */); } if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* SetAccessor */); + return parseAccessorDeclaration(node, 157 /* SetAccessor */); } if (token() === 123 /* ConstructorKeyword */) { return parseConstructorDeclaration(node); @@ -19897,13 +19945,13 @@ var ts; return parsePropertyDeclaration(node); } // 'isClassMemberStart' should have hinted not to attempt parsing. - ts.Debug.fail("Should not have attempted to parse class member declaration."); + return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 204 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 205 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 234 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 235 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -19945,17 +19993,15 @@ var ts; } function parseHeritageClause() { var tok = token(); - if (tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */) { - var node = createNode(267 /* HeritageClause */); - node.token = tok; - nextToken(); - node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); - return finishNode(node); - } - return undefined; + ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(268 /* HeritageClause */); + node.token = tok; + nextToken(); + node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(206 /* ExpressionWithTypeArguments */); + var node = createNode(207 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -19972,7 +20018,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 235 /* InterfaceDeclaration */; + node.kind = 236 /* InterfaceDeclaration */; parseExpected(109 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -19981,7 +20027,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 236 /* TypeAliasDeclaration */; + node.kind = 237 /* TypeAliasDeclaration */; parseExpected(139 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -19995,13 +20041,13 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(272 /* EnumMember */); + var node = createNodeWithJSDoc(273 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 237 /* EnumDeclaration */; + node.kind = 238 /* EnumDeclaration */; parseExpected(83 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(17 /* OpenBraceToken */)) { @@ -20014,7 +20060,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(239 /* ModuleBlock */); + var node = createNode(240 /* ModuleBlock */); if (parseExpected(17 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(18 /* CloseBraceToken */); @@ -20025,7 +20071,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 238 /* ModuleDeclaration */; + node.kind = 239 /* ModuleDeclaration */; // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -20037,8 +20083,8 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 238 /* ModuleDeclaration */; - if (token() === 143 /* GlobalKeyword */) { + node.kind = 239 /* ModuleDeclaration */; + if (token() === 144 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -20057,7 +20103,7 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 143 /* GlobalKeyword */) { + if (token() === 144 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } @@ -20083,7 +20129,7 @@ var ts; return nextToken() === 41 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 241 /* NamespaceExportDeclaration */; + node.kind = 242 /* NamespaceExportDeclaration */; parseExpected(118 /* AsKeyword */); parseExpected(130 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -20096,12 +20142,12 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 26 /* CommaToken */ && token() !== 142 /* FromKeyword */) { + if (token() !== 26 /* CommaToken */ && token() !== 143 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 243 /* ImportDeclaration */; + node.kind = 244 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -20109,14 +20155,14 @@ var ts; token() === 39 /* AsteriskToken */ || // import * token() === 17 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(142 /* FromKeyword */); + parseExpected(143 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 242 /* ImportEqualsDeclaration */; + node.kind = 243 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(58 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -20130,7 +20176,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(244 /* ImportClause */, fullStart); + var importClause = createNode(245 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -20140,7 +20186,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(246 /* NamedImports */); + importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(247 /* NamedImports */); } return finishNode(importClause); } @@ -20150,7 +20196,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(253 /* ExternalModuleReference */); + var node = createNode(254 /* ExternalModuleReference */); parseExpected(133 /* RequireKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -20173,7 +20219,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(245 /* NamespaceImport */); + var namespaceImport = createNode(246 /* NamespaceImport */); parseExpected(39 /* AsteriskToken */); parseExpected(118 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -20188,14 +20234,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 246 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 247 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(251 /* ExportSpecifier */); + return parseImportOrExportSpecifier(252 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(247 /* ImportSpecifier */); + return parseImportOrExportSpecifier(248 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -20220,24 +20266,24 @@ var ts; else { node.name = identifierName; } - if (kind === 247 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 248 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 249 /* ExportDeclaration */; + node.kind = 250 /* ExportDeclaration */; if (parseOptional(39 /* AsteriskToken */)) { - parseExpected(142 /* FromKeyword */); + parseExpected(143 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(250 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(251 /* 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() === 142 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(142 /* FromKeyword */); + if (token() === 143 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(143 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -20245,7 +20291,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 248 /* ExportAssignment */; + node.kind = 249 /* ExportAssignment */; if (parseOptional(58 /* EqualsToken */)) { node.isExportEquals = true; } @@ -20265,10 +20311,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 242 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 253 /* ExternalModuleReference */ - || node.kind === 243 /* ImportDeclaration */ - || node.kind === 248 /* ExportAssignment */ - || node.kind === 249 /* ExportDeclaration */ + || node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */ + || node.kind === 244 /* ImportDeclaration */ + || node.kind === 249 /* ExportAssignment */ + || node.kind === 250 /* ExportDeclaration */ ? node : undefined; } @@ -20331,7 +20377,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(277 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -20384,8 +20430,8 @@ var ts; PropertyLikeParse[PropertyLikeParse["CallbackParameter"] = 4] = "CallbackParameter"; })(PropertyLikeParse || (PropertyLikeParse = {})); function parseJSDocCommentWorker(start, length) { + if (start === void 0) { start = 0; } var content = sourceText; - start = start || 0; var end = length === undefined ? content.length : start + length; length = end - start; ts.Debug.assert(start >= 0); @@ -20415,17 +20461,15 @@ var ts; comments.push(text); indent += text.length; } - var t = nextJSDocToken(); - while (t === 5 /* WhitespaceTrivia */) { - t = nextJSDocToken(); - } - if (t === 4 /* NewLineTrivia */) { + nextJSDocToken(); + while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) + ; + if (parseOptionalJsdoc(4 /* NewLineTrivia */)) { state = 0 /* BeginningOfLine */; indent = 0; - t = nextJSDocToken(); } loop: while (true) { - switch (t) { + switch (token()) { case 57 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingNewlines(comments); @@ -20485,7 +20529,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - t = nextJSDocToken(); + nextJSDocToken(); } removeLeadingNewlines(comments); removeTrailingNewlines(comments); @@ -20503,7 +20547,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(285 /* JSDocComment */, start); + var result = createNode(286 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -20650,7 +20694,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(288 /* JSDocTag */, atToken.pos); + var result = createNode(289 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -20694,7 +20738,7 @@ var ts; switch (node.kind) { case 135 /* ObjectKeyword */: return true; - case 166 /* ArrayType */: + case 167 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -20710,12 +20754,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(297 /* JSDocPropertyTag */, atToken.pos) : - createNode(292 /* JSDocParameterTag */, atToken.pos); + createNode(298 /* JSDocPropertyTag */, atToken.pos) : + createNode(293 /* JSDocParameterTag */, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); - var nestedTypeLiteral = parseNestedTypeLiteral(typeExpression, name, target); + var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; @@ -20731,20 +20775,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(277 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) { - if (child.kind === 292 /* JSDocParameterTag */ || child.kind === 297 /* JSDocPropertyTag */) { + if (child.kind === 293 /* JSDocParameterTag */ || child.kind === 298 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(286 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 166 /* ArrayType */) { + if (typeExpression.type.kind === 167 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -20753,27 +20797,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 293 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(293 /* JSDocReturnTag */, atToken.pos); + var result = createNode(294 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 295 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(294 /* JSDocTypeTag */, atToken.pos); + var result = createNode(295 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(289 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(290 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -20781,7 +20825,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(206 /* ExpressionWithTypeArguments */); + var node = createNode(207 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -20793,15 +20837,15 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(/*createIfMissing*/ true); while (parseOptional(23 /* DotToken */)) { - var prop = createNode(184 /* PropertyAccessExpression */, node.pos); + var prop = createNode(185 /* PropertyAccessExpression */, node.pos); prop.expression = node; - prop.name = parseJSDocIdentifierName(); + prop.name = parseJSDocIdentifierName(); // TODO: GH#18217 node = finishNode(prop); } return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(290 /* JSDocClassTag */, atToken.pos); + var tag = createNode(291 /* JSDocClassTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); @@ -20809,7 +20853,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(296 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(297 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -20825,9 +20869,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(286 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_3); } - if (child.kind === 294 /* JSDocTypeTag */) { + if (child.kind === 295 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -20840,7 +20884,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 166 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 167 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -20856,7 +20900,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(238 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(239 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -20870,7 +20914,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(291 /* JSDocCallbackTag */, atToken.pos); + var callbackTag = createNode(292 /* JSDocCallbackTag */, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -20879,16 +20923,15 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(287 /* JSDocSignature */, start); + var jsdocSignature = createNode(288 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (token() === 57 /* AtToken */) { - nextJSDocToken(); + if (parseOptionalJsdoc(57 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 293 /* JSDocReturnTag */) { + if (tag && tag.kind === 294 /* JSDocReturnTag */) { return tag; } } @@ -20933,9 +20976,9 @@ var ts; case 57 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 292 /* JSDocParameterTag */ && + if (child && child.kind === 293 /* JSDocParameterTag */ && target !== 4 /* CallbackParameter */ && - (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { + (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { // TODO: GH#18217 return false; } return child; @@ -20994,49 +21037,45 @@ var ts; return tag; } function parseTemplateTag(atToken, tagName) { - if (ts.some(tags, ts.isJSDocTemplateTag)) { - parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); + // the template tag looks like '@template {Constraint} T,U,V' + var constraint; + if (token() === 17 /* OpenBraceToken */) { + constraint = parseJSDocTypeExpression(); } - // Type parameter list looks like '@template T,U,V' var typeParameters = []; var typeParametersPos = getNodePos(); - while (true) { - var typeParameter = createNode(147 /* TypeParameter */); - var name = parseJSDocIdentifierNameWithOptionalBraces(); + do { skipWhitespace(); - if (!name) { - parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); + var typeParameter = createNode(148 /* TypeParameter */); + if (!ts.tokenIsIdentifierOrKeyword(token())) { + parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); return undefined; } - typeParameter.name = name; + typeParameter.name = parseJSDocIdentifierName(); + skipWhitespace(); finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 26 /* CommaToken */) { - nextJSDocToken(); - skipWhitespace(); - } - else { - break; - } + } while (parseOptionalJsdoc(26 /* CommaToken */)); + if (constraint) { + ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(295 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(296 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); finishNode(result); return result; } - function parseJSDocIdentifierNameWithOptionalBraces() { - var parsedBrace = parseOptional(17 /* OpenBraceToken */); - var res = parseJSDocIdentifierName(); - if (parsedBrace) { - parseExpected(18 /* CloseBraceToken */); - } - return res; - } function nextJSDocToken() { return currentToken = scanner.scanJSDocToken(); } + function parseOptionalJsdoc(t) { + if (token() === t) { + nextJSDocToken(); + return true; + } + return false; + } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(/*createIfMissing*/ true); if (parseOptional(21 /* OpenBracketToken */)) { @@ -21581,7 +21620,7 @@ var ts; context.pragmas = ts.createMap(); for (var _i = 0, pragmas_1 = pragmas; _i < pragmas_1.length; _i++) { var pragma = pragmas_1[_i]; - if (context.pragmas.has(pragma.name)) { + if (context.pragmas.has(pragma.name)) { // TODO: GH#18217 var currentValue = context.pragmas.get(pragma.name); if (currentValue instanceof Array) { currentValue.push(pragma.args); @@ -21610,6 +21649,7 @@ var ts; var referencedFiles_1 = context.referencedFiles; var typeReferenceDirectives_1 = context.typeReferenceDirectives; ts.forEach(ts.toArray(entryOrList), function (arg) { + // TODO: GH#18217 if (arg.arguments["no-default-lib"]) { context.hasNoDefaultLib = true; } @@ -21626,10 +21666,7 @@ var ts; break; } case "amd-dependency": { - context.amdDependencies = ts.map(ts.toArray(entryOrList), function (_a) { - var _b = _a.arguments, name = _b.name, path = _b.path; - return ({ name: name, path: path }); - }); + context.amdDependencies = ts.map(ts.toArray(entryOrList), function (x) { return ({ name: x.arguments.name, path: x.arguments.path }); }); // TODO: GH#18217 break; } case "amd-module": { @@ -21652,7 +21689,7 @@ var ts; case "ts-check": { // _last_ of either nocheck or check in a file is the "winner" ts.forEach(ts.toArray(entryOrList), function (entry) { - if (!context.checkJsDirective || entry.range.pos > context.checkJsDirective.pos) { + if (!context.checkJsDirective || entry.range.pos > context.checkJsDirective.pos) { // TODO: GH#18217 context.checkJsDirective = { enabled: key === "ts-check", end: entry.range.end, @@ -21763,6 +21800,24 @@ var ts; } return argMap; } + /** @internal */ + function tagNamesAreEquivalent(lhs, rhs) { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === 71 /* Identifier */) { + return lhs.escapedText === rhs.escapedText; + } + if (lhs.kind === 99 /* ThisKeyword */) { + return true; + } + // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only + // take forms of JsxTagNameExpression which includes an identifier, "this" expression, or another propertyAccessExpression + // it is safe to case the expression property as such. See parseJsxElementName for how we parse tag name in Jsx element + return lhs.name.escapedText === rhs.name.escapedText && + tagNamesAreEquivalent(lhs.expression, rhs.expression); + } + ts.tagNamesAreEquivalent = tagNamesAreEquivalent; })(ts || (ts = {})); /* @internal */ var ts; @@ -21781,24 +21836,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: if (ts.isConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 239 /* ModuleBlock */: { + case 240 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -21820,7 +21875,7 @@ var ts; }); return state_1; } - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return getModuleInstanceState(node); case 71 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -21970,7 +22025,7 @@ var ts; if (symbolFlags & 67216319 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 238 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 239 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -21979,7 +22034,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 === 248 /* ExportAssignment */) { + if (node.kind === 249 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -21988,7 +22043,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 146 /* ComputedPropertyName */) { + if (name.kind === 147 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression)) { @@ -22000,43 +22055,43 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 154 /* Constructor */: + case 155 /* Constructor */: return "__constructor" /* Constructor */; - case 162 /* FunctionType */: - case 157 /* CallSignature */: - case 287 /* JSDocSignature */: + case 163 /* FunctionType */: + case 158 /* CallSignature */: + case 288 /* JSDocSignature */: return "__call" /* Call */; - case 163 /* ConstructorType */: - case 158 /* ConstructSignature */: + case 164 /* ConstructorType */: + case 159 /* ConstructSignature */: return "__new" /* New */; - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: return "__index" /* Index */; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 273 /* SourceFile */: + case 274 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 148 /* Parameter */: + case 149 /* 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 === 283 /* 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 === 284 /* 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; } } function getDisplayName(node) { - return ts.isNamedDeclaration(node) ? ts.declarationNameToString(node.name) : ts.unescapeLeadingUnderscores(getDeclarationName(node)); + return ts.isNamedDeclaration(node) ? ts.declarationNameToString(node.name) : ts.unescapeLeadingUnderscores(getDeclarationName(node)); // TODO: GH#18217 } /** * Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names. @@ -22123,7 +22178,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 === 248 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 249 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -22148,7 +22203,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 251 /* ExportSpecifier */ || (node.kind === 242 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 252 /* ExportSpecifier */ || (node.kind === 243 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -22215,7 +22270,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 !== 192 /* ArrowFunction */) { + if (node.kind !== 193 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -22247,7 +22302,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 intialization checks. - currentReturnTarget = isIIFE || node.kind === 154 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 155 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -22260,13 +22315,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 154 /* Constructor */) { + if (node.kind === 155 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -22309,8 +22364,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 233 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 233 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -22342,77 +22397,77 @@ var ts; return; } switch (node.kind) { - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: bindWhileStatement(node); break; - case 217 /* DoStatement */: + case 218 /* DoStatement */: bindDoStatement(node); break; - case 219 /* ForStatement */: + case 220 /* ForStatement */: bindForStatement(node); break; - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 216 /* IfStatement */: + case 217 /* IfStatement */: bindIfStatement(node); break; - case 224 /* ReturnStatement */: - case 228 /* ThrowStatement */: + case 225 /* ReturnStatement */: + case 229 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 229 /* TryStatement */: + case 230 /* TryStatement */: bindTryStatement(node); break; - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: bindSwitchStatement(node); break; - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: bindCaseBlock(node); break; - case 265 /* CaseClause */: + case 266 /* CaseClause */: bindCaseClause(node); break; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: bindLabeledStatement(node); break; - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 186 /* CallExpression */: + case 187 /* CallExpression */: bindCallExpressionFlow(node); break; - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 273 /* SourceFile */: + case 274 /* SourceFile */: bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 212 /* Block */: - case 239 /* ModuleBlock */: + case 213 /* Block */: + case 240 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -22425,15 +22480,15 @@ var ts; switch (expr.kind) { case 71 /* Identifier */: case 99 /* ThisKeyword */: - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return hasNarrowableArgument(expr); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -22442,7 +22497,7 @@ var ts; return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || - expr.kind === 184 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 185 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -22453,7 +22508,7 @@ var ts; } } } - if (expr.expression.kind === 184 /* PropertyAccessExpression */ && + if (expr.expression.kind === 185 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -22486,9 +22541,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 58 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -22566,33 +22621,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 216 /* IfStatement */: - case 218 /* WhileStatement */: - case 217 /* DoStatement */: + case 217 /* IfStatement */: + case 219 /* WhileStatement */: + case 218 /* DoStatement */: return parent.expression === node; - case 219 /* ForStatement */: - case 200 /* ConditionalExpression */: + case 220 /* ForStatement */: + case 201 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 190 /* ParenthesizedExpression */) { + if (node.kind === 191 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 197 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 198 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 199 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || + return node.kind === 200 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 54 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 190 /* ParenthesizedExpression */ || - node.parent.kind === 197 /* PrefixUnaryExpression */ && + while (node.parent.kind === 191 /* ParenthesizedExpression */ || + node.parent.kind === 198 /* PrefixUnaryExpression */ && node.parent.operator === 51 /* ExclamationToken */) { node = node.parent; } @@ -22634,7 +22689,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 227 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 228 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -22668,13 +22723,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 221 /* ForOfStatement */) { + if (node.kind === 222 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 232 /* VariableDeclarationList */) { + if (node.initializer.kind !== 233 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -22696,7 +22751,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 224 /* ReturnStatement */) { + if (node.kind === 225 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -22716,7 +22771,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 223 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 224 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -22812,7 +22867,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 266 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267 /* 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). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -22836,6 +22891,7 @@ var ts; } var preCaseLabel = createBranchLabel(); addAntecedent(preCaseLabel, createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1)); + addAntecedent(preCaseLabel, createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1)); addAntecedent(preCaseLabel, fallthroughFlow); currentFlow = finishFlowLabel(preCaseLabel); var clause = clauses[i]; @@ -22877,16 +22933,16 @@ var ts; bind(node.statement); popActiveLabel(); if (!activeLabel.referenced && !options.allowUnusedLabels) { - file.bindDiagnostics.push(createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); + errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 217 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 218 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 199 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -22897,10 +22953,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 182 /* ArrayLiteralExpression */) { + else if (node.kind === 183 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 203 /* SpreadElement */) { + if (e.kind === 204 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -22908,16 +22964,16 @@ var ts; } } } - else if (node.kind === 183 /* ObjectLiteralExpression */) { + else if (node.kind === 184 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 269 /* PropertyAssignment */) { + if (p.kind === 270 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 270 /* ShorthandPropertyAssignment */) { + else if (p.kind === 271 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 271 /* SpreadAssignment */) { + else if (p.kind === 272 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -22973,7 +23029,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 185 /* ElementAccessExpression */) { + if (operator === 58 /* EqualsToken */ && node.left.kind === 186 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -22984,7 +23040,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 184 /* PropertyAccessExpression */) { + if (node.expression.kind === 185 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -23031,10 +23087,10 @@ 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 = node.expression; - while (expr.kind === 190 /* ParenthesizedExpression */) { + while (expr.kind === 191 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 191 /* FunctionExpression */ || expr.kind === 192 /* ArrowFunction */) { + if (expr.kind === 192 /* FunctionExpression */ || expr.kind === 193 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -23042,7 +23098,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 184 /* PropertyAccessExpression */) { + if (node.expression.kind === 185 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -23051,54 +23107,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 204 /* ClassExpression */: - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: - case 183 /* ObjectLiteralExpression */: - case 165 /* TypeLiteral */: - case 286 /* JSDocTypeLiteral */: - case 262 /* JsxAttributes */: + case 205 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 184 /* ObjectLiteralExpression */: + case 166 /* TypeLiteral */: + case 287 /* JSDocTypeLiteral */: + case 263 /* JsxAttributes */: return 1 /* IsContainer */; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 238 /* ModuleDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 176 /* MappedType */: + case 239 /* ModuleDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 177 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 273 /* SourceFile */: + case 274 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 154 /* Constructor */: - case 233 /* FunctionDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 157 /* CallSignature */: - case 287 /* JSDocSignature */: - case 283 /* JSDocFunctionType */: - case 162 /* FunctionType */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 163 /* ConstructorType */: + case 155 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 158 /* CallSignature */: + case 288 /* JSDocSignature */: + case 284 /* JSDocFunctionType */: + case 163 /* FunctionType */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 164 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 268 /* CatchClause */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 240 /* CaseBlock */: + case 269 /* CatchClause */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 241 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 212 /* Block */: + case 213 /* 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 @@ -23131,45 +23187,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 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 273 /* SourceFile */: + case 274 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 204 /* ClassExpression */: - case 234 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 235 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 165 /* TypeLiteral */: - case 286 /* JSDocTypeLiteral */: - case 183 /* ObjectLiteralExpression */: - case 235 /* InterfaceDeclaration */: - case 262 /* JsxAttributes */: + case 166 /* TypeLiteral */: + case 287 /* JSDocTypeLiteral */: + case 184 /* ObjectLiteralExpression */: + case 236 /* InterfaceDeclaration */: + case 263 /* 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 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 287 /* JSDocSignature */: - case 159 /* IndexSignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 283 /* JSDocFunctionType */: - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: - case 236 /* TypeAliasDeclaration */: - case 176 /* MappedType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 288 /* JSDocSignature */: + case 160 /* IndexSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 284 /* JSDocFunctionType */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 237 /* TypeAliasDeclaration */: + case 177 /* 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 @@ -23190,11 +23246,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 273 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 273 /* SourceFile */ || body.kind === 239 /* ModuleBlock */)) { + var body = node.kind === 274 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 274 /* SourceFile */ || body.kind === 240 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 249 /* ExportDeclaration */ || stat.kind === 248 /* ExportAssignment */) { + if (stat.kind === 250 /* ExportDeclaration */ || stat.kind === 249 /* ExportAssignment */) { return true; } } @@ -23261,7 +23317,7 @@ var ts; // We do that by making an anonymous type literal symbol, and then setting the function // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); + var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); // TODO: GH#18217 addDeclarationToSymbol(symbol, node, 131072 /* Signature */); var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); @@ -23278,7 +23334,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 271 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 272 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { continue; } var identifier = prop.name; @@ -23290,7 +23346,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 === 269 /* PropertyAssignment */ || prop.kind === 270 /* ShorthandPropertyAssignment */ || prop.kind === 153 /* MethodDeclaration */ + var currentKind = prop.kind === 270 /* PropertyAssignment */ || prop.kind === 271 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -23318,13 +23374,14 @@ var ts; symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); + return symbol; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -23465,8 +23522,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 273 /* SourceFile */ && - blockScopeContainer.kind !== 238 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 274 /* SourceFile */ && + blockScopeContainer.kind !== 239 /* 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. @@ -23507,6 +23564,16 @@ var ts; var span = ts.getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } + function errorOrSuggestionOnFirstToken(isError, node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + var diag = ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2); + if (isError) { + file.bindDiagnostics.push(diag); + } + else { + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + } + } function bind(node) { if (!node) { return; @@ -23538,7 +23605,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 > 144 /* LastToken */) { + if (node.kind > 145 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -23610,11 +23677,11 @@ var ts; } // falls through case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 270 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 271 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -23622,7 +23689,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -23650,137 +23717,137 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return checkStrictModeCatchClause(node); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return checkStrictModeWithStatement(node); - case 173 /* ThisType */: + case 174 /* ThisType */: seenThisKeyword = true; return; - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: break; // Binding the children will handle everything - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return bindTypeParameter(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return bindParameter(node); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 181 /* BindingElement */: + case 182 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return bindPropertyWorker(node); - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 272 /* EnumMember */: + case 273 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* 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 */ : 67208127 /* MethodExcludes */); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67150783 /* GetAccessorExcludes */); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67183551 /* SetAccessorExcludes */); - case 162 /* FunctionType */: - case 283 /* JSDocFunctionType */: - case 287 /* JSDocSignature */: - case 163 /* ConstructorType */: + case 163 /* FunctionType */: + case 284 /* JSDocFunctionType */: + case 288 /* JSDocSignature */: + case 164 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 165 /* TypeLiteral */: - case 286 /* JSDocTypeLiteral */: - case 176 /* MappedType */: + case 166 /* TypeLiteral */: + case 287 /* JSDocTypeLiteral */: + case 177 /* MappedType */: return bindAnonymousTypeWorker(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return bindFunctionExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 204 /* ClassExpression */: - case 234 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 235 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67901832 /* InterfaceExcludes */); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return bindJsxAttributes(node); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 242 /* ImportEqualsDeclaration */: - case 245 /* NamespaceImport */: - case 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 243 /* ImportEqualsDeclaration */: + case 246 /* NamespaceImport */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return bindImportClause(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return bindExportDeclaration(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return bindExportAssignment(node); - case 273 /* SourceFile */: + case 274 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 212 /* Block */: + case 213 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 292 /* JSDocParameterTag */: - if (node.parent.kind === 287 /* JSDocSignature */) { + case 293 /* JSDocParameterTag */: + if (node.parent.kind === 288 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 286 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 287 /* JSDocTypeLiteral */) { break; } // falls through - case 297 /* JSDocPropertyTag */: + case 298 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 282 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -23812,7 +23879,7 @@ var ts; bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); } else { - var flags = node.kind === 248 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 249 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; ? 2097152 /* Alias */ // An export default clause with any other expression exports a value @@ -23826,7 +23893,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 273 /* SourceFile */) { + if (node.parent.kind !== 274 /* SourceFile */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -23872,13 +23939,11 @@ var ts; // expression is the declaration setCommonJsModuleIndicator(node); var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, function (id, original) { - if (!original) { - return undefined; + var symbol = forEachIdentifierInEntityName(lhs.expression, /*parent*/ undefined, function (id, symbol) { + if (symbol) { + addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* JSContainer */); } - var s = ts.getJSInitializerSymbol(original); - addDeclarationToSymbol(s, id, 1536 /* Module */ | 67108864 /* JSContainer */); - return s; + return symbol; }); if (symbol) { var flags = ts.isClassExpression(node.right) ? @@ -23909,14 +23974,14 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 192 /* 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 === 58 /* EqualsToken */) { var l = thisContainer.parent.left; if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { - constructorSymbol = getJSInitializerSymbolFromName(l.expression.expression, thisParentContainer); + constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } if (constructorSymbol) { @@ -23926,18 +23991,18 @@ var ts; declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } break; - case 154 /* Constructor */: - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 155 /* Constructor */: + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 273 /* SourceFile */: + case 274 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -23949,7 +24014,7 @@ var ts; if (node.expression.kind === 99 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 273 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -24003,43 +24068,65 @@ var ts; node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); } - function getJSInitializerSymbolFromName(name, lookupContainer) { - return ts.getJSInitializerSymbol(lookupSymbolForPropertyAccess(name, lookupContainer)); - } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { - var symbol = getJSInitializerSymbolFromName(name); + var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 273 /* SourceFile */ && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 /* SourceFile */ && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 273 /* SourceFile */; - if (!isPrototypeProperty && (!symbol || !(symbol.flags & 1920 /* Namespace */)) && isToplevelNamespaceableInitializer) { + : propertyAccess.parent.parent.kind === 274 /* SourceFile */; + if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */)) && isToplevelNamespaceableInitializer) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* JSContainer */; var excludeFlags_1 = 67215503 /* ValueModuleExcludes */ & ~67108864 /* JSContainer */; - forEachIdentifierInEntityName(propertyAccess.expression, function (id, original) { - if (original) { - // Note: add declaration to original symbol, not the special-syntax's symbol, so that namespaces work for type lookup - addDeclarationToSymbol(original, id, flags_1); - return original; + namespaceSymbol = forEachIdentifierInEntityName(propertyAccess.expression, namespaceSymbol, function (id, symbol, parent) { + if (symbol) { + addDeclarationToSymbol(symbol, id, flags_1); + return symbol; } else { - return symbol = declareSymbol(symbol ? symbol.exports : container.locals, symbol, id, flags_1, excludeFlags_1); + return declareSymbol(parent ? parent.exports : container.locals, parent, id, flags_1, excludeFlags_1); } }); } - if (!symbol || !(symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */ | 4096 /* ObjectLiteral */))) { + if (!namespaceSymbol || !isJavascriptContainer(namespaceSymbol)) { return; } // Set up the members collection if it doesn't exist already var symbolTable = isPrototypeProperty ? - (symbol.members || (symbol.members = ts.createSymbolTable())) : - (symbol.exports || (symbol.exports = ts.createSymbolTable())); + (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : + (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); // Declare the method/property var jsContainerFlag = isToplevelNamespaceableInitializer ? 67108864 /* JSContainer */ : 0; var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedJavascriptInitializer(propertyAccess)); var symbolFlags = (isMethod ? 8192 /* Method */ : 4 /* Property */) | jsContainerFlag; var symbolExcludes = (isMethod ? 67208127 /* MethodExcludes */ : 0 /* PropertyExcludes */) & ~jsContainerFlag; - declareSymbol(symbolTable, symbol, propertyAccess, symbolFlags, symbolExcludes); + declareSymbol(symbolTable, namespaceSymbol, propertyAccess, symbolFlags, symbolExcludes); + } + /** + * Javascript containers are: + * - Functions + * - classes + * - namespaces + * - variables initialized with function expressions + * - with class expressions + * - with empty object literals + * - with non-empty object literals if assigned to the prototype property + */ + function isJavascriptContainer(symbol) { + if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) { + return true; + } + var node = symbol.valueDeclaration; + var init = !node ? undefined : + ts.isVariableDeclaration(node) ? node.initializer : + ts.isBinaryExpression(node) ? node.right : + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) ? node.parent.right : + undefined; + if (init) { + var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); + return !!ts.getJavascriptInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 54 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + } + return false; } function getParentOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.parent)) { @@ -24053,21 +24140,22 @@ var ts; return lookupSymbolForNameWorker(lookupContainer, node.escapedText); } else { - var symbol = ts.getJSInitializerSymbol(lookupSymbolForPropertyAccess(node.expression)); + var symbol = lookupSymbolForPropertyAccess(node.expression); return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); } } - function forEachIdentifierInEntityName(e, action) { + function forEachIdentifierInEntityName(e, parent, action) { if (isExportsOrModuleExportsOrAlias(file, e)) { return file.symbol; } else if (ts.isIdentifier(e)) { - return action(e, lookupSymbolForPropertyAccess(e)); + return action(e, lookupSymbolForPropertyAccess(e), parent); } else { - var s = ts.getJSInitializerSymbol(forEachIdentifierInEntityName(e.expression, action)); - ts.Debug.assert(!!s && !!s.exports); - return action(e.name, s.exports.get(e.name.escapedText)); + var s = forEachIdentifierInEntityName(e.expression, parent, action); + if (!s || !s.exports) + return ts.Debug.fail(); + return action(e.name, s.exports.get(e.name.escapedText), s); } } function bindCallExpression(node) { @@ -24078,7 +24166,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 234 /* ClassDeclaration */) { + if (node.kind === 235 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -24124,7 +24212,7 @@ var ts; bindBlockScopedVariableDeclaration(node); } else if (ts.isParameterDeclaration(node)) { - // It is safe to walk up parent chain to find whether the node is a destructing parameter declaration + // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration // because its parent chain has already been set up, since parents are set before descending into children. // // If node is a binding element in parameter declaration, we need to use ParameterExcludes. @@ -24141,7 +24229,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 292 /* JSDocParameterTag */ && container.kind !== 287 /* JSDocSignature */) { + if (node.kind === 293 /* JSDocParameterTag */ && container.kind !== 288 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -24207,7 +24295,7 @@ var ts; } function bindTypeParameter(node) { if (ts.isJSDocTemplateTag(node.parent)) { - var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent); + var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent); // TODO: GH#18217 if (container_1) { if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); @@ -24218,7 +24306,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 171 /* InferType */) { + else if (node.parent.kind === 172 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -24227,7 +24315,7 @@ var ts; declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */); } else { - bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { @@ -24237,7 +24325,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 */ && !!options.preserveConstEnums); } function checkUnreachable(node) { if (!(currentFlow.flags & 1 /* Unreachable */)) { @@ -24246,31 +24334,31 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 214 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 215 /* EmptyStatement */) || // report error on class declarations - node.kind === 234 /* ClassDeclaration */ || + node.kind === 235 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 238 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 239 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 237 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 238 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; - // unreachable code is reported if - // - user has explicitly asked about it AND - // - statement is in not ambient context (statements in ambient context is already an error - // so we should not report extras) AND - // - node is not variable statement OR - // - node is block scoped variable statement OR - // - node is not block scoped variable statement and at least one variable declaration has initializer - // Rationale: we don't want to report errors on non-initialized var's since they are hoisted - // On the other side we do want to report errors on non-initialized 'lets' because of TDZ - var reportUnreachableCode = !options.allowUnreachableCode && - !(node.flags & 4194304 /* Ambient */) && - (node.kind !== 213 /* VariableStatement */ || - ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || - ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); - if (reportUnreachableCode) { - errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); + if (!options.allowUnreachableCode) { + // unreachable code is reported if + // - user has explicitly asked about it AND + // - statement is in not ambient context (statements in ambient context is already an error + // so we should not report extras) AND + // - node is not variable statement OR + // - node is block scoped variable statement OR + // - node is not block scoped variable statement and at least one variable declaration has initializer + // Rationale: we don't want to report errors on non-initialized var's since they are hoisted + // On the other side we do want to report errors on non-initialized 'lets' because of TDZ + var isError = ts.unreachableCodeIsError(options) && + !(node.flags & 4194304 /* Ambient */) && + (!ts.isVariableStatement(node) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || + node.declarationList.declarations.some(function (d) { return !!d.initializer; })); + errorOrSuggestionOnFirstToken(isError, node, ts.Diagnostics.Unreachable_code_detected); } } } @@ -24286,8 +24374,8 @@ var ts; ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias; function isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node) { var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText); - return symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && - symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer); + return !!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && + !!symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer); } function isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node) { return isExportsOrModuleExportsOrAlias(sourceFile, node) || @@ -24309,58 +24397,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 186 /* CallExpression */: + case 187 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 148 /* Parameter */: + case 149 /* Parameter */: return computeParameter(node, subtreeFlags); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 154 /* Constructor */: + case 155 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -24412,12 +24500,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 183 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 184 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ESNext if they contain rest transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 182 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 183 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -24466,8 +24554,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 207 /* AsExpression */ - || expressionKind === 189 /* TypeAssertionExpression */) { + if (expressionKind === 208 /* AsExpression */ + || expressionKind === 190 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -24844,13 +24932,13 @@ var ts; var excludeFlags = 939525441 /* NodeExcludes */; switch (kind) { case 120 /* AsyncKeyword */: - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: - case 300 /* PartiallyEmittedExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: + case 301 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -24861,25 +24949,25 @@ var ts; case 117 /* AbstractKeyword */: case 124 /* DeclareKeyword */: case 76 /* ConstKeyword */: - case 237 /* EnumDeclaration */: - case 272 /* EnumMember */: - case 208 /* NonNullExpression */: + case 238 /* EnumDeclaration */: + case 273 /* EnumMember */: + case 209 /* NonNullExpression */: case 132 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: - case 256 /* JsxOpeningElement */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: case 10 /* JsxText */: - case 257 /* JsxClosingElement */: - case 258 /* JsxFragment */: - case 259 /* JsxOpeningFragment */: - case 260 /* JsxClosingFragment */: - case 261 /* JsxAttribute */: - case 262 /* JsxAttributes */: - case 263 /* JsxSpreadAttribute */: - case 264 /* JsxExpression */: + case 258 /* JsxClosingElement */: + case 259 /* JsxFragment */: + case 260 /* JsxOpeningFragment */: + case 261 /* JsxClosingFragment */: + case 262 /* JsxAttribute */: + case 263 /* JsxAttributes */: + case 264 /* JsxSpreadAttribute */: + case 265 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; @@ -24887,11 +24975,11 @@ var ts; case 14 /* TemplateHead */: case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: - case 201 /* TemplateExpression */: - case 188 /* TaggedTemplateExpression */: - case 270 /* ShorthandPropertyAssignment */: + case 202 /* TemplateExpression */: + case 189 /* TaggedTemplateExpression */: + case 271 /* ShorthandPropertyAssignment */: case 115 /* StaticKeyword */: - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -24905,14 +24993,14 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 8 /* AssertESNext */; } transformFlags |= 192 /* AssertES2015 */; break; - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; @@ -24925,38 +25013,38 @@ var ts; case 122 /* BooleanKeyword */: case 138 /* SymbolKeyword */: case 105 /* VoidKeyword */: - case 147 /* TypeParameter */: - case 150 /* PropertySignature */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 160 /* TypePredicate */: - case 161 /* TypeReference */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 164 /* TypeQuery */: - case 165 /* TypeLiteral */: - case 166 /* ArrayType */: - case 167 /* TupleType */: - case 168 /* UnionType */: - case 169 /* IntersectionType */: - case 170 /* ConditionalType */: - case 171 /* InferType */: - case 172 /* ParenthesizedType */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 173 /* ThisType */: - case 174 /* TypeOperator */: - case 175 /* IndexedAccessType */: - case 176 /* MappedType */: - case 177 /* LiteralType */: - case 241 /* NamespaceExportDeclaration */: + case 148 /* TypeParameter */: + case 151 /* PropertySignature */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 161 /* TypePredicate */: + case 162 /* TypeReference */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 165 /* TypeQuery */: + case 166 /* TypeLiteral */: + case 167 /* ArrayType */: + case 168 /* TupleType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: + case 171 /* ConditionalType */: + case 172 /* InferType */: + case 173 /* ParenthesizedType */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 174 /* ThisType */: + case 175 /* TypeOperator */: + case 176 /* IndexedAccessType */: + case 177 /* MappedType */: + case 178 /* LiteralType */: + case 242 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. @@ -24973,10 +25061,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 97 /* SuperKeyword */: @@ -24988,28 +25076,28 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 181 /* BindingElement */: + case 182 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; } break; - case 149 /* Decorator */: + case 150 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: excludeFlags = 942740801 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -25027,8 +25115,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 182 /* ArrayLiteralExpression */: - case 187 /* NewExpression */: + case 183 /* ArrayLiteralExpression */: + case 188 /* NewExpression */: excludeFlags = 940049729 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -25036,23 +25124,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 224 /* ReturnStatement */: - case 222 /* ContinueStatement */: - case 223 /* BreakStatement */: + case 225 /* ReturnStatement */: + // Return statements may require an `await` in ESNext. + transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; + break; + case 223 /* ContinueStatement */: + case 224 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -25068,33 +25159,33 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 160 /* FirstTypeNode */ && kind <= 178 /* LastTypeNode */) { + if (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 182 /* ArrayLiteralExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 183 /* ArrayLiteralExpression */: return 940049729 /* ArrayLiteralOrCallOrNewExcludes */; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return 977327425 /* ModuleExcludes */; - case 148 /* Parameter */: + case 149 /* Parameter */: return 939525441 /* ParameterExcludes */; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return 1003902273 /* ArrowFunctionExcludes */; - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: return 1003935041 /* FunctionExcludes */; - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return 948962625 /* VariableDeclarationListExcludes */; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: return 942011713 /* ClassExcludes */; - case 154 /* Constructor */: + case 155 /* Constructor */: return 1003668801 /* ConstructorExcludes */; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return 1003668801 /* MethodOrAccessorExcludes */; case 119 /* AnyKeyword */: case 134 /* NumberKeyword */: @@ -25104,30 +25195,30 @@ var ts; case 122 /* BooleanKeyword */: case 138 /* SymbolKeyword */: case 105 /* VoidKeyword */: - case 147 /* TypeParameter */: - case 150 /* PropertySignature */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 148 /* TypeParameter */: + case 151 /* PropertySignature */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return 942740801 /* ObjectLiteralExcludes */; - case 268 /* CatchClause */: + case 269 /* CatchClause */: return 940574017 /* CatchClauseExcludes */; - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: return 940049729 /* BindingPatternExcludes */; - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: - case 300 /* PartiallyEmittedExpression */: - case 190 /* ParenthesizedExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: + case 301 /* PartiallyEmittedExpression */: + case 191 /* ParenthesizedExpression */: case 97 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: return 671089985 /* PropertyAccessExcludes */; default: return 939525441 /* NodeExcludes */; @@ -25188,7 +25279,7 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var objectType = type; var objectFlags = objectType.objectFlags; if (objectFlags & 4 /* Reference */) { @@ -25204,16 +25295,16 @@ var ts; visitObjectType(objectType); } } - if (type.flags & 32768 /* TypeParameter */) { + if (type.flags & 65536 /* TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 393216 /* UnionOrIntersection */) { + if (type.flags & 786432 /* UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 524288 /* Index */) { + if (type.flags & 1048576 /* Index */) { visitIndexType(type); } - if (type.flags & 1048576 /* IndexedAccess */) { + if (type.flags & 2097152 /* IndexedAccess */) { visitIndexedAccessType(type); } } @@ -25282,11 +25373,11 @@ var ts; } function visitSymbol(symbol) { if (!symbol) { - return; + return false; } var symbolId = ts.getSymbolId(symbol); if (visitedSymbols[symbolId]) { - return; + return false; } visitedSymbols[symbolId] = symbol; if (!accept(symbol)) { @@ -25302,12 +25393,13 @@ 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 === 164 /* TypeQuery */) { + if (d.type && d.type.kind === 165 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); } }); + return false; } } } @@ -25321,7 +25413,7 @@ var ts; ts.trace = trace; /* @internal */ function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; + return !!compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; function withPackageId(packageId, r) { @@ -25501,7 +25593,6 @@ var ts; } } function secondaryLookup() { - var resolvedFile; var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); if (initialLocationForSecondaryLookup !== undefined) { // check secondary locations @@ -25509,7 +25600,7 @@ var ts; trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*cache*/ undefined); - resolvedFile = resolvedTypeScriptOnly(result && result.value); + var resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -25582,7 +25673,7 @@ var ts; } function getOrCreateCacheForModuleName(nonRelativeModuleName) { if (ts.isExternalModuleNameRelative(nonRelativeModuleName)) { - return undefined; + return undefined; // TODO: GH#18217 } var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); if (!perModuleNameCache) { @@ -25694,7 +25785,7 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); break; default: - ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } if (perFolderCache) { perFolderCache.set(moduleName, result); @@ -25947,7 +26038,7 @@ var ts; var originalPath = void 0; if (!compilerOptions.preserveSymlinks && resolvedValue) { originalPath = resolvedValue.path; - var path = realPath(resolved_1.value.path, host, traceEnabled); + var path = realPath(resolvedValue.path, host, traceEnabled); if (path === originalPath) { originalPath = undefined; } @@ -26066,7 +26157,7 @@ var ts; function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (extensions === Extensions.Json) { var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); - return extensionLess && tryAddingExtensions(extensionLess, extensions, failedLookupLocations, onlyRecordFailures, state); + return extensionLess === undefined ? undefined : tryAddingExtensions(extensionLess, extensions, failedLookupLocations, onlyRecordFailures, state); } // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); @@ -26105,7 +26196,7 @@ var ts; } function tryExtension(ext) { var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); - return path && { path: path, ext: ext }; + return path === undefined ? undefined : { path: path, ext: ext }; } } /** Return the file if it exists. */ @@ -26525,11 +26616,12 @@ var ts; getGlobalDiagnostics: getGlobalDiagnostics, getTypeOfSymbolAtLocation: function (symbol, location) { location = ts.getParseTreeNode(location); - return location ? getTypeOfSymbolAtLocation(symbol, location) : unknownType; + return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType; }, - getSymbolsOfParameterPropertyDeclaration: function (parameter, parameterName) { - parameter = ts.getParseTreeNode(parameter, ts.isParameter); - ts.Debug.assert(parameter !== undefined, "Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); + getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) { + var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter); + if (parameter === undefined) + return ts.Debug.fail("Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); return getSymbolsOfParameterPropertyDeclaration(parameter, ts.escapeLeadingUnderscores(parameterName)); }, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, @@ -26541,9 +26633,9 @@ var ts; getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, getWidenedType: getWidenedType, - getTypeFromTypeNode: function (node) { - node = ts.getParseTreeNode(node, ts.isTypeNode); - return node ? getTypeFromTypeNode(node) : unknownType; + getTypeFromTypeNode: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode); + return node ? getTypeFromTypeNode(node) : errorType; }, getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, @@ -26569,8 +26661,8 @@ var ts; node = ts.getParseTreeNode(node); return node ? getShorthandAssignmentValueSymbol(node) : undefined; }, - getExportSpecifierLocalTargetSymbol: function (node) { - node = ts.getParseTreeNode(node, ts.isExportSpecifier); + getExportSpecifierLocalTargetSymbol: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isExportSpecifier); return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; }, getExportSymbolOfSymbol: function (symbol) { @@ -26578,10 +26670,10 @@ var ts; }, getTypeAtLocation: function (node) { node = ts.getParseTreeNode(node); - return node ? getTypeOfNode(node) : unknownType; + return node ? getTypeOfNode(node) : errorType; }, - getPropertySymbolOfDestructuringAssignment: function (location) { - location = ts.getParseTreeNode(location, ts.isIdentifier); + getPropertySymbolOfDestructuringAssignment: function (locationIn) { + var location = ts.getParseTreeNode(locationIn, ts.isIdentifier); return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined; }, signatureToString: function (signature, enclosingDeclaration, flags, kind) { @@ -26611,41 +26703,41 @@ var ts; getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: function (node) { - node = ts.getParseTreeNode(node, ts.isExpression); + getContextualType: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isExpression); return node ? getContextualType(node) : undefined; }, - getContextualTypeForArgumentAtIndex: function (node, argIndex) { - node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) { + var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); return node && getContextualTypeForArgumentAtIndex(node, argIndex); }, - getContextualTypeForJsxAttribute: function (node) { - node = ts.getParseTreeNode(node, ts.isJsxAttributeLike); + getContextualTypeForJsxAttribute: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike); return node && getContextualTypeForJsxAttribute(node); }, isContextSensitive: isContextSensitive, getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: function (node, candidatesOutArray, theArgumentCount) { - node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + getResolvedSignature: function (nodeIn, candidatesOutArray, theArgumentCount) { + var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); apparentArgumentCount = theArgumentCount; var res = node ? getResolvedSignature(node, candidatesOutArray) : undefined; apparentArgumentCount = undefined; return res; }, - getConstantValue: function (node) { - node = ts.getParseTreeNode(node, canHaveConstantValue); + getConstantValue: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue); return node ? getConstantValue(node) : undefined; }, - isValidPropertyAccess: function (node, propertyName) { - node = ts.getParseTreeNode(node, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode); + isValidPropertyAccess: function (nodeIn, propertyName) { + var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode); return !!node && isValidPropertyAccess(node, ts.escapeLeadingUnderscores(propertyName)); }, - isValidPropertyAccessForCompletions: function (node, type, property) { - node = ts.getParseTreeNode(node, ts.isPropertyAccessExpression); + isValidPropertyAccessForCompletions: function (nodeIn, type, property) { + var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessExpression); return !!node && isValidPropertyAccessForCompletions(node, type, property); }, - getSignatureFromDeclaration: function (declaration) { - declaration = ts.getParseTreeNode(declaration, ts.isFunctionLike); + getSignatureFromDeclaration: function (declarationIn) { + var declaration = ts.getParseTreeNode(declarationIn, ts.isFunctionLike); return declaration ? getSignatureFromDeclaration(declaration) : undefined; }, isImplementationOfOverload: function (node) { @@ -26657,7 +26749,8 @@ var ts; var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); + if (!node) + return ts.Debug.fail(); links.immediateTarget = getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true); } return links.immediateTarget; @@ -26668,13 +26761,13 @@ var ts; getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { - node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); + getAllAttributesTypeFromJsxOpeningLikeElement: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isJsxOpeningLikeElement); return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; }, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, - isOptionalParameter: function (node) { - node = ts.getParseTreeNode(node, ts.isParameter); + isOptionalParameter: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isParameter); return node ? isOptionalParameter(node) : false; }, tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); }, @@ -26708,7 +26801,7 @@ var ts; getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, getSuggestionForNonexistentModule: function (node, target) { return getSuggestionForNonexistentModule(node, target); }, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 32768 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 65536 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -26720,24 +26813,35 @@ var ts; node = ts.getParseTreeNode(node); return node && tryGetThisTypeAt(node); }, - getTypeArgumentConstraint: function (node) { - node = ts.getParseTreeNode(node, ts.isTypeNode); + getTypeArgumentConstraint: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode); return node && getTypeArgumentConstraint(node); }, - getSuggestionDiagnostics: function (file) { - return (suggestionDiagnostics.get(file.fileName) || ts.emptyArray).concat(getUnusedDiagnostics()); - function getUnusedDiagnostics() { - if (file.isDeclarationFile) - return ts.emptyArray; + getSuggestionDiagnostics: function (file, ct) { + var diagnostics; + try { + // Record the cancellation token so it can be checked later on during checkSourceElement. + // Do this in a finally block so we can ensure that it gets reset back to nothing after + // this call is done. + cancellationToken = ct; + // Ensure file is type checked checkSourceFile(file); - var diagnostics = []; ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + if (!file.isDeclarationFile && (!unusedIsError(0 /* Local */) || !unusedIsError(1 /* Parameter */))) { + addUnusedDiagnostics(); + } + return diagnostics || ts.emptyArray; + } + finally { + cancellationToken = undefined; + } + function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (kind, diag) { if (!unusedIsError(kind)) { - diagnostics.push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); } }); - return diagnostics; } }, runWithCancellationToken: function (token, callback) { @@ -26762,22 +26866,23 @@ var ts; var anyType = createIntrinsicType(1 /* Any */, "any"); var autoType = createIntrinsicType(1 /* Any */, "any"); var wildcardType = createIntrinsicType(1 /* Any */, "any"); - var unknownType = createIntrinsicType(1 /* Any */, "unknown"); - var undefinedType = createIntrinsicType(4096 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(4096 /* Undefined */ | 16777216 /* ContainsWideningType */, "undefined"); - var nullType = createIntrinsicType(8192 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(8192 /* Null */ | 16777216 /* ContainsWideningType */, "null"); - var stringType = createIntrinsicType(2 /* String */, "string"); - var numberType = createIntrinsicType(4 /* Number */, "number"); - var trueType = createIntrinsicType(128 /* BooleanLiteral */, "true"); - var falseType = createIntrinsicType(128 /* BooleanLiteral */, "false"); + var errorType = createIntrinsicType(1 /* Any */, "error"); + var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); + var undefinedType = createIntrinsicType(8192 /* Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(8192 /* Undefined */ | 134217728 /* ContainsWideningType */, "undefined"); + var nullType = createIntrinsicType(16384 /* Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(16384 /* Null */ | 134217728 /* ContainsWideningType */, "null"); + var stringType = createIntrinsicType(4 /* String */, "string"); + var numberType = createIntrinsicType(8 /* Number */, "number"); + var trueType = createIntrinsicType(256 /* BooleanLiteral */, "true"); + var falseType = createIntrinsicType(256 /* BooleanLiteral */, "false"); var booleanType = createBooleanType([trueType, falseType]); - var esSymbolType = createIntrinsicType(512 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(2048 /* Void */, "void"); - var neverType = createIntrinsicType(16384 /* Never */, "never"); - var silentNeverType = createIntrinsicType(16384 /* Never */, "never"); - var implicitNeverType = createIntrinsicType(16384 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(134217728 /* NonPrimitive */, "object"); + var esSymbolType = createIntrinsicType(1024 /* ESSymbol */, "symbol"); + var voidType = createIntrinsicType(4096 /* Void */, "void"); + var neverType = createIntrinsicType(32768 /* Never */, "never"); + var silentNeverType = createIntrinsicType(32768 /* Never */, "never"); + var implicitNeverType = createIntrinsicType(32768 /* Never */, "never"); + var nonPrimitiveType = createIntrinsicType(16777216 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -26789,17 +26894,17 @@ 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.flags |= 67108864 /* ContainsAnyFunctionType */; + anyFunctionType.flags |= 536870912 /* ContainsAnyFunctionType */; 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); - var markerSuperType = createType(32768 /* TypeParameter */); - var markerSubType = createType(32768 /* TypeParameter */); + var markerSuperType = createType(65536 /* TypeParameter */); + var markerSubType = createType(65536 /* TypeParameter */); markerSubType.constraint = markerSuperType; - var markerOtherType = createType(32768 /* TypeParameter */); + var markerOtherType = createType(65536 /* TypeParameter */); var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, unknownType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignaturesArray = [resolvingSignature]; @@ -27028,6 +27133,7 @@ var ts; typeToString(type, enclosingDeclaration, flags, emitTextWriterWrapper(writer)); }, buildSymbolDisplay: function (symbol, writer, enclosingDeclaration, meaning, flags) { + if (flags === void 0) { flags = 0 /* None */; } symbolToString(symbol, enclosingDeclaration, meaning, flags | 4 /* AllowAnyNodeKind */, emitTextWriterWrapper(writer)); }, buildSignatureDisplay: function (signature, writer, enclosing, flags, kind) { @@ -27041,12 +27147,12 @@ var ts; buildParameterDisplay: function (symbol, writer, enclosing, flags) { var node = nodeBuilder.symbolToParameterDeclaration(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); + printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 }, buildTypeParameterDisplay: function (tp, writer, enclosing, flags) { var node = nodeBuilder.typeParameterToDeclaration(tp, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 8192 /* OmitParameterModifiers */, writer); var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); + printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 }, buildTypePredicateDisplay: function (predicate, writer, enclosing, flags) { typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); @@ -27059,13 +27165,13 @@ var ts; buildDisplayForParametersAndDelimiters: function (thisParameter, parameters, writer, enclosing, originalFlags) { var printer = ts.createPrinter({ removeComments: true }); var flags = 8192 /* OmitParameterModifiers */ | 3112960 /* IgnoreErrors */ | toNodeBuilderFlags(originalFlags); - var thisParameterArray = thisParameter ? [nodeBuilder.symbolToParameterDeclaration(thisParameter, enclosing, flags)] : []; - var params = ts.createNodeArray(thisParameterArray.concat(ts.map(parameters, function (param) { return nodeBuilder.symbolToParameterDeclaration(param, enclosing, flags); }))); + var thisParameterArray = thisParameter ? [nodeBuilder.symbolToParameterDeclaration(thisParameter, enclosing, flags)] : []; // TODO: GH#18217 + var params = ts.createNodeArray(thisParameterArray.concat(ts.map(parameters, function (param) { return nodeBuilder.symbolToParameterDeclaration(param, enclosing, flags); }))); // TODO: GH#18217 printer.writeList(1296 /* CallExpressionArguments */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); }, buildDisplayForTypeParametersAndDelimiters: function (typeParameters, writer, enclosing, flags) { var printer = ts.createPrinter({ removeComments: true }); - var args = ts.createNodeArray(ts.map(typeParameters, function (p) { return nodeBuilder.typeParameterToDeclaration(p, enclosing, toNodeBuilderFlags(flags)); })); + var args = ts.createNodeArray(ts.map(typeParameters, function (p) { return nodeBuilder.typeParameterToDeclaration(p, enclosing, toNodeBuilderFlags(flags)); })); // TODO: GH#18217 printer.writeList(26896 /* TypeParameters */, args, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); }, buildReturnTypeDisplay: function (signature, writer, enclosing, flags) { @@ -27077,7 +27183,7 @@ var ts; } var node = nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); + printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 } }; function emitTextWriterWrapper(underlying) { @@ -27164,7 +27270,7 @@ var ts; } var jsxPragma = file_1.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 file_1.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file_1.localJsxFactory) { return file_1.localJsxNamespace = getFirstIdentifier(file_1.localJsxFactory).escapedText; @@ -27276,11 +27382,17 @@ var ts; recordMergedSymbol(result, symbol); return result; } + /** + * Note: if target is transient, then it is mutable, and mergeSymbol with both mutate and return it. + * If target is not transient, mergeSymbol will produce a transient clone, mutate that and return it. + */ function mergeSymbol(target, source) { if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864 /* JSContainer */) { - var targetValueDeclaration = target.valueDeclaration; - ts.Debug.assert(!!(target.flags & 33554432 /* Transient */)); + ts.Debug.assert(source !== target); + if (!(target.flags & 33554432 /* Transient */)) { + target = cloneSymbol(target); + } // Javascript static-property-assignment declarations always merge, even though they are also values if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { // reset flag when merging instantiated module into value module that has only const enums @@ -27289,7 +27401,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 238 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 238 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 239 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 239 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -27304,18 +27416,6 @@ var ts; target.exports = ts.createSymbolTable(); mergeSymbolTable(target.exports, source.exports); } - if ((source.flags | target.flags) & 67108864 /* JSContainer */) { - var sourceInitializer = ts.getJSInitializerSymbol(source); - var init = ts.getDeclaredJavascriptInitializer(targetValueDeclaration) || ts.getAssignedJavascriptInitializer(targetValueDeclaration); - var targetInitializer = init && init.symbol ? init.symbol : target; - if (!(targetInitializer.flags & 33554432 /* Transient */)) { - var mergedInitializer = getMergedSymbol(targetInitializer); - targetInitializer = mergedInitializer === targetInitializer ? cloneSymbol(targetInitializer) : mergedInitializer; - } - if (sourceInitializer !== source || targetInitializer !== target) { - mergeSymbol(targetInitializer, sourceInitializer); - } - } recordMergedSymbol(target, source); } else if (target.flags & 1024 /* NamespaceModule */) { @@ -27336,11 +27436,12 @@ var ts; error(errorNode, message_2, symbolToString(source)); }); } + return target; } function combineSymbolTables(first, second) { - if (!first || first.size === 0) + if (!ts.hasEntries(first)) return second; - if (!second || second.size === 0) + if (!ts.hasEntries(second)) return first; var combined = ts.createSymbolTable(); mergeSymbolTable(combined, first); @@ -27349,17 +27450,7 @@ var ts; } function mergeSymbolTable(target, source) { source.forEach(function (sourceSymbol, id) { - var targetSymbol = target.get(id); - if (!targetSymbol) { - target.set(id, sourceSymbol); - } - else { - if (!(targetSymbol.flags & 33554432 /* Transient */)) { - targetSymbol = cloneSymbol(targetSymbol); - target.set(id, targetSymbol); - } - mergeSymbol(targetSymbol, sourceSymbol); - } + target.set(id, target.has(id) ? mergeSymbol(target.get(id), sourceSymbol) : sourceSymbol); }); } function mergeModuleAugmentation(moduleName) { @@ -27387,10 +27478,7 @@ var ts; // obtain item referenced by 'export=' mainModule = resolveExternalModuleSymbol(mainModule); if (mainModule.flags & 1920 /* Namespace */) { - // if module symbol has already been merged - it is safe to use it. - // otherwise clone it - mainModule = mainModule.flags & 33554432 /* Transient */ ? mainModule : cloneSymbol(mainModule); - mergeSymbol(mainModule, moduleAugmentation.symbol); + mainModule = mergeSymbol(mainModule, moduleAugmentation.symbol); } else { // moduleName will be a StringLiteral since this is not `declare global`. @@ -27424,7 +27512,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 273 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -27459,7 +27547,7 @@ var ts; if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } - ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration"); + return ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration"); } function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { var declarationFile = ts.getSourceFileOfNode(declaration); @@ -27482,17 +27570,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 181 /* BindingElement */) { + if (declaration.kind === 182 /* 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, 181 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 182 /* 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, 231 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 232 /* VariableDeclaration */), usage); } - else if (declaration.kind === 231 /* VariableDeclaration */) { + else if (declaration.kind === 232 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -27510,12 +27598,12 @@ var ts; // 5. inside a TS export= declaration (since we will move the export statement during emit to avoid TDZ) // or if usage is in a type context: // 1. inside a type query (typeof in type position) - if (usage.parent.kind === 251 /* ExportSpecifier */ || (usage.parent.kind === 248 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 252 /* ExportSpecifier */ || (usage.parent.kind === 249 /* 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 === 248 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 249 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -27523,9 +27611,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 213 /* VariableStatement */: - case 219 /* ForStatement */: - case 221 /* ForOfStatement */: + case 214 /* VariableStatement */: + case 220 /* ForStatement */: + case 222 /* 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, container)) { @@ -27534,7 +27622,8 @@ var ts; break; } // ForIn/ForOf case - use site should not be used in expression part - return ts.isForInOrOfStatement(declaration.parent.parent) && isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container); + var grandparent = declaration.parent.parent; + return ts.isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, container); } function isUsedInFunctionOrInstanceProperty(usage, declaration, container) { return !!ts.findAncestor(usage, function (current) { @@ -27545,21 +27634,22 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 151 /* PropertyDeclaration */ && + current.parent.kind === 152 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 153 /* MethodDeclaration */) { + if (declaration.kind === 154 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 151 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 152 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } } } + return false; }); } } @@ -27595,12 +27685,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 & 67901928 /* Type */ && lastLocation.kind !== 285 /* JSDocComment */) { + if (meaning & result.flags & 67901928 /* Type */ && lastLocation.kind !== 286 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 148 /* Parameter */ || - lastLocation.kind === 147 /* TypeParameter */ + lastLocation.kind === 149 /* Parameter */ || + lastLocation.kind === 148 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -27610,12 +27700,12 @@ 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 === 148 /* Parameter */ || + lastLocation.kind === 149 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 170 /* ConditionalType */) { + else if (location.kind === 171 /* 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; @@ -27629,14 +27719,14 @@ var ts; } } switch (location.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 273 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 274 /* SourceFile */ || ts.isAmbientModule(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 */)) { @@ -27660,21 +27750,27 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 251 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 252 /* ExportSpecifier */)) { 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 */))) { - break loop; + if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) { + result = undefined; + } + else { + break loop; + } } break; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: // 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 @@ -27691,9 +27787,9 @@ var ts; } } break; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container @@ -27709,7 +27805,7 @@ var ts; } break loop; } - if (location.kind === 204 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 205 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -27717,7 +27813,7 @@ var ts; } } break; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 85 /* ExtendsKeyword */) { var container = location.parent.parent; @@ -27737,9 +27833,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 235 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 236 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67901928 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -27747,19 +27843,19 @@ var ts; } } break; - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -27772,7 +27868,7 @@ var ts; } } break; - case 149 /* Decorator */: + case 150 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -27781,7 +27877,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 === 148 /* Parameter */) { + if (location.parent && location.parent.kind === 149 /* Parameter */) { location = location.parent; } // @@ -27794,12 +27890,11 @@ var ts; location = location.parent; } break; - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it - lastLocation = location; - location = ts.getJSDocHost(location).parent; - continue; + location = ts.getJSDocHost(location); + break; } if (isSelfReferenceLocation(location)) { lastSelfReferenceLocation = location; @@ -27815,7 +27910,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 273 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 274 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -27838,7 +27933,7 @@ var ts; if (!result) { if (nameNotFoundMessage) { if (!errorLocation || - !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && + !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217 !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) && @@ -27889,8 +27984,8 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 67216319 /* Value */) === 67216319 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 241 /* NamespaceExportDeclaration */) { - error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); + if (decls && decls.length === 1 && decls[0].kind === 242 /* NamespaceExportDeclaration */) { + error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); // TODO: GH#18217 } } } @@ -27898,12 +27993,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 238 /* ModuleDeclaration */: // For `namespace N { N; }` + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 239 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -27915,10 +28010,10 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 147 /* TypeParameter */) { + if (decl.kind === 148 /* 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)); + return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 } } } @@ -27945,7 +28040,7 @@ var ts; // No static member is present. // Check if we're in an instance method and look for a relevant instance member. if (location === container && !ts.hasModifier(location, 32 /* Static */)) { - var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; + var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; // TODO: GH#18217 if (getPropertyOfType(instanceType, name)) { error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg)); return true; @@ -27958,11 +28053,11 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - var isError = !!(expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)); - if (isError) { + if (expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); + return true; } - return isError; + return false; } /** * Climbs up parents to an ExpressionWithTypeArguments, and returns its expression, @@ -27971,9 +28066,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71 /* Identifier */: - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -28037,8 +28132,9 @@ var ts; function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); // Block-scoped variables cannot be used before their definition - var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 237 /* EnumDeclaration */) ? d : undefined; }); - ts.Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined"); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 238 /* EnumDeclaration */) ? d : undefined; }); + if (declaration === undefined) + return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { if (result.flags & 2 /* BlockScopedVariable */) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); @@ -28056,17 +28152,17 @@ var ts; * Return false if 'stopAt' node is reached or isFunctionLike(current) === true. */ function isSameScopeDescendentOf(initial, parent, stopAt) { - return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); + return !!parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); } function getAnyImportSyntax(node) { switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return node; - case 244 /* ImportClause */: + case 245 /* ImportClause */: return node.parent; - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return node.parent.parent; - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -28076,7 +28172,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 253 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -28088,7 +28184,7 @@ var ts; : resolveSymbol(moduleSymbol.exports.get(name), dontResolveAlias); } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasModifier(node, 512 /* Default */)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasModifier(node, 512 /* Default */) || ts.isExportSpecifier(node)); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias) { if (!allowSyntheticDefaultImports) { @@ -28191,12 +28287,13 @@ var ts; if (symbol.flags & 3 /* Variable */) { var typeAnnotation = symbol.valueDeclaration.type; if (typeAnnotation) { - return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); + return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); // TODO: GH#18217 } } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + if (dontResolveAlias === void 0) { dontResolveAlias = false; } + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); if (targetSymbol) { var name = specifier.propertyName || specifier.name; @@ -28261,22 +28358,25 @@ var ts; return getNodeLinks(expression).resolvedSymbol; } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { + if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 251 /* ExportSpecifier */: + case 252 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 248 /* ExportAssignment */: - case 199 /* BinaryExpression */: + case 249 /* ExportAssignment */: + case 200 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + default: + return ts.Debug.fail(); } } /** @@ -28287,11 +28387,10 @@ var ts; if (excludes === void 0) { excludes = 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */; } if (!symbol) return false; - return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || (symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* JSContainer */); + return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* JSContainer */); } function resolveSymbol(symbol, dontResolveAlias) { - var shouldResolve = !dontResolveAlias && isNonLocalAlias(symbol); - return shouldResolve ? resolveAlias(symbol) : symbol; + return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); @@ -28299,7 +28398,8 @@ var ts; if (!links.target) { links.target = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); + if (!node) + return ts.Debug.fail(); var target = getTargetOfAliasDeclaration(node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; @@ -28332,12 +28432,13 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); - if (node.kind === 248 /* ExportAssignment */) { + if (!node) + return ts.Debug.fail(); + if (node.kind === 249 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 251 /* ExportSpecifier */) { + else if (node.kind === 252 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -28359,13 +28460,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 71 /* Identifier */ || entityName.parent.kind === 145 /* QualifiedName */) { + if (entityName.kind === 71 /* Identifier */ || entityName.parent.kind === 146 /* 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 === 242 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 243 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -28389,9 +28490,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 145 /* QualifiedName */ || name.kind === 184 /* PropertyAccessExpression */) { - var left = name.kind === 145 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 145 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 146 /* QualifiedName */ || name.kind === 185 /* PropertyAccessExpression */) { + var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; var namespace_1 = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace_1 || ts.nodeIsMissing(right)) { return undefined; @@ -28400,14 +28501,6 @@ var ts; return namespace_1; } if (ts.isInJavaScriptFile(name)) { - var initializer = ts.getDeclaredJavascriptInitializer(namespace_1.valueDeclaration) || ts.getAssignedJavascriptInitializer(namespace_1.valueDeclaration); - if (initializer) { - namespace_1 = getSymbolOfNode(initializer); - } - // Currently, IIFEs may not have a symbol and we don't know about their contents. Give up in this case. - if (!namespace_1) { - return undefined; - } if (namespace_1.valueDeclaration && ts.isVariableDeclaration(namespace_1.valueDeclaration) && namespace_1.valueDeclaration.initializer && @@ -28431,7 +28524,7 @@ var ts; } } else { - ts.Debug.assertNever(name, "Unknown entity name kind."); + 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."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -28492,7 +28585,7 @@ var ts; return ambientModule; } var currentSourceFile = ts.getSourceFileOfNode(location); - var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference); + var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference); // TODO: GH#18217 var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule); var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { @@ -28566,8 +28659,6 @@ var ts; /*details*/ undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, ts.getMangledNameForScopedPackage(packageId.name)); errorOrSuggestion(isError, errorNode, ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedFileName)); } - // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, - // and an external module with no 'export =' declaration resolves to the module itself. function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; } @@ -28583,14 +28674,7 @@ var ts; moduleSymbol.exports.forEach(function (s, name) { if (name === "export=" /* ExportEquals */) return; - if (!merged.exports.has(name)) { - merged.exports.set(name, s); - } - else { - var ms = cloneSymbol(merged.exports.get(name)); - mergeSymbol(ms, s); - merged.exports.set(name, ms); - } + merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); return merged; } @@ -28668,7 +28752,7 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 16382 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); + return type.flags & 32764 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : @@ -28758,6 +28842,43 @@ var ts; function getParentOfSymbol(symbol) { return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent)); } + /** + * Attempts to find the symbol corresponding to the container a symbol is in - usually this + * is just its' `.parent`, but for locals, this value is `undefined` + */ + function getContainerOfSymbol(symbol) { + var container = getParentOfSymbol(symbol); + if (container) { + return container; + } + var candidate = ts.forEach(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + if (!candidate) { + return undefined; + } + var alias = getAliasForSymbolInContainer(candidate, symbol); + return alias ? candidate : undefined; + } + function getAliasForSymbolInContainer(container, symbol) { + if (container === getParentOfSymbol(symbol)) { + // fast path, `symbol` is either already the alias or isn't aliased + return symbol; + } + var exports = getExportsOfSymbol(container); + var quick = exports.get(symbol.escapedName); + if (quick && symbolRefersToTarget(quick)) { + return quick; + } + return ts.forEachEntry(exports, function (exported) { + if (symbolRefersToTarget(exported)) { + return exported; + } + }); + function symbolRefersToTarget(s) { + if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { + return s; + } + } + } function getExportSymbolOfValueSymbolIfExported(symbol) { return symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? getMergedSymbol(symbol.exportSymbol) @@ -28770,7 +28891,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 154 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 155 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -28788,12 +28909,12 @@ var ts; } function createBooleanType(trueFalseTypes) { var type = getUnionType(trueFalseTypes); - type.flags |= 8 /* Boolean */; + type.flags |= 16 /* Boolean */; type.intrinsicName = "boolean"; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(65536 /* Object */); + var type = createType(131072 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; return type; @@ -28848,12 +28969,12 @@ var ts; } } switch (location.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -28899,7 +29020,7 @@ var ts; // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible - !ts.some(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); } function trySymbolTable(symbols, ignoreQualification) { @@ -28927,6 +29048,11 @@ var ts; return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); } } + if (symbolFromSymbolTable.escapedName === symbol.escapedName && symbolFromSymbolTable.exportSymbol) { + if (isAccessible(getMergedSymbol(symbolFromSymbolTable.exportSymbol), /*aliasSymbol*/ undefined, ignoreQualification)) { + return [symbol]; + } + } }); } } @@ -28934,7 +29060,7 @@ var ts; var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { // If symbol of this name is not available in the symbol table we are ok - var symbolFromSymbolTable = symbolTable.get(symbol.escapedName); + var symbolFromSymbolTable = getMergedSymbol(symbolTable.get(symbol.escapedName)); if (!symbolFromSymbolTable) { // Continue to the next symbol table return false; @@ -28945,7 +29071,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, 251 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 252 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -28960,10 +29086,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: continue; default: return false; @@ -29008,7 +29134,7 @@ var ts; return hasAccessibleDeclarations; } else { - if (ts.some(symbol.declarations, hasExternalModuleSymbol)) { + if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // Any meaning of a module symbol is always accessible via an `import` type return { accessibility: 0 /* Accessible */ @@ -29028,7 +29154,7 @@ var ts; // But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible // It is accessible if the parent m is accessible because then m.c can be accessed through qualification meaningToLook = getQualifiedLeftMeaning(meaning); - symbol = getParentOfSymbol(symbol); + symbol = getContainerOfSymbol(symbol); } // This could be a symbol that is not exported in the external module // or it could be a symbol from different external module that is not aliased and hence cannot be named @@ -29057,7 +29183,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 273 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + } + function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -29104,14 +29233,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 164 /* TypeQuery */ || + if (entityName.parent.kind === 165 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 146 /* ComputedPropertyName */) { + entityName.parent.kind === 147 /* ComputedPropertyName */) { // Typeof value meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 145 /* QualifiedName */ || entityName.kind === 184 /* PropertyAccessExpression */ || - entityName.parent.kind === 242 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 185 /* PropertyAccessExpression */ || + entityName.parent.kind === 243 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -29144,7 +29273,7 @@ var ts; var builder = flags & 4 /* AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker); function symbolToStringWorker(writer) { - var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); + var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); @@ -29152,27 +29281,29 @@ var ts; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { + if (flags === void 0) { flags = 0 /* None */; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 163 /* ConstructorType */ : 162 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 164 /* ConstructorType */ : 163 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 158 /* ConstructSignature */ : 157 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 159 /* ConstructSignature */ : 158 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, writer); // TODO: GH#18217 return writer; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */; } + if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; } if (writer === void 0) { writer = ts.createTextWriter(""); } var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - ts.Debug.assert(typeNode !== undefined, "should always get typenode"); + if (typeNode === undefined) + return ts.Debug.fail("should always get typenode"); var options = { removeComments: true }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); @@ -29185,6 +29316,7 @@ var ts; return result; } function toNodeBuilderFlags(flags) { + if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; } function createNodeBuilder() { @@ -29201,7 +29333,7 @@ var ts; var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); var result = context.encounteredError ? undefined : resultingNode; - return result; + return result; // TODO: GH#18217 }, signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); @@ -29249,7 +29381,7 @@ var ts; function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { return { enclosingDeclaration: enclosingDeclaration, - flags: flags, + flags: flags || 0 /* None */, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, encounteredError: false, visitedSymbols: undefined, @@ -29264,40 +29396,43 @@ var ts; context.flags &= ~8388608 /* InTypeAlias */; if (!type) { context.encounteredError = true; - return undefined; + return undefined; // TODO: GH#18217 } if (type.flags & 1 /* Any */) { return ts.createKeywordTypeNode(119 /* AnyKeyword */); } - if (type.flags & 2 /* String */) { + if (type.flags & 2 /* Unknown */) { + return ts.createKeywordTypeNode(142 /* UnknownKeyword */); + } + if (type.flags & 4 /* String */) { return ts.createKeywordTypeNode(137 /* StringKeyword */); } - if (type.flags & 4 /* Number */) { + if (type.flags & 8 /* Number */) { return ts.createKeywordTypeNode(134 /* NumberKeyword */); } - if (type.flags & 8 /* Boolean */) { + if (type.flags & 16 /* Boolean */) { return ts.createKeywordTypeNode(122 /* BooleanKeyword */); } - if (type.flags & 256 /* EnumLiteral */ && !(type.flags & 131072 /* Union */)) { + if (type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); var parentName = symbolToName(parentSymbol, context, 67901928 /* Type */, /*expectsIdentifier*/ false); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : ts.createQualifiedName(parentName, ts.symbolName(type.symbol)); return ts.createTypeReferenceNode(enumLiteralName, /*typeArguments*/ undefined); } - if (type.flags & 272 /* EnumLike */) { + if (type.flags & 544 /* EnumLike */) { var name = symbolToName(type.symbol, context, 67901928 /* Type */, /*expectsIdentifier*/ false); return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); } - if (type.flags & (32 /* StringLiteral */)) { + if (type.flags & (64 /* StringLiteral */)) { return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value), 16777216 /* NoAsciiEscaping */)); } - if (type.flags & (64 /* NumberLiteral */)) { + if (type.flags & (128 /* NumberLiteral */)) { return ts.createLiteralTypeNode((ts.createLiteral(type.value))); } - if (type.flags & 128 /* BooleanLiteral */) { + if (type.flags & 256 /* BooleanLiteral */) { return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); } - if (type.flags & 1024 /* UniqueESSymbol */) { + if (type.flags & 2048 /* UniqueESSymbol */) { if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return symbolToTypeNode(type.symbol, context, 67216319 /* Value */); @@ -29308,25 +29443,25 @@ var ts; } return ts.createTypeOperatorNode(141 /* UniqueKeyword */, ts.createKeywordTypeNode(138 /* SymbolKeyword */)); } - if (type.flags & 2048 /* Void */) { + if (type.flags & 4096 /* Void */) { return ts.createKeywordTypeNode(105 /* VoidKeyword */); } - if (type.flags & 4096 /* Undefined */) { + if (type.flags & 8192 /* Undefined */) { return ts.createKeywordTypeNode(140 /* UndefinedKeyword */); } - if (type.flags & 8192 /* Null */) { + if (type.flags & 16384 /* Null */) { return ts.createKeywordTypeNode(95 /* NullKeyword */); } - if (type.flags & 16384 /* Never */) { + if (type.flags & 32768 /* Never */) { return ts.createKeywordTypeNode(131 /* NeverKeyword */); } - if (type.flags & 512 /* ESSymbol */) { + if (type.flags & 1024 /* ESSymbol */) { return ts.createKeywordTypeNode(138 /* SymbolKeyword */); } - if (type.flags & 134217728 /* NonPrimitive */) { + if (type.flags & 16777216 /* NonPrimitive */) { return ts.createKeywordTypeNode(135 /* ObjectKeyword */); } - if (type.flags & 32768 /* TypeParameter */ && type.isThisType) { + if (type.flags & 65536 /* TypeParameter */ && type.isThisType) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { context.encounteredError = true; @@ -29339,24 +29474,25 @@ var ts; } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 65536 /* Object */)); + ts.Debug.assert(!!(type.flags & 131072 /* Object */)); return typeReferenceToTypeNode(type); } - if (type.flags & 32768 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 32768 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 65536 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { + if (type.flags & 65536 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 32768 /* TypeParameter */ && + type.flags & 65536 /* TypeParameter */ && ts.length(type.symbol.declarations) && ts.isTypeParameterDeclaration(type.symbol.declarations[0]) && typeParameterShadowsNameInScope(type, context) && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return ts.createTypeReferenceNode(ts.getGeneratedNameForNode(type.symbol.declarations[0].name, 16 /* Optimistic */ | 8 /* ReservedInNestedScopes */), /*typeArguments*/ undefined); } - var name = type.symbol ? symbolToName(type.symbol, context, 67901928 /* Type */, /*expectsIdentifier*/ false) : ts.createIdentifier("?"); // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. - return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + return type.symbol + ? symbolToTypeNode(type.symbol, context, 67901928 /* Type */) + : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); @@ -29364,36 +29500,36 @@ var ts; return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); return symbolToTypeNode(type.aliasSymbol, context, 67901928 /* Type */, typeArgumentNodes); } - if (type.flags & (131072 /* Union */ | 262144 /* Intersection */)) { - var types = type.flags & 131072 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (262144 /* Union */ | 524288 /* Intersection */)) { + var types = type.flags & 262144 /* Union */ ? formatUnionTypes(type.types) : type.types; var typeNodes = mapToTypeNodes(types, context); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 131072 /* Union */ ? 168 /* UnionType */ : 169 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 169 /* UnionType */ : 170 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { if (!context.encounteredError && !(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; } - return undefined; + return undefined; // TODO: GH#18217 } } if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 65536 /* Object */)); + ts.Debug.assert(!!(type.flags & 131072 /* Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 524288 /* Index */) { + if (type.flags & 1048576 /* Index */) { var indexedType = type.type; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); return ts.createTypeOperatorNode(indexTypeNode); } - if (type.flags & 1048576 /* IndexedAccess */) { + if (type.flags & 2097152 /* IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 2097152 /* Conditional */) { + if (type.flags & 4194304 /* Conditional */) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -29403,12 +29539,12 @@ var ts; var falseTypeNode = typeToTypeNodeHelper(getFalseTypeFromConditionalType(type), context); return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } - if (type.flags & 4194304 /* Substitution */) { + if (type.flags & 8388608 /* Substitution */) { return typeToTypeNodeHelper(type.typeVariable, context); } - ts.Debug.fail("Should be unreachable."); + return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 65536 /* Object */)); + ts.Debug.assert(!!(type.flags & 131072 /* Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -29437,7 +29573,7 @@ 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 === 204 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 205 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319 /* Value */); @@ -29475,12 +29611,12 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 273 /* SourceFile */ || declaration.parent.kind === 239 /* ModuleBlock */; + return declaration.parent.kind === 274 /* SourceFile */ || declaration.parent.kind === 240 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedSymbols && context.visitedSymbols.has(id))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } @@ -29495,12 +29631,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 162 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 163 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 163 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 164 /* ConstructorType */, context); return signatureNode; } } @@ -29532,7 +29668,7 @@ var ts; return ts.createTupleTypeNode([]); } context.encounteredError = true; - return undefined; + return undefined; // TODO: GH#18217 } else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && @@ -29621,11 +29757,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 157 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 158 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 158 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 159 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexInfo = resolvedType.objectFlags & 2048 /* ReverseMapped */ ? @@ -29655,7 +29791,7 @@ var ts; var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; if (ts.getCheckFlags(propertySymbol) & 1024 /* Late */) { - var decl = ts.firstOrUndefined(propertySymbol.declarations); + var decl = ts.first(propertySymbol.declarations); var name = hasLateBindableName(decl) && resolveEntityName(decl.name.expression, 67216319 /* Value */); if (name && context.tracker.trackSymbol) { context.tracker.trackSymbol(name, saveEnclosingDeclaration, 67216319 /* Value */); @@ -29668,7 +29804,7 @@ var ts; var signatures = getSignaturesOfType(propertyType, 0 /* Call */); for (var _e = 0, signatures_1 = signatures; _e < signatures_1.length; _e++) { var signature = signatures_1[_e]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 152 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 153 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -29718,7 +29854,7 @@ var ts; /*dotDotDotToken*/ undefined, name, /*questionToken*/ undefined, indexerTypeNode, /*initializer*/ undefined); - var typeNode = indexInfo.type ? typeToTypeNodeHelper(indexInfo.type, context) : typeToTypeNodeHelper(anyType, context); + var typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); if (!indexInfo.type && !(context.flags & 2097152 /* AllowEmptyIndexInfoType */)) { context.encounteredError = true; } @@ -29734,7 +29870,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 154 /* Constructor */); }); + var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -29786,22 +29922,22 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 148 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 292 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); - var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(ts.getSynthesizedClone); + var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration ? ts.isRestParameter(parameterDeclaration) : parameterSymbol.isRestParameter; var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? parameterDeclaration.name.kind === 71 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 145 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 146 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -29815,7 +29951,7 @@ var ts; function elideInitializerAndSetEmitFlags(node) { var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 181 /* BindingElement */) { + if (clone.kind === 182 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -29823,12 +29959,12 @@ var ts; } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { - context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); + context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); // TODO: GH#18217 // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */)) { - chain = getSymbolChain(symbol, meaning, /*endOfChain*/ true); + chain = ts.Debug.assertDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); ts.Debug.assert(chain && chain.length > 0); } else { @@ -29842,12 +29978,12 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + var parent = getContainerOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); if (parent) { var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { parentSymbol = parent; - accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); } } } @@ -29858,7 +29994,7 @@ var ts; // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) - (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol))) && + (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol))) && // If a parent symbol is an anonymous type, don't write it. !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { return [symbol]; @@ -30035,6 +30171,7 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { + if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */)); @@ -30050,10 +30187,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 12288 /* Nullable */)) { - if (t.flags & (128 /* BooleanLiteral */ | 256 /* EnumLiteral */)) { - var baseType = t.flags & 128 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 131072 /* Union */) { + if (!(t.flags & 24576 /* Nullable */)) { + if (t.flags & (256 /* BooleanLiteral */ | 512 /* EnumLiteral */)) { + var baseType = t.flags & 256 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 262144 /* Union */) { var count = baseType.types.length; if (i + count <= types.length && types[i + count - 1] === baseType.types[count - 1]) { result.push(baseType); @@ -30065,9 +30202,9 @@ var ts; result.push(t); } } - if (flags & 8192 /* Null */) + if (flags & 16384 /* Null */) result.push(nullType); - if (flags & 4096 /* Undefined */) + if (flags & 8192 /* Undefined */) result.push(undefinedType); return result || types; } @@ -30082,8 +30219,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 172 /* ParenthesizedType */; }); - if (node.kind === 236 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 173 /* ParenthesizedType */; }); + if (node.kind === 237 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -30091,11 +30228,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 239 /* ModuleBlock */ && + node.parent.kind === 240 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 273 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -30115,15 +30252,15 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { - var file_3 = ts.getDeclarationOfKind(symbol, 273 /* SourceFile */); + if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { // TODO: GH#18217 + var file_3 = ts.getDeclarationOfKind(symbol, 274 /* SourceFile */); if (!file_3 || !context.tracker.moduleResolverHost) { 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]; - context.tracker.trackReferencedAmbientModule(decl); + context.tracker.trackReferencedAmbientModule(decl); // TODO: GH#18217 } } } @@ -30138,26 +30275,26 @@ var ts; if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 231 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 232 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } switch (declaration.kind) { - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return "(Anonymous class)"; - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return "(Anonymous function)"; } } var nameType = symbol.nameType; if (nameType) { - if (nameType.flags & 32 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { + if (nameType.flags & 64 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { return "\"" + ts.escapeString(nameType.value, 34 /* doubleQuote */) + "\""; } - if (nameType && nameType.flags & 1024 /* UniqueESSymbol */) { + if (nameType && nameType.flags & 2048 /* UniqueESSymbol */) { return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; } } @@ -30174,27 +30311,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 291 /* JSDocCallbackTag */: - case 296 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: // 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 181 /* BindingElement */: + case 182 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 231 /* VariableDeclaration */: + case 232 /* 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 238 /* ModuleDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 233 /* FunctionDeclaration */: - case 237 /* EnumDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 239 /* ModuleDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 234 /* FunctionDeclaration */: + case 238 /* EnumDeclaration */: + case 243 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -30202,53 +30339,53 @@ 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 !== 242 /* ImportEqualsDeclaration */ && parent.kind !== 273 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 243 /* ImportEqualsDeclaration */ && parent.kind !== 274 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.hasModifier(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 154 /* Constructor */: - case 158 /* ConstructSignature */: - case 157 /* CallSignature */: - case 159 /* IndexSignature */: - case 148 /* Parameter */: - case 239 /* ModuleBlock */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 165 /* TypeLiteral */: - case 161 /* TypeReference */: - case 166 /* ArrayType */: - case 167 /* TupleType */: - case 168 /* UnionType */: - case 169 /* IntersectionType */: - case 172 /* ParenthesizedType */: + case 155 /* Constructor */: + case 159 /* ConstructSignature */: + case 158 /* CallSignature */: + case 160 /* IndexSignature */: + case 149 /* Parameter */: + case 240 /* ModuleBlock */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 166 /* TypeLiteral */: + case 162 /* TypeReference */: + case 167 /* ArrayType */: + case 168 /* TupleType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: + case 173 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 244 /* ImportClause */: - case 245 /* NamespaceImport */: - case 247 /* ImportSpecifier */: + case 245 /* ImportClause */: + case 246 /* NamespaceImport */: + case 248 /* ImportSpecifier */: return false; // Type parameters are always visible - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: // Source file and namespace export are always visible - case 273 /* SourceFile */: - case 241 /* NamespaceExportDeclaration */: + case 274 /* SourceFile */: + case 242 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return false; default: return false; @@ -30257,10 +30394,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 248 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 249 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 251 /* ExportSpecifier */) { + else if (node.parent.kind === 252 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -30329,22 +30466,22 @@ var ts; } function hasType(target, propertyName) { if (propertyName === 0 /* Type */) { - return getSymbolLinks(target).type; + return !!getSymbolLinks(target).type; } if (propertyName === 2 /* DeclaredType */) { - return getSymbolLinks(target).declaredType; + return !!getSymbolLinks(target).declaredType; } if (propertyName === 1 /* ResolvedBaseConstructorType */) { - return target.resolvedBaseConstructorType; + return !!target.resolvedBaseConstructorType; } if (propertyName === 3 /* ResolvedReturnType */) { - return target.resolvedReturnType; + return !!target.resolvedReturnType; } if (propertyName === 4 /* ResolvedBaseConstraint */) { var bc = target.resolvedBaseConstraint; - return bc && bc !== circularConstraintType; + return !!bc && bc !== circularConstraintType; } - ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + return ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); } // Pop an entry from the type resolution stack and return its associated result value. The result value will // be true if no circularities were detected, or false if a circularity was found. @@ -30354,20 +30491,19 @@ var ts; return resolutionResults.pop(); } function getDeclarationContainer(node) { - node = ts.findAncestor(ts.getRootDeclaration(node), function (node) { + return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 231 /* VariableDeclaration */: - case 232 /* VariableDeclarationList */: - case 247 /* ImportSpecifier */: - case 246 /* NamedImports */: - case 245 /* NamespaceImport */: - case 244 /* ImportClause */: + case 232 /* VariableDeclaration */: + case 233 /* VariableDeclarationList */: + case 248 /* ImportSpecifier */: + case 247 /* NamedImports */: + case 246 /* NamespaceImport */: + case 245 /* ImportClause */: return false; default: return true; } - }); - return node && node.parent; + }).parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -30392,14 +30528,14 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 146 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 147 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 12288 /* Nullable */); }); - if (source.flags & 16384 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 24576 /* Nullable */); }); + if (source.flags & 32768 /* Never */) { return emptyObjectType; } - if (source.flags & 131072 /* Union */) { + if (source.flags & 262144 /* Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var members = ts.createSymbolTable(); @@ -30426,8 +30562,8 @@ var ts; var pattern = declaration.parent; var parentType = getTypeForBindingElementParent(pattern.parent); // If parent has the unknown (error) type, then so does this binding element - if (parentType === unknownType) { - return unknownType; + if (parentType === errorType) { + return errorType; } // If no type was specified or inferred for parent, // infer from the initializer of the binding element if one is present. @@ -30439,11 +30575,11 @@ var ts; return parentType; } var type; - if (pattern.kind === 179 /* ObjectBindingPattern */) { + if (pattern.kind === 180 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { - if (!isValidSpreadType(parentType)) { + if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); - return unknownType; + return errorType; } var literalMembers = []; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { @@ -30461,13 +30597,13 @@ var ts; var isWellKnown = ts.isComputedPropertyName(name) && ts.isWellKnownSymbolSyntactically(name.expression); if (!isLate && !isWellKnown && isComputedNonLiteralName(name)) { var exprType = checkExpression(name.expression); - if (isTypeAssignableToKind(exprType, 1536 /* ESSymbolLike */)) { + if (isTypeAssignableToKind(exprType, 3072 /* ESSymbolLike */)) { if (noImplicitAny) { error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(exprType), typeToString(parentType)); } return anyType; } - var indexerType = isTypeAssignableToKind(exprType, 84 /* NumberLike */) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); + var indexerType = isTypeAssignableToKind(exprType, 168 /* NumberLike */) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); if (!indexerType && noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { if (getIndexTypeOfType(parentType, 1 /* Number */)) { error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); @@ -30480,7 +30616,7 @@ var ts; } // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. - var nameType = isLate && checkComputedPropertyName(name); + var nameType = isLate ? checkComputedPropertyName(name) : undefined; var text = isLate ? getLateBoundNameFromType(nameType) : isWellKnown ? ts.getPropertyNameForKnownSymbolName(ts.idText(name.expression.name)) : ts.getTextOfPropertyName(name); @@ -30488,7 +30624,7 @@ var ts; if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } - if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 1536 /* ESSymbolLike */)) { + if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */)) { if (noImplicitAny) { error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(nameType), typeToString(parentType)); } @@ -30500,7 +30636,7 @@ var ts; getIndexTypeOfType(parentType, 0 /* String */); if (!type) { error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); - return unknownType; + return errorType; } } } @@ -30526,13 +30662,13 @@ var ts; else { error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); } - return unknownType; + return errorType; } } } // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 4096 /* Undefined */)) { + if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192 /* Undefined */)) { type = getTypeWithFacts(type, 131072 /* NEUndefined */); } return declaration.initializer ? @@ -30552,7 +30688,7 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 182 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 183 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -30562,11 +30698,11 @@ var ts; 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 === 220 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 221 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); - return indexType.flags & (32768 /* TypeParameter */ | 524288 /* Index */) ? getExtractStringType(indexType) : stringType; + return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 221 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 222 /* 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, @@ -30585,7 +30721,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 231 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 232 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -30599,11 +30735,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 148 /* Parameter */) { + if (declaration.kind === 149 /* Parameter */) { 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 === 156 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 155 /* GetAccessor */); + if (func.kind === 157 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 156 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -30657,20 +30793,20 @@ var ts; var jsDocType; var _loop_3 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 199 /* BinaryExpression */ ? declaration : - declaration.kind === 184 /* PropertyAccessExpression */ ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = declaration.kind === 200 /* BinaryExpression */ ? declaration : + declaration.kind === 185 /* PropertyAccessExpression */ ? ts.cast(declaration.parent, ts.isBinaryExpression) : undefined; if (!expression) { - return { value: unknownType }; + return { value: errorType }; } var special = ts.getSpecialPropertyAssignmentKind(expression); if (special === 4 /* ThisProperty */) { 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. - declarationInConstructor = thisContainer.kind === 154 /* Constructor */ || - thisContainer.kind === 233 /* FunctionDeclaration */ || - (thisContainer.kind === 191 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + declarationInConstructor = thisContainer.kind === 155 /* Constructor */ || + thisContainer.kind === 234 /* FunctionDeclaration */ || + (thisContainer.kind === 192 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -30685,7 +30821,7 @@ var ts; if (!jsDocType) { jsDocType = declarationType; } - else if (jsDocType !== unknownType && declarationType !== unknownType && + else if (jsDocType !== errorType && declarationType !== errorType && !isTypeIdenticalTo(jsDocType, declarationType) && !(symbol.flags & 67108864 /* JSContainer */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); @@ -30742,11 +30878,11 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(12288 /* Nullable */ | 16777216 /* ContainsWideningType */)); }) ? constructorTypes : types; + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(24576 /* Nullable */ | 134217728 /* ContainsWideningType */)); }) ? constructorTypes : types; // TODO: GH#18217 type = getUnionType(sourceTypes, 2 /* Subtype */); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~12288 /* Nullable */); }) === neverType) { + if (filterType(widened, function (t) { return !!(t.flags & ~24576 /* Nullable */); }) === neverType) { if (noImplicitAny) { reportImplicitAnyError(symbol.valueDeclaration, anyType); } @@ -30807,7 +30943,7 @@ var ts; members.set(symbol.escapedName, symbol); }); var result = createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); - result.flags |= 33554432 /* ContainsObjectLiteral */; + result.flags |= 268435456 /* ContainsObjectLiteral */; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; @@ -30818,7 +30954,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (elements.length === 0 || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. @@ -30838,7 +30974,9 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 179 /* ObjectBindingPattern */ + if (includePatternInType === void 0) { includePatternInType = false; } + if (reportErrors === void 0) { reportErrors = false; } + return pattern.kind === 180 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -30858,7 +30996,7 @@ var ts; reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 1024 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 2048 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -30875,7 +31013,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 148 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 149 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -30905,7 +31043,7 @@ var ts; var jsonSourceFile = ts.cast(declaration, ts.isJsonSourceFile); return links.type = jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType; } - if (declaration.kind === 248 /* ExportAssignment */) { + if (declaration.kind === 249 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } if (ts.isInJavaScriptFile(declaration) && ts.isJSDocPropertyLikeTag(declaration) && declaration.typeExpression) { @@ -30913,7 +31051,7 @@ var ts; } // Handle variable, parameter or property if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; + return errorType; } var type = void 0; // Handle certain special assignment kinds, which happen to union across multiple declarations: @@ -30921,13 +31059,15 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 199 /* BinaryExpression */ || - declaration.kind === 184 /* PropertyAccessExpression */ && declaration.parent.kind === 199 /* BinaryExpression */) { + if (declaration.kind === 200 /* BinaryExpression */ || + declaration.kind === 185 /* PropertyAccessExpression */ && declaration.parent.kind === 200 /* BinaryExpression */) { type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isClassDeclaration(declaration) + || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) || ts.isMethodSignature(declaration)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` @@ -30956,7 +31096,7 @@ var ts; type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); } else { - ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration)); + return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol)); } if (!popTypeResolution()) { type = reportCircularityError(symbol); @@ -30967,7 +31107,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 155 /* GetAccessor */) { + if (accessor.kind === 156 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation && getTypeFromTypeNode(getterTypeAnnotation); } @@ -30988,8 +31128,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 155 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 156 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 157 /* SetAccessor */); if (getter && ts.isInJavaScriptFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -30997,7 +31137,7 @@ var ts; } } if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; + return errorType; } var type = void 0; // First try to see if the user specified a return type on the get-accessor. @@ -31034,7 +31174,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 155 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); error(getter_1, 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)); } } @@ -31044,16 +31184,33 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 1081344 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 2162688 /* TypeVariable */ ? baseConstructorType : undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { + var jsDeclaration = ts.getDeclarationOfJSInitializer(symbol.valueDeclaration); + if (jsDeclaration) { + var jsSymbol = getSymbolOfNode(jsDeclaration); + if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { + symbol = cloneSymbol(symbol); + // note:we overwrite links because we just cloned the symbol + links = symbol; + if (ts.hasEntries(jsSymbol.exports)) { + symbol.exports = symbol.exports || ts.createSymbolTable(); + mergeSymbolTable(symbol.exports, jsSymbol.exports); + } + if (ts.hasEntries(jsSymbol.members)) { + symbol.members = symbol.members || ts.createSymbolTable(); + mergeSymbolTable(symbol.members, jsSymbol.members); + } + } + } if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 199 /* BinaryExpression */ || - symbol.valueDeclaration.kind === 184 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 199 /* BinaryExpression */) { + else if (symbol.valueDeclaration.kind === 200 /* BinaryExpression */ || + symbol.valueDeclaration.kind === 185 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 200 /* BinaryExpression */) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -31087,7 +31244,7 @@ var ts; // up recursively calling getTypeOfAlias, causing a stack overflow. links.type = targetSymbol.flags & 67216319 /* Value */ ? getTypeOfSymbol(targetSymbol) - : unknownType; + : errorType; } return links.type; } @@ -31096,11 +31253,11 @@ var ts; if (!links.type) { if (symbolInstantiationDepth === 100) { error(symbol.valueDeclaration, ts.Diagnostics.Generic_type_instantiation_is_excessively_deep_and_possibly_infinite); - links.type = unknownType; + links.type = errorType; } else { if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; + return errorType; } symbolInstantiationDepth++; var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); @@ -31117,7 +31274,7 @@ var ts; // Check if variable has type annotation that circularly references the variable itself if (ts.getEffectiveTypeAnnotationNode(symbol.valueDeclaration)) { error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); - return unknownType; + return errorType; } // Otherwise variable has initializer that circularly references the variable itself if (noImplicitAny) { @@ -31147,7 +31304,7 @@ var ts; if (symbol.flags & 2097152 /* Alias */) { return getTypeOfAlias(symbol); } - return unknownType; + return errorType; } function isReferenceToType(type, target) { return type !== undefined @@ -31158,16 +31315,18 @@ var ts; function getTargetType(type) { return ts.getObjectFlags(type) & 4 /* Reference */ ? type.target : type; } + // TODO: GH#18217 If `checkBase` is undefined, we should not call this because this will always return false. function hasBaseType(type, checkBase) { return check(type); function check(type) { if (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 262144 /* Intersection */) { - return ts.forEach(type.types, check); + else if (type.flags & 524288 /* Intersection */) { + return ts.some(type.types, check); } + return false; } } // Appends the type parameters given by a list of declarations to a set of type parameters and returns the resulting set. @@ -31183,40 +31342,40 @@ var ts; // Return the outer type parameters of a node or undefined if the node has no outer type parameters. function getOuterTypeParameters(node, includeThisTypes) { while (true) { - node = node.parent; + node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead if (!node) { return undefined; } switch (node.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 152 /* MethodSignature */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 283 /* JSDocFunctionType */: - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 236 /* TypeAliasDeclaration */: - case 295 /* JSDocTemplateTag */: - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: - case 176 /* MappedType */: - case 170 /* ConditionalType */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 153 /* MethodSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 284 /* JSDocFunctionType */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 237 /* TypeAliasDeclaration */: + case 296 /* JSDocTemplateTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 177 /* MappedType */: + case 171 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 176 /* MappedType */) { + if (node.kind === 177 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 170 /* ConditionalType */) { + else if (node.kind === 171 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 234 /* ClassDeclaration */ || node.kind === 204 /* ClassExpression */ || node.kind === 235 /* InterfaceDeclaration */) && + (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */ || node.kind === 236 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -31224,7 +31383,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 235 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 236 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -31233,9 +31392,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 235 /* InterfaceDeclaration */ || - node.kind === 234 /* ClassDeclaration */ || - node.kind === 204 /* ClassExpression */ || + if (node.kind === 236 /* InterfaceDeclaration */ || + node.kind === 235 /* ClassDeclaration */ || + node.kind === 205 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -31262,9 +31421,9 @@ var ts; if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } - if (type.flags & 1081344 /* TypeVariable */) { + if (type.flags & 2162688 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } return false; } @@ -31306,25 +31465,25 @@ var ts; return type.resolvedBaseConstructorType = undefinedType; } if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { - return unknownType; + return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); if (extended && baseTypeNode !== extended) { ts.Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag checkExpression(extended.expression); } - if (baseConstructorType.flags & (65536 /* Object */ | 262144 /* Intersection */)) { + if (baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */)) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); - return type.resolvedBaseConstructorType = unknownType; + return type.resolvedBaseConstructorType = errorType; } if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - return type.resolvedBaseConstructorType = unknownType; + return type.resolvedBaseConstructorType = errorType; } type.resolvedBaseConstructorType = baseConstructorType; } @@ -31352,7 +31511,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (65536 /* Object */ | 262144 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 1 /* Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -31380,7 +31539,7 @@ var ts; } baseType = getReturnTypeOfSignature(constructors[0]); } - if (baseType === unknownType) { + if (baseType === errorType) { return type.resolvedBaseTypes = ts.emptyArray; } if (!isValidBaseType(baseType)) { @@ -31396,7 +31555,7 @@ var ts; // (otherwise there'd be an error from hasBaseType) - this is fine, but `.members` should be reset // as `getIndexedAccessType` via `instantiateType` via `getTypeFromClassOrInterfaceReference` forces a // partial instantiation of the members without the base types fully resolved - type.members = undefined; + type.members = undefined; // TODO: GH#18217 } return type.resolvedBaseTypes = [baseType]; } @@ -31414,18 +31573,18 @@ var ts; // A valid base type is `any`, any non-generic object type or intersection of non-generic // object types. function isValidBaseType(type) { - return type.flags & (65536 /* Object */ | 134217728 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || - type.flags & 262144 /* Intersection */ && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + return !!(type.flags & (131072 /* Object */ | 16777216 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || + !!(type.flags & 524288 /* Intersection */) && !ts.some(type.types, function (t) { return !isValidBaseType(t); }); } 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 === 235 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 236 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); - if (baseType !== unknownType) { + if (baseType !== errorType) { if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === ts.emptyArray) { @@ -31457,7 +31616,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 235 /* InterfaceDeclaration */) { + if (declaration.kind === 236 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -31498,7 +31657,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(32768 /* TypeParameter */); + type.thisType = createType(65536 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; @@ -31512,14 +31671,14 @@ var ts; // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { - return unknownType; + return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 236 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 237 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. - var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType; + var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { @@ -31531,7 +31690,7 @@ var ts; } } else { - type = unknownType; + type = errorType; error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; @@ -31542,7 +31701,7 @@ var ts; if (expr.kind === 9 /* StringLiteral */) { return true; } - else if (expr.kind === 199 /* BinaryExpression */) { + else if (expr.kind === 200 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -31556,12 +31715,12 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 71 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -31575,7 +31734,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 237 /* EnumDeclaration */) { + if (declaration.kind === 238 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { @@ -31590,7 +31749,7 @@ var ts; return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 256 /* EnumLiteral */ && !(type.flags & 131072 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); @@ -31602,10 +31761,10 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 237 /* EnumDeclaration */) { + if (declaration.kind === 238 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); + var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); // TODO: GH#18217 getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; memberTypeList.push(memberType); } @@ -31613,14 +31772,14 @@ var ts; } if (memberTypeList.length) { var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 131072 /* Union */) { - enumType_1.flags |= 256 /* EnumLiteral */; + if (enumType_1.flags & 262144 /* Union */) { + enumType_1.flags |= 512 /* EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(16 /* Enum */); + var enumType = createType(32 /* Enum */); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -31637,7 +31796,7 @@ var ts; function getDeclaredTypeOfTypeParameter(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(32768 /* TypeParameter */); + var type = createType(65536 /* TypeParameter */); type.symbol = symbol; links.declaredType = type; } @@ -31651,7 +31810,7 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - return tryGetDeclaredTypeOfSymbol(symbol) || unknownType; + return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { @@ -31682,6 +31841,7 @@ var ts; function isThislessType(node) { switch (node.kind) { case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 137 /* StringKeyword */: case 134 /* NumberKeyword */: case 122 /* BooleanKeyword */: @@ -31691,11 +31851,11 @@ var ts; case 140 /* UndefinedKeyword */: case 95 /* NullKeyword */: case 131 /* NeverKeyword */: - case 177 /* LiteralType */: + case 178 /* LiteralType */: return true; - case 166 /* ArrayType */: + case 167 /* ArrayType */: return isThislessType(node.elementType); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -31720,7 +31880,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 154 /* Constructor */ || (returnType && isThislessType(returnType))) && + return (node.kind === 155 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -31736,12 +31896,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -31785,7 +31945,7 @@ var ts; * Indicates whether a type can be used as a late-bound name. */ function isTypeUsableAsLateBoundName(type) { - return !!(type.flags & 1120 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 2240 /* StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -31805,7 +31965,7 @@ var ts; */ function hasLateBindableName(node) { var name = ts.getNameOfDeclaration(node); - return name && isLateBindableName(name); + return !!name && isLateBindableName(name); } /** * Indicates whether a declaration has a dynamic name that cannot be late-bound. @@ -31823,12 +31983,13 @@ var ts; * Gets the symbolic name for a late-bound member from its type. */ function getLateBoundNameFromType(type) { - if (type.flags & 1024 /* UniqueESSymbol */) { + if (type.flags & 2048 /* UniqueESSymbol */) { return "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); } - if (type.flags & 96 /* StringOrNumberLiteral */) { + if (type.flags & 192 /* StringOrNumberLiteral */) { return ts.escapeLeadingUnderscores("" + type.value); } + return ts.Debug.fail(); } /** * Adds a declaration to a late-bound dynamic member. This performs the same function for @@ -31846,8 +32007,7 @@ var ts; symbol.declarations.push(member); } if (symbolFlags & 67216319 /* Value */) { - var valueDeclaration = symbol.valueDeclaration; - if (!valueDeclaration || valueDeclaration.kind !== member.kind) { + if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } } @@ -31991,7 +32151,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 262144 /* Intersection */) { + else if (type.flags & 524288 /* Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); })); } return needApparentType ? getApparentType(type) : type; @@ -32075,7 +32235,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJavaScriptFile(baseTypeNode); @@ -32147,6 +32307,7 @@ var ts; if (unionSignatures.length > 1) { var thisParameter = signature.thisParameter; if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { + // TODO: GH#18217 We tested that *some* has thisParameter and now act as if *all* do var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */); thisParameter = createSymbolWithType(signature.thisParameter, thisType); } @@ -32273,7 +32434,7 @@ var ts; if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (65536 /* Object */ | 262144 /* Intersection */ | 1081344 /* TypeVariable */)) { + if (baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 2162688 /* TypeVariable */)) { members = ts.createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -32334,7 +32495,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 32 /* StringLiteral */ : 1120 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 64 /* StringLiteral */ : 2240 /* StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { @@ -32352,8 +32513,8 @@ var ts; // First, if the constraint type is a type parameter, obtain the base constraint. Then, // if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. // Finally, iterate over the constituents of the resulting iteration type. - var keyType = constraintType.flags & 7372800 /* InstantiableNonPrimitive */ ? getApparentType(constraintType) : constraintType; - var iterationType = keyType.flags & 524288 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType; + var keyType = constraintType.flags & 14745600 /* InstantiableNonPrimitive */ ? getApparentType(constraintType) : constraintType; + var iterationType = keyType.flags & 1048576 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); @@ -32365,7 +32526,7 @@ var ts; var propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. // Otherwise, for type string create a string index signature. - if (t.flags & 1120 /* StringOrNumberLiteralOrUnique */) { + if (t.flags & 2240 /* StringOrNumberLiteralOrUnique */) { var propName = getLateBoundNameFromType(t); var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || @@ -32386,10 +32547,10 @@ var ts; prop.nameType = t; members.set(propName, prop); } - else if (t.flags & (1 /* Any */ | 2 /* String */)) { + else if (t.flags & (1 /* Any */ | 4 /* String */)) { stringIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1 /* IncludeReadonly */)); } - else if (t.flags & 4 /* Number */) { + else if (t.flags & 8 /* Number */) { numberIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1 /* IncludeReadonly */)); } } @@ -32400,20 +32561,20 @@ var ts; } function getConstraintTypeFromMappedType(type) { return type.constraintType || - (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || unknownType); + (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || errorType); } function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper || identityMapper) : - unknownType); + errorType); } function getConstraintDeclarationForMappedType(type) { return type.declaration.typeParameter.constraint; } function isMappedTypeWithKeyofConstraintDeclaration(type) { - var constraintDeclaration = getConstraintDeclarationForMappedType(type); - return constraintDeclaration.kind === 174 /* TypeOperator */ && + var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 + return constraintDeclaration.kind === 175 /* TypeOperator */ && constraintDeclaration.operator === 128 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -32430,8 +32591,8 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is {}. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 32768 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 524288 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 1048576 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -32454,11 +32615,11 @@ var ts; return !!(ts.getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */); } function isGenericMappedType(type) { - return ts.getObjectFlags(type) & 32 /* Mapped */ && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { if (type.objectFlags & 4 /* Reference */) { resolveTypeReferenceMembers(type); } @@ -32475,10 +32636,10 @@ var ts; resolveMappedTypeMembers(type); } } - else if (type.flags & 131072 /* Union */) { + else if (type.flags & 262144 /* Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 262144 /* Intersection */) { + else if (type.flags & 524288 /* Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -32486,7 +32647,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -32495,7 +32656,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -32519,7 +32680,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { break; } } @@ -32529,13 +32690,13 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 393216 /* UnionOrIntersection */ ? + return type.flags & 786432 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 131072 /* Union */)) { + if (!(unionType.flags & 262144 /* Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -32554,9 +32715,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 32768 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 1048576 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 2097152 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 2097152 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 4194304 /* Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -32566,12 +32727,12 @@ var ts; var objectType = getBaseConstraintOfType(type.objectType) || type.objectType; var indexType = getBaseConstraintOfType(type.indexType) || type.indexType; var constraint = !isGenericObjectType(objectType) && !isGenericIndexType(indexType) ? getIndexedAccessType(objectType, indexType) : undefined; - return constraint && constraint !== unknownType ? constraint : undefined; + return constraint && constraint !== errorType ? constraint : undefined; } function getDefaultConstraintOfConditionalType(type) { if (!type.resolvedDefaultConstraint) { var rootTrueType = type.root.trueType; - var rootTrueConstraint = rootTrueType.flags & 4194304 /* Substitution */ ? rootTrueType.substitute : rootTrueType; + var rootTrueConstraint = rootTrueType.flags & 8388608 /* Substitution */ ? rootTrueType.substitute : rootTrueType; type.resolvedDefaultConstraint = getUnionType([instantiateType(rootTrueConstraint, type.combinedMapper || type.mapper), getFalseTypeFromConditionalType(type)]); } return type.resolvedDefaultConstraint; @@ -32587,7 +32748,7 @@ var ts; if (constraint) { var mapper = makeUnaryTypeMapper(type.root.checkType, constraint); var instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper)); - if (!(instantiated.flags & 16384 /* Never */)) { + if (!(instantiated.flags & 32768 /* Never */)) { return instantiated; } } @@ -32602,23 +32763,23 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 7897088 /* Instantiable */) { + if (t.flags & 15794176 /* Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (32768 /* TypeParameter */ | 524288 /* Index */ | 2097152 /* Conditional */)) { + while (constraint && constraint.flags & (65536 /* TypeParameter */ | 1048576 /* Index */ | 4194304 /* Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { // A constraint that isn't a union type implies that the final type would be a non-union // type as well. Since non-union constraints are of no interest, we can exit here. - if (!(constraint.flags & 131072 /* Union */)) { + if (!(constraint.flags & 262144 /* Union */)) { return undefined; } constraints = ts.append(constraints, constraint); } } - else if (t.flags & 134233854 /* DisjointDomains */) { + else if (t.flags & 16809468 /* DisjointDomains */) { hasDisjointDomainType = true; } } @@ -32630,7 +32791,7 @@ var ts; // intersection operation to reduce the union constraints. for (var _b = 0, _c = type.types; _b < _c.length; _b++) { var t = _c[_b]; - if (t.flags & 134233854 /* DisjointDomains */) { + if (t.flags & 16809468 /* DisjointDomains */) { constraints = ts.append(constraints, t); } } @@ -32640,7 +32801,7 @@ var ts; return undefined; } function getBaseConstraintOfInstantiableNonPrimitiveUnionOrIntersection(type) { - if (type.flags & (7372800 /* InstantiableNonPrimitive */ | 393216 /* UnionOrIntersection */)) { + if (type.flags & (14745600 /* InstantiableNonPrimitive */ | 786432 /* UnionOrIntersection */)) { var constraint = getResolvedBaseConstraint(type); if (constraint !== noConstraintType && constraint !== circularConstraintType) { return constraint; @@ -32649,7 +32810,7 @@ var ts; } function getBaseConstraintOfType(type) { var constraint = getBaseConstraintOfInstantiableNonPrimitiveUnionOrIntersection(type); - if (!constraint && type.flags & 524288 /* Index */) { + if (!constraint && type.flags & 1048576 /* Index */) { return keyofConstraintType; } return constraint; @@ -32689,13 +32850,13 @@ var ts; return result; } function computeBaseConstraint(t) { - if (t.flags & 32768 /* TypeParameter */) { + if (t.flags & 65536 /* TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 393216 /* UnionOrIntersection */) { + if (t.flags & 786432 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { @@ -32705,24 +32866,24 @@ var ts; baseTypes.push(baseType); } } - return t.flags & 131072 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 262144 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 262144 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 524288 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 524288 /* Index */) { + if (t.flags & 1048576 /* Index */) { return keyofConstraintType; } - if (t.flags & 1048576 /* IndexedAccess */) { + if (t.flags & 2097152 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; - return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + return baseIndexedAccess && baseIndexedAccess !== errorType ? getBaseConstraint(baseIndexedAccess) : undefined; } - if (t.flags & 2097152 /* Conditional */) { + if (t.flags & 4194304 /* Conditional */) { var constraint = getConstraintOfConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 4194304 /* Substitution */) { + if (t.flags & 8388608 /* Substitution */) { return getBaseConstraint(t.substitute); } if (isGenericMappedType(t)) { @@ -32783,19 +32944,19 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - var t = type.flags & 7897088 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; - return t.flags & 262144 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 34 /* StringLike */ ? globalStringType : - t.flags & 84 /* NumberLike */ ? globalNumberType : - t.flags & 136 /* BooleanLike */ ? globalBooleanType : - t.flags & 1536 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : - t.flags & 134217728 /* NonPrimitive */ ? emptyObjectType : - t.flags & 524288 /* Index */ ? keyofConstraintType : + var t = type.flags & 15794176 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 524288 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 68 /* StringLike */ ? globalStringType : + t.flags & 168 /* NumberLike */ ? globalNumberType : + t.flags & 272 /* BooleanLike */ ? globalBooleanType : + t.flags & 3072 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : + t.flags & 16777216 /* NonPrimitive */ ? emptyObjectType : + t.flags & 1048576 /* Index */ ? keyofConstraintType : t; } function createUnionOrIntersectionProperty(containingType, name) { var props; - var isUnion = containingType.flags & 131072 /* Union */; + var isUnion = containingType.flags & 262144 /* Union */; var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols var commonFlags = isUnion ? 0 /* None */ : 16777216 /* Optional */; @@ -32804,7 +32965,7 @@ var ts; for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var current = _a[_i]; var type = getApparentType(current); - if (type !== unknownType) { + if (type !== errorType) { var prop = getPropertyOfType(type, name); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop && !(modifiers & excludeModifiers)) { @@ -32900,7 +33061,7 @@ var ts; */ function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -32914,13 +33075,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 393216 /* UnionOrIntersection */) { + if (type.flags & 786432 /* UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 458752 /* StructuredType */) { + if (type.flags & 917504 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -32934,7 +33095,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 458752 /* StructuredType */) { + if (type.flags & 917504 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -32990,10 +33151,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJavaScriptFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 282 /* JSDocOptionalType */ + node.type && node.type.kind === 283 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 282 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -33027,7 +33188,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 282 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -33061,14 +33222,6 @@ var ts; } return minTypeArgumentCount; } - /** - * Fill in default types for unsupplied type arguments. If `typeArguments` is undefined - * when a default type is supplied, a new array will be created and returned. - * - * @param typeArguments The supplied type arguments. - * @param typeParameters The requested type parameters. - * @param minTypeArgumentCount The minimum number of required type arguments. - */ function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) { var numTypeParameters = ts.length(typeParameters); if (numTypeParameters) { @@ -33103,7 +33256,7 @@ var ts; var hasLiteralTypes = false; var minArgumentCount = 0; var thisParameter = void 0; - var hasThisParameter = void 0; + var hasThisParameter = false; var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); var isUntypedSignatureInJSFile = !iife && @@ -33130,7 +33283,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 177 /* LiteralType */) { + if (type && type.kind === 178 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -33144,16 +33297,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 === 155 /* GetAccessor */ || declaration.kind === 156 /* SetAccessor */) && + if ((declaration.kind === 156 /* GetAccessor */ || declaration.kind === 157 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 155 /* GetAccessor */ ? 156 /* SetAccessor */ : 155 /* GetAccessor */; + var otherKind = declaration.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 154 /* Constructor */ ? + var classType = declaration.kind === 155 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -33190,7 +33343,7 @@ var ts; } function getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType) { if (isJSConstructSignature) { - return getTypeFromTypeNode(declaration.parameters[0].type); + return getTypeFromTypeNode(declaration.parameters[0].type); // TODO: GH#18217 } else if (classType) { return classType; @@ -33201,8 +33354,8 @@ var ts; } // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 155 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 156 /* SetAccessor */); + if (declaration.kind === 156 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 157 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -33226,14 +33379,14 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - return node.name.kind === 146 /* ComputedPropertyName */ + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + return node.name.kind === 147 /* ComputedPropertyName */ && traverse(node.name); default: - return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && ts.forEachChild(node, traverse); + return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); } } } @@ -33243,19 +33396,18 @@ var ts; var result = []; for (var i = 0; i < symbol.declarations.length; i++) { var decl = symbol.declarations[i]; - var node = ts.isPropertyAccessExpression(decl) ? ts.getAssignedJavascriptInitializer(decl) : decl; - if (!ts.isFunctionLike(node)) + if (!ts.isFunctionLike(decl)) continue; // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). - if (i > 0 && node.body) { + if (i > 0 && decl.body) { var previous = symbol.declarations[i - 1]; - if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { + if (decl.parent === previous.parent && decl.kind === previous.kind && decl.pos === previous.end) { continue; } } - result.push(getSignatureFromDeclaration(node)); + result.push(getSignatureFromDeclaration(decl)); } return result; } @@ -33288,7 +33440,7 @@ var ts; } else { var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 160 /* TypePredicate */ ? + signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : noTypePredicate; } @@ -33299,7 +33451,7 @@ var ts; function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { - return unknownType; + return errorType; } var type = void 0; if (signature.target) { @@ -33333,7 +33485,7 @@ var ts; } function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); + var type = getTypeOfSymbol(ts.last(signature.parameters)); if (ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType) { return type.typeArguments[0]; } @@ -33394,7 +33546,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 154 /* Constructor */ || signature.declaration.kind === 158 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 155 /* Constructor */ || signature.declaration.kind === 159 /* ConstructSignature */; // TODO: GH#18217 var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -33435,7 +33587,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 147 /* TypeParameter */); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 148 /* TypeParameter */); return decl && decl.constraint; } function getInferredTypeParameterConstraint(typeParameter) { @@ -33447,7 +33599,7 @@ var ts; // (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. - if (declaration.parent.kind === 171 /* InferType */ && declaration.parent.parent.kind === 161 /* TypeReference */) { + if (declaration.parent.kind === 172 /* InferType */ && declaration.parent.parent.kind === 162 /* TypeReference */) { var typeReference = declaration.parent.parent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -33489,7 +33641,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 147 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 148 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; @@ -33526,7 +33678,7 @@ var ts; result |= type.flags; } } - return result & 117440512 /* PropagatingFlags */; + return result & 939524096 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -33563,7 +33715,7 @@ var ts; var isJs = ts.isInJavaScriptFile(node); var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { - var missingAugmentsTag = isJs && node.parent.kind !== 289 /* JSDocAugmentsTag */; + var missingAugmentsTag = isJs && node.parent.kind !== 290 /* JSDocAugmentsTag */; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -33575,7 +33727,7 @@ var ts; error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) - return unknownType; + return errorType; } } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -33584,7 +33736,7 @@ var ts; var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } - return checkNoTypeArguments(node, symbol) ? type : unknownType; + return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeAliasInstantiation(symbol, typeArguments) { var type = getDeclaredTypeOfSymbol(symbol); @@ -33612,17 +33764,17 @@ var ts; error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); - return unknownType; + return errorType; } return getTypeAliasInstantiation(symbol, typeArguments); } - return checkNoTypeArguments(node, symbol) ? type : unknownType; + return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return node.typeName; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -33642,7 +33794,7 @@ var ts; function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { - return unknownType; + return errorType; } var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); if (type) { @@ -33652,11 +33804,11 @@ var ts; var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { return checkNoTypeArguments(node, symbol) ? - res.flags & 32768 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : res : - unknownType; + res.flags & 65536 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : res : + errorType; } if (!(symbol.flags & 67216319 /* Value */ && isJSDocTypeReference(node))) { - return unknownType; + return errorType; } var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); if (jsdocType) { @@ -33676,7 +33828,8 @@ var ts; var valueType = getTypeOfSymbol(symbol); var referenceType = valueType.symbol && valueType.symbol !== symbol && !isInferredClassType(valueType) && getTypeReferenceTypeWorker(node, valueType.symbol, typeArguments); if (referenceType || assignedType) { - return referenceType && assignedType ? getIntersectionType([assignedType, referenceType]) : referenceType || assignedType; + // TODO: GH#18217 (should the `|| assignedType` be at a lower precedence?) + return (referenceType && assignedType ? getIntersectionType([assignedType, referenceType]) : referenceType || assignedType); } } function getTypeReferenceTypeWorker(node, symbol, typeArguments) { @@ -33699,13 +33852,13 @@ var ts; } } function getSubstitutionType(typeVariable, substitute) { - var result = createType(4194304 /* Substitution */); + var result = createType(8388608 /* Substitution */); result.typeVariable = typeVariable; result.substitute = substitute; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 167 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 168 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -33714,9 +33867,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 285 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 286 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 170 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 171 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -33727,7 +33880,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return node.flags & 2097152 /* JSDoc */ && node.kind === 161 /* TypeReference */; + return !!(node.flags & 2097152 /* JSDoc */) && node.kind === 162 /* TypeReference */; } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -33774,7 +33927,7 @@ var ts; var indexed = getTypeFromTypeNode(typeArgs[0]); var target = getTypeFromTypeNode(typeArgs[1]); var index = createIndexInfo(target, /*isReadonly*/ false); - return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType && index, indexed === numberType && index); + return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType ? index : undefined, indexed === numberType ? index : undefined); } return anyType; } @@ -33785,7 +33938,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 8192 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 16384 /* Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -33828,9 +33981,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: return declaration; } } @@ -33839,7 +33992,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 65536 /* Object */)) { + if (!(type.flags & 131072 /* Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -33911,7 +34064,7 @@ var ts; return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { - return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); + return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 } /** * Instantiates a global type that is generic with some element type, and returns that instantiation. @@ -33955,7 +34108,7 @@ var ts; var typeParameters = []; var properties = []; for (var i = 0; i < arity; i++) { - var typeParameter = createType(32768 /* TypeParameter */); + var typeParameter = createType(65536 /* TypeParameter */); typeParameters.push(typeParameter); var property = createSymbol(4 /* Property */, "" + i); property.type = typeParameter; @@ -33972,7 +34125,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(32768 /* TypeParameter */); + type.thisType = createType(65536 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; @@ -34013,16 +34166,16 @@ var ts; var combined = 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 13536 /* Unit */ && combined & 13536 /* Unit */) { + if (t.flags & 27072 /* Unit */ && combined & 27072 /* Unit */) { return true; } combined |= t.flags; - if (combined & 12288 /* Nullable */ && combined & (65536 /* Object */ | 134217728 /* NonPrimitive */) || - combined & 134217728 /* NonPrimitive */ && combined & (134233854 /* DisjointDomains */ & ~134217728 /* NonPrimitive */) || - combined & 34 /* StringLike */ && combined & (134233854 /* DisjointDomains */ & ~34 /* StringLike */) || - combined & 84 /* NumberLike */ && combined & (134233854 /* DisjointDomains */ & ~84 /* NumberLike */) || - combined & 1536 /* ESSymbolLike */ && combined & (134233854 /* DisjointDomains */ & ~1536 /* ESSymbolLike */) || - combined & 6144 /* VoidLike */ && combined & (134233854 /* DisjointDomains */ & ~6144 /* VoidLike */)) { + if (combined & 24576 /* Nullable */ && combined & (131072 /* Object */ | 16777216 /* NonPrimitive */) || + combined & 16777216 /* NonPrimitive */ && combined & (16809468 /* DisjointDomains */ & ~16777216 /* NonPrimitive */) || + combined & 68 /* StringLike */ && combined & (16809468 /* DisjointDomains */ & ~68 /* StringLike */) || + combined & 168 /* NumberLike */ && combined & (16809468 /* DisjointDomains */ & ~168 /* NumberLike */) || + combined & 3072 /* ESSymbolLike */ && combined & (16809468 /* DisjointDomains */ & ~3072 /* ESSymbolLike */) || + combined & 12288 /* VoidLike */ && combined & (16809468 /* DisjointDomains */ & ~12288 /* VoidLike */)) { return true; } } @@ -34030,28 +34183,28 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 131072 /* Union */) { + if (flags & 262144 /* Union */) { return addTypesToUnion(typeSet, includes, type.types); } // We ignore 'never' types in unions. Likewise, we ignore intersections of unit types as they are // another form of 'never' (in that they have an empty value domain). We could in theory turn // intersections of unit types into 'never' upon construction, but deferring the reduction makes it // easier to reason about their origin. - if (!(flags & 16384 /* Never */ || flags & 262144 /* Intersection */ && isEmptyIntersectionType(type))) { - includes |= flags & ~117440512 /* ConstructionFlags */; - if (flags & 1 /* Any */) { + if (!(flags & 32768 /* Never */ || flags & 524288 /* Intersection */ && isEmptyIntersectionType(type))) { + includes |= flags & ~939524096 /* ConstructionFlags */; + if (flags & 3 /* AnyOrUnknown */) { if (type === wildcardType) - includes |= 33554432 /* Wildcard */; + includes |= 268435456 /* Wildcard */; } - else if (!strictNullChecks && flags & 12288 /* Nullable */) { - if (!(flags & 16777216 /* ContainsWideningType */)) - includes |= 16777216 /* NonWideningType */; + else if (!strictNullChecks && flags & 24576 /* Nullable */) { + if (!(flags & 134217728 /* ContainsWideningType */)) + includes |= 134217728 /* NonWideningType */; } else { var len = typeSet.length; var index = len && type.id > typeSet[len - 1].id ? ~len : ts.binarySearch(typeSet, type, getTypeId, ts.compareValues); if (index < 0) { - if (!(flags & 65536 /* Object */ && type.objectFlags & 16 /* Anonymous */ && + if (!(flags & 131072 /* Object */ && type.objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */) && containsIdenticalType(typeSet, type))) { typeSet.splice(~index, 0, type); } @@ -34091,11 +34244,11 @@ var ts; } function isSetOfLiteralsFromSameEnum(types) { var first = types[0]; - if (first.flags & 256 /* EnumLiteral */) { + if (first.flags & 512 /* EnumLiteral */) { var firstEnum = getParentOfSymbol(first.symbol); for (var i = 1; i < types.length; i++) { var other = types[i]; - if (!(other.flags & 256 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { + if (!(other.flags & 512 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { return false; } } @@ -34120,10 +34273,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 32 /* StringLiteral */ && includes & 2 /* String */ || - t.flags & 64 /* NumberLiteral */ && includes & 4 /* Number */ || - t.flags & 1024 /* UniqueESSymbol */ && includes & 512 /* ESSymbol */ || - t.flags & 96 /* StringOrNumberLiteral */ && t.flags & 8388608 /* FreshLiteral */ && containsType(types, t.regularType); + var remove = t.flags & 64 /* StringLiteral */ && includes & 4 /* String */ || + t.flags & 128 /* NumberLiteral */ && includes & 8 /* Number */ || + t.flags & 2048 /* UniqueESSymbol */ && includes & 1024 /* ESSymbol */ || + t.flags & 192 /* StringOrNumberLiteral */ && t.flags & 33554432 /* FreshLiteral */ && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -34146,12 +34299,12 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (includes & 1 /* Any */) { - return includes & 33554432 /* Wildcard */ ? wildcardType : anyType; + if (includes & 3 /* AnyOrUnknown */) { + return includes & 1 /* Any */ ? includes & 268435456 /* Wildcard */ ? wildcardType : anyType : unknownType; } switch (unionReduction) { case 1 /* Literal */: - if (includes & 1120 /* StringOrNumberLiteralOrUnique */) { + if (includes & 2240 /* StringOrNumberLiteralOrUnique */) { removeRedundantLiteralTypes(typeSet, includes); } break; @@ -34160,11 +34313,11 @@ var ts; break; } if (typeSet.length === 0) { - return includes & 8192 /* Null */ ? includes & 16777216 /* NonWideningType */ ? nullType : nullWideningType : - includes & 4096 /* Undefined */ ? includes & 16777216 /* NonWideningType */ ? undefinedType : undefinedWideningType : + return includes & 16384 /* Null */ ? includes & 134217728 /* NonWideningType */ ? nullType : nullWideningType : + includes & 8192 /* Undefined */ ? includes & 134217728 /* NonWideningType */ ? undefinedType : undefinedWideningType : neverType; } - return getUnionTypeFromSortedList(typeSet, includes & 8374815 /* NotUnit */ ? 0 : 268435456 /* UnionOfUnitTypes */, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, includes & 16749629 /* NotUnit */ ? 0 : 67108864 /* UnionOfUnitTypes */, aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -34211,8 +34364,8 @@ var ts; var id = getTypeListId(types); var type = unionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 12288 /* Nullable */); - type = createType(131072 /* Union */ | propagatedFlags | unionOfUnitTypes); + var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 24576 /* Nullable */); + type = createType(262144 /* Union */ | propagatedFlags | unionOfUnitTypes); unionTypes.set(id, type); type.types = types; /* @@ -34236,20 +34389,20 @@ var ts; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 262144 /* Intersection */) { + if (flags & 524288 /* Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } if (ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type)) { - includes |= 67108864 /* EmptyObject */; + includes |= 536870912 /* EmptyObject */; } else { - includes |= flags & ~117440512 /* ConstructionFlags */; - if (flags & 1 /* Any */) { + includes |= flags & ~939524096 /* ConstructionFlags */; + if (flags & 3 /* AnyOrUnknown */) { if (type === wildcardType) - includes |= 33554432 /* Wildcard */; + includes |= 268435456 /* Wildcard */; } - else if ((strictNullChecks || !(flags & 12288 /* Nullable */)) && !ts.contains(typeSet, type) && - !(flags & 65536 /* Object */ && type.objectFlags & 16 /* Anonymous */ && + else if ((strictNullChecks || !(flags & 24576 /* Nullable */)) && !ts.contains(typeSet, type) && + !(flags & 131072 /* Object */ && type.objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */) && containsIdenticalType(typeSet, type))) { typeSet.push(type); @@ -34271,9 +34424,9 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 2 /* String */ && includes & 32 /* StringLiteral */ || - t.flags & 4 /* Number */ && includes & 64 /* NumberLiteral */ || - t.flags & 512 /* ESSymbol */ && includes & 1024 /* UniqueESSymbol */; + var remove = t.flags & 4 /* String */ && includes & 64 /* StringLiteral */ || + t.flags & 8 /* Number */ && includes & 128 /* NumberLiteral */ || + t.flags & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -34283,13 +34436,13 @@ var ts; // Here we remove all unions of unit types from the given list and replace them with a // a single union containing an intersection of the unit types. function intersectUnionsOfUnitTypes(types) { - var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 268435456 /* UnionOfUnitTypes */) !== 0; }); + var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 67108864 /* UnionOfUnitTypes */) !== 0; }); var unionType = types[unionIndex]; var intersection = unionType.types; var i = types.length - 1; var _loop_5 = function () { var t = types[i]; - if (t.flags & 268435456 /* UnionOfUnitTypes */) { + if (t.flags & 67108864 /* UnionOfUnitTypes */) { intersection = ts.filter(intersection, function (u) { return containsType(t.types, u); }); ts.orderedRemoveItemAt(types, i); } @@ -34301,7 +34454,7 @@ var ts; if (intersection === unionType.types) { return false; } - types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 268435456 /* UnionOfUnitTypes */); + types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 67108864 /* UnionOfUnitTypes */); return true; } // We normalize combinations of intersection and union types based on the distributive property of the '&' @@ -34315,30 +34468,33 @@ var ts; // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution // for intersections of types with signatures can be deterministic. function getIntersectionType(types, aliasSymbol, aliasTypeArguments) { - if (types.length === 0) { - return emptyObjectType; - } var typeSet = []; var includes = addTypesToIntersection(typeSet, 0, types); - if (includes & 16384 /* Never */) { + if (includes & 32768 /* Never */) { return neverType; } if (includes & 1 /* Any */) { - return includes & 33554432 /* Wildcard */ ? wildcardType : anyType; + return includes & 268435456 /* Wildcard */ ? wildcardType : anyType; } - if (includes & 2 /* String */ && includes & 32 /* StringLiteral */ || - includes & 4 /* Number */ && includes & 64 /* NumberLiteral */ || - includes & 512 /* ESSymbol */ && includes & 1024 /* UniqueESSymbol */) { + if (!strictNullChecks && includes & 24576 /* Nullable */) { + return includes & 8192 /* Undefined */ ? undefinedType : nullType; + } + if (includes & 4 /* String */ && includes & 64 /* StringLiteral */ || + includes & 8 /* Number */ && includes & 128 /* NumberLiteral */ || + includes & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 67108864 /* EmptyObject */ && !(includes & 65536 /* Object */)) { + if (includes & 536870912 /* EmptyObject */ && !(includes & 131072 /* Object */)) { typeSet.push(emptyObjectType); } + if (typeSet.length === 0) { + return unknownType; + } if (typeSet.length === 1) { return typeSet[0]; } - if (includes & 131072 /* Union */) { - if (includes & 268435456 /* UnionOfUnitTypes */ && intersectUnionsOfUnitTypes(typeSet)) { + if (includes & 262144 /* Union */) { + if (includes & 67108864 /* UnionOfUnitTypes */ && intersectUnionsOfUnitTypes(typeSet)) { // When the intersection creates a reduced set (which might mean that *all* union types have // disappeared), we restart the operation to get a new set of combined flags. Once we have // reduced we'll never reduce again, so this occurs at most once. @@ -34346,15 +34502,15 @@ var ts; } // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. - var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 131072 /* Union */) !== 0; }); + var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 262144 /* Union */) !== 0; }); var unionType = typeSet[unionIndex_1]; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); var type = intersectionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 12288 /* Nullable */); - type = createType(262144 /* Intersection */ | propagatedFlags); + var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 24576 /* Nullable */); + type = createType(524288 /* Intersection */ | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. @@ -34371,7 +34527,7 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(524288 /* Index */); + var result = createType(1048576 /* Index */); result.type = type; result.stringsOnly = stringsOnly; return result; @@ -34387,7 +34543,7 @@ var ts; if (!type && !ts.isKnownSymbol(prop)) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : - name && name.kind === 146 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : + name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); } if (type && type.flags & include) { @@ -34405,16 +34561,16 @@ var ts; } function getIndexType(type, stringsOnly) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } - return type.flags & 131072 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - type.flags & 262144 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - maybeTypeOfKind(type, 7372800 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : + return type.flags & 262144 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + type.flags & 524288 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 /* Mapped */ ? getConstraintTypeFromMappedType(type) : type === wildcardType ? wildcardType : type.flags & 1 /* Any */ ? keyofConstraintType : - stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromPropertyNames(type, 32 /* StringLiteral */) : - getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 1024 /* UniqueESSymbol */)]) : - getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 32 /* StringLiteral */ | 1024 /* UniqueESSymbol */)]) : - getLiteralTypeFromPropertyNames(type, 1120 /* StringOrNumberLiteralOrUnique */); + stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */) : + getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 2048 /* UniqueESSymbol */)]) : + getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */ | 2048 /* UniqueESSymbol */)]) : + getLiteralTypeFromPropertyNames(type, 2240 /* StringOrNumberLiteralOrUnique */); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -34425,7 +34581,7 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 16384 /* Never */ ? stringType : indexType; + return indexType.flags & 32768 /* Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); @@ -34437,20 +34593,20 @@ var ts; case 141 /* UniqueKeyword */: links.resolvedType = node.type.kind === 138 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) - : unknownType; + : errorType; break; } } - return links.resolvedType; + return links.resolvedType; // TODO: GH#18217 } function createIndexedAccessType(objectType, indexType) { - var type = createType(1048576 /* IndexedAccess */); + var type = createType(2097152 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 185 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -34462,7 +34618,7 @@ var ts; markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 99 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); - return unknownType; + return errorType; } if (cacheSymbol) { getNodeLinks(accessNode).resolvedSymbol = prop; @@ -34471,16 +34627,16 @@ var ts; return getTypeOfSymbol(prop); } } - if (!(indexType.flags & 12288 /* Nullable */) && isTypeAssignableToKind(indexType, 34 /* StringLike */ | 84 /* NumberLike */ | 1536 /* ESSymbolLike */)) { + if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { if (isTypeAny(objectType)) { return objectType; } - var indexInfo = isTypeAssignableToKind(indexType, 84 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(indexType, 168 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { - if (accessNode && !isTypeAssignableToKind(indexType, 2 /* String */ | 4 /* Number */)) { - var indexNode = accessNode.kind === 185 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -34488,7 +34644,7 @@ var ts; } return indexInfo.type; } - if (indexType.flags & 16384 /* Never */) { + if (indexType.flags & 32768 /* Never */) { return neverType; } if (accessExpression && !isConstEnumObjectType(objectType)) { @@ -34504,41 +34660,41 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 185 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; - if (indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */)) { + var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + if (indexType.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (2 /* String */ | 4 /* Number */)) { + else if (indexType.flags & (4 /* String */ | 8 /* Number */)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } } - return unknownType; + return errorType; } function isGenericObjectType(type) { - return maybeTypeOfKind(type, 7372800 /* InstantiableNonPrimitive */ | 536870912 /* GenericMappedType */); + return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 134217728 /* GenericMappedType */); } function isGenericIndexType(type) { - return maybeTypeOfKind(type, 7372800 /* InstantiableNonPrimitive */ | 524288 /* Index */); + return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 1048576 /* Index */); } // Return true if the given type is a non-generic object type with a string index signature and no // other members. function isStringIndexOnlyType(type) { - if (type.flags & 65536 /* Object */ && !isGenericMappedType(type)) { + if (type.flags & 131072 /* Object */ && !isGenericMappedType(type)) { var t = resolveStructuredTypeMembers(type); return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && - t.stringIndexInfo && !t.numberIndexInfo; + !!t.stringIndexInfo && !t.numberIndexInfo; } return false; } function isMappedTypeToNever(type) { - return ts.getObjectFlags(type) & 32 /* Mapped */ && getTemplateTypeFromMappedType(type) === neverType; + return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && getTemplateTypeFromMappedType(type) === neverType; } function getSimplifiedType(type) { - return type.flags & 1048576 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; + return type.flags & 2097152 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; } // Transform an indexed access to a simpler form, if possible. Return the simpler form, or return // the type itself if no transformation is possible. @@ -34547,8 +34703,10 @@ var ts; return type.simplified === circularConstraintType ? type : type.simplified; } type.simplified = circularConstraintType; - var objectType = type.objectType; - if (objectType.flags & 262144 /* Intersection */ && isGenericObjectType(objectType)) { + // We recursively simplify the object type as it may in turn be an indexed access type. For example, with + // '{ [P in T]: { [Q in U]: number } }[T][U]' we want to first simplify the inner indexed access type. + var objectType = getSimplifiedType(type.objectType); + if (objectType.flags & 524288 /* Intersection */ && isGenericObjectType(objectType)) { // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or // more object types with only a string index signature, e.g. '(U & V & { [x: string]: D })[K]', return a // transformed type of the form '(U & V)[K] | D'. This allows us to properly reason about higher order indexed @@ -34586,7 +34744,7 @@ var ts; if (isGenericMappedType(objectType)) { return type.simplified = substituteIndexedMappedType(objectType, type); } - if (objectType.flags & 32768 /* TypeParameter */) { + if (objectType.flags & 65536 /* TypeParameter */) { var constraint = getConstraintFromTypeParameter(objectType); if (constraint && isGenericMappedType(constraint)) { return type.simplified = substituteIndexedMappedType(constraint, type); @@ -34608,8 +34766,8 @@ var ts; // 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 === 185 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { - if (objectType.flags & 1 /* Any */) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 186 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. @@ -34624,13 +34782,13 @@ var ts; // We treat boolean as different from other unions to improve errors; // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getApparentType(objectType); - if (indexType.flags & 131072 /* Union */ && !(indexType.flags & 8 /* Boolean */)) { + if (indexType.flags & 262144 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { var propTypes = []; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; var propType = getPropertyTypeForIndexType(apparentObjectType, t, accessNode, /*cacheSymbol*/ false); - if (propType === unknownType) { - return unknownType; + if (propType === errorType) { + return errorType; } propTypes.push(propType); } @@ -34644,7 +34802,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var resolved = getIndexedAccessType(objectType, indexType, node); - links.resolvedType = resolved.flags & 1048576 /* IndexedAccess */ && + links.resolvedType = resolved.flags & 2097152 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConstrainedTypeVariable(resolved, node) : resolved; @@ -34666,7 +34824,7 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - return type.flags & 4194304 /* Substitution */ ? type.typeVariable : type; + return type.flags & 8388608 /* Substitution */ ? type.typeVariable : type; } function getConditionalType(root, mapper) { var checkType = instantiateType(root.checkType, mapper); @@ -34677,7 +34835,7 @@ var ts; // If this is a distributive conditional type and the check type is generic we need to defer // resolution of the conditional type such that a later instantiation will properly distribute // over union types. - var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 7897088 /* Instantiable */); + var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 15794176 /* Instantiable */); var combinedMapper; if (root.inferTypeParameters) { var context_1 = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */); @@ -34690,6 +34848,9 @@ var ts; combinedMapper = combineTypeMappers(mapper, context_1); } if (!isDeferred) { + if (extendsType.flags & 3 /* AnyOrUnknown */) { + return instantiateType(root.trueType, mapper); + } // Return union of trueType and falseType for 'any' since it matches anything if (checkType.flags & 1 /* Any */) { return getUnionType([instantiateType(root.trueType, combinedMapper || mapper), instantiateType(root.falseType, mapper)]); @@ -34713,14 +34874,14 @@ var ts; } // Return a deferred type for a check that is neither definitely true nor definitely false var erasedCheckType = getActualTypeVariable(checkType); - var result = createType(2097152 /* Conditional */); + var result = createType(4194304 /* Conditional */); result.root = root; result.checkType = erasedCheckType; result.extendsType = extendsType; result.mapper = mapper; result.combinedMapper = combinedMapper; result.aliasSymbol = root.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper); + result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 return result; } function getTrueTypeFromConditionalType(type) { @@ -34745,7 +34906,7 @@ var ts; return true; } while (node) { - if (node.kind === 170 /* ConditionalType */) { + if (node.kind === 171 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -34768,7 +34929,7 @@ var ts; extendsType: getTypeFromTypeNode(node.extendsType), trueType: getTypeFromTypeNode(node.trueType), falseType: getTypeFromTypeNode(node.falseType), - isDistributive: !!(checkType.flags & 32768 /* TypeParameter */), + isDistributive: !!(checkType.flags & 65536 /* TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -34804,12 +34965,12 @@ var ts; if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments error(node, ts.Diagnostics.Type_arguments_cannot_be_used_here); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } if (!ts.isLiteralImportTypeNode(node)) { error(node.argument, ts.Diagnostics.String_literal_expected); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } var argumentType = getTypeFromTypeNode(node.argument); var targetMeaning = node.isTypeOf ? 67216319 /* Value */ : 67901928 /* Type */; @@ -34818,7 +34979,7 @@ var ts; var innerModuleSymbol = resolveExternalModule(node, moduleName, ts.Diagnostics.Cannot_find_module_0, node, /*isForAugmentation*/ false); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } var moduleSymbol_1 = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false); if (!ts.nodeIsMissing(node.qualifier)) { @@ -34830,7 +34991,7 @@ var ts; var next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning); if (!next) { error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current)); - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } getNodeLinks(current).resolvedSymbol = next; getNodeLinks(current.parent).resolvedSymbol = next; @@ -34845,11 +35006,11 @@ var ts; else { error(node, targetMeaning === 67216319 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); links.resolvedSymbol = unknownSymbol; - links.resolvedType = unknownType; + links.resolvedType = errorType; } } } - return links.resolvedType; + return links.resolvedType; // TODO: GH#18217 } function resolveImportSymbolType(node, links, symbol, meaning) { links.resolvedSymbol = symbol; @@ -34895,19 +35056,22 @@ var ts; if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { return anyType; } - if (left.flags & 16384 /* Never */) { + if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { + return unknownType; + } + if (left.flags & 32768 /* Never */) { return right; } - if (right.flags & 16384 /* Never */) { + if (right.flags & 32768 /* Never */) { return left; } - if (left.flags & 131072 /* Union */) { + if (left.flags & 262144 /* Union */) { return mapType(left, function (t) { return getSpreadType(t, right, symbol, typeFlags, objectFlags); }); } - if (right.flags & 131072 /* Union */) { + if (right.flags & 262144 /* Union */) { return mapType(right, function (t) { return getSpreadType(left, t, symbol, typeFlags, objectFlags); }); } - if (right.flags & (136 /* BooleanLike */ | 84 /* NumberLike */ | 34 /* StringLike */ | 272 /* EnumLike */ | 134217728 /* NonPrimitive */ | 524288 /* Index */)) { + if (right.flags & (272 /* BooleanLike */ | 168 /* NumberLike */ | 68 /* StringLike */ | 544 /* EnumLike */ | 16777216 /* NonPrimitive */ | 1048576 /* Index */)) { return left; } var members = ts.createSymbolTable(); @@ -34961,7 +35125,7 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getNonReadonlyIndexSignature(stringIndexInfo), getNonReadonlyIndexSignature(numberIndexInfo)); - spread.flags |= typeFlags | 33554432 /* ContainsObjectLiteral */; + spread.flags |= typeFlags | 268435456 /* ContainsObjectLiteral */; spread.objectFlags |= objectFlags | (128 /* ObjectLiteral */ | 1024 /* ContainsSpread */); return spread; } @@ -34993,9 +35157,9 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 96 /* StringOrNumberLiteral */ && !(type.flags & 8388608 /* FreshLiteral */)) { + if (type.flags & 192 /* StringOrNumberLiteral */ && !(type.flags & 33554432 /* FreshLiteral */)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 8388608 /* FreshLiteral */, type.value, type.symbol); + var freshType = createLiteralType(type.flags | 33554432 /* FreshLiteral */, type.value, type.symbol); freshType.regularType = type; type.freshType = freshType; } @@ -35004,7 +35168,9 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 8388608 /* FreshLiteral */ ? type.regularType : type; + return type.flags & 192 /* StringOrNumberLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? type.regularType : + type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : + type; } function getLiteralType(value, enumId, symbol) { // We store all literal types in a single map with keys of the form '#NNN' and '@SSS', @@ -35015,7 +35181,7 @@ var ts; var key = enumId ? enumId + qualifier + value : qualifier + value; var type = literalTypes.get(key); if (!type) { - var flags = (typeof value === "number" ? 64 /* NumberLiteral */ : 32 /* StringLiteral */) | (enumId ? 256 /* EnumLiteral */ : 0); + var flags = (typeof value === "number" ? 128 /* NumberLiteral */ : 64 /* StringLiteral */) | (enumId ? 512 /* EnumLiteral */ : 0); literalTypes.set(key, type = createLiteralType(flags, value, symbol)); } return type; @@ -35028,7 +35194,7 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(1024 /* UniqueESSymbol */); + var type = createType(2048 /* UniqueESSymbol */); type.symbol = symbol; return type; } @@ -35043,14 +35209,14 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 235 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 236 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 154 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); - return unknownType; + return errorType; } function getTypeFromThisTypeNode(node) { var links = getNodeLinks(node); @@ -35062,9 +35228,11 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119 /* AnyKeyword */: - case 278 /* JSDocAllType */: - case 279 /* JSDocUnknownType */: + case 279 /* JSDocAllType */: + case 280 /* JSDocUnknownType */: return anyType; + case 142 /* UnknownKeyword */: + return unknownType; case 137 /* StringKeyword */: return stringType; case 134 /* NumberKeyword */: @@ -35083,64 +35251,64 @@ var ts; return neverType; case 135 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 173 /* ThisType */: + case 174 /* ThisType */: case 99 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 177 /* LiteralType */: + case 178 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return getTypeFromTypeReference(node); - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return booleanType; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 167 /* TupleType */: + case 168 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 168 /* UnionType */: + case 169 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 169 /* IntersectionType */: + case 170 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 280 /* JSDocNullableType */: + case 281 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 282 /* JSDocOptionalType */: + case 283 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 172 /* ParenthesizedType */: - case 281 /* JSDocNonNullableType */: - case 277 /* JSDocTypeExpression */: + case 173 /* ParenthesizedType */: + case 282 /* JSDocNonNullableType */: + case 278 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 165 /* TypeLiteral */: - case 286 /* JSDocTypeLiteral */: - case 283 /* JSDocFunctionType */: - case 287 /* JSDocSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 166 /* TypeLiteral */: + case 287 /* JSDocTypeLiteral */: + case 284 /* JSDocFunctionType */: + case 288 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 174 /* TypeOperator */: + case 175 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 176 /* MappedType */: + case 177 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 171 /* InferType */: + case 172 /* InferType */: return getTypeFromInferTypeNode(node); - case 178 /* ImportType */: + case 179 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 71 /* Identifier */: - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: var symbol = getSymbolAtLocation(node); - return symbol && getDeclaredTypeOfSymbol(symbol); + return (symbol && getDeclaredTypeOfSymbol(symbol)); // TODO: GH#18217 default: - return unknownType; + return errorType; } } function instantiateList(items, mapper, instantiator) { @@ -35217,10 +35385,10 @@ var ts; return function (t) { return t === source ? target : baseMapper(t); }; } function wildcardMapper(type) { - return type.flags & 32768 /* TypeParameter */ ? wildcardType : type; + return type.flags & 65536 /* TypeParameter */ ? wildcardType : type; } function cloneTypeParameter(typeParameter) { - var result = createType(32768 /* TypeParameter */); + var result = createType(65536 /* TypeParameter */); result.symbol = typeParameter.symbol; result.target = typeParameter; return result; @@ -35266,7 +35434,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 65536 /* Object */ | 7897088 /* Instantiable */)) { + if (links.type && !maybeTypeOfKind(links.type, 131072 /* Object */ | 15794176 /* Instantiable */)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -35351,8 +35519,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 145 /* QualifiedName */ || - node.parent.kind === 161 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 146 /* QualifiedName */ || + node.parent.kind === 162 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -35360,22 +35528,22 @@ var ts; // type parameter, or if the node contains type queries, we consider the type parameter possibly referenced. if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 212 /* Block */ ? "quit" : n === container_3; })) { - return ts.forEachChild(node, containsReference); + if (ts.findAncestor(node, function (n) { return n.kind === 213 /* Block */ ? "quit" : n === container_3; })) { + return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 173 /* ThisType */: - return tp.isThisType; + case 174 /* ThisType */: + return !!tp.isThisType; case 71 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return true; } - return ts.forEachChild(node, containsReference); + return !!ts.forEachChild(node, containsReference); } } function instantiateMappedType(type, mapper) { @@ -35385,9 +35553,9 @@ var ts; // homomorphic mapped types we leave primitive types alone. For example, when T is instantiated to a // union type A | undefined, we produce { [P in keyof A]: X } | undefined. var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 524288 /* Index */) { + if (constraintType.flags & 1048576 /* Index */) { var typeVariable_1 = constraintType.type; - if (typeVariable_1.flags & 32768 /* TypeParameter */) { + if (typeVariable_1.flags & 65536 /* TypeParameter */) { var mappedTypeVariable = instantiateType(typeVariable_1, mapper); if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { @@ -35402,7 +35570,7 @@ var ts; return instantiateAnonymousType(type, mapper); } function isMappableType(type) { - return type.flags & (1 /* Any */ | 7372800 /* InstantiableNonPrimitive */ | 65536 /* Object */ | 262144 /* Intersection */); + return type.flags & (3 /* AnyOrUnknown */ | 14745600 /* InstantiableNonPrimitive */ | 131072 /* Object */ | 524288 /* Intersection */); } function instantiateAnonymousType(type, mapper) { var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); @@ -35440,7 +35608,7 @@ var ts; if (root.isDistributive) { var checkType_1 = root.checkType; var instantiatedType = mapper(checkType_1); - if (checkType_1 !== instantiatedType && instantiatedType.flags & (131072 /* Union */ | 16384 /* Never */)) { + if (checkType_1 !== instantiatedType && instantiatedType.flags & (262144 /* Union */ | 32768 /* Never */)) { return mapType(instantiatedType, function (t) { return getConditionalType(root, createReplacementMapper(checkType_1, t, mapper)); }); } } @@ -35448,10 +35616,10 @@ var ts; } function instantiateType(type, mapper) { if (type && mapper && mapper !== identityMapper) { - if (type.flags & 32768 /* TypeParameter */) { + if (type.flags & 65536 /* TypeParameter */) { return mapper(type); } - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { if (type.objectFlags & 16 /* Anonymous */) { // If the anonymous type originates in a declaration of a function, method, class, or // interface, in an object type literal, or in an object literal expression, we may need @@ -35468,33 +35636,33 @@ var ts; return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; } } - if (type.flags & 131072 /* Union */ && !(type.flags & 16382 /* Primitive */)) { + if (type.flags & 262144 /* Union */ && !(type.flags & 32764 /* Primitive */)) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (type.flags & 262144 /* Intersection */) { + if (type.flags & 524288 /* Intersection */) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (type.flags & 524288 /* Index */) { + if (type.flags & 1048576 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (type.flags & 1048576 /* IndexedAccess */) { + if (type.flags & 2097152 /* IndexedAccess */) { return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - if (type.flags & 2097152 /* Conditional */) { + if (type.flags & 4194304 /* Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); } - if (type.flags & 4194304 /* Substitution */) { + if (type.flags & 8388608 /* Substitution */) { return instantiateType(type.typeVariable, mapper); } } return type; } function getWildcardInstantiation(type) { - return type.flags & (16382 /* Primitive */ | 1 /* Any */ | 16384 /* Never */) ? type : + return type.flags & (32764 /* Primitive */ | 3 /* AnyOrUnknown */ | 32768 /* Never */) ? type : type.wildcardInstantiation || (type.wildcardInstantiation = instantiateType(type, wildcardMapper)); } function instantiateIndexInfo(info, mapper) { @@ -35503,34 +35671,38 @@ 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 !== 153 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 183 /* ObjectLiteralExpression */: - return ts.forEach(node.properties, isContextSensitive); - case 182 /* ArrayLiteralExpression */: - return ts.forEach(node.elements, isContextSensitive); - case 200 /* ConditionalExpression */: + case 184 /* ObjectLiteralExpression */: + return ts.some(node.properties, isContextSensitive); + case 183 /* ArrayLiteralExpression */: + return ts.some(node.elements, isContextSensitive); + case 201 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return node.operatorToken.kind === 54 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 262 /* JsxAttributes */: - return ts.forEach(node.properties, isContextSensitive); - case 261 /* JsxAttribute */: + case 263 /* JsxAttributes */: + return ts.some(node.properties, isContextSensitive); + case 262 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. - return node.initializer && isContextSensitive(node.initializer); - case 264 /* JsxExpression */: + var initializer = node.initializer; + return !!initializer && isContextSensitive(initializer); + } + case 265 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) - return node.expression && isContextSensitive(node.expression); + var expression = node.expression; + return !!expression && isContextSensitive(expression); + } } return false; } @@ -35540,10 +35712,10 @@ var ts; return false; } // Functions with any parameters that lack type annotations are context sensitive. - if (ts.forEach(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { + if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 192 /* ArrowFunction */) { + if (node.kind !== 193 /* 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); @@ -35552,14 +35724,15 @@ var ts; } } // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return node.body.kind === 212 /* Block */ ? false : isContextSensitive(node.body); + var body = node.body; + return body.kind === 213 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(16 /* Anonymous */, type.symbol); @@ -35570,7 +35743,7 @@ var ts; return result; } } - else if (type.flags & 262144 /* Intersection */) { + else if (type.flags & 524288 /* Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -35600,9 +35773,9 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 131072 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 131072 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 7372800 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : + return source.flags & 262144 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 262144 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 14745600 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : target === globalObjectType || target === globalFunctionType ? isTypeSubtypeOf(source, target) : hasBaseType(source, getTargetType(target)); } @@ -35652,8 +35825,8 @@ var ts; source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 153 /* MethodDeclaration */ && - kind !== 152 /* MethodSignature */ && kind !== 154 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && + kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -35690,8 +35863,9 @@ var ts; var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && - (getFalsyFlags(sourceType) & 12288 /* Nullable */) === (getFalsyFlags(targetType) & 12288 /* Nullable */); + (getFalsyFlags(sourceType) & 24576 /* Nullable */) === (getFalsyFlags(targetType) & 24576 /* Nullable */); var related = callbacks ? + // TODO: GH#18217 It will work if they're both `undefined`, but not if only one is compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { @@ -35713,7 +35887,7 @@ var ts; if (targetTypePredicate) { var sourceTypePredicate = getTypePredicateOfSignature(source); if (sourceTypePredicate) { - result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, source.declaration, target.declaration, reportErrors, errorReporter, compareTypes); + result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, source.declaration, target.declaration, reportErrors, errorReporter, compareTypes); // TODO: GH#18217 } else if (ts.isIdentifierTypePredicate(targetTypePredicate)) { if (reportErrors) { @@ -35803,10 +35977,10 @@ var ts; !t.numberIndexInfo; } function isEmptyObjectType(type) { - return type.flags & 65536 /* Object */ ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 134217728 /* NonPrimitive */ ? true : - type.flags & 131072 /* Union */ ? ts.forEach(type.types, isEmptyObjectType) : - type.flags & 262144 /* Intersection */ ? !ts.forEach(type.types, function (t) { return !isEmptyObjectType(t); }) : + return type.flags & 131072 /* Object */ ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 16777216 /* NonPrimitive */ ? true : + type.flags & 262144 /* Union */ ? ts.some(type.types, isEmptyObjectType) : + type.flags & 524288 /* Intersection */ ? !ts.some(type.types, function (t) { return !isEmptyObjectType(t); }) : false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -35842,43 +36016,43 @@ var ts; function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 1 /* Any */ || s & 16384 /* Never */ || source === wildcardType) + if (t & 3 /* AnyOrUnknown */ || s & 32768 /* Never */ || source === wildcardType) return true; - if (t & 16384 /* Never */) + if (t & 32768 /* Never */) return false; - if (s & 34 /* StringLike */ && t & 2 /* String */) + if (s & 68 /* StringLike */ && t & 4 /* String */) return true; - if (s & 32 /* StringLiteral */ && s & 256 /* EnumLiteral */ && - t & 32 /* StringLiteral */ && !(t & 256 /* EnumLiteral */) && + if (s & 64 /* StringLiteral */ && s & 512 /* EnumLiteral */ && + t & 64 /* StringLiteral */ && !(t & 512 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 84 /* NumberLike */ && t & 4 /* Number */) + if (s & 168 /* NumberLike */ && t & 8 /* Number */) return true; - if (s & 64 /* NumberLiteral */ && s & 256 /* EnumLiteral */ && - t & 64 /* NumberLiteral */ && !(t & 256 /* EnumLiteral */) && + if (s & 128 /* NumberLiteral */ && s & 512 /* EnumLiteral */ && + t & 128 /* NumberLiteral */ && !(t & 512 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 136 /* BooleanLike */ && t & 8 /* Boolean */) + if (s & 272 /* BooleanLike */ && t & 16 /* Boolean */) return true; - if (s & 1536 /* ESSymbolLike */ && t & 512 /* ESSymbol */) + if (s & 3072 /* ESSymbolLike */ && t & 1024 /* ESSymbol */) return true; - if (s & 16 /* Enum */ && t & 16 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 256 /* EnumLiteral */ && t & 256 /* EnumLiteral */) { - if (s & 131072 /* Union */ && t & 131072 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 512 /* EnumLiteral */ && t & 512 /* EnumLiteral */) { + if (s & 262144 /* Union */ && t & 262144 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 224 /* Literal */ && t & 224 /* Literal */ && + if (s & 448 /* Literal */ && t & 448 /* Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } - if (s & 4096 /* Undefined */ && (!strictNullChecks || t & (4096 /* Undefined */ | 2048 /* Void */))) + if (s & 8192 /* Undefined */ && (!strictNullChecks || t & (8192 /* Undefined */ | 4096 /* Void */))) return true; - if (s & 8192 /* Null */ && (!strictNullChecks || t & 8192 /* Null */)) + if (s & 16384 /* Null */ && (!strictNullChecks || t & 16384 /* Null */)) return true; - if (s & 65536 /* Object */ && t & 134217728 /* NonPrimitive */) + if (s & 131072 /* Object */ && t & 16777216 /* NonPrimitive */) return true; - if (s & 1024 /* UniqueESSymbol */ || t & 1024 /* UniqueESSymbol */) + if (s & 2048 /* UniqueESSymbol */ || t & 2048 /* UniqueESSymbol */) return false; if (relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) { if (s & 1 /* Any */) @@ -35886,30 +36060,30 @@ 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 & (4 /* Number */ | 64 /* NumberLiteral */) && !(s & 256 /* EnumLiteral */) && (t & 16 /* Enum */ || t & 64 /* NumberLiteral */ && t & 256 /* EnumLiteral */)) + if (s & (8 /* Number */ | 128 /* NumberLiteral */) && !(s & 512 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 128 /* NumberLiteral */ && t & 512 /* EnumLiteral */)) return true; } return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 8388608 /* FreshLiteral */) { + if (source.flags & 192 /* StringOrNumberLiteral */ && source.flags & 33554432 /* FreshLiteral */) { source = source.regularType; } - if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 8388608 /* FreshLiteral */) { + if (target.flags & 192 /* StringOrNumberLiteral */ && target.flags & 33554432 /* FreshLiteral */) { target = target.regularType; } if (source === target || - relation === comparableRelation && !(target.flags & 16384 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 65536 /* Object */ && target.flags & 65536 /* Object */) { + if (source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1 /* Succeeded */; } } - if (source.flags & 8355840 /* StructuredOrInstantiable */ || target.flags & 8355840 /* StructuredOrInstantiable */) { + if (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; @@ -35949,7 +36123,7 @@ var ts; errorInfo = ts.concatenateDiagnosticMessageChains(chain_1, errorInfo); } } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); // TODO: GH#18217 } // Check if we should issue an extra diagnostic to produce a quickfix for a slightly incorrect import statement if (headMessage && errorNode && !result && source.symbol) { @@ -35998,7 +36172,7 @@ var ts; } } function isUnionOrIntersectionTypeWithoutNullableConstituents(type) { - if (!(type.flags & 393216 /* UnionOrIntersection */)) { + if (!(type.flags & 786432 /* UnionOrIntersection */)) { return false; } // at this point we know that this is union or intersection type possibly with nullable constituents. @@ -36006,7 +36180,7 @@ var ts; var seenNonNullable = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 12288 /* Nullable */) { + if (t.flags & 24576 /* Nullable */) { continue; } if (seenNonNullable) { @@ -36023,22 +36197,23 @@ var ts; * * Ternary.False if they are not related. */ function isRelatedTo(source, target, reportErrors, headMessage) { - if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 8388608 /* FreshLiteral */) { + if (reportErrors === void 0) { reportErrors = false; } + if (source.flags & 192 /* StringOrNumberLiteral */ && source.flags & 33554432 /* FreshLiteral */) { source = source.regularType; } - if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 8388608 /* FreshLiteral */) { + if (target.flags & 192 /* StringOrNumberLiteral */ && target.flags & 33554432 /* FreshLiteral */) { target = target.regularType; } - if (source.flags & 4194304 /* Substitution */) { + if (source.flags & 8388608 /* Substitution */) { source = relation === definitelyAssignableRelation ? source.typeVariable : source.substitute; } - if (target.flags & 4194304 /* Substitution */) { + if (target.flags & 8388608 /* Substitution */) { target = target.typeVariable; } - if (source.flags & 1048576 /* IndexedAccess */) { + if (source.flags & 2097152 /* IndexedAccess */) { source = getSimplifiedType(source); } - if (target.flags & 1048576 /* IndexedAccess */) { + if (target.flags & 2097152 /* IndexedAccess */) { target = getSimplifiedType(target); } // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases @@ -36047,11 +36222,11 @@ var ts; if (relation === identityRelation) { return isIdenticalTo(source, target); } - if (relation === comparableRelation && !(target.flags & 16384 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - if (isObjectLiteralType(source) && source.flags & 8388608 /* FreshLiteral */) { - var discriminantType = target.flags & 131072 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; + if (isObjectLiteralType(source) && source.flags & 33554432 /* FreshLiteral */) { + var discriminantType = target.flags & 262144 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -36067,8 +36242,8 @@ var ts; } } if (relation !== comparableRelation && - !(source.flags & 393216 /* UnionOrIntersection */) && - !(target.flags & 131072 /* Union */) && + !(source.flags & 786432 /* UnionOrIntersection */) && + !(target.flags & 262144 /* Union */) && !isIntersectionConstituent && source !== globalObjectType && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && @@ -36094,20 +36269,20 @@ var ts; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. - if (source.flags & 131072 /* Union */) { + if (source.flags & 262144 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 16382 /* Primitive */)) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 16382 /* Primitive */)); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)); } else { - if (target.flags & 131072 /* Union */) { - result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 16382 /* Primitive */) && !(target.flags & 16382 /* Primitive */)); + if (target.flags & 262144 /* Union */) { + result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */) && !(target.flags & 32764 /* Primitive */)); } - else if (target.flags & 262144 /* Intersection */) { + else if (target.flags & 524288 /* Intersection */) { isIntersectionConstituent = true; result = typeRelatedToEachType(source, target, reportErrors); } - else if (source.flags & 262144 /* Intersection */) { + else if (source.flags & 524288 /* Intersection */) { // 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 @@ -36123,13 +36298,13 @@ var ts; // breaking the intersection apart. result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } - if (!result && (source.flags & 8355840 /* StructuredOrInstantiable */ || target.flags & 8355840 /* StructuredOrInstantiable */)) { + if (!result && (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { errorInfo = saveErrorInfo; } } } - if (!result && source.flags & 262144 /* Intersection */) { + if (!result && source.flags & 524288 /* Intersection */) { // The combined constraint of an intersection type is the intersection of the constraints of // the constituents. When an intersection type contains instantiable types with union type // constraints, there are situations where we need to examine the combined constraint. One is @@ -36139,7 +36314,7 @@ var ts; // we need to check this constraint against a union on the target side. Also, given a type // variable V constrained to 'string | number', 'V & number' has a combined constraint of // 'string & number | number & number' which reduces to just 'number'. - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 131072 /* Union */)); + var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 262144 /* Union */)); if (constraint) { if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; @@ -36148,12 +36323,22 @@ var ts; } isIntersectionConstituent = saveIsIntersectionConstituent; if (!result && reportErrors) { - if (source.flags & 65536 /* Object */ && target.flags & 16382 /* Primitive */) { + if (source.flags & 131072 /* Object */ && target.flags & 32764 /* Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 65536 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 131072 /* Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } + else if (ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && target.flags & 524288 /* Intersection */) { + var targetTypes = target.types; + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); + var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); + if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType && + (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) { + // do not report top error + return result; + } + } reportRelationError(headMessage, source, target); } return result; @@ -36161,27 +36346,27 @@ var ts; function isIdenticalTo(source, target) { var result; var flags = source.flags & target.flags; - if (flags & 65536 /* Object */) { + if (flags & 131072 /* Object */) { return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false); } - if (flags & (131072 /* Union */ | 262144 /* Intersection */)) { + if (flags & (262144 /* Union */ | 524288 /* Intersection */)) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } } - if (flags & 524288 /* Index */) { + if (flags & 1048576 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } - if (flags & 1048576 /* IndexedAccess */) { + if (flags & 2097152 /* IndexedAccess */) { if (result = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { if (result &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { return result; } } } - if (flags & 2097152 /* Conditional */) { + if (flags & 4194304 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { if (result = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { if (result &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { @@ -36194,13 +36379,13 @@ var ts; } } } - if (flags & 4194304 /* Substitution */) { + if (flags & 8388608 /* Substitution */) { return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false); } return 0 /* False */; } function hasExcessProperties(source, target, discriminant, reportErrors) { - if (maybeTypeOfKind(target, 65536 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + if (maybeTypeOfKind(target, 131072 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); if ((relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { @@ -36216,7 +36401,8 @@ var ts; // We know *exactly* where things went wrong when comparing the types. // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. - ts.Debug.assert(!!errorNode); + if (!errorNode) + return { value: ts.Debug.fail() }; if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. @@ -36230,8 +36416,9 @@ var ts; var propDeclaration = prop.valueDeclaration; ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike); errorNode = propDeclaration; - if (ts.isIdentifier(propDeclaration.name)) { - suggestion = getSuggestionForNonexistentProperty(propDeclaration.name, target); + var name = propDeclaration.name; + if (ts.isIdentifier(name)) { + suggestion = getSuggestionForNonexistentProperty(name, target); } } if (suggestion !== undefined) { @@ -36269,7 +36456,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 131072 /* Union */ && containsType(targetTypes, source)) { + if (target.flags & 262144 /* Union */ && containsType(targetTypes, source)) { return -1 /* True */; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { @@ -36327,7 +36514,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 131072 /* Union */ && containsType(sourceTypes, target)) { + if (source.flags & 262144 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; @@ -36479,7 +36666,7 @@ var ts; var result; var originalErrorInfo; var saveErrorInfo = errorInfo; - if (target.flags & 32768 /* TypeParameter */) { + if (target.flags & 65536 /* TypeParameter */) { // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. if (ts.getObjectFlags(source) & 32 /* Mapped */ && getConstraintTypeFromMappedType(source) === getIndexType(target)) { if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { @@ -36491,9 +36678,9 @@ var ts; } } } - else if (target.flags & 524288 /* Index */) { + else if (target.flags & 1048576 /* Index */) { // A keyof S is related to a keyof T if T is related to S. - if (source.flags & 524288 /* Index */) { + if (source.flags & 1048576 /* Index */) { if (result = isRelatedTo(target.type, source.type, /*reportErrors*/ false)) { return result; } @@ -36510,7 +36697,7 @@ var ts; } } } - else if (target.flags & 1048576 /* IndexedAccess */) { + else if (target.flags & 2097152 /* IndexedAccess */) { // A type S is related to a type T[K] if S is related to C, where C is the // constraint of T[K] var constraint = getConstraintForRelation(target); @@ -36526,7 +36713,7 @@ var ts; var template = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); if (!(modifiers & 8 /* ExcludeOptional */)) { - if (template.flags & 1048576 /* IndexedAccess */ && template.objectType === source && + if (template.flags & 2097152 /* IndexedAccess */ && template.objectType === source && template.indexType === getTypeParameterFromMappedType(target)) { return -1 /* True */; } @@ -36541,8 +36728,8 @@ var ts; } } } - if (source.flags & 1081344 /* TypeVariable */) { - if (source.flags & 1048576 /* IndexedAccess */ && target.flags & 1048576 /* IndexedAccess */) { + if (source.flags & 2162688 /* TypeVariable */) { + if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* 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); @@ -36553,9 +36740,9 @@ var ts; } } var constraint = getConstraintForRelation(source); - if (!constraint || (source.flags & 32768 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { + if (!constraint || (source.flags & 65536 /* TypeParameter */ && constraint.flags & 3 /* AnyOrUnknown */)) { // A type variable with no constraint is not related to the non-primitive object type. - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~134217728 /* NonPrimitive */))) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~16777216 /* NonPrimitive */))) { errorInfo = saveErrorInfo; return result; } @@ -36568,14 +36755,14 @@ var ts; } } } - else if (source.flags & 524288 /* Index */) { + else if (source.flags & 1048576 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 2097152 /* Conditional */) { - if (target.flags & 2097152 /* Conditional */) { + else if (source.flags & 4194304 /* Conditional */) { + if (target.flags & 4194304 /* Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. @@ -36643,14 +36830,14 @@ var ts; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. - var sourceIsPrimitive = !!(source.flags & 16382 /* Primitive */); + var sourceIsPrimitive = !!(source.flags & 32764 /* Primitive */); if (relation !== identityRelation) { source = getApparentType(source); } // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (source.flags & (65536 /* Object */ | 262144 /* Intersection */) && target.flags & 65536 /* Object */) { + if (source.flags & (131072 /* Object */ | 524288 /* Intersection */) && target.flags & 131072 /* Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; // An empty object type is related to any mapped type that includes a '?' modifier. @@ -36805,14 +36992,14 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo && resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); } - if (type.flags & 262144 /* Intersection */) { + if (type.flags & 524288 /* Intersection */) { return ts.every(type.types, isWeakType); } return false; @@ -36828,7 +37015,7 @@ var ts; return false; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 65536 /* Object */ && target.flags & 65536 /* Object */)) { + if (!(source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */)) { return 0 /* False */; } var sourceProperties = getPropertiesOfObjectType(source); @@ -36896,7 +37083,7 @@ var ts; // in the context of the target signature before checking the relationship. Ideally we'd do // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. - var eraseGenerics = relation === comparableRelation || compilerOptions.noStrictGenericChecks; + var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); } else { @@ -36952,7 +37139,7 @@ var ts; continue; } // Skip over symbol-named members - if (prop.nameType && prop.nameType.flags & 1024 /* UniqueESSymbol */) { + if (prop.nameType && prop.nameType.flags & 2048 /* UniqueESSymbol */) { continue; } if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { @@ -36980,7 +37167,7 @@ var ts; return indexTypesIdenticalTo(source, target, kind); } var targetInfo = getIndexInfoOfType(target, kind); - if (!targetInfo || targetInfo.type.flags & 1 /* Any */ && !sourceIsPrimitive) { + if (!targetInfo || targetInfo.type.flags & 3 /* AnyOrUnknown */ && !sourceIsPrimitive) { // Index signature of type any permits assignment from everything but primitives return -1 /* True */; } @@ -36992,7 +37179,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors); + return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -37102,17 +37289,17 @@ var ts; // See comment at call in recursiveTypeRelatedTo for when this case matters. function hasCovariantVoidArgument(type, variances) { for (var i = 0; i < variances.length; i++) { - if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 2048 /* Void */) { + if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 4096 /* Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 32768 /* TypeParameter */ && !getConstraintFromTypeParameter(type); + return type.flags & 65536 /* TypeParameter */ && !getConstraintFromTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -37202,13 +37389,13 @@ var ts; // levels, but unequal at some level beyond that. function isDeeplyNestedType(type, stack, depth) { // We track all object types that have an associated symbol (representing the origin of the type) - if (depth >= 5 && type.flags & 65536 /* Object */) { + if (depth >= 5 && type.flags & 131072 /* Object */) { var symbol = type.symbol; if (symbol) { var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 65536 /* Object */ && t.symbol === symbol) { + if (t.flags & 131072 /* Object */ && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -37356,9 +37543,9 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 12288 /* Nullable */); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 24576 /* Nullable */); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 12288 /* Nullable */) : + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 24576 /* Nullable */) : getUnionType(types, 2 /* Subtype */); } // Return the leftmost type for which no type to the right is a subtype. @@ -37366,13 +37553,13 @@ var ts; return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType; + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalArrayType; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray return ts.getObjectFlags(type) & 4 /* Reference */ && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || - !(type.flags & 12288 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + !(type.flags & 24576 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; @@ -37382,35 +37569,35 @@ var ts; return !!getPropertyOfType(type, "0"); } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (13536 /* Unit */ | 16384 /* Never */)); + return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); } function isUnitType(type) { - return !!(type.flags & 13536 /* Unit */); + return !!(type.flags & 27072 /* Unit */); } function isLiteralType(type) { - return type.flags & 8 /* Boolean */ ? true : - type.flags & 131072 /* Union */ ? type.flags & 256 /* EnumLiteral */ ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : + return type.flags & 16 /* Boolean */ ? true : + type.flags & 262144 /* Union */ ? type.flags & 512 /* EnumLiteral */ ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 256 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 32 /* StringLiteral */ ? stringType : - type.flags & 64 /* NumberLiteral */ ? numberType : - type.flags & 128 /* BooleanLiteral */ ? booleanType : - type.flags & 131072 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + return type.flags & 512 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 64 /* StringLiteral */ ? stringType : + type.flags & 128 /* NumberLiteral */ ? numberType : + type.flags & 256 /* BooleanLiteral */ ? booleanType : + type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { - return type.flags & 256 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 32 /* StringLiteral */ && type.flags & 8388608 /* FreshLiteral */ ? stringType : - type.flags & 64 /* NumberLiteral */ && type.flags & 8388608 /* FreshLiteral */ ? numberType : - type.flags & 128 /* BooleanLiteral */ ? booleanType : - type.flags & 131072 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + return type.flags & 512 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 64 /* StringLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? stringType : + type.flags & 128 /* NumberLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? numberType : + type.flags & 256 /* BooleanLiteral */ ? booleanType : + type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 1024 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 131072 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : + return type.flags & 2048 /* UniqueESSymbol */ ? esSymbolType : + type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -37438,27 +37625,27 @@ var ts; // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns // no flags for all other types (including non-falsy literal types). function getFalsyFlags(type) { - return type.flags & 131072 /* Union */ ? getFalsyFlagsOfTypes(type.types) : - type.flags & 32 /* StringLiteral */ ? type.value === "" ? 32 /* StringLiteral */ : 0 : - type.flags & 64 /* NumberLiteral */ ? type.value === 0 ? 64 /* NumberLiteral */ : 0 : - type.flags & 128 /* BooleanLiteral */ ? type === falseType ? 128 /* BooleanLiteral */ : 0 : - type.flags & 14574 /* PossiblyFalsy */; + return type.flags & 262144 /* Union */ ? getFalsyFlagsOfTypes(type.types) : + type.flags & 64 /* StringLiteral */ ? type.value === "" ? 64 /* StringLiteral */ : 0 : + type.flags & 128 /* NumberLiteral */ ? type.value === 0 ? 128 /* NumberLiteral */ : 0 : + type.flags & 256 /* BooleanLiteral */ ? type === falseType ? 256 /* BooleanLiteral */ : 0 : + type.flags & 29148 /* PossiblyFalsy */; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 14560 /* DefinitelyFalsy */ ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 14560 /* DefinitelyFalsy */); }) : + return getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 29120 /* DefinitelyFalsy */); }) : type; } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 2 /* String */ ? emptyStringType : - type.flags & 4 /* Number */ ? zeroType : - type.flags & 8 /* Boolean */ || type === falseType ? falseType : - type.flags & (2048 /* Void */ | 4096 /* Undefined */ | 8192 /* Null */) || - type.flags & 32 /* StringLiteral */ && type.value === "" || - type.flags & 64 /* NumberLiteral */ && type.value === 0 ? type : + return type.flags & 4 /* String */ ? emptyStringType : + type.flags & 8 /* Number */ ? zeroType : + type.flags & 16 /* Boolean */ || type === falseType ? falseType : + type.flags & (4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */) || + type.flags & 64 /* StringLiteral */ && type.value === "" || + type.flags & 128 /* NumberLiteral */ && type.value === 0 ? type : neverType; } /** @@ -37467,15 +37654,15 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (4096 /* Undefined */ | 8192 /* Null */); + var missing = (flags & ~type.flags) & (8192 /* Undefined */ | 16384 /* Null */); return missing === 0 ? type : - missing === 4096 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 8192 /* Null */ ? getUnionType([type, nullType]) : + missing === 8192 /* Undefined */ ? getUnionType([type, undefinedType]) : + missing === 16384 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type) { ts.Debug.assert(strictNullChecks); - return type.flags & 4096 /* Undefined */ ? type : getUnionType([type, undefinedType]); + return type.flags & 8192 /* Undefined */ ? type : getUnionType([type, undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { @@ -37528,7 +37715,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && type.flags & 8388608 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && type.flags & 33554432 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -37538,7 +37725,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~8388608 /* FreshLiteral */; + regularNew.flags = resolved.flags & ~33554432 /* FreshLiteral */; regularNew.objectFlags |= 128 /* ObjectLiteral */; type.regularType = regularNew; return regularNew; @@ -37620,16 +37807,16 @@ var ts; return getWidenedTypeWithContext(type, /*context*/ undefined); } function getWidenedTypeWithContext(type, context) { - if (type.flags & 50331648 /* RequiresWidening */) { - if (type.flags & 12288 /* Nullable */) { + if (type.flags & 402653184 /* RequiresWidening */) { + if (type.flags & 24576 /* Nullable */) { return anyType; } if (isObjectLiteralType(type)) { return getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 12288 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 24576 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). @@ -37654,8 +37841,8 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (type.flags & 16777216 /* ContainsWideningType */) { - if (type.flags & 131072 /* Union */) { + if (type.flags & 134217728 /* ContainsWideningType */) { + if (type.flags & 262144 /* Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -37680,7 +37867,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 16777216 /* ContainsWideningType */) { + if (t.flags & 134217728 /* ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -37695,33 +37882,33 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 199 /* BinaryExpression */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 200 /* BinaryExpression */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 148 /* Parameter */: + case 149 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 181 /* BindingElement */: + case 182 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 176 /* MappedType */: + case 177 /* MappedType */: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -37730,7 +37917,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && noImplicitAny && type.flags & 16777216 /* ContainsWideningType */) { + if (produceDiagnostics && noImplicitAny && type.flags & 134217728 /* ContainsWideningType */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -37803,26 +37990,26 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - return !!(type.flags & 7897088 /* Instantiable */ || + return !!(type.flags & 15794176 /* Instantiable */ || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) || objectFlags & 32 /* Mapped */ || - type.flags & 393216 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 786432 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { - type.couldContainTypeVariables = ts.forEach(type.types, couldContainTypeVariables); + type.couldContainTypeVariables = ts.some(type.types, couldContainTypeVariables); } return type.couldContainTypeVariables; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || type.flags & 393216 /* UnionOrIntersection */ && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || !!(type.flags & 786432 /* UnionOrIntersection */) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); } /** Create an object with properties named in the string literal type. Every property has type `any` */ function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 32 /* StringLiteral */)) { + if (!(t.flags & 64 /* StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); @@ -37834,7 +38021,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfo = type.flags & 2 /* String */ ? createIndexInfo(emptyObjectType, /*isReadonly*/ false) : undefined; + var indexInfo = type.flags & 4 /* String */ ? createIndexInfo(emptyObjectType, /*isReadonly*/ false) : undefined; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfo, undefined); } /** @@ -37862,7 +38049,7 @@ var ts; // is incomplete and we can't infer a meaningful input type. for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; - if (getTypeOfSymbol(prop).flags & 67108864 /* ContainsAnyFunctionType */) { + if (getTypeOfSymbol(prop).flags & 536870912 /* ContainsAnyFunctionType */) { return undefined; } } @@ -37882,7 +38069,7 @@ var ts; return getTypeFromInference(inference); } function getUnmatchedProperty(source, target, requireOptionalProperties) { - var properties = target.flags & 262144 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); + var properties = target.flags & 524288 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { var targetProp = properties_5[_i]; if (requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */)) { @@ -37936,8 +38123,8 @@ var ts; } return; } - if (source.flags & 131072 /* Union */ && target.flags & 131072 /* Union */ && !(source.flags & 256 /* EnumLiteral */ && target.flags & 256 /* EnumLiteral */) || - source.flags & 262144 /* Intersection */ && target.flags & 262144 /* Intersection */) { + if (source.flags & 262144 /* Union */ && target.flags & 262144 /* Union */ && !(source.flags & 512 /* EnumLiteral */ && target.flags & 512 /* EnumLiteral */) || + source.flags & 524288 /* Intersection */ && target.flags & 524288 /* Intersection */) { // Source and target are both unions or both intersections. If source and target // are the same type, just relate each constituent type to itself. if (source === target) { @@ -37960,7 +38147,7 @@ var ts; (matchingTypes || (matchingTypes = [])).push(t); inferFromTypes(t, t); } - else if (t.flags & (64 /* NumberLiteral */ | 32 /* StringLiteral */)) { + else if (t.flags & (128 /* NumberLiteral */ | 64 /* StringLiteral */)) { var b = getBaseTypeOfLiteralType(t); if (typeIdenticalToSomeType(b, target.types)) { (matchingTypes || (matchingTypes = [])).push(t, b); @@ -37975,7 +38162,7 @@ var ts; target = removeTypesFromUnionOrIntersection(target, matchingTypes); } } - if (target.flags & 1081344 /* TypeVariable */) { + if (target.flags & 2162688 /* TypeVariable */) { // If target is a type parameter, make an inference, unless the source type contains // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). // Because the anyFunctionType is internal, it should not be exposed to the user by adding @@ -37983,7 +38170,7 @@ 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 (source.flags & 67108864 /* ContainsAnyFunctionType */ || source === silentNeverType) { + if (source.flags & 536870912 /* ContainsAnyFunctionType */ || source === silentNeverType) { return; } var inference = getInferenceInfoForType(target); @@ -38003,7 +38190,7 @@ var ts; inference.candidates = ts.append(inference.candidates, candidate); } } - if (!(priority & 8 /* ReturnType */) && target.flags & 32768 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 8 /* ReturnType */) && target.flags & 65536 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; } } @@ -38025,12 +38212,12 @@ var ts; } } } - else if (source.flags & 524288 /* Index */ && target.flags & 524288 /* Index */) { + else if (source.flags & 1048576 /* Index */ && target.flags & 1048576 /* Index */) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 2 /* String */) && target.flags & 524288 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 1048576 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; var savePriority = priority; @@ -38039,17 +38226,17 @@ var ts; priority = savePriority; contravariant = !contravariant; } - else if (source.flags & 1048576 /* IndexedAccess */ && target.flags & 1048576 /* IndexedAccess */) { + else if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 2097152 /* Conditional */ && target.flags & 2097152 /* Conditional */) { + else if (source.flags & 4194304 /* Conditional */ && target.flags & 4194304 /* Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } - else if (target.flags & 393216 /* UnionOrIntersection */) { + else if (target.flags & 786432 /* UnionOrIntersection */) { var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; @@ -38074,7 +38261,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 131072 /* Union */) { + else if (source.flags & 262144 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { @@ -38083,10 +38270,10 @@ var ts; } } else { - if (!(priority & 32 /* NoConstraints */ && source.flags & (262144 /* Intersection */ | 7897088 /* Instantiable */))) { + if (!(priority & 32 /* NoConstraints */ && source.flags & (524288 /* Intersection */ | 15794176 /* Instantiable */))) { source = getApparentType(source); } - if (source.flags & (65536 /* Object */ | 262144 /* Intersection */)) { + if (source.flags & (131072 /* Object */ | 524288 /* Intersection */)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -38096,7 +38283,7 @@ var ts; // an instantiation of the same generic type), we do not explore this target as it would yield // no further inferences. We exclude the static side of classes from this check since it shares // its symbol with the instance side which would lead to false positives. - var isNonConstructorObject = target.flags & 65536 /* Object */ && + var isNonConstructorObject = target.flags & 131072 /* Object */ && !(ts.getObjectFlags(target) & 16 /* Anonymous */ && target.symbol && target.symbol.flags & 32 /* Class */); var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { @@ -38124,7 +38311,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 1081344 /* TypeVariable */) { + if (type.flags & 2162688 /* TypeVariable */) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { var inference = inferences_1[_i]; if (type === inference.typeParameter) { @@ -38143,7 +38330,7 @@ var ts; } if (ts.getObjectFlags(target) & 32 /* Mapped */) { var constraintType = getConstraintTypeFromMappedType(target); - if (constraintType.flags & 524288 /* Index */) { + if (constraintType.flags & 1048576 /* Index */) { // We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X }, // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference @@ -38160,7 +38347,7 @@ var ts; } return; } - if (constraintType.flags & 32768 /* TypeParameter */) { + if (constraintType.flags & 65536 /* TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. var savePriority = priority; @@ -38251,11 +38438,11 @@ var ts; reducedTypes.push(t); } } - return type.flags & 131072 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 262144 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return constraint && maybeTypeOfKind(constraint, 16382 /* Primitive */ | 524288 /* Index */); + return !!constraint && maybeTypeOfKind(constraint, 32764 /* Primitive */ | 1048576 /* Index */); } function isObjectLiteralType(type) { return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); @@ -38280,10 +38467,12 @@ var ts; // all inferences were made to top-level occurrences of the type parameter, and // the type parameter has no constraint or its constraint includes no primitive or literal types, and // the type parameter was fixed during inference or does not occur at top-level in the return type. - var widenLiteralTypes = inference.topLevel && - !hasPrimitiveConstraint(inference.typeParameter) && + var primitiveConstraint = hasPrimitiveConstraint(inference.typeParameter); + var widenLiteralTypes = !primitiveConstraint && inference.topLevel && (inference.isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), inference.typeParameter)); - var baseCandidates = widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) : candidates; + var baseCandidates = primitiveConstraint ? ts.sameMap(candidates, getRegularTypeOfLiteralType) : + widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) : + candidates; // If all inferences were made from contravariant positions, infer a common subtype. Otherwise, if // union types were requested or if all inferences were made from the return type position, infer a // union type. Otherwise, infer a common supertype. @@ -38302,7 +38491,7 @@ var ts; inferredType = getCovariantInference(inference, context, signature); // If we have inferred 'never' but have contravariant candidates. To get a more specific type we // infer from the contravariant candidates instead. - if (inferredType.flags & 16384 /* Never */ && inference.contraCandidates) { + if (inferredType.flags & 32768 /* Never */ && inference.contraCandidates) { inferredType = getContravariantInference(inference); } } @@ -38369,7 +38558,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 164 /* TypeQuery */ ? true : n.kind === 71 /* Identifier */ || n.kind === 145 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 165 /* TypeQuery */ ? true : n.kind === 71 /* Identifier */ || n.kind === 146 /* 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 @@ -38385,13 +38574,13 @@ var ts; if (node.kind === 99 /* ThisKeyword */) { return "0"; } - if (node.kind === 184 /* PropertyAccessExpression */) { + if (node.kind === 185 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 181 /* BindingElement */) { + if (node.kind === 182 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 181 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 182 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -38399,12 +38588,13 @@ var ts; return undefined; } function getBindingElementNameText(element) { - if (element.parent.kind === 179 /* ObjectBindingPattern */) { + var parent = element.parent; + if (parent.kind === 180 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { case 71 /* Identifier */: return ts.idText(name); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return ts.isStringOrNumericLiteral(name.expression) ? name.expression.text : undefined; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -38415,41 +38605,41 @@ var ts; } } else { - return "" + element.parent.elements.indexOf(element); + return "" + parent.elements.indexOf(element); } } function isMatchingReference(source, target) { switch (source.kind) { case 71 /* Identifier */: return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 231 /* VariableDeclaration */ || target.kind === 181 /* BindingElement */) && + (target.kind === 232 /* VariableDeclaration */ || target.kind === 182 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99 /* ThisKeyword */: return target.kind === 99 /* ThisKeyword */; case 97 /* SuperKeyword */: return target.kind === 97 /* SuperKeyword */; - case 184 /* PropertyAccessExpression */: - return target.kind === 184 /* PropertyAccessExpression */ && + case 185 /* PropertyAccessExpression */: + return target.kind === 185 /* PropertyAccessExpression */ && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 181 /* BindingElement */: - if (target.kind !== 184 /* PropertyAccessExpression */) + case 182 /* BindingElement */: + if (target.kind !== 185 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 181 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 182 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 231 /* VariableDeclaration */) { + if (source.parent.parent.kind === 232 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; - return maybeId && isMatchingReference(maybeId, t.expression); + return !!maybeId && isMatchingReference(maybeId, t.expression); } } return false; } function containsMatchingReference(source, target) { - while (source.kind === 184 /* PropertyAccessExpression */) { + while (source.kind === 185 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -38462,7 +38652,7 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 184 /* PropertyAccessExpression */ && + return target.kind === 185 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -38470,18 +38660,18 @@ var ts; if (expr.kind === 71 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 184 /* PropertyAccessExpression */) { + if (expr.kind === 185 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } return undefined; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 131072 /* Union */) { + if (type && type.flags & 262144 /* Union */) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.checkFlags & 32 /* HasNonUniformType */ && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = !!(prop.checkFlags & 32 /* HasNonUniformType */) && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -38514,7 +38704,7 @@ var ts; } } } - if (callExpression.expression.kind === 184 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 185 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -38528,7 +38718,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 131072 /* Union */)) { + if (!(source.flags & 262144 /* Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -38544,11 +38734,11 @@ var ts; // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 16384 /* Never */) { + if (assignedType.flags & 32768 /* Never */) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (!(reducedType.flags & 16384 /* Never */)) { + if (!(reducedType.flags & 32768 /* Never */)) { return reducedType; } } @@ -38571,53 +38761,53 @@ var ts; } function getTypeFacts(type) { var flags = type.flags; - if (flags & 2 /* String */) { + if (flags & 4 /* String */) { return strictNullChecks ? 4079361 /* StringStrictFacts */ : 4194049 /* StringFacts */; } - if (flags & 32 /* StringLiteral */) { + if (flags & 64 /* StringLiteral */) { var isEmpty = type.value === ""; return strictNullChecks ? isEmpty ? 3030785 /* EmptyStringStrictFacts */ : 1982209 /* NonEmptyStringStrictFacts */ : isEmpty ? 3145473 /* EmptyStringFacts */ : 4194049 /* NonEmptyStringFacts */; } - if (flags & (4 /* Number */ | 16 /* Enum */)) { + if (flags & (8 /* Number */ | 32 /* Enum */)) { return strictNullChecks ? 4079234 /* NumberStrictFacts */ : 4193922 /* NumberFacts */; } - if (flags & 64 /* NumberLiteral */) { + if (flags & 128 /* NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? isZero ? 3030658 /* ZeroStrictFacts */ : 1982082 /* NonZeroStrictFacts */ : isZero ? 3145346 /* ZeroFacts */ : 4193922 /* NonZeroFacts */; } - if (flags & 8 /* Boolean */) { + if (flags & 16 /* Boolean */) { return strictNullChecks ? 4078980 /* BooleanStrictFacts */ : 4193668 /* BooleanFacts */; } - if (flags & 136 /* BooleanLike */) { + if (flags & 272 /* BooleanLike */) { return strictNullChecks ? type === falseType ? 3030404 /* FalseStrictFacts */ : 1981828 /* TrueStrictFacts */ : type === falseType ? 3145092 /* FalseFacts */ : 4193668 /* TrueFacts */; } - if (flags & 65536 /* Object */) { + if (flags & 131072 /* Object */) { return isFunctionObjectType(type) ? strictNullChecks ? 1970144 /* FunctionStrictFacts */ : 4181984 /* FunctionFacts */ : strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; } - if (flags & (2048 /* Void */ | 4096 /* Undefined */)) { + if (flags & (4096 /* Void */ | 8192 /* Undefined */)) { return 2457472 /* UndefinedFacts */; } - if (flags & 8192 /* Null */) { + if (flags & 16384 /* Null */) { return 2340752 /* NullFacts */; } - if (flags & 1536 /* ESSymbolLike */) { + if (flags & 3072 /* ESSymbolLike */) { return strictNullChecks ? 1981320 /* SymbolStrictFacts */ : 4193160 /* SymbolFacts */; } - if (flags & 134217728 /* NonPrimitive */) { + if (flags & 16777216 /* NonPrimitive */) { return strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; } - if (flags & 7897088 /* Instantiable */) { + if (flags & 15794176 /* Instantiable */) { return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } - if (flags & 393216 /* UnionOrIntersection */) { + if (flags & 786432 /* UnionOrIntersection */) { return getTypeFactsOfTypes(type.types); } return 4194303 /* All */; @@ -38637,26 +38827,26 @@ var ts; return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || isNumericLiteralName(text) && getIndexTypeOfType(type, 1 /* Number */) || getIndexTypeOfType(type, 0 /* String */) || - unknownType; + errorType; } function getTypeOfDestructuredArrayElement(type, index) { return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || - unknownType; + errorType; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType); + return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 182 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 269 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 183 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 270 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 199 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 221 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 200 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 222 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -38673,29 +38863,29 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return stringType; - case 221 /* ForOfStatement */: - return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || unknownType; - case 199 /* BinaryExpression */: + case 222 /* ForOfStatement */: + return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; + case 200 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return undefinedType; - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } - return unknownType; + return errorType; } function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 179 /* ObjectBindingPattern */ ? + var type = pattern.kind === 180 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -38713,35 +38903,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 220 /* ForInStatement */) { + if (node.parent.parent.kind === 221 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 221 /* ForOfStatement */) { - return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || unknownType; + if (node.parent.parent.kind === 222 /* ForOfStatement */) { + return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } - return unknownType; + return errorType; } function getInitialType(node) { - return node.kind === 231 /* VariableDeclaration */ ? + return node.kind === 232 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 231 /* VariableDeclaration */ || node.kind === 181 /* BindingElement */ ? + return node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 231 /* VariableDeclaration */ && node.initializer && + return node.kind === 232 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 181 /* BindingElement */ && node.parent.kind === 199 /* BinaryExpression */ && + node.kind !== 182 /* BindingElement */ && node.parent.kind === 200 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: switch (node.operatorToken.kind) { case 58 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -38753,13 +38943,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 190 /* ParenthesizedExpression */ || - parent.kind === 199 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || - parent.kind === 199 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? + return parent.kind === 191 /* ParenthesizedExpression */ || + parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || + parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 265 /* CaseClause */) { + if (clause.kind === 266 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -38776,13 +38966,13 @@ var ts; return links.switchTypes; } function eachTypeContainedIn(source, types) { - return source.flags & 131072 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 262144 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 131072 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 262144 /* Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 131072 /* Union */) { + if (source.flags & 262144 /* Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -38791,30 +38981,27 @@ var ts; } return true; } - if (source.flags & 256 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 512 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 131072 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 262144 /* Union */ ? ts.forEach(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 268435456 /* UnionOfUnitTypes */); + return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 67108864 /* UnionOfUnitTypes */); } return f(type) ? type : neverType; } - // Apply a mapping function to a type and return the resulting type. If the source type - // is a union type, the mapping function is applied to each constituent type and a union - // of the resulting types is returned. function mapType(type, mapper, noReductions) { - if (type.flags & 16384 /* Never */) { + if (type.flags & 32768 /* Never */) { return type; } - if (!(type.flags & 131072 /* Union */)) { + if (!(type.flags & 262144 /* Union */)) { return mapper(type); } var types = type.types; @@ -38844,11 +39031,11 @@ var ts; // typeWithPrimitives have been replaced with occurrences of string literals and numeric // literals in typeWithLiterals, respectively. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 32 /* StringLiteral */) || - isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64 /* NumberLiteral */)) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64 /* StringLiteral */) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* NumberLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 2 /* String */ ? extractTypesOfKind(typeWithLiterals, 2 /* String */ | 32 /* StringLiteral */) : - t.flags & 4 /* Number */ ? extractTypesOfKind(typeWithLiterals, 4 /* Number */ | 64 /* NumberLiteral */) : + return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 64 /* StringLiteral */) : + t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 128 /* NumberLiteral */) : t; }); } @@ -38883,9 +39070,9 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 16384 /* Never */ ? + return elementType.flags & 32768 /* Never */ ? autoArrayType : - createArrayType(elementType.flags & 131072 /* Union */ ? + createArrayType(elementType.flags & 262144 /* Union */ ? getUnionType(elementType.types, 2 /* Subtype */) : elementType); } @@ -38903,7 +39090,7 @@ var ts; var hasEvolvingArrayType = false; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var t = types_14[_i]; - if (!(t.flags & 16384 /* Never */)) { + if (!(t.flags & 32768 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; } @@ -38925,15 +39112,15 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 184 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 186 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 185 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 185 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 187 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 186 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 199 /* BinaryExpression */ && + parent.parent.kind === 200 /* BinaryExpression */ && parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 84 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 168 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -38948,7 +39135,7 @@ var ts; var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); - return apparentType !== unknownType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); + return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); } } return false; @@ -38964,9 +39151,9 @@ var ts; var key; var flowDepth = 0; if (flowAnalysisDisabled) { - return unknownType; + return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 142575359 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 33492479 /* Narrowable */)) { return declaredType; } var sharedFlowStart = sharedFlowCount; @@ -38977,7 +39164,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) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 208 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 16384 /* Never */) { + if (reference.parent && reference.parent.kind === 209 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { return declaredType; } return resultType; @@ -38987,7 +39174,7 @@ var ts; // and disable further control flow analysis in the containing function or module body. flowAnalysisDisabled = true; reportFlowControlError(reference); - return unknownType; + return errorType; } flowDepth++; while (true) { @@ -39048,7 +39235,7 @@ var ts; else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 184 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { + if (container && container !== flowContainer && reference.kind !== 185 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -39086,7 +39273,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 131072 /* Union */) { + if (declaredType.flags & 262144 /* Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); } return declaredType; @@ -39104,7 +39291,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 186 /* CallExpression */ ? + var expr = node.kind === 187 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -39112,7 +39299,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 186 /* CallExpression */) { + if (node.kind === 187 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -39120,7 +39307,7 @@ var ts; } else { var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 84 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 168 /* NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -39134,7 +39321,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 16384 /* Never */) { + if (type.flags & 32768 /* Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -39151,7 +39338,7 @@ var ts; return flowType; } var incomplete = isIncomplete(flowType); - var resultType = incomplete && narrowedType.flags & 16384 /* Never */ ? silentNeverType : narrowedType; + var resultType = incomplete && narrowedType.flags & 32768 /* Never */ ? silentNeverType : narrowedType; return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { @@ -39277,8 +39464,8 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 184 /* PropertyAccessExpression */ && - computedType.flags & 131072 /* Union */ && + return expr.kind === 185 /* PropertyAccessExpression */ && + computedType.flags & 262144 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); } @@ -39311,7 +39498,7 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if ((type.flags & (131072 /* Union */ | 65536 /* Object */)) || (type.flags & 32768 /* TypeParameter */ && type.isThisType)) { + if ((type.flags & (262144 /* Union */ | 131072 /* Object */)) || (type.flags & 65536 /* TypeParameter */ && type.isThisType)) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); }); } @@ -39328,10 +39515,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 194 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 194 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -39371,24 +39558,24 @@ var ts; assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (valueType.flags & 12288 /* Nullable */) { + if (valueType.flags & 24576 /* Nullable */) { if (!strictNullChecks) { return type; } var doubleEquals = operator === 32 /* EqualsEqualsToken */ || operator === 33 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ : - valueType.flags & 8192 /* Null */ ? + valueType.flags & 16384 /* Null */ ? assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ : assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 134283777 /* NotUnionOrUnit */) { + if (type.flags & 16909315 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 16384 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); + return narrowedType.flags & 32768 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -39410,16 +39597,19 @@ var ts; if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } - if (assumeTrue && !(type.flags & 131072 /* Union */)) { + if (type.flags & 1 /* Any */ && literal.text === "function") { + return type; + } + if (assumeTrue && !(type.flags & 262144 /* Union */)) { // We narrow a non-union type to an exact primitive type if the non-union type // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. - var targetType = typeofTypesByName.get(literal.text); + var targetType = literal.text === "function" ? globalFunctionType : typeofTypesByName.get(literal.text); if (targetType) { if (isTypeSubtypeOf(targetType, type)) { return targetType; } - if (type.flags & 7897088 /* Instantiable */) { + if (type.flags & 15794176 /* Instantiable */) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(targetType, constraint)) { return getIntersectionType([type, targetType]); @@ -39441,13 +39631,13 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 16384 /* Never */ ? neverType : + var caseType = discriminantType.flags & 32768 /* Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); - return caseType.flags & 16384 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 32768 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); } function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); @@ -39501,9 +39691,9 @@ var ts; } // If the current type is a union type, remove all constituents that couldn't be instances of // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 16384 /* Never */)) { + if (!(assignableType.flags & 32768 /* Never */)) { return assignableType; } } @@ -39543,7 +39733,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 185 /* ElementAccessExpression */ || invokedExpression.kind === 184 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 186 /* ElementAccessExpression */ || invokedExpression.kind === 185 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -39563,15 +39753,15 @@ var ts; case 71 /* Identifier */: case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: if (expr.operator === 51 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -39607,9 +39797,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 239 /* ModuleBlock */ || - node.kind === 273 /* SourceFile */ || - node.kind === 151 /* PropertyDeclaration */; + node.kind === 240 /* ModuleBlock */ || + node.kind === 274 /* SourceFile */ || + node.kind === 152 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -39631,7 +39821,7 @@ var ts; if (node.kind === 71 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 148 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 149 /* Parameter */) { symbol.isAssigned = true; } } @@ -39646,21 +39836,21 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 148 /* Parameter */ && + declaration.kind === 149 /* Parameter */ && declaration.initializer && - getFalsyFlags(declaredType) & 4096 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 4096 /* Undefined */); + getFalsyFlags(declaredType) & 8192 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 8192 /* Undefined */); return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072 /* NEUndefined */) : declaredType; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 184 /* PropertyAccessExpression */ || - parent.kind === 186 /* CallExpression */ && parent.expression === node || - parent.kind === 185 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 181 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 185 /* PropertyAccessExpression */ || + parent.kind === 187 /* CallExpression */ && parent.expression === node || + parent.kind === 186 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 182 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { - return type.flags & 7372800 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 12288 /* Nullable */); + return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); } function getConstraintForLocation(type, node) { // When a node is the left hand expression of a property access, element access, or call expression, @@ -39680,7 +39870,7 @@ var ts; function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { - return unknownType; + return errorType; } // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. // Although in down-level emit of arrow function, we emit it using function expression which means that @@ -39691,7 +39881,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 192 /* ArrowFunction */) { + if (container.kind === 193 /* 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.hasModifier(container, 256 /* Async */)) { @@ -39712,7 +39902,7 @@ var ts; // 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 === 234 /* ClassDeclaration */ + if (declaration.kind === 235 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -39724,14 +39914,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 204 /* ClassExpression */) { + else if (declaration.kind === 205 /* 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 !== undefined) { + while (container.kind !== 274 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 151 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -39748,11 +39938,11 @@ var ts; if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(ts.isInJavaScriptFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); - return unknownType; + return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(symbol)); - return unknownType; + return errorType; } } var isAlias = localOrExportSymbol.flags & 2097152 /* Alias */; @@ -39775,7 +39965,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 148 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 149 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -39783,8 +39973,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 === 191 /* FunctionExpression */ || - flowContainer.kind === 192 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 192 /* FunctionExpression */ || + flowContainer.kind === 193 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -39792,10 +39982,10 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAsignmentTarget || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 251 /* ExportSpecifier */) || - node.parent.kind === 208 /* NonNullExpression */ || - declaration.kind === 231 /* VariableDeclaration */ && declaration.exclamationToken || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || + isInTypeQuery(node) || node.parent.kind === 252 /* ExportSpecifier */) || + node.parent.kind === 209 /* NonNullExpression */ || + declaration.kind === 232 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -39813,7 +40003,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 4096 /* Undefined */) && getFalsyFlags(flowType) & 4096 /* Undefined */) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); // Return the declared type to reduce follow-on errors return type; @@ -39826,7 +40016,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 268 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 269 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -39851,8 +40041,8 @@ var ts; } // 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 (container.kind === 219 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 232 /* VariableDeclarationList */).parent === container && + if (container.kind === 220 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 233 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -39866,7 +40056,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 190 /* ParenthesizedExpression */) { + while (current.parent.kind === 191 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -39874,7 +40064,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 197 /* PrefixUnaryExpression */ || current.parent.kind === 198 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 198 /* PrefixUnaryExpression */ || current.parent.kind === 199 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; } @@ -39887,7 +40077,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 151 /* PropertyDeclaration */ || container.kind === 154 /* Constructor */) { + if (container.kind === 152 /* PropertyDeclaration */ || container.kind === 155 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -39955,38 +40145,38 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 154 /* Constructor */) { + if (container.kind === 155 /* 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 === 192 /* ArrowFunction */) { + if (container.kind === 193 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES2015 */); } switch (container.kind) { - case 238 /* ModuleDeclaration */: + case 239 /* 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 237 /* EnumDeclaration */: + case 238 /* 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 154 /* Constructor */: + case 155 /* 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 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { 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 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -40007,8 +40197,8 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } - if (container.kind === 191 /* FunctionExpression */ && - container.parent.kind === 199 /* BinaryExpression */ && + if (container.kind === 192 /* FunctionExpression */ && + container.parent.kind === 200 /* BinaryExpression */ && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') var className = container.parent // x.prototype.y = f @@ -40032,14 +40222,14 @@ var ts; } if (ts.isInJavaScriptFile(node)) { var type = getTypeForThisExpressionFromJSDoc(container); - if (type && type !== unknownType) { + if (type && type !== errorType) { return getFlowTypeOfReference(node, type); } } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 283 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 284 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -40049,15 +40239,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 148 /* Parameter */; }); + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 186 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 187 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); 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 === 192 /* ArrowFunction */) { + while (container && container.kind === 193 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -40070,22 +40260,22 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 146 /* ComputedPropertyName */; }); - if (current && current.kind === 146 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 147 /* ComputedPropertyName */; }); + if (current && current.kind === 147 /* 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 === 183 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 184 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); } - return unknownType; + return errorType; } - if (!isCallExpression && container.kind === 154 /* Constructor */) { + if (!isCallExpression && container.kind === 155 /* 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.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -40151,7 +40341,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 153 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 154 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -40165,10 +40355,10 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 183 /* ObjectLiteralExpression */) { + if (container.parent.kind === 184 /* 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 unknownType; + return errorType; } else { // for object literal assume that type of 'super' is 'any' @@ -40179,17 +40369,17 @@ var ts; var classLikeDeclaration = container.parent; if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); - return unknownType; + return errorType; } var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classLikeDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; if (!baseClassType) { - return unknownType; + return errorType; } - if (container.kind === 154 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 155 /* 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 unknownType; + return errorType; } return nodeCheckFlag === 512 /* SuperStatic */ ? getBaseConstructorTypeOfClass(classType) @@ -40201,7 +40391,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 === 154 /* Constructor */; + return container.kind === 155 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -40209,21 +40399,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 === 183 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 184 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 153 /* MethodDeclaration */ || - container.kind === 152 /* MethodSignature */ || - container.kind === 155 /* GetAccessor */ || - container.kind === 156 /* SetAccessor */; + return container.kind === 154 /* MethodDeclaration */ || + container.kind === 153 /* MethodSignature */ || + container.kind === 156 /* GetAccessor */ || + container.kind === 157 /* SetAccessor */; } else { - return container.kind === 153 /* MethodDeclaration */ || - container.kind === 152 /* MethodSignature */ || - container.kind === 155 /* GetAccessor */ || - container.kind === 156 /* SetAccessor */ || - container.kind === 151 /* PropertyDeclaration */ || - container.kind === 150 /* PropertySignature */ || - container.kind === 154 /* Constructor */; + return container.kind === 154 /* MethodDeclaration */ || + container.kind === 153 /* MethodSignature */ || + container.kind === 156 /* GetAccessor */ || + container.kind === 157 /* SetAccessor */ || + container.kind === 152 /* PropertyDeclaration */ || + container.kind === 151 /* PropertySignature */ || + container.kind === 155 /* Constructor */; } } } @@ -40231,10 +40421,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 153 /* MethodDeclaration */ || - func.kind === 155 /* GetAccessor */ || - func.kind === 156 /* SetAccessor */) && func.parent.kind === 183 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 191 /* FunctionExpression */ && func.parent.kind === 269 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 154 /* MethodDeclaration */ || + func.kind === 156 /* GetAccessor */ || + func.kind === 157 /* SetAccessor */) && func.parent.kind === 184 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 192 /* FunctionExpression */ && func.parent.kind === 270 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -40242,11 +40432,11 @@ var ts; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 262144 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 524288 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 192 /* ArrowFunction */) { + if (func.kind === 193 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -40273,7 +40463,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 269 /* PropertyAssignment */) { + if (literal.parent.kind !== 270 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -40287,9 +40477,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 199 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { var target = parent.left; - if (target.kind === 184 /* PropertyAccessExpression */ || target.kind === 185 /* ElementAccessExpression */) { + if (target.kind === 185 /* PropertyAccessExpression */ || target.kind === 186 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -40345,7 +40535,7 @@ var ts; if (funcHasRestParameters && indexOfParameter === (func.parameters.length - 1) && isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); + return getTypeOfSymbol(ts.last(contextualSignature.parameters)); } } } @@ -40364,7 +40554,7 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 148 /* Parameter */) { + if (declaration.kind === 149 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -40376,7 +40566,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 181 /* BindingElement */) { + if (parentDeclaration.kind !== 182 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -40432,7 +40622,7 @@ var ts; function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed - if (functionDecl.kind === 154 /* Constructor */ || + if (functionDecl.kind === 155 /* Constructor */ || ts.getEffectiveReturnTypeNode(functionDecl) || isGetAccessorWithAnnotatedSetAccessor(functionDecl)) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); @@ -40447,7 +40637,7 @@ var ts; } // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. function getContextualTypeForArgument(callTarget, arg) { - var args = getEffectiveCallArguments(callTarget); + var args = getEffectiveCallArguments(callTarget); // TODO: GH#18217 var argIndex = args.indexOf(arg); // -1 for e.g. the expression of a CallExpression, or the tag of a TaggedTemplateExpression return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex); } @@ -40458,7 +40648,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 188 /* TaggedTemplateExpression */) { + if (template.parent.kind === 189 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -40474,7 +40664,7 @@ var ts; // expression has no contextual type, the right operand is contextually typed by the type of the left operand, // except for the special case of Javascript declarations of the form `namespace.prop = namespace.prop || {}` var type = getContextualType(binaryExpression); - return !type && node === right && !ts.getDeclaredJavascriptInitializer(binaryExpression.parent) && !ts.getAssignedJavascriptInitializer(binaryExpression) ? + return !type && node === right && !ts.isDefaultedJavascriptInitializer(binaryExpression) ? getTypeOfExpression(left) : type; case 53 /* AmpersandAmpersandToken */: case 26 /* CommaToken */: @@ -40501,12 +40691,12 @@ var ts; case 6 /* Prototype */: return false; default: - ts.Debug.assertNever(kind); + return ts.Debug.assertNever(kind); } } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 458752 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; + var prop = t.flags & 917504 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }, /*noReductions*/ true); } @@ -40515,7 +40705,7 @@ var ts; } // Return true if the given contextual type is a tuple-like type function contextualTypeIsTupleLikeType(type) { - return !!(type.flags & 131072 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); + return !!(type.flags & 262144 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one @@ -40590,12 +40780,31 @@ var ts; return getContextualType(attribute.parent); } } + // Return true if the given expression is possibly a discriminant value. We limit the kinds of + // expressions we check to those that don't depend on their contextual type in order not to cause + // recursive (and possibly infinite) invocations of getContextualType. + function isPossiblyDiscriminantValue(node) { + switch (node.kind) { + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: + case 95 /* NullKeyword */: + case 71 /* Identifier */: + return true; + case 185 /* PropertyAccessExpression */: + case 191 /* ParenthesizedExpression */: + return isPossiblyDiscriminantValue(node.expression); + } + return false; + } // 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. function getApparentTypeOfContextualType(node) { var contextualType = getContextualType(node); contextualType = contextualType && mapType(contextualType, getApparentType); - if (!(contextualType && contextualType.flags & 131072 /* Union */ && ts.isObjectLiteralExpression(node))) { + if (!(contextualType && contextualType.flags & 262144 /* Union */ && ts.isObjectLiteralExpression(node))) { return contextualType; } // Keep the below up-to-date with the work done within `isRelatedTo` by `findMatchingDiscriminantType` @@ -40604,10 +40813,10 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 269 /* PropertyAssignment */) + if (prop.kind !== 270 /* PropertyAssignment */) continue; - if (isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { - var discriminatingType = getTypeOfNode(prop.initializer); + if (isPossiblyDiscriminantValue(prop.initializer) && isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { + var discriminatingType = checkExpression(prop.initializer); for (var _b = 0, _c = contextualType.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, prop.symbol.escapedName); @@ -40652,59 +40861,59 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 181 /* BindingElement */: + case 232 /* VariableDeclaration */: + case 149 /* Parameter */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 182 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 192 /* ArrowFunction */: - case 224 /* ReturnStatement */: + case 193 /* ArrowFunction */: + case 225 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 182 /* ArrayLiteralExpression */: { + case 183 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 210 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 201 /* TemplateExpression */); + case 211 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 202 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 190 /* ParenthesizedExpression */: { + case 191 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 261 /* JsxAttribute */: - case 263 /* JsxSpreadAttribute */: + case 262 /* JsxAttribute */: + case 264 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 256 /* JsxOpeningElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; } function getContextualMapper(node) { - node = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); - return node ? node.contextualMapper : identityMapper; + var ancestor = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); + return ancestor ? ancestor.contextualMapper : identityMapper; } function getContextualJsxElementAttributesType(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { @@ -40720,16 +40929,16 @@ var ts; } function getJsxSignaturesParameterTypes(valueType, isJs, context) { // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - if (valueType.flags & 2 /* String */) { + if (valueType.flags & 4 /* String */) { return anyType; } - else if (valueType.flags & 32 /* StringLiteral */) { + else if (valueType.flags & 64 /* StringLiteral */) { // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type // For example: // var CustomTag: "h1" = "h1"; // Hello World var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, context); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { var stringLiteralTypeName = valueType.value; var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); if (intrinsicProp) { @@ -40751,7 +40960,7 @@ var ts; ctor = false; if (signatures.length === 0) { // We found no signatures at all, which is an error - return unknownType; + return errorType; } } var links = getNodeLinks(context); @@ -40772,7 +40981,7 @@ var ts; function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); - if (intrinsicAttribs !== unknownType) { + if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); } return propsType; @@ -40806,7 +41015,7 @@ var ts; // Normal case -- add in IntrinsicClassElements and IntrinsicElements var apparentAttributesType = attributesType; var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context); - if (intrinsicClassAttribs !== unknownType) { + if (intrinsicClassAttribs !== errorType) { var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol); var hostClassType = getReturnTypeOfSignature(sig); apparentAttributesType = intersectTypes(typeParams @@ -40814,7 +41023,7 @@ var ts; : intrinsicClassAttribs, apparentAttributesType); } var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); - if (intrinsicAttribs !== unknownType) { + if (intrinsicAttribs !== errorType) { apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType); } return apparentAttributesType; @@ -40847,7 +41056,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 191 /* FunctionExpression */ || node.kind === 192 /* ArrowFunction */; + return node.kind === 192 /* FunctionExpression */ || node.kind === 193 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -40866,7 +41075,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 !== 153 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type; if (ts.isInJavaScriptFile(node)) { var jsdoc = ts.getJSDocType(node); @@ -40880,7 +41089,7 @@ var ts; if (!type) { return undefined; } - if (!(type.flags & 131072 /* Union */)) { + if (!(type.flags & 262144 /* Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -40919,8 +41128,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 181 /* BindingElement */ && !!node.initializer) || - (node.kind === 199 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 182 /* BindingElement */ && !!node.initializer) || + (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; @@ -40930,7 +41139,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); for (var index = 0; index < elements.length; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 203 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 204 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -40955,7 +41164,7 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 203 /* SpreadElement */; + hasSpreadElement = hasSpreadElement || e.kind === 204 /* SpreadElement */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -40969,7 +41178,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 180 /* ArrayBindingPattern */ || pattern.kind === 182 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 181 /* ArrayBindingPattern */ || pattern.kind === 183 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -40977,7 +41186,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 205 /* OmittedExpression */) { + if (patternElement.kind !== 206 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); @@ -40995,7 +41204,7 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return isNumericComputedName(name); case 71 /* Identifier */: return isNumericLiteralName(name.escapedText); @@ -41009,7 +41218,7 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAssignableToKind(checkComputedPropertyName(name), 84 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 168 /* NumberLike */); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -41044,8 +41253,8 @@ var ts; links.resolvedType = checkExpression(node.expression); // 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 & 12288 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 34 /* StringLike */ | 84 /* NumberLike */ | 1536 /* ESSymbolLike */) && + if (links.resolvedType.flags & 24576 /* Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -41072,23 +41281,26 @@ var ts; var propertiesTable; var propertiesArray = []; var spread = emptyObjectType; - var propagatedFlags = 8388608 /* FreshLiteral */; + var propagatedFlags = 33554432 /* FreshLiteral */; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 179 /* ObjectBindingPattern */ || contextualType.pattern.kind === 183 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 180 /* ObjectBindingPattern */ || contextualType.pattern.kind === 184 /* ObjectLiteralExpression */); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; var hasComputedNumberProperty = false; - if (isInJSFile && node.properties.length === 0) { - // an empty JS object literal that nonetheless has members is a JS namespace - var symbol = getSymbolOfNode(node); - if (symbol.exports) { - propertiesTable = symbol.exports; - symbol.exports.forEach(function (symbol) { return propertiesArray.push(getMergedSymbol(symbol)); }); - return createObjectLiteralType(); + if (isInJSFile) { + var decl = ts.getDeclarationOfJSInitializer(node); + if (decl) { + // a JS object literal whose declaration's symbol has exports is a JS namespace + var symbol = getMergedSymbol(decl.symbol); + if (symbol && ts.hasEntries(symbol.exports)) { + propertiesTable = symbol.exports; + symbol.exports.forEach(function (symbol) { return propertiesArray.push(getMergedSymbol(symbol)); }); + return createObjectLiteralType(); + } } } propertiesTable = ts.createSymbolTable(); @@ -41096,13 +41308,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 146 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 269 /* PropertyAssignment */ || - memberDecl.kind === 270 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 270 /* PropertyAssignment */ || + memberDecl.kind === 271 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 269 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 270 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 270 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 271 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -41112,7 +41324,7 @@ var ts; } } typeFlags |= type.flags; - var nameType = computedNameType && computedNameType.flags & 1120 /* StringOrNumberLiteralOrUnique */ ? + var nameType = computedNameType && computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */ ? computedNameType : undefined; var prop = nameType ? createSymbol(4 /* Property */ | member.flags, getLateBoundNameFromType(nameType), 1024 /* Late */) : @@ -41123,8 +41335,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 === 269 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 270 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 270 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 271 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -41149,7 +41361,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 271 /* SpreadAssignment */) { + else if (memberDecl.kind === 272 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -41164,7 +41376,7 @@ var ts; var type = checkExpression(memberDecl.expression); if (!isValidSpreadType(type)) { error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); - return unknownType; + return errorType; } spread = getSpreadType(spread, type, node.symbol, propagatedFlags, /*objectFlags*/ 0); offset = i + 1; @@ -41176,10 +41388,10 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 155 /* GetAccessor */ || memberDecl.kind === 156 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 156 /* GetAccessor */ || memberDecl.kind === 157 /* SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 1120 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -41222,8 +41434,8 @@ var ts; var stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0 /* String */) : undefined; var numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8388608 /* FreshLiteral */; - result.flags |= 33554432 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 117440512 /* PropagatingFlags */); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 33554432 /* FreshLiteral */; + result.flags |= 268435456 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 939524096 /* PropagatingFlags */); result.objectFlags |= 128 /* ObjectLiteral */; if (patternWithComputedProperties) { result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; @@ -41231,17 +41443,17 @@ var ts; if (inDestructuringPattern) { result.pattern = node; } - if (!(result.flags & 12288 /* Nullable */)) { - propagatedFlags |= (result.flags & 117440512 /* PropagatingFlags */); + if (!(result.flags & 24576 /* Nullable */)) { + propagatedFlags |= (result.flags & 939524096 /* PropagatingFlags */); } return result; } } function isValidSpreadType(type) { - return !!(type.flags & (1 /* Any */ | 134217728 /* NonPrimitive */) || - getFalsyFlags(type) & 14560 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || - type.flags & 65536 /* Object */ && !isGenericMappedType(type) || - type.flags & 393216 /* UnionOrIntersection */ && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); + return !!(type.flags & (3 /* AnyOrUnknown */ | 16777216 /* NonPrimitive */) || + getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || + type.flags & 131072 /* Object */ && !isGenericMappedType(type) || + type.flags & 786432 /* UnionOrIntersection */ && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } function checkJsxSelfClosingElement(node, checkMode) { checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); @@ -41281,13 +41493,13 @@ var ts; function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment switch (tagName.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: case 99 /* ThisKeyword */: return false; case 71 /* Identifier */: return ts.isIntrinsicJsxName(tagName.escapedText); default: - ts.Debug.fail(); + return ts.Debug.fail(); } } function checkJsxAttribute(node, checkMode) { @@ -41331,7 +41543,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 263 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 264 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, /*typeFlags*/ 0, 4096 /* JsxAttributes */); attributesTable = ts.createSymbolTable(); @@ -41354,7 +41566,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 254 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 255 /* 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); @@ -41389,7 +41601,7 @@ var ts; */ function createJsxAttributesType() { var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.flags |= 33554432 /* ContainsObjectLiteral */; + result.flags |= 268435456 /* ContainsObjectLiteral */; result.objectFlags |= 128 /* ObjectLiteral */ | 4096 /* JsxAttributes */; return result; } @@ -41423,7 +41635,7 @@ var ts; var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); var typeSymbol = exports && getSymbol(exports, name, 67901928 /* Type */); - return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : unknownType; + return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** * Looks up an intrinsic tag name and returns a symbol that either points to an intrinsic @@ -41435,7 +41647,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { // Property case if (!ts.isIdentifier(node.tagName)) return ts.Debug.fail(); @@ -41501,6 +41713,7 @@ var ts; return instantiatedSignatures; } function getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, reportErrors) { + if (reportErrors === void 0) { reportErrors = false; } if (!node.typeArguments) { return; } @@ -41523,7 +41736,7 @@ var ts; } } // JSX global fallback - return getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined); + return getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined); // TODO: GH#18217 } /** * Look into JSX namespace and then look for container with matching name as nameOfAttribPropContainer. @@ -41571,7 +41784,7 @@ var ts; if (!propsType) { return undefined; } - if (propsType.flags & 262144 /* Intersection */) { + if (propsType.flags & 524288 /* Intersection */) { var propsApparentType = []; for (var _i = 0, _a = propsType.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -41592,7 +41805,7 @@ var ts; * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global */ function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 131072 /* Union */)); + ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); if (jsxStatelessElementType) { @@ -41605,7 +41818,7 @@ var ts; if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { // Intersect in JSX.IntrinsicAttributes if it exists var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== unknownType) { + if (intrinsicAttributes !== errorType) { paramType = intersectTypes(intrinsicAttributes, paramType); } return paramType; @@ -41626,7 +41839,7 @@ var ts; * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global */ function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 131072 /* Union */)); + ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); @@ -41639,6 +41852,7 @@ var ts; for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { var candidate = candidatesOutArray_1[_i]; var callReturnType = getReturnTypeOfSignature(candidate); + // TODO: GH#18217: callReturnType should always be defined... var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); paramType = getApparentTypeOfJsxPropsType(paramType); if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { @@ -41647,7 +41861,7 @@ var ts; var attribute = _b[_a]; if (ts.isJsxAttribute(attribute) && isUnhyphenatedJsxName(attribute.name.escapedText) && - !getPropertyOfType(paramType, attribute.name.escapedText)) { + !getPropertyOfType(paramType, attribute.name.escapedText)) { // TODO: GH#18217 shouldBeCandidate = false; break; } @@ -41664,7 +41878,7 @@ var ts; } // Intersect in JSX.IntrinsicAttributes if it exists var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== unknownType) { + if (intrinsicAttributes !== errorType) { result = intersectTypes(intrinsicAttributes, result); } return result; @@ -41722,7 +41936,7 @@ var ts; * emptyObjectType if there is no "prop" in the element instance type */ function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (elementType.flags & 131072 /* Union */) { + if (elementType.flags & 262144 /* Union */) { var types = elementType.types; return getUnionType(types.map(function (type) { return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); @@ -41733,16 +41947,16 @@ var ts; return elementType; } // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - else if (elementType.flags & 2 /* String */) { + else if (elementType.flags & 4 /* String */) { return anyType; } - else if (elementType.flags & 32 /* StringLiteral */) { + else if (elementType.flags & 64 /* StringLiteral */) { // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type // For example: // var CustomTag: "h1" = "h1"; // Hello World var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, openingLikeElement); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { var stringLiteralTypeName = elementType.value; var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); if (intrinsicProp) { @@ -41760,9 +41974,9 @@ var ts; // Get the element instance type (the result of newing or invoking this tag) var instantiatedSignatures = getInstantiatedJsxSignatures(openingLikeElement, elementType, /*reportErrors*/ true); if (!ts.length(instantiatedSignatures)) { - return unknownType; + return errorType; } - var elemInstanceType = getUnionType(ts.map(instantiatedSignatures, getReturnTypeOfSignature), 2 /* Subtype */); + var elemInstanceType = getUnionType(instantiatedSignatures.map(getReturnTypeOfSignature), 2 /* Subtype */); // If we should include all stateless attributes type, then get all attributes type from all stateless function signature. // Otherwise get only attributes type from the signature picked by choose-overload logic. var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? @@ -41776,7 +41990,7 @@ var ts; checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } var isJs = ts.isInJavaScriptFile(openingLikeElement); - return getUnionType(ts.map(instantiatedSignatures, function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, /*reportErrors*/ true); })); + return getUnionType(instantiatedSignatures.map(function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, /*reportErrors*/ true); })); } /** * Get attributes type of the given intrinsic opening-like Jsx element by resolving the tag name. @@ -41795,7 +42009,7 @@ var ts; return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0 /* String */).type; } else { - return links.resolvedJsxElementAttributesType = unknownType; + return links.resolvedJsxElementAttributesType = errorType; } } return links.resolvedJsxElementAttributesType; @@ -41849,7 +42063,7 @@ var ts; } function getJsxElementClassTypeAt(location) { var type = getJsxType(JsxNames.ElementClass, location); - if (type === unknownType) + if (type === errorType) return undefined; return type; } @@ -41922,7 +42136,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 65536 /* Object */) { + if (targetType.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(targetType); if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || @@ -41932,7 +42146,7 @@ var ts; return true; } } - else if (targetType.flags & 393216 /* UnionOrIntersection */) { + else if (targetType.flags & 786432 /* UnionOrIntersection */) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -42018,13 +42232,13 @@ var ts; return type; } else { - return unknownType; + return errorType; } } // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 151 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 152 /* PropertyDeclaration */; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; @@ -42053,9 +42267,9 @@ var ts; */ function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 184 /* PropertyAccessExpression */ || node.kind === 231 /* VariableDeclaration */ ? + var errorNode = node.kind === 185 /* PropertyAccessExpression */ || node.kind === 232 /* VariableDeclaration */ ? node.name : - node.kind === 178 /* ImportType */ ? + node.kind === 179 /* ImportType */ ? node : node.right; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { @@ -42090,7 +42304,7 @@ var ts; if ((flags & 128 /* Abstract */) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeWithinConstructorOfClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); + 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; } } @@ -42128,9 +42342,9 @@ var ts; if (flags & 32 /* Static */) { return true; } - if (type.flags & 32768 /* TypeParameter */) { + if (type.flags & 65536 /* TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type - type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + 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)); @@ -42141,21 +42355,25 @@ var ts; function symbolHasNonMethodDeclaration(symbol) { return forEachProperty(symbol, function (prop) { var propKind = getDeclarationKindFromSymbol(prop); - return propKind !== 153 /* MethodDeclaration */ && propKind !== 152 /* MethodSignature */; + return propKind !== 154 /* MethodDeclaration */ && propKind !== 153 /* MethodSignature */; }); } function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 12288 /* Nullable */; + if (type.flags & 2 /* Unknown */) { + error(node, ts.Diagnostics.Object_is_of_type_unknown); + return errorType; + } + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 24576 /* Nullable */; if (kind) { - error(node, kind & 4096 /* Undefined */ ? kind & 8192 /* Null */ ? + error(node, kind & 8192 /* Undefined */ ? kind & 16384 /* Null */ ? (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); var t = getNonNullableType(type); - return t.flags & (12288 /* Nullable */ | 16384 /* Never */) ? unknownType : t; + return t.flags & (24576 /* Nullable */ | 32768 /* Never */) ? errorType : t; } return type; } @@ -42185,9 +42403,9 @@ var ts; var indexInfo = getIndexInfoOfType(apparentType, 0 /* String */); if (!(indexInfo && indexInfo.type)) { if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, leftType.flags & 32768 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); + reportNonexistentProperty(right, leftType.flags & 65536 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); } - return unknownType; + return errorType; } if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) { error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType)); @@ -42202,7 +42420,7 @@ var ts; if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, ts.idText(right)); - return unknownType; + return errorType; } } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); @@ -42210,9 +42428,9 @@ var ts; // 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. - if (node.kind !== 184 /* PropertyAccessExpression */ || + if (node.kind !== 185 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || - prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 131072 /* Union */)) { + prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { return propType; } // If strict null checks and strict property initialization checks are enabled, if we have @@ -42224,14 +42442,14 @@ var ts; var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 154 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 155 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 4096 /* Undefined */) && getFalsyFlags(flowType) & 4096 /* Undefined */) { - error(right, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); + if (assumeUninitialized && !(getFalsyFlags(propType) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { + error(right, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217 // Return the declared type to reduce follow-on errors return propType; } @@ -42247,8 +42465,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); } - else if (valueDeclaration.kind === 234 /* ClassDeclaration */ && - node.parent.kind !== 161 /* TypeReference */ && + else if (valueDeclaration.kind === 235 /* ClassDeclaration */ && + node.parent.kind !== 162 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.idText(right)); @@ -42257,9 +42475,9 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return true; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -42296,7 +42514,7 @@ var ts; } function reportNonexistentProperty(propNode, containingType) { var errorInfo; - if (containingType.flags & 131072 /* Union */ && !(containingType.flags & 16382 /* Primitive */)) { + if (containingType.flags & 262144 /* Union */ && !(containingType.flags & 32764 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText)) { @@ -42453,20 +42671,20 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 178 /* ImportType */: + case 179 /* ImportType */: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 178 /* ImportType */ ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 179 /* ImportType */ ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { - var propType = getTypeOfFuncClassEnumModule(method); + var propType = getTypeOfPropertyOfType(actualThisType, method.escapedName); var signatures = getSignaturesOfType(getNonNullableType(propType), 0 /* Call */); ts.Debug.assert(signatures.length !== 0); return signatures.some(function (sig) { @@ -42483,20 +42701,20 @@ var ts; return instantiateType(signatureThisType, createSignatureTypeMapper(sig, getInferredTypes(context))); } function isValidPropertyAccessWithType(node, left, propertyName, type) { - if (type === unknownType || isTypeAny(type)) { + if (type === errorType || isTypeAny(type)) { return true; } var prop = getPropertyOfType(type, propertyName); return prop ? checkPropertyAccessibility(node, left, type, prop) // In js files properties of unions are allowed in completion - : ts.isInJavaScriptFile(node) && (type.flags & 131072 /* Union */) && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, left, propertyName, elementType); }); + : ts.isInJavaScriptFile(node) && (type.flags & 262144 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, left, propertyName, elementType); }); } /** * Return the symbol of the for-in variable declared or referenced by the given for-in statement. */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 232 /* VariableDeclarationList */) { + if (initializer.kind === 233 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -42525,7 +42743,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 220 /* ForInStatement */ && + if (node.kind === 221 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -42543,7 +42761,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 187 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 188 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -42553,20 +42771,20 @@ var ts; var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); } - return unknownType; + return errorType; } var indexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : checkExpression(indexExpression); - if (objectType === unknownType || objectType === silentNeverType) { + if (objectType === errorType || objectType === silentNeverType) { return objectType; } if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9 /* StringLiteral */) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); - return unknownType; + return errorType; } return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === unknownType) { + if (expressionType === errorType) { // There is already an error, so no need to report one. return false; } @@ -42574,7 +42792,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 1536 /* ESSymbolLike */) === 0) { + if ((expressionType.flags & 3072 /* ESSymbolLike */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -42610,10 +42828,10 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 188 /* TaggedTemplateExpression */) { + if (node.kind === 189 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 149 /* Decorator */) { + else if (node.kind !== 150 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -42646,7 +42864,7 @@ var ts; var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { if (lastParent && parent === lastParent) { - index++; + index = index + 1; } else { lastParent = parent; @@ -42679,7 +42897,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 203 /* SpreadElement */) { + if (arg && arg.kind === 204 /* SpreadElement */) { return i; } } @@ -42689,22 +42907,21 @@ var ts; if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } var argCount; // Apparent number of arguments we will have in this call var typeArguments; // Type arguments (undefined if none) - var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments + var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var spreadArgIndex = -1; if (ts.isJsxOpeningLikeElement(node)) { // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". return true; } - if (node.kind === 188 /* TaggedTemplateExpression */) { + if (node.kind === 189 /* TaggedTemplateExpression */) { // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length argCount = args.length; - typeArguments = undefined; - if (node.template.kind === 201 /* TemplateExpression */) { + typeArguments = node.typeArguments; + if (node.template.kind === 202 /* 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.lastOrUndefined(node.template.templateSpans); - ts.Debug.assert(lastSpan !== undefined); // we should always have at least one span. + var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; } else { @@ -42716,14 +42933,14 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 149 /* Decorator */) { + else if (node.kind === 150 /* Decorator */) { typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); } else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 187 /* NewExpression */); + ts.Debug.assert(node.kind === 188 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -42758,7 +42975,7 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -42806,7 +43023,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 !== 149 /* Decorator */) { + if (node.kind !== 150 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the contextual mapper to avoid disturbing a resolution in progress for an @@ -42841,7 +43058,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 205 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 206 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -42882,7 +43099,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (!constraint) continue; - var errorInfo = reportErrors && headMessage && (function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }); + var errorInfo = reportErrors && headMessage ? (function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }) : undefined; var typeArgumentHeadMessage = headMessage || ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; if (!mapper) { mapper = createTypeMapper(typeParameters, typeArgumentTypes); @@ -42931,7 +43148,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 187 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 188 /* 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. @@ -42939,7 +43156,7 @@ var ts; var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; 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, getThisTypeOfSignature(signature), relation, errorNode, headMessage_1)) { + if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1)) { return false; } } @@ -42948,7 +43165,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 205 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 206 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); // If the effective argument type is undefined, there is no synthetic type for the argument. @@ -42972,9 +43189,9 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 186 /* CallExpression */) { + if (node.kind === 187 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 184 /* PropertyAccessExpression */ || callee.kind === 185 /* ElementAccessExpression */) { + if (callee.kind === 185 /* PropertyAccessExpression */ || callee.kind === 186 /* ElementAccessExpression */) { return callee.expression; } } @@ -42989,17 +43206,17 @@ var ts; * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. */ function getEffectiveCallArguments(node) { - if (node.kind === 188 /* TaggedTemplateExpression */) { + if (node.kind === 189 /* TaggedTemplateExpression */) { var template = node.template; - var args_4 = [undefined]; - if (template.kind === 201 /* TemplateExpression */) { + var args_4 = [undefined]; // TODO: GH#18217 + if (template.kind === 202 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); } return args_4; } - else if (node.kind === 149 /* Decorator */) { + else if (node.kind === 150 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -43026,19 +43243,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 149 /* Decorator */) { + if (node.kind === 150 /* Decorator */) { switch (node.parent.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* 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. @@ -43048,10 +43265,12 @@ var ts; // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 148 /* Parameter */: + case 149 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; + default: + return ts.Debug.fail(); } } else { @@ -43072,25 +43291,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 234 /* ClassDeclaration */) { + if (node.kind === 235 /* ClassDeclaration */) { // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 154 /* Constructor */) { + if (node.kind === 155 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 151 /* PropertyDeclaration */ || - node.kind === 153 /* MethodDeclaration */ || - node.kind === 155 /* GetAccessor */ || - node.kind === 156 /* SetAccessor */) { + if (node.kind === 152 /* PropertyDeclaration */ || + node.kind === 154 /* MethodDeclaration */ || + node.kind === 156 /* GetAccessor */ || + node.kind === 157 /* SetAccessor */) { // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -43098,7 +43317,7 @@ var ts; return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } /** * Returns the effective type for the second argument to a decorator. @@ -43117,37 +43336,38 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 234 /* ClassDeclaration */) { + if (node.kind === 235 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* Parameter */) { node = node.parent; - if (node.kind === 154 /* Constructor */) { + if (node.kind === 155 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. } - if (node.kind === 151 /* PropertyDeclaration */ || - node.kind === 153 /* MethodDeclaration */ || - node.kind === 155 /* GetAccessor */ || - node.kind === 156 /* SetAccessor */) { + if (node.kind === 152 /* PropertyDeclaration */ || + node.kind === 154 /* MethodDeclaration */ || + node.kind === 156 /* GetAccessor */ || + node.kind === 157 /* SetAccessor */) { // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; - switch (element.name.kind) { + var name = element.name; + switch (name.kind) { case 71 /* Identifier */: - return getLiteralType(ts.idText(element.name)); + return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - return getLiteralType(element.name.text); - case 146 /* ComputedPropertyName */: - var nameType = checkComputedPropertyName(element.name); - if (isTypeAssignableToKind(nameType, 1536 /* ESSymbolLike */)) { + return getLiteralType(name.text); + case 147 /* ComputedPropertyName */: + var nameType = checkComputedPropertyName(name); + if (isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */)) { return nameType; } else { @@ -43155,11 +43375,11 @@ var ts; } default: ts.Debug.fail("Unsupported property name."); - return unknownType; + return errorType; } } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } /** * Returns the effective argument type for the third argument to a decorator. @@ -43171,28 +43391,28 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 234 /* ClassDeclaration */) { + if (node.kind === 235 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 151 /* PropertyDeclaration */) { + if (node.kind === 152 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 153 /* MethodDeclaration */ || - node.kind === 155 /* GetAccessor */ || - node.kind === 156 /* SetAccessor */) { + if (node.kind === 154 /* MethodDeclaration */ || + node.kind === 156 /* GetAccessor */ || + node.kind === 157 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. - var propertyType = getTypeOfNode(node); + var propertyType = getTypeOfNode(node); // TODO: GH#18217 return createTypedPropertyDescriptorType(propertyType); } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } /** * Returns the effective argument type for the provided argument to a decorator. @@ -43208,7 +43428,7 @@ var ts; return getEffectiveDecoratorThirdArgumentType(node.parent); } ts.Debug.fail("Decorators should not have a fourth synthetic argument."); - return unknownType; + return errorType; } /** * Gets the effective argument type for an argument in a call expression. @@ -43217,10 +43437,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 149 /* Decorator */) { + if (node.kind === 150 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 188 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -43232,8 +43452,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 149 /* Decorator */ || - (argIndex === 0 && node.kind === 188 /* TaggedTemplateExpression */)) { + if (node.kind === 150 /* Decorator */ || + (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -43242,11 +43462,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 149 /* Decorator */) { + if (node.kind === 150 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 188 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -43266,8 +43486,8 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, fallbackError) { - var isTaggedTemplate = node.kind === 188 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 149 /* Decorator */; + var isTaggedTemplate = node.kind === 189 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 150 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; if (!isDecorator) { @@ -43341,7 +43561,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 = candidatesOutArray && node.kind === 186 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 187 /* 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 @@ -43423,7 +43643,7 @@ var ts; var candidate = candidates[bestIndex]; var typeParameters = candidate.typeParameters; if (typeParameters && callLikeExpressionMayHaveTypeArguments(node) && node.typeArguments) { - var typeArguments_1 = node.typeArguments.map(getTypeOfNode); + var typeArguments_1 = node.typeArguments.map(getTypeOfNode); // TODO: GH#18217 while (typeArguments_1.length > typeParameters.length) { typeArguments_1.pop(); } @@ -43520,9 +43740,10 @@ var ts; if (node.expression.kind === 97 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { + ts.forEach(node.arguments, checkExpression); // Still visit arguments so they get marked for visibility, etc return anySignature; } - if (superType !== unknownType) { + if (superType !== errorType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated // with the type arguments specified in the extends clause. var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -43538,7 +43759,7 @@ var ts; return silentNeverSignature; } var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { + if (apparentType === errorType) { // Another error has already been reported return resolveErrorCall(node); } @@ -43554,7 +43775,7 @@ var ts; if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, constructSignatures.length)) { // The unknownType indicates that an error already occurred (and was reported). No // need to report another error in this case. - if (funcType !== unknownType && node.typeArguments) { + if (funcType !== errorType && node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); } return resolveUntypedCall(node); @@ -43580,8 +43801,8 @@ 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 & 32768 /* TypeParameter */ || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (131072 /* Union */ | 16384 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && funcType.flags & 65536 /* TypeParameter */ || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (262144 /* Union */ | 32768 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray) { if (node.arguments && languageVersion < 1 /* ES5 */) { @@ -43600,7 +43821,7 @@ var ts; // signatures for overload resolution. The result type of the function call becomes // the result type of the operation. expressionType = getApparentType(expressionType); - if (expressionType === unknownType) { + if (expressionType === errorType) { // Another error has already been reported return resolveErrorCall(node); } @@ -43711,7 +43932,7 @@ var ts; function resolveTaggedTemplateExpression(node, candidatesOutArray) { var tagType = checkExpression(node.tag); var apparentType = getApparentType(tagType); - if (apparentType === unknownType) { + if (apparentType === errorType) { // Another error has already been reported return resolveErrorCall(node); } @@ -43731,17 +43952,19 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 148 /* Parameter */: + case 149 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; + default: + return ts.Debug.fail(); } } /** @@ -43750,7 +43973,7 @@ var ts; function resolveDecorator(node, candidatesOutArray) { var funcType = checkExpression(node.expression); var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { + if (apparentType === errorType) { return resolveErrorCall(node); } var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); @@ -43765,8 +43988,7 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorInfo = void 0; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); + var errorInfo = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); invocationErrorRecovery(apparentType, 0 /* Call */); @@ -43797,7 +44019,7 @@ var ts; * the function will fill it up with appropriate candidate signatures */ function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { - ts.Debug.assert(!(elementType.flags & 131072 /* Union */)); + ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); var callSignatures = elementType && getSignaturesOfType(elementType, 0 /* Call */); if (callSignatures && callSignatures.length > 0) { return resolveCall(openingLikeElement, callSignatures, candidatesOutArray); @@ -43806,16 +44028,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 186 /* CallExpression */: + case 187 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 149 /* Decorator */: + case 150 /* Decorator */: return resolveDecorator(node, candidatesOutArray); - case 256 /* JsxOpeningElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: // This code-path is called by language service var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { @@ -43830,7 +44052,7 @@ var ts; return ts.length(sigs) ? sigs[0] : unknownSignature; }) || unknownSignature; } - ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); + throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } /** * Resolve a signature of a given call-like expression. @@ -43870,15 +44092,11 @@ var ts; var symbol = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? getSymbolOfNode(node) : ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : undefined; - return symbol && symbol.members !== undefined; + return !!symbol && symbol.members !== undefined; } return false; } function getJavaScriptClassType(symbol) { - var initializer = ts.getDeclaredJavascriptInitializer(symbol.valueDeclaration); - if (initializer) { - symbol = getSymbolOfNode(initializer); - } var inferred; if (isJavaScriptConstructor(symbol.valueDeclaration)) { inferred = getInferredClassType(symbol); @@ -43909,7 +44127,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 184 /* PropertyAccessExpression */) { + while (parent && parent.kind === 185 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -43941,12 +44159,12 @@ var ts; if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; } - if (node.kind === 187 /* NewExpression */) { + if (node.kind === 188 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 154 /* Constructor */ && - declaration.kind !== 158 /* ConstructSignature */ && - declaration.kind !== 163 /* ConstructorType */ && + declaration.kind !== 155 /* Constructor */ && + declaration.kind !== 159 /* ConstructSignature */ && + declaration.kind !== 164 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations @@ -43974,10 +44192,20 @@ var ts; var returnType = getReturnTypeOfSignature(signature); // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property // as a fresh unique symbol literal type. - if (returnType.flags & 1536 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 3072 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - return returnType; + var jsAssignmentType; + if (ts.isInJavaScriptFile(node)) { + var decl = ts.getDeclarationOfJSInitializer(node); + if (decl) { + var jsSymbol = getSymbolOfNode(decl); + if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { + jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, jsObjectLiteralIndexInfo, undefined); + } + } + } + return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -44009,7 +44237,7 @@ var ts; for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 4096 /* Undefined */ || specifierType.flags & 8192 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 8192 /* Undefined */ || specifierType.flags & 16384 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -44023,7 +44251,7 @@ var ts; return createPromiseReturnType(node, anyType); } function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) { - if (allowSyntheticDefaultImports && type && type !== unknownType) { + if (allowSyntheticDefaultImports && type && type !== errorType) { var synthType = type; if (!synthType.syntheticType) { var file_4 = ts.find(originalSymbol.declarations, ts.isSourceFile); @@ -44053,7 +44281,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67216319 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67216319 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } @@ -44062,9 +44290,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 233 /* FunctionDeclaration */ + ? 234 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 231 /* VariableDeclaration */ + ? 232 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -44087,7 +44315,7 @@ var ts; var exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(checkExpression(expression, checkMode))); checkSourceElement(type); var targetType = getTypeFromTypeNode(type); - if (produceDiagnostics && targetType !== unknownType) { + if (produceDiagnostics && targetType !== errorType) { var widenedType = getWidenedType(exprType); if (!isTypeComparableTo(targetType, widenedType)) { checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Type_0_cannot_be_converted_to_type_1); @@ -44106,14 +44334,15 @@ var ts; if (node.keywordToken === 91 /* ImportKeyword */) { return checkImportMetaProperty(node); } + return ts.Debug.assertNever(node.keywordToken); } function checkNewTargetMetaProperty(node) { var container = ts.getNewTargetContainer(node); if (!container) { error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); - return unknownType; + return errorType; } - else if (container.kind === 154 /* Constructor */) { + else if (container.kind === 155 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -44129,7 +44358,7 @@ var ts; var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); - return node.name.escapedText === "meta" ? getGlobalImportMetaType() : unknownType; + return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); @@ -44185,9 +44414,9 @@ var ts; } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { // parameter might be a transient symbol generated by use of `arguments` in the function body. - var parameter = ts.lastOrUndefined(signature.parameters); + var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -44237,7 +44466,7 @@ var ts; error(func, ts.isImportCall(func) ? ts.Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option : ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); - return unknownType; + return errorType; } else if (!getGlobalPromiseConstructorSymbol(/*reportErrors*/ true)) { error(func, ts.isImportCall(func) ? @@ -44248,11 +44477,11 @@ var ts; } function getReturnTypeFromBody(func, checkMode) { if (!func.body) { - return unknownType; + return errorType; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 212 /* Block */) { + if (func.body.kind !== 213 /* Block */) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any @@ -44366,7 +44595,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 226 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -44388,7 +44617,7 @@ var ts; // the native Promise type by the caller. type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - if (type.flags & 16384 /* Never */) { + if (type.flags & 32768 /* Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -44409,11 +44638,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return true; - case 153 /* MethodDeclaration */: - return func.parent.kind === 183 /* ObjectLiteralExpression */; + case 154 /* MethodDeclaration */: + return func.parent.kind === 184 /* ObjectLiteralExpression */; default: return false; } @@ -44432,16 +44661,16 @@ var ts; return; } // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (returnType && maybeTypeOfKind(returnType, 1 /* Any */ | 2048 /* Void */)) { + if (returnType && maybeTypeOfKind(returnType, 3 /* AnyOrUnknown */ | 4096 /* Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 152 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 212 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 213 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; - if (returnType && returnType.flags & 16384 /* Never */) { + if (returnType && returnType.flags & 32768 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (returnType && !hasExplicitReturn) { @@ -44470,14 +44699,14 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 153 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode === 1 /* SkipContextSensitive */ && isContextSensitive(node)) { return anyFunctionType; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 191 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 192 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -44518,7 +44747,7 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 153 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnTypeNode = ts.getEffectiveReturnTypeNode(node); var returnOrPromisedType = returnTypeNode && @@ -44538,7 +44767,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 212 /* Block */) { + if (node.body.kind === 213 /* Block */) { checkSourceElement(node.body); } else { @@ -44561,7 +44790,7 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAssignableToKind(type, 84 /* NumberLike */)) { + if (!isTypeAssignableToKind(type, 168 /* NumberLike */)) { error(operand, diagnostic); return false; } @@ -44584,11 +44813,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 184 /* PropertyAccessExpression */ || expr.kind === 185 /* ElementAccessExpression */) && + (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) && expr.expression.kind === 99 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 154 /* Constructor */)) { + if (!(func && func.kind === 155 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -44601,13 +44830,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 184 /* PropertyAccessExpression */ || expr.kind === 185 /* ElementAccessExpression */) { + if (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 71 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 245 /* NamespaceImport */; + return !!declaration && declaration.kind === 246 /* NamespaceImport */; } } } @@ -44616,7 +44845,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 71 /* Identifier */ && node.kind !== 184 /* PropertyAccessExpression */ && node.kind !== 185 /* ElementAccessExpression */) { + if (node.kind !== 71 /* Identifier */ && node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -44625,7 +44854,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 184 /* PropertyAccessExpression */ && expr.kind !== 185 /* ElementAccessExpression */) { + if (expr.kind !== 185 /* PropertyAccessExpression */ && expr.kind !== 186 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -44675,7 +44904,7 @@ var ts; case 38 /* MinusToken */: case 52 /* TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKind(operandType, 1536 /* ESSymbolLike */)) { + if (maybeTypeOfKind(operandType, 3072 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; @@ -44693,7 +44922,7 @@ var ts; } return numberType; } - return unknownType; + return errorType; } function checkPostfixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -44710,10 +44939,10 @@ var ts; // Return true if type might be of the given kind. A union or intersection type might be of a given // kind if at least one constituent type is of the given kind. function maybeTypeOfKind(type, kind) { - if (type.flags & kind || kind & 536870912 /* GenericMappedType */ && isGenericMappedType(type)) { + if (type.flags & kind & ~134217728 /* GenericMappedType */ || kind & 134217728 /* GenericMappedType */ && isGenericMappedType(type)) { return true; } - if (type.flags & 393216 /* UnionOrIntersection */) { + if (type.flags & 786432 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; @@ -44728,26 +44957,26 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (1 /* Any */ | 2048 /* Void */ | 4096 /* Undefined */ | 8192 /* Null */)) { + if (strict && source.flags & (3 /* AnyOrUnknown */ | 4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */)) { return false; } - return (kind & 84 /* NumberLike */ && isTypeAssignableTo(source, numberType)) || - (kind & 34 /* StringLike */ && isTypeAssignableTo(source, stringType)) || - (kind & 136 /* BooleanLike */ && isTypeAssignableTo(source, booleanType)) || - (kind & 2048 /* Void */ && isTypeAssignableTo(source, voidType)) || - (kind & 16384 /* Never */ && isTypeAssignableTo(source, neverType)) || - (kind & 8192 /* Null */ && isTypeAssignableTo(source, nullType)) || - (kind & 4096 /* Undefined */ && isTypeAssignableTo(source, undefinedType)) || - (kind & 512 /* ESSymbol */ && isTypeAssignableTo(source, esSymbolType)) || - (kind & 134217728 /* NonPrimitive */ && isTypeAssignableTo(source, nonPrimitiveType)); + return !!(kind & 168 /* NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 68 /* StringLike */) && isTypeAssignableTo(source, stringType) || + !!(kind & 272 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || + !!(kind & 4096 /* Void */) && isTypeAssignableTo(source, voidType) || + !!(kind & 32768 /* Never */) && isTypeAssignableTo(source, neverType) || + !!(kind & 16384 /* Null */) && isTypeAssignableTo(source, nullType) || + !!(kind & 8192 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 1024 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 16777216 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 131072 /* Union */ ? + return source.flags & 262144 /* Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { return (symbol.flags & 128 /* ConstEnum */) !== 0; @@ -44762,7 +44991,7 @@ var ts; // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 16382 /* Primitive */)) { + allTypesAssignableToKind(leftType, 32764 /* Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -44781,10 +45010,10 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 84 /* NumberLike */ | 1536 /* ESSymbolLike */))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 168 /* NumberLike */ | 3072 /* ESSymbolLike */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAssignableToKind(rightType, 134217728 /* NonPrimitive */ | 7372800 /* InstantiableNonPrimitive */)) { + if (!isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 14745600 /* 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); } return booleanType; @@ -44803,9 +45032,9 @@ var ts; } /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 269 /* PropertyAssignment */ || property.kind === 270 /* ShorthandPropertyAssignment */) { + if (property.kind === 270 /* PropertyAssignment */ || property.kind === 271 /* ShorthandPropertyAssignment */) { var name = property.name; - if (name.kind === 146 /* ComputedPropertyName */) { + if (name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -44818,7 +45047,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 270 /* ShorthandPropertyAssignment */) { + if (property.kind === 271 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -44830,7 +45059,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 271 /* SpreadAssignment */) { + else if (property.kind === 272 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -44856,7 +45085,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType; + var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; for (var i = 0; i < elements.length; i++) { checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); } @@ -44865,8 +45094,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 205 /* OmittedExpression */) { - if (element.kind !== 203 /* SpreadElement */) { + if (element.kind !== 206 /* OmittedExpression */) { + if (element.kind !== 204 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -44894,7 +45123,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 199 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 200 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -44907,13 +45136,13 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 270 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 271 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. if (strictNullChecks && - !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 4096 /* Undefined */)) { + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 8192 /* Undefined */)) { sourceType = getTypeWithFacts(sourceType, 131072 /* NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); @@ -44923,21 +45152,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 199 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 200 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 183 /* ObjectLiteralExpression */) { + if (target.kind === 184 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 182 /* ArrayLiteralExpression */) { + if (target.kind === 183 /* 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 === 271 /* SpreadAssignment */ ? + var error = target.parent.kind === 272 /* 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; if (checkReferenceExpression(target, error)) { @@ -44959,35 +45188,35 @@ var ts; case 71 /* Identifier */: case 9 /* StringLiteral */: case 12 /* RegularExpressionLiteral */: - case 188 /* TaggedTemplateExpression */: - case 201 /* TemplateExpression */: + case 189 /* TaggedTemplateExpression */: + case 202 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 140 /* UndefinedKeyword */: - case 191 /* FunctionExpression */: - case 204 /* ClassExpression */: - case 192 /* ArrowFunction */: - case 182 /* ArrayLiteralExpression */: - case 183 /* ObjectLiteralExpression */: - case 194 /* TypeOfExpression */: - case 208 /* NonNullExpression */: - case 255 /* JsxSelfClosingElement */: - case 254 /* JsxElement */: + case 192 /* FunctionExpression */: + case 205 /* ClassExpression */: + case 193 /* ArrowFunction */: + case 183 /* ArrayLiteralExpression */: + case 184 /* ObjectLiteralExpression */: + case 195 /* TypeOfExpression */: + case 209 /* NonNullExpression */: + case 256 /* JsxSelfClosingElement */: + case 255 /* JsxElement */: return true; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -44999,15 +45228,15 @@ var ts; } return false; // Some forms listed here for clarity - case 195 /* VoidExpression */: // Explicit opt-out - case 189 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 207 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 196 /* VoidExpression */: // Explicit opt-out + case 190 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 208 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 12288 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 24576 /* Nullable */) !== 0 || isTypeComparableTo(source, target); } function checkBinaryExpression(node, checkMode) { if (ts.isInJavaScriptFile(node) && ts.getAssignedJavascriptInitializer(node)) { @@ -45017,7 +45246,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 183 /* ObjectLiteralExpression */ || left.kind === 182 /* ArrayLiteralExpression */)) { + if (operator === 58 /* EqualsToken */ && (left.kind === 184 /* ObjectLiteralExpression */ || left.kind === 183 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -45053,8 +45282,8 @@ var ts; var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion - if ((leftType.flags & 136 /* BooleanLike */) && - (rightType.flags & 136 /* BooleanLike */) && + if ((leftType.flags & 272 /* BooleanLike */) && + (rightType.flags & 272 /* BooleanLike */) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } @@ -45072,24 +45301,24 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 34 /* StringLike */) && !isTypeAssignableToKind(rightType, 34 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 68 /* StringLike */) && !isTypeAssignableToKind(rightType, 68 /* StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 84 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 84 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 168 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 168 /* NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 34 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 34 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 68 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 68 /* StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } else if (isTypeAny(leftType) || isTypeAny(rightType)) { // Otherwise, the result is of type Any. // NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we. - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + resultType = leftType === errorType || rightType === errorType ? errorType : anyType; } // Symbols are not allowed at all in arithmetic expressions if (resultType && !checkForDisallowedESSymbolOperand(operator)) { @@ -45150,6 +45379,8 @@ var ts; error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } return rightType; + default: + return ts.Debug.fail(); } function checkSpecialAssignment(left, right) { var special = ts.getSpecialPropertyAssignmentKind(left.parent); @@ -45161,7 +45392,7 @@ var ts; if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; var symbol = resolveName(prop.valueDeclaration, name, 67901928 /* Type */, undefined, name, /*isUse*/ false); - if (symbol) { + if (symbol && symbol.declarations.some(function (d) { return d.kind === 297 /* JSDocTypedefTag */; })) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); } @@ -45174,8 +45405,8 @@ var ts; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKind(leftType, 1536 /* ESSymbolLike */) ? left : - maybeTypeOfKind(rightType, 1536 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 3072 /* ESSymbolLike */) ? left : + maybeTypeOfKind(rightType, 3072 /* ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -45243,7 +45474,9 @@ var ts; } } var func = ts.getContainingFunction(node); - var functionFlags = func ? ts.getFunctionFlags(func) : 0 /* Normal */; + if (!func) + return anyType; + var functionFlags = ts.getFunctionFlags(func); if (!(functionFlags & 1 /* Generator */)) { // If the user's code is syntactically correct, the func should always have a star. After all, we are in a yield context. return anyType; @@ -45262,7 +45495,7 @@ var ts; } } var isAsync = (functionFlags & 2 /* Async */) !== 0; - var yieldedType = getYieldedTypeOfYieldExpression(node, isAsync); + var yieldedType = getYieldedTypeOfYieldExpression(node, isAsync); // TODO: GH#18217 // There is no point in doing an assignability check if the function // has no explicit return type because the return type is directly computed // from the yield expressions. @@ -45287,14 +45520,14 @@ var ts; // A place where we actually *are* concerned with the expressions' types are // in tagged templates. ts.forEach(node.templateSpans, function (templateSpan) { - if (maybeTypeOfKind(checkExpression(templateSpan.expression), 1536 /* ESSymbolLike */)) { + if (maybeTypeOfKind(checkExpression(templateSpan.expression), 3072 /* ESSymbolLike */)) { error(templateSpan.expression, ts.Diagnostics.Type_0_cannot_be_converted_to_type_1, typeToString(esSymbolType), typeToString(stringType)); } }); return stringType; } function getContextNode(node) { - if (node.kind === 262 /* JsxAttributes */) { + if (node.kind === 263 /* JsxAttributes */) { 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; @@ -45330,17 +45563,16 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 189 /* TypeAssertionExpression */ || node.kind === 207 /* AsExpression */; + return node.kind === 190 /* TypeAssertionExpression */ || node.kind === 208 /* AsExpression */; } function checkDeclarationInitializer(declaration) { - var inJs = ts.isInJavaScriptFile(declaration); - var initializer = inJs && ts.getDeclaredJavascriptInitializer(declaration) || declaration.initializer; + var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || (ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)) || isTypeAssertion(initializer) ? type : getWidenedLiteralType(type); - if (inJs) { - if (widened.flags & 12288 /* Nullable */) { + if (ts.isInJavaScriptFile(declaration)) { + if (widened.flags & 24576 /* Nullable */) { if (noImplicitAny) { reportImplicitAnyError(declaration, anyType); } @@ -45355,38 +45587,28 @@ var ts; } return widened; } - function isTypeParameterWithKeyofConstraint(type) { - if (type.flags & 32768 /* TypeParameter */) { - var constraintDeclaration = getConstraintDeclaration(type); - return constraintDeclaration && constraintDeclaration.kind === 174 /* TypeOperator */ && - constraintDeclaration.operator === 128 /* KeyOfKeyword */; - } - return false; - } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 393216 /* UnionOrIntersection */) { + if (contextualType.flags & 786432 /* UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 7372800 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 14745600 /* InstantiableNonPrimitive */) { // If the contextual type is a type variable constrained to a primitive type, consider // this a literal context for literals of that primitive type. For example, given a // type parameter 'T extends string', infer string literal types for T. var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; - return isTypeParameterWithKeyofConstraint(contextualType) && maybeTypeOfKind(candidateType, 32 /* StringLiteral */ | 64 /* NumberLiteral */ | 1024 /* UniqueESSymbol */) || - constraint.flags & 2 /* String */ && maybeTypeOfKind(candidateType, 32 /* StringLiteral */) || - constraint.flags & 4 /* Number */ && maybeTypeOfKind(candidateType, 64 /* NumberLiteral */) || - constraint.flags & 8 /* Boolean */ && maybeTypeOfKind(candidateType, 128 /* BooleanLiteral */) || - constraint.flags & 512 /* ESSymbol */ && maybeTypeOfKind(candidateType, 1024 /* UniqueESSymbol */) || + return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || + maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || + maybeTypeOfKind(constraint, 1024 /* ESSymbol */) && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint); } // If the contextual type is a literal of a particular primitive type, we consider this a // literal context for all literals of that primitive type. - return contextualType.flags & (32 /* StringLiteral */ | 524288 /* Index */) && maybeTypeOfKind(candidateType, 32 /* StringLiteral */) || - contextualType.flags & 64 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 64 /* NumberLiteral */) || - contextualType.flags & 128 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 128 /* BooleanLiteral */) || - contextualType.flags & 1024 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 1024 /* UniqueESSymbol */); + return !!(contextualType.flags & (64 /* StringLiteral */ | 1048576 /* Index */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || + contextualType.flags & 128 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || + contextualType.flags & 256 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 256 /* BooleanLiteral */) || + contextualType.flags & 2048 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */)); } return false; } @@ -45402,7 +45624,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 === 146 /* ComputedPropertyName */) { + if (node.name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -45413,7 +45635,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 === 146 /* ComputedPropertyName */) { + if (node.name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -45443,7 +45665,7 @@ var ts; function getTypeOfExpression(node, cache) { // 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 (node.kind === 186 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 187 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -45478,7 +45700,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, checkMode) { var type; - if (node.kind === 145 /* QualifiedName */) { + if (node.kind === 146 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -45490,10 +45712,10 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 185 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 71 /* Identifier */ || node.kind === 145 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 164 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 186 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 165 /* TypeQuery */ && node.parent.exprName === node)); 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); } @@ -45527,77 +45749,77 @@ var ts; return trueType; case 86 /* FalseKeyword */: return falseType; - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* RegularExpressionLiteral */: return globalRegExpType; - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (node.expression.kind === 91 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 187 /* NewExpression */: + case 188 /* NewExpression */: return checkCallExpression(node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return checkClassExpression(node); - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 194 /* TypeOfExpression */: + case 195 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: return checkAssertion(node); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: return checkNonNullAssertion(node); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return checkMetaProperty(node); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return checkDeleteExpression(node); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return checkVoidExpression(node); - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return checkAwaitExpression(node); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 205 /* OmittedExpression */: + case 206 /* OmittedExpression */: return undefinedWideningType; - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return checkYieldExpression(node); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 254 /* JsxElement */: + case 255 /* JsxElement */: return checkJsxElement(node, checkMode); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return checkJsxFragment(node, checkMode); - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 256 /* JsxOpeningElement */: + case 257 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } - return unknownType; + return errorType; } // DECLARATION AND STATEMENT TYPE CHECKING function checkTypeParameter(node) { @@ -45632,7 +45854,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 154 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 155 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -45643,7 +45865,7 @@ 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 === 154 /* Constructor */ || func.kind === 158 /* ConstructSignature */ || func.kind === 163 /* ConstructorType */) { + if (func.kind === 155 /* Constructor */ || func.kind === 159 /* ConstructSignature */ || func.kind === 164 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -45687,7 +45909,8 @@ var ts; } else { var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), node.type, + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), // TODO: GH#18217 + node.type, /*headMessage*/ undefined, leadingError); } } @@ -45709,13 +45932,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 192 /* ArrowFunction */: - case 157 /* CallSignature */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 162 /* FunctionType */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 193 /* ArrowFunction */: + case 158 /* CallSignature */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 163 /* FunctionType */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -45733,7 +45956,7 @@ var ts; error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 180 /* ArrayBindingPattern */ || name.kind === 179 /* ObjectBindingPattern */) { + else if (name.kind === 181 /* ArrayBindingPattern */ || name.kind === 180 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -45742,13 +45965,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 159 /* IndexSignature */) { + if (node.kind === 160 /* 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 === 162 /* FunctionType */ || node.kind === 233 /* FunctionDeclaration */ || node.kind === 163 /* ConstructorType */ || - node.kind === 157 /* CallSignature */ || node.kind === 154 /* Constructor */ || - node.kind === 158 /* ConstructSignature */) { + else if (node.kind === 163 /* FunctionType */ || node.kind === 234 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || + node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || + node.kind === 159 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -45778,10 +46001,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 157 /* CallSignature */: + case 158 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -45811,7 +46034,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 159 /* IndexSignature */ && node.kind !== 283 /* JSDocFunctionType */) { + if (node.kind !== 160 /* IndexSignature */ && node.kind !== 284 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -45828,7 +46051,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* Constructor */) { + if (member.kind === 155 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { @@ -45839,20 +46062,21 @@ var ts; else { var isStatic = ts.hasModifier(member, 32 /* Static */); var names = isStatic ? staticNames : instanceNames; - var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); - if (memberName) { + var name = member.name; + var memberName = name && ts.getPropertyNameForPropertyNameNode(name); + if (name && memberName) { switch (member.kind) { - case 155 /* GetAccessor */: - addName(names, member.name, memberName, 1 /* Getter */); + case 156 /* GetAccessor */: + addName(names, name, memberName, 1 /* Getter */); break; - case 156 /* SetAccessor */: - addName(names, member.name, memberName, 2 /* Setter */); + case 157 /* SetAccessor */: + addName(names, name, memberName, 2 /* Setter */); break; - case 151 /* PropertyDeclaration */: - addName(names, member.name, memberName, 3 /* Property */); + case 152 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* Property */); break; - case 153 /* MethodDeclaration */: - addName(names, member.name, memberName, 4 /* Method */); + case 154 /* MethodDeclaration */: + addName(names, name, memberName, 4 /* Method */); break; } } @@ -45914,15 +46138,16 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 /* PropertySignature */) { + if (member.kind === 151 /* PropertySignature */) { var memberName = void 0; - switch (member.name.kind) { + var name = member.name; + switch (name.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - memberName = member.name.text; + memberName = name.text; break; case 71 /* Identifier */: - memberName = ts.idText(member.name); + memberName = ts.idText(name); break; default: continue; @@ -45938,7 +46163,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 235 /* InterfaceDeclaration */) { + if (node.kind === 236 /* 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 @@ -45993,7 +46218,7 @@ var ts; 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.hasModifier(node, 128 /* Abstract */) && node.kind === 153 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 154 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -46018,7 +46243,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 151 /* PropertyDeclaration */ && + return n.kind === 152 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -46048,7 +46273,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 215 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -46073,7 +46298,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 155 /* GetAccessor */) { + if (node.kind === 156 /* GetAccessor */) { if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -46083,13 +46308,13 @@ 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 === 146 /* ComputedPropertyName */) { + if (node.name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(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 === 155 /* GetAccessor */ ? 156 /* SetAccessor */ : 155 /* GetAccessor */; + var otherKind = node.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -46107,7 +46332,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 155 /* GetAccessor */) { + if (node.kind === 156 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -46144,7 +46369,7 @@ var ts; } function getTypeParametersForTypeReference(node) { var type = getTypeFromTypeReference(node); - if (type !== unknownType) { + if (type !== errorType) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters || @@ -46155,11 +46380,11 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 161 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 162 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } var type = getTypeFromTypeReference(node); - if (type !== unknownType) { + if (type !== errorType) { if (node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved ts.forEach(node.typeArguments, checkSourceElement); @@ -46170,7 +46395,7 @@ var ts; } } } - if (type.flags & 16 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { + if (type.flags & 32 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -46179,7 +46404,7 @@ var ts; var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType); if (!typeReferenceNode) return undefined; - var typeParameters = getTypeParametersForTypeReference(typeReferenceNode); + var typeParameters = getTypeParametersForTypeReference(typeReferenceNode); // TODO: GH#18217 var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]); return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters))); } @@ -46210,14 +46435,14 @@ var ts; ts.forEach(node.types, checkSourceElement); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 1048576 /* IndexedAccess */)) { + if (!(type.flags & 2097152 /* IndexedAccess */)) { return type; } // Check if the index type is assignable to 'keyof T' for the object type. var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 185 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 186 /* 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)); } @@ -46225,7 +46450,7 @@ var ts; } // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. - if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 84 /* NumberLike */)) { + if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 168 /* NumberLike */)) { return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); @@ -46254,7 +46479,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 170 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 /* 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); @@ -46270,9 +46495,9 @@ var ts; 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 !== 235 /* InterfaceDeclaration */ && - n.parent.kind !== 234 /* ClassDeclaration */ && - n.parent.kind !== 204 /* ClassExpression */ && + if (n.parent.kind !== 236 /* InterfaceDeclaration */ && + n.parent.kind !== 235 /* ClassDeclaration */ && + n.parent.kind !== 205 /* ClassExpression */ && n.flags & 4194304 /* 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 @@ -46363,7 +46588,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 153 /* MethodDeclaration */ || node.kind === 152 /* MethodSignature */) && + var reportError = (node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -46402,7 +46627,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 235 /* InterfaceDeclaration */ || node.parent.kind === 165 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 236 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -46413,7 +46638,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 233 /* FunctionDeclaration */ || node.kind === 153 /* MethodDeclaration */ || node.kind === 152 /* MethodSignature */ || node.kind === 154 /* Constructor */) { + if (node.kind === 234 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -46542,22 +46767,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 273 /* SourceFile */: + case 274 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; @@ -46565,20 +46790,20 @@ var ts; d = d.expression; /* falls through */ // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 242 /* ImportEqualsDeclaration */: - case 245 /* NamespaceImport */: - case 244 /* ImportClause */: + case 243 /* ImportEqualsDeclaration */: + case 246 /* NamespaceImport */: + case 245 /* ImportClause */: var result_3 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); return result_3; - case 231 /* VariableDeclaration */: - case 181 /* BindingElement */: - case 233 /* FunctionDeclaration */: - case 247 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 232 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 234 /* FunctionDeclaration */: + case 248 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: - ts.Debug.fail(ts.Debug.showSyntaxKind(d)); + return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); } } } @@ -46611,7 +46836,7 @@ var ts; if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; } - var thenFunction = getTypeOfPropertyOfType(promise, "then"); + var thenFunction = getTypeOfPropertyOfType(promise, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; } @@ -46643,7 +46868,7 @@ var ts; * The runtime behavior of the `await` keyword. */ function checkAwaitedType(type, errorNode, diagnosticMessage) { - return getAwaitedType(type, errorNode, diagnosticMessage) || unknownType; + return getAwaitedType(type, errorNode, diagnosticMessage) || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage) { var typeAsAwaitable = type; @@ -46653,7 +46878,7 @@ var ts; if (isTypeAny(type)) { return typeAsAwaitable.awaitedTypeOfType = type; } - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { var types = void 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -46732,7 +46957,8 @@ var ts; var thenFunction = getTypeOfPropertyOfType(type, "then"); if (thenFunction && getSignaturesOfType(thenFunction, 0 /* Call */).length > 0) { if (errorNode) { - ts.Debug.assert(!!diagnosticMessage); + if (!diagnosticMessage) + return ts.Debug.fail(); error(errorNode, diagnosticMessage); } return undefined; @@ -46777,58 +47003,58 @@ var ts; // then(...): Promise; // } // - var returnTypeNode = ts.getEffectiveReturnTypeNode(node); + var returnTypeNode = ts.getEffectiveReturnTypeNode(node); // TODO: GH#18217 var returnType = getTypeFromTypeNode(returnTypeNode); if (languageVersion >= 2 /* ES2015 */) { - if (returnType === unknownType) { - return unknownType; + if (returnType === errorType) { + return errorType; } var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true); if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { // The promise type was not a valid type reference to the global promise type, so we // report an error and return the unknown type. error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); - return unknownType; + return errorType; } } else { // Always mark the type node as referenced if it points to a value markTypeNodeAsReferenced(returnTypeNode); - if (returnType === unknownType) { - return unknownType; + if (returnType === errorType) { + return errorType; } var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode); if (promiseConstructorName === undefined) { error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); - return unknownType; + return errorType; } var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67216319 /* Value */, /*ignoreErrors*/ true); - var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; - if (promiseConstructorType === unknownType) { + var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; + if (promiseConstructorType === errorType) { if (promiseConstructorName.kind === 71 /* 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 { error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); } - return unknownType; + return errorType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(/*reportErrors*/ true); if (globalPromiseConstructorLikeType === emptyObjectType) { // If we couldn't resolve the global PromiseConstructorLike type we cannot verify // compatibility with __awaiter. error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); - return unknownType; + return errorType; } if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value)) { - return unknownType; + return errorType; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67216319 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); - return unknownType; + return errorType; } } // Get and return the awaited type of the return type. @@ -46845,26 +47071,30 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 148 /* Parameter */: + case 149 /* Parameter */: expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); + errorInfo = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); + errorInfo = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - var methodType = getTypeOfNode(node.parent); + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + var methodType = getTypeOfNode(node.parent); // TODO: GH#18217 var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); break; + default: + return ts.Debug.fail(); } checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; }); } @@ -46904,12 +47134,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 169 /* IntersectionType */: - case 168 /* UnionType */: + case 170 /* IntersectionType */: + case 169 /* UnionType */: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 172 /* ParenthesizedType */) { + while (typeNode.kind === 173 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -46941,9 +47171,9 @@ var ts; } } return commonEntityName; - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return node.typeName; } } @@ -46967,14 +47197,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* 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 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -46983,19 +47213,19 @@ var ts; } } break; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 148 /* Parameter */: + case 149 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -47038,12 +47268,12 @@ var ts; return; } if (!containsArgumentsReference(decl)) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 145 /* 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, ts.idText(node.name.kind === 146 /* QualifiedName */ ? node.name.right : node.name)); } 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 === 145 /* 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 === 146 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -47072,7 +47302,7 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -47085,7 +47315,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 146 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 147 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -47114,7 +47344,7 @@ var ts; } } } - var body = node.kind === 152 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 153 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if ((functionFlags & 1 /* Generator */) === 0) { // Async function or normal function @@ -47155,41 +47385,41 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 273 /* SourceFile */: - case 238 /* ModuleDeclaration */: - case 212 /* Block */: - case 240 /* CaseBlock */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 274 /* SourceFile */: + case 239 /* ModuleDeclaration */: + case 213 /* Block */: + case 241 /* CaseBlock */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 154 /* Constructor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 155 /* Constructor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 236 /* TypeAliasDeclaration */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 237 /* TypeAliasDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -47199,15 +47429,8 @@ var ts; } function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; - if (isIdentifierThatStartsWithUnderScore(node)) { - var declaration_2 = ts.getRootDeclaration(node.parent); - if ((declaration_2.kind === 231 /* VariableDeclaration */ && ts.isForInOrOfStatement(declaration_2.parent.parent)) || - declaration_2.kind === 147 /* TypeParameter */) { - return; - } - } var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(0 /* Local */, ts.createDiagnosticForNodeSpan(ts.getSourceFileOfNode(declaration), declaration, node, message, name)); + addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(node, message, name)); } function parameterNameStartsWithUnderscore(parameterName) { return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); @@ -47220,11 +47443,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 153 /* MethodDeclaration */: - case 151 /* PropertyDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - if (member.kind === 156 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 154 /* MethodDeclaration */: + case 152 /* PropertyDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + if (member.kind === 157 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -47233,7 +47456,7 @@ var ts; addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 154 /* Constructor */: + case 155 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -47241,8 +47464,8 @@ var ts; } } break; - case 159 /* IndexSignature */: - case 211 /* SemicolonClassElement */: + case 160 /* IndexSignature */: + case 212 /* SemicolonClassElement */: // Can't be private break; default: @@ -47283,6 +47506,7 @@ var ts; // Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value. var unusedImports = ts.createMap(); var unusedDestructures = ts.createMap(); + var unusedVariables = ts.createMap(); nodeWithLocals.locals.forEach(function (local) { // If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`. // If it's a type parameter merged with a parameter, check if the parameter-side is used. @@ -47303,6 +47527,11 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } } + else if (ts.isVariableDeclaration(declaration)) { + if (!isIdentifierThatStartsWithUnderScore(declaration.name) || !ts.isForInOrOfStatement(declaration.parent.parent)) { + addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); + } + } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); if (parameter) { @@ -47320,50 +47549,77 @@ var ts; unusedImports.forEach(function (_a) { var importClause = _a[0], unuseds = _a[1]; var importDecl = importClause.parent; - if (forEachImportedDeclaration(importClause, function (d) { return !ts.contains(unuseds, d); })) { + var nDeclarations = (importClause.name ? 1 : 0) + + (importClause.namedBindings ? + (importClause.namedBindings.kind === 246 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + : 0); + if (nDeclarations === unuseds.length) { + addDiagnostic(0 /* Local */, unuseds.length === 1 + ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) + : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); + } + else { for (var _i = 0, unuseds_1 = unuseds; _i < unuseds_1.length; _i++) { var unused = unuseds_1[_i]; errorUnusedLocal(unused, ts.idText(unused.name), addDiagnostic); } } - else if (unuseds.length === 1) { - addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name))); - } - else { - addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); - } }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; - if (!bindingPattern.elements.every(function (e) { return ts.contains(bindingElements, e); })) { + if (bindingPattern.elements.length === bindingElements.length) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 233 /* VariableDeclarationList */) { + addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); + } + else { + addDiagnostic(kind, bindingElements.length === 1 + ? ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(ts.first(bindingElements).name, ts.isIdentifier))) + : ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused)); + } + } + else { for (var _i = 0, bindingElements_1 = bindingElements; _i < bindingElements_1.length; _i++) { var e = bindingElements_1[_i]; addDiagnostic(kind, ts.createDiagnosticForNode(e, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(e.name, ts.isIdentifier)))); } } - else if (bindingElements.length === 1) { - addDiagnostic(kind, ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(ts.first(bindingElements).name, ts.isIdentifier)))); + }); + unusedVariables.forEach(function (_a) { + var declarationList = _a[0], declarations = _a[1]; + if (declarationList.declarations.length === declarations.length) { + addDiagnostic(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 === 214 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { - addDiagnostic(kind, ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused)); + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var decl = declarations_5[_i]; + addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(decl.name, ts.isIdentifier)))); + } } }); } + function bindingNameText(name) { + switch (name.kind) { + case 71 /* Identifier */: + return ts.idText(name); + case 181 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); + default: + return ts.Debug.assertNever(name); + } + } function isImportedDeclaration(node) { - return node.kind === 244 /* ImportClause */ || node.kind === 247 /* ImportSpecifier */ || node.kind === 245 /* NamespaceImport */; + return node.kind === 245 /* ImportClause */ || node.kind === 248 /* ImportSpecifier */ || node.kind === 246 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 244 /* ImportClause */ ? decl : decl.kind === 245 /* NamespaceImport */ ? decl.parent : decl.parent.parent; - } - function forEachImportedDeclaration(importClause, cb) { - var defaultName = importClause.name, namedBindings = importClause.namedBindings; - return (defaultName && cb(importClause)) || - namedBindings && (namedBindings.kind === 245 /* NamespaceImport */ ? cb(namedBindings) : ts.forEach(namedBindings.elements, cb)); + return decl.kind === 245 /* ImportClause */ ? decl : decl.kind === 246 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 212 /* Block */) { + if (node.kind === 213 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -47393,12 +47649,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 151 /* PropertyDeclaration */ || - node.kind === 150 /* PropertySignature */ || - node.kind === 153 /* MethodDeclaration */ || - node.kind === 152 /* MethodSignature */ || - node.kind === 155 /* GetAccessor */ || - node.kind === 156 /* SetAccessor */) { + if (node.kind === 152 /* PropertyDeclaration */ || + node.kind === 151 /* PropertySignature */ || + node.kind === 154 /* MethodDeclaration */ || + node.kind === 153 /* MethodSignature */ || + node.kind === 156 /* GetAccessor */ || + node.kind === 157 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -47407,7 +47663,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 148 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 149 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -47426,6 +47682,7 @@ var ts; } return true; } + return false; }); } function checkIfNewTargetIsCapturedInEnclosingScope(node) { @@ -47440,6 +47697,7 @@ var ts; } return true; } + return false; }); } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { @@ -47456,7 +47714,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 === 273 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -47471,7 +47729,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 === 273 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(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)); } @@ -47506,7 +47764,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 === 231 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 232 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -47518,17 +47776,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 232 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 213 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 214 /* 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 === 212 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 239 /* ModuleBlock */ || - container.kind === 238 /* ModuleDeclaration */ || - container.kind === 273 /* SourceFile */); + (container.kind === 213 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 240 /* ModuleBlock */ || + container.kind === 239 /* ModuleDeclaration */ || + container.kind === 274 /* 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 @@ -47543,7 +47801,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 148 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 149 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -47554,7 +47812,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 184 /* PropertyAccessExpression */) { + if (n.kind === 185 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -47573,8 +47831,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 148 /* Parameter */ || - symbol.valueDeclaration.kind === 181 /* BindingElement */) { + if (symbol.valueDeclaration.kind === 149 /* Parameter */ || + symbol.valueDeclaration.kind === 182 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -47588,7 +47846,7 @@ var ts; return ts.isFunctionLike(current.parent) || // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - (current.parent.kind === 151 /* PropertyDeclaration */ && + (current.parent.kind === 152 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)); })) { @@ -47621,18 +47879,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 === 146 /* ComputedPropertyName */) { + if (node.name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 181 /* BindingElement */) { - if (node.parent.kind === 179 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 182 /* BindingElement */) { + if (node.parent.kind === 180 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 146 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -47640,7 +47898,7 @@ var ts; var parentType = getTypeForBindingElementParent(parent); var name = node.propertyName || node.name; if (!ts.isBindingPattern(name)) { - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); // TODO: GH#18217 markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. if (parent.initializer && property) { checkPropertyAccessibility(parent, parent.initializer, parentType, property); @@ -47649,20 +47907,20 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 180 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 181 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 148 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 149 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 220 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 221 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); @@ -47679,8 +47937,8 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 220 /* ForInStatement */) { - var initializer = ts.isInJavaScriptFile(node) && ts.getDeclaredJavascriptInitializer(node) || node.initializer; + var initializer = ts.getEffectiveInitializer(node); + if (initializer && node.parent.parent.kind !== 221 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -47689,7 +47947,7 @@ var ts; // Node is a secondary declaration, check that type is identical to primary declaration and check that // initializer is consistent with type associated with the node var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); - if (type !== unknownType && declarationType !== unknownType && + if (type !== errorType && declarationType !== errorType && !isTypeIdenticalTo(type, declarationType) && !(symbol.flags & 67108864 /* JSContainer */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); @@ -47702,10 +47960,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 151 /* PropertyDeclaration */ && node.kind !== 150 /* PropertySignature */) { + if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 231 /* VariableDeclaration */ || node.kind === 181 /* BindingElement */) { + if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -47714,14 +47972,14 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 151 /* PropertyDeclaration */ || nextDeclaration.kind === 150 /* PropertySignature */ + var message = nextDeclaration.kind === 152 /* PropertyDeclaration */ || nextDeclaration.kind === 151 /* 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; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 148 /* Parameter */ && right.kind === 231 /* VariableDeclaration */) || - (left.kind === 231 /* VariableDeclaration */ && right.kind === 148 /* Parameter */)) { + if ((left.kind === 149 /* Parameter */ && right.kind === 232 /* VariableDeclaration */) || + (left.kind === 232 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -47760,7 +48018,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 214 /* EmptyStatement */) { + if (node.thenStatement.kind === 215 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -47780,12 +48038,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 232 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 233 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 232 /* VariableDeclarationList */) { + if (node.initializer.kind === 233 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -47819,18 +48077,18 @@ 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 === 232 /* VariableDeclarationList */) { + if (node.initializer.kind === 233 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 182 /* ArrayLiteralExpression */ || varExpr.kind === 183 /* ObjectLiteralExpression */) { + if (varExpr.kind === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* 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. - checkDestructuringAssignment(varExpr, iteratedType || unknownType); + checkDestructuringAssignment(varExpr, iteratedType || errorType); } else { var leftType = checkExpression(varExpr); @@ -47858,7 +48116,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 === 232 /* VariableDeclarationList */) { + if (node.initializer.kind === 233 /* 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); @@ -47872,7 +48130,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 === 182 /* ArrayLiteralExpression */ || varExpr.kind === 183 /* ObjectLiteralExpression */) { + if (varExpr.kind === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* 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)) { @@ -47885,7 +48143,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (rightType === neverType || !isTypeAssignableToKind(rightType, 134217728 /* NonPrimitive */ | 7372800 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 14745600 /* InstantiableNonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -47918,7 +48176,7 @@ var ts; */ function getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterables, checkAssignability) { if (inputType === neverType) { - reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); + reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); // TODO: GH#18217 return undefined; } var uplevelIteration = languageVersion >= 2 /* ES2015 */; @@ -47940,16 +48198,16 @@ var ts; // This allows us to find other non-string element types from an array unioned with // a string. if (allowStringInput) { - if (arrayType.flags & 131072 /* Union */) { + if (arrayType.flags & 262144 /* Union */) { // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the result of filter is a new array. var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 34 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 68 /* StringLike */); }); if (filteredTypes !== arrayTypes) { arrayType = getUnionType(filteredTypes, 2 /* Subtype */); } } - else if (arrayType.flags & 34 /* StringLike */) { + else if (arrayType.flags & 68 /* StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; @@ -47962,7 +48220,7 @@ var ts; } // Now that we've removed all the StringLike types, if no constituents remain, then the entire // arrayOrStringType was a string. - if (arrayType.flags & 16384 /* Never */) { + if (arrayType.flags & 32768 /* Never */) { return stringType; } } @@ -47993,7 +48251,7 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 34 /* StringLike */) { + if (arrayElementType.flags & 68 /* StringLike */) { return stringType; } return getUnionType([arrayElementType, stringType], 2 /* Subtype */); @@ -48068,11 +48326,11 @@ var ts; } } var asyncMethodType = allowAsyncIterables && getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); - var methodType = asyncMethodType || (allowSyncIterables && getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator"))); + var methodType = asyncMethodType || (allowSyncIterables ? getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")) : undefined); if (isTypeAny(methodType)) { return undefined; } - var signatures = methodType && getSignaturesOfType(methodType, 0 /* Call */); + var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined; if (!ts.some(signatures)) { if (errorNode) { // only report on the first error @@ -48198,14 +48456,14 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return node.kind === 155 /* GetAccessor */ - && ts.getEffectiveSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 156 /* SetAccessor */)) !== undefined; + return node.kind === 156 /* GetAccessor */ + && ts.getEffectiveSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 157 /* SetAccessor */)) !== undefined; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = (ts.getFunctionFlags(func) & 3 /* AsyncGenerator */) === 2 /* Async */ ? getPromisedTypeOfPromise(returnType) // Async function : returnType; // AsyncGenerator function, Generator function, or normal function - return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 2048 /* Void */ | 1 /* Any */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 4096 /* Void */ | 3 /* AnyOrUnknown */); } function checkReturnStatement(node) { // Grammar checking @@ -48221,7 +48479,7 @@ var ts; var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(func); var isGenerator = functionFlags & 1 /* Generator */; - if (strictNullChecks || node.expression || returnType.flags & 16384 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 32768 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; if (isGenerator) { // AsyncGenerator function or Generator function // A generator does not need its return expressions checked against its return type. @@ -48230,12 +48488,12 @@ var ts; // for generators. return; } - else if (func.kind === 156 /* SetAccessor */) { + else if (func.kind === 157 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 154 /* Constructor */) { + else if (func.kind === 155 /* Constructor */) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -48256,7 +48514,7 @@ var ts; } } } - else if (func.kind !== 154 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { + else if (func.kind !== 155 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { // 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); } @@ -48285,7 +48543,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 === 266 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 267 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -48297,7 +48555,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 265 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 266 /* 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. @@ -48326,10 +48584,11 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 227 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 228 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } + return false; }); } // ensure that label is unique @@ -48389,8 +48648,8 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); - if (ts.getObjectFlags(type) & 1 /* Class */ && ts.isClassLike(type.symbol.valueDeclaration)) { - var classDeclaration = type.symbol.valueDeclaration; + 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]; // Only process instance properties with computed names here. @@ -48414,7 +48673,7 @@ var ts; errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; } } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { + if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { // TODO: GH#18217 error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); } function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { @@ -48431,8 +48690,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 && - (propDeclaration.kind === 199 /* BinaryExpression */ || - ts.getNameOfDeclaration(propDeclaration).kind === 146 /* ComputedPropertyName */ || + (propDeclaration.kind === 200 /* BinaryExpression */ || + ts.getNameOfDeclaration(propDeclaration).kind === 147 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -48459,6 +48718,7 @@ var ts; // The predefined type keywords are reserved and cannot be used as names of user defined types. switch (name.escapedText) { case "any": + case "unknown": case "number": case "boolean": case "string": @@ -48468,6 +48728,15 @@ var ts; error(name, message, name.escapedText); } } + /** + * The name cannot be used as 'Object' of user defined types with special target. + */ + function checkClassNameCollisionWithObject(name) { + if (languageVersion === 1 /* ES5 */ && name.escapedText === "Object" + && moduleKind !== ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.ESNext) { + error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 + } + } /** * Check each type parameter and check that type parameters have no duplicate type parameter declarations */ @@ -48509,8 +48778,8 @@ var ts; if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } @@ -48519,8 +48788,8 @@ var ts; function areTypeParametersIdentical(declarations, targetParameters) { var maxTypeArgumentCount = ts.length(targetParameters); var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters); - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; // If this declaration has too few or too many type parameters, we report an error var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration); var numTypeParameters = sourceParameters.length; @@ -48580,6 +48849,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + if (!(node.flags & 4194304 /* Ambient */)) { + checkClassNameCollisionWithObject(node.name); + } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); checkExportsOnMergedDeclarations(node); @@ -48619,10 +48891,10 @@ var ts; issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); } checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseConstructorType.flags & 1081344 /* TypeVariable */ && !isMixinConstructorType(staticType)) { + if (baseConstructorType.flags & 2162688 /* TypeVariable */ && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 1081344 /* TypeVariable */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 2162688 /* TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. We can simply compare the type // references (as opposed to checking the structure of the types) because elsewhere we have already checked @@ -48645,7 +48917,7 @@ var ts; checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); - if (t !== unknownType) { + if (t !== errorType) { if (isValidBaseType(t)) { var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : @@ -48716,7 +48988,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 234 /* ClassDeclaration */ || d.kind === 235 /* InterfaceDeclaration */; + return d.kind === 235 /* ClassDeclaration */ || d.kind === 236 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -48741,7 +49013,7 @@ var ts; if (base.flags & 4194304 /* Prototype */) { continue; } - var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); + var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); // TODO: GH#18217 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { @@ -48755,7 +49027,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 204 /* ClassExpression */) { + if (derivedClassDecl.kind === 205 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -48770,7 +49042,7 @@ var ts; // either base or derived property is private - not override, skip it continue; } - if (isPrototypeProperty(base) && isPrototypeProperty(derived) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { + if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { // method is overridden with method or property/accessor is overridden with property/accessor - correct case continue; } @@ -48837,7 +49109,7 @@ var ts; var propName = member.name; if (ts.isIdentifier(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 1 /* Any */ || getFalsyFlags(type) & 4096 /* Undefined */)) { + if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 8192 /* Undefined */)) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -48847,7 +49119,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 151 /* PropertyDeclaration */ && + return node.kind === 152 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -48856,7 +49128,7 @@ var ts; var reference = ts.createPropertyAccess(ts.createThis(), propName); reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 4096 /* Undefined */); + return !(getFalsyFlags(flowType) & 8192 /* Undefined */); } function checkInterfaceDeclaration(node) { // Grammar checking @@ -48869,7 +49141,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 235 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -48974,7 +49246,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -48984,7 +49256,7 @@ var ts; } } break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -49012,18 +49284,22 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return evaluate(expr.expression); case 71 /* Identifier */: - return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), expr.escapedText); - case 185 /* ElementAccessExpression */: - case 184 /* PropertyAccessExpression */: + var identifier = expr; + if (isInfinityOrNaNString(identifier.escapedText)) { + return +(identifier.escapedText); + } + return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); + case 186 /* ElementAccessExpression */: + case 185 /* 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 === 184 /* PropertyAccessExpression */) { + if (ex.kind === 185 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -49055,8 +49331,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 /* Identifier */ || - node.kind === 184 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 185 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 185 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 186 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -49094,7 +49370,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 !== 237 /* EnumDeclaration */) { + if (declaration.kind !== 238 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -49115,10 +49391,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; - if ((declaration.kind === 234 /* ClassDeclaration */ || - (declaration.kind === 233 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 235 /* ClassDeclaration */ || + (declaration.kind === 234 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -49169,7 +49445,7 @@ var ts; if (symbol.flags & 512 /* ValueModule */ && symbol.declarations.length > 1 && !inAmbientContext - && isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { + && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -49181,7 +49457,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, 234 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 235 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -49231,23 +49507,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* 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]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 248 /* ExportAssignment */: - case 249 /* ExportDeclaration */: + case 249 /* ExportAssignment */: + case 250 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 242 /* ImportEqualsDeclaration */: - case 243 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 181 /* BindingElement */: - case 231 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 232 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -49258,12 +49534,12 @@ var ts; break; } // falls through - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: - case 233 /* FunctionDeclaration */: - case 235 /* InterfaceDeclaration */: - case 238 /* ModuleDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 234 /* FunctionDeclaration */: + case 236 /* InterfaceDeclaration */: + case 239 /* ModuleDeclaration */: + case 237 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -49286,12 +49562,12 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node; - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: do { node = node.left; } while (node.kind !== 71 /* Identifier */); return node; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 71 /* Identifier */); @@ -49300,7 +49576,7 @@ var ts; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (ts.nodeIsMissing(moduleName)) { + if (!moduleName || ts.nodeIsMissing(moduleName)) { // Should be a parse error. return false; } @@ -49308,9 +49584,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 239 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 273 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 249 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 250 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -49343,14 +49619,14 @@ var ts; (symbol.flags & 67901928 /* Type */ ? 67901928 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 251 /* ExportSpecifier */ ? + var message = node.kind === 252 /* 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 === 251 /* ExportSpecifier */ + && node.kind === 252 /* ExportSpecifier */ && !(target.flags & 67216319 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -49377,7 +49653,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 245 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -49401,7 +49677,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 253 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 254 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319 /* Value */) { @@ -49437,10 +49713,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 239 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 239 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 273 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -49457,7 +49733,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 273 /* SourceFile */ || node.parent.kind === 239 /* ModuleBlock */ || node.parent.kind === 238 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 274 /* SourceFile */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 239 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -49486,8 +49762,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 273 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 238 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -49558,8 +49834,8 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; + 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))); } @@ -49575,168 +49851,168 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 233 /* FunctionDeclaration */ && declaration.kind !== 153 /* MethodDeclaration */) || + return (declaration.kind !== 234 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { if (!node) { return; } - if (ts.isInJavaScriptFile(node) && node.jsDoc) { - for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { - var tags = _a[_i].tags; - ts.forEach(tags, checkSourceElement); - } + if (ts.isInJavaScriptFile(node)) { + ts.forEach(node.jsDoc, function (_a) { + var tags = _a.tags; + return ts.forEach(tags, checkSourceElement); + }); } var kind = node.kind; if (cancellationToken) { // 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 238 /* ModuleDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 233 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 234 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return checkTypeParameter(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return checkParameter(node); - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return checkPropertyDeclaration(node); - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: return checkSignatureDeclaration(node); - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: return checkMethodDeclaration(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return checkConstructorDeclaration(node); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return checkAccessorDeclaration(node); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return checkTypeReferenceNode(node); - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return checkTypePredicate(node); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return checkTypeQuery(node); - case 165 /* TypeLiteral */: + case 166 /* TypeLiteral */: return checkTypeLiteral(node); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return checkArrayType(node); - case 167 /* TupleType */: + case 168 /* TupleType */: return checkTupleType(node); - case 168 /* UnionType */: - case 169 /* IntersectionType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return checkSourceElement(node.type); - case 174 /* TypeOperator */: + case 175 /* TypeOperator */: return checkTypeOperator(node); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return checkConditionalType(node); - case 171 /* InferType */: + case 172 /* InferType */: return checkInferType(node); - case 178 /* ImportType */: + case 179 /* ImportType */: return checkImportType(node); - case 289 /* JSDocAugmentsTag */: + case 290 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 292 /* JSDocParameterTag */: + case 293 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: checkSignatureDeclaration(node); // falls through - case 281 /* JSDocNonNullableType */: - case 280 /* JSDocNullableType */: - case 278 /* JSDocAllType */: - case 279 /* JSDocUnknownType */: - case 286 /* JSDocTypeLiteral */: + case 282 /* JSDocNonNullableType */: + case 281 /* JSDocNullableType */: + case 279 /* JSDocAllType */: + case 280 /* JSDocUnknownType */: + case 287 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 277 /* JSDocTypeExpression */: + case 278 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 176 /* MappedType */: + case 177 /* MappedType */: return checkMappedType(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 212 /* Block */: - case 239 /* ModuleBlock */: + case 213 /* Block */: + case 240 /* ModuleBlock */: return checkBlock(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return checkVariableStatement(node); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return checkExpressionStatement(node); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return checkIfStatement(node); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return checkDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return checkWhileStatement(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return checkForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return checkForInStatement(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return checkForOfStatement(node); - case 222 /* ContinueStatement */: - case 223 /* BreakStatement */: + case 223 /* ContinueStatement */: + case 224 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return checkReturnStatement(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return checkWithStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return checkSwitchStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return checkLabeledStatement(node); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return checkThrowStatement(node); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return checkTryStatement(node); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return checkBindingElement(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return checkClassDeclaration(node); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return checkImportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return checkExportDeclaration(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return checkExportAssignment(node); - case 214 /* EmptyStatement */: - case 230 /* DebuggerStatement */: + case 215 /* EmptyStatement */: + case 231 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 252 /* MissingDeclaration */: + case 253 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -49759,7 +50035,7 @@ var ts; if (!ts.isJSDocTypeExpression(parent)) { error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature); } - var paramTag = parent.parent; + var paramTag = node.parent.parent; if (!ts.isJSDocParameterTag(paramTag)) { error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature); return; @@ -49777,8 +50053,8 @@ var ts; function getTypeFromJSDocVariadicType(node) { var type = getTypeFromTypeNode(node.type); var parent = node.parent; - var paramTag = parent.parent; - if (ts.isJSDocTypeExpression(parent) && ts.isJSDocParameterTag(paramTag)) { + var paramTag = node.parent.parent; + 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) { @@ -49817,20 +50093,20 @@ var ts; } } function checkDeferredNodes() { - for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { - var node = deferredNodes_1[_i]; + for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { + var node = _a[_i]; switch (node.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -49845,9 +50121,9 @@ var ts; function unusedIsError(kind) { switch (kind) { case 0 /* Local */: - return compilerOptions.noUnusedLocals; + return !!compilerOptions.noUnusedLocals; case 1 /* Parameter */: - return compilerOptions.noUnusedParameters; + return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); } @@ -49963,13 +50239,13 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -49977,8 +50253,8 @@ var ts; // falls through // 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 - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* 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. @@ -49987,7 +50263,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928 /* Type */); } break; - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -50035,28 +50311,28 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 147 /* TypeParameter */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 237 /* EnumDeclaration */: + case 148 /* TypeParameter */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 238 /* EnumDeclaration */: return true; + default: + return false; } } // True if the given identifier is part of a type reference - function isTypeReferenceIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 145 /* QualifiedName */) { + function isTypeReferenceIdentifier(node) { + while (node.parent.kind === 146 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 161 /* TypeReference */; + return node.parent.kind === 162 /* TypeReference */; } - function isHeritageClauseElementIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 184 /* PropertyAccessExpression */) { + function isHeritageClauseElementIdentifier(node) { + while (node.parent.kind === 185 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 206 /* ExpressionWithTypeArguments */; + return node.parent.kind === 207 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -50084,14 +50360,14 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 145 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 242 /* ImportEqualsDeclaration */) { - return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; + if (nodeOnRightSide.parent.kind === 243 /* ImportEqualsDeclaration */) { + return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 248 /* ExportAssignment */) { - return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; + if (nodeOnRightSide.parent.kind === 249 /* ExportAssignment */) { + return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; } @@ -50116,7 +50392,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 178 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 179 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -50126,7 +50402,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 184 /* PropertyAccessExpression */ && + entityName.parent.kind === 185 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -50134,7 +50410,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 248 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 249 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -50144,7 +50420,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 242 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 243 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -50162,7 +50438,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 206 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 207 /* ExpressionWithTypeArguments */) { meaning = 67901928 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -50178,10 +50454,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 292 /* JSDocParameterTag */) { + if (entityName.parent.kind === 293 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 147 /* TypeParameter */ && entityName.parent.parent.kind === 295 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 296 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -50198,12 +50474,12 @@ var ts; } return resolveEntityName(entityName, 67216319 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 184 /* PropertyAccessExpression */ || entityName.kind === 145 /* QualifiedName */) { + else if (entityName.kind === 185 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 184 /* PropertyAccessExpression */) { + if (entityName.kind === 185 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -50213,41 +50489,43 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 161 /* TypeReference */ ? 67901928 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67901928 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 261 /* JsxAttribute */) { + else if (entityName.parent.kind === 262 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 160 /* TypePredicate */) { + if (entityName.parent.kind === 161 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } + var parent = node.parent; + var grandParent = parent.parent; if (node.flags & 8388608 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } if (isDeclarationNameOrImportPropertyName(node)) { // This is a declaration, call getSymbolOfNode - return getSymbolOfNode(node.parent); + return getSymbolOfNode(parent); } else if (ts.isLiteralComputedPropertyDeclarationName(node)) { - return getSymbolOfNode(node.parent.parent); + return getSymbolOfNode(parent.parent); } if (node.kind === 71 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 181 /* BindingElement */ && - node.parent.parent.kind === 179 /* ObjectBindingPattern */ && - node === node.parent.propertyName) { - var typeOfPattern = getTypeOfNode(node.parent.parent); + else if (parent.kind === 182 /* BindingElement */ && + grandParent.kind === 180 /* ObjectBindingPattern */ && + node === parent.propertyName) { + var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); if (propertyDeclaration) { return propertyDeclaration; @@ -50256,8 +50534,8 @@ var ts; } switch (node.kind) { case 71 /* Identifier */: - case 184 /* PropertyAccessExpression */: - case 145 /* QualifiedName */: + case 185 /* PropertyAccessExpression */: + case 146 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -50271,14 +50549,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 173 /* ThisType */: + case 174 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 97 /* SuperKeyword */: return checkExpression(node).symbol; case 123 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 154 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 155 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -50289,7 +50567,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 === 243 /* ImportDeclaration */ || node.parent.kind === 249 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 244 /* ImportDeclaration */ || node.parent.kind === 250 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJavaScriptFile(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); @@ -50297,24 +50575,24 @@ var ts; // falls through case 8 /* NumericLiteral */: // index access - var objectType = ts.isElementAccessExpression(node.parent) - ? node.parent.argumentExpression === node ? getTypeOfExpression(node.parent.expression) : undefined - : ts.isLiteralTypeNode(node.parent) && ts.isIndexedAccessTypeNode(node.parent.parent) - ? getTypeFromTypeNode(node.parent.parent.objectType) + var objectType = ts.isElementAccessExpression(parent) + ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined + : ts.isLiteralTypeNode(parent) && ts.isIndexedAccessTypeNode(grandParent) + ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); case 79 /* DefaultKeyword */: case 89 /* FunctionKeyword */: case 36 /* EqualsGreaterThanToken */: return getSymbolOfNode(node.parent); - case 178 /* ImportType */: + case 179 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 270 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 271 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67216319 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -50328,7 +50606,7 @@ var ts; function getTypeOfNode(node) { if (node.flags & 8388608 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further - return unknownType; + return errorType; } if (ts.isPartOfTypeNode(node)) { var typeFromTypeNode = getTypeFromTypeNode(node); @@ -50375,10 +50653,10 @@ var ts; var symbol = getSymbolAtLocation(node); if (symbol) { var declaredType = getDeclaredTypeOfSymbol(symbol); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); + return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol); } } - return unknownType; + return errorType; } // Gets the type of object literal or array literal of destructuring assignment. // { a } from @@ -50387,32 +50665,32 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 183 /* ObjectLiteralExpression */ || expr.kind === 182 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 184 /* ObjectLiteralExpression */ || expr.kind === 183 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 221 /* ForOfStatement */) { + if (expr.parent.kind === 222 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); - return checkDestructuringAssignment(expr, iteratedType || unknownType); + return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 199 /* BinaryExpression */) { + if (expr.parent.kind === 200 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); - return checkDestructuringAssignment(expr, iteratedType || unknownType); + 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 === 269 /* PropertyAssignment */) { + if (expr.parent.kind === 270 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); - return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 182 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 183 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); - var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType; - return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || unknownType); + var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; + return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || errorType); // TODO: GH#18217 } // Gets the property symbol corresponding to the property in destructuring assignment // 'property1' from @@ -50483,11 +50761,11 @@ var ts; return target; } // Emitter support - function isArgumentsLocalBinding(node) { - if (!ts.isGeneratedIdentifier(node)) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function isArgumentsLocalBinding(nodeIn) { + if (!ts.isGeneratedIdentifier(nodeIn)) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -50518,13 +50796,12 @@ var ts; } } function isNameOfModuleOrEnumDeclaration(node) { - var parent = node.parent; - return parent && ts.isModuleOrEnumDeclaration(parent) && node === parent.name; + return ts.isModuleOrEnumDeclaration(node.parent) && node === node.parent.name; } // 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(node, prefixLocals) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedExportContainer(nodeIn, prefixLocals) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { // When resolving the export container for the name of a module or enum // declaration, we need to start resolution at the declaration's container. @@ -50544,7 +50821,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 273 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 274 /* 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. @@ -50558,8 +50835,8 @@ var ts; } // When resolved as an expression identifier, if the given node references an import, return the declaration of // that import. Otherwise, return undefined. - function getReferencedImportDeclaration(node) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedImportDeclaration(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value @@ -50599,7 +50876,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 212 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 213 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -50614,9 +50891,9 @@ var ts; // When resolved as an expression identifier, if the given node references a nested block scoped entity with // a name that either hides an existing name or might hide it when compiled downlevel, // return the declaration of that entity. Otherwise, return undefined. - function getReferencedDeclarationWithCollidingName(node) { - if (!ts.isGeneratedIdentifier(node)) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedDeclarationWithCollidingName(nodeIn) { + if (!ts.isGeneratedIdentifier(nodeIn)) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node); if (symbol && isSymbolOfDeclarationWithCollidingName(symbol)) { @@ -50628,8 +50905,8 @@ var ts; } // Return true if the given node is a declaration of a nested block scoped entity with a name that either hides an // existing name or might hide a name when compiled downlevel - function isDeclarationWithCollidingName(node) { - node = ts.getParseTreeNode(node, ts.isDeclaration); + function isDeclarationWithCollidingName(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); if (node) { var symbol = getSymbolOfNode(node); if (symbol) { @@ -50640,16 +50917,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: - case 244 /* ImportClause */: - case 245 /* NamespaceImport */: - case 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 243 /* ImportEqualsDeclaration */: + case 245 /* ImportClause */: + case 246 /* NamespaceImport */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: var exportClause = node.exportClause; - return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 248 /* ExportAssignment */: + return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); + case 249 /* ExportAssignment */: return node.expression && node.expression.kind === 71 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -50657,9 +50934,9 @@ var ts; } return false; } - function isTopLevelValueImportEqualsWithEntityName(node) { - node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 273 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + function isTopLevelValueImportEqualsWithEntityName(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); + if (node === undefined || node.parent.kind !== 274 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -50673,11 +50950,11 @@ 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 & 67216319 /* Value */ && + return !!(target.flags & 67216319 /* Value */) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { - return isConstEnumSymbol(s) || s.constEnumOnlyModule; + return isConstEnumSymbol(s) || !!s.constEnumOnlyModule; } function isReferencedAliasDeclaration(node, checkChildren) { if (ts.isAliasSymbolDeclaration(node)) { @@ -50685,14 +50962,14 @@ var ts; if (symbol && getSymbolLinks(symbol).referenced) { return true; } - var target = getSymbolLinks(symbol).target; + var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getModifierFlags(node) & 1 /* Export */ && target.flags & 67216319 /* Value */) { // An `export import ... =` of a value symbol is always considered referenced return true; } } if (checkChildren) { - return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); + return !!ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); } return false; } @@ -50719,10 +50996,10 @@ var ts; return false; } function isRequiredInitializedParameter(parameter) { - return strictNullChecks && + return !!strictNullChecks && !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && - parameter.initializer && + !!parameter.initializer && !ts.hasModifier(parameter, 92 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { @@ -50732,7 +51009,7 @@ var ts; ts.hasModifier(parameter, 92 /* ParameterPropertyModifier */); } function getNodeCheckFlags(node) { - return getNodeLinks(node).flags; + return getNodeLinks(node).flags || 0; } function getEnumMemberValue(node) { computeEnumMemberValues(node.parent); @@ -50740,15 +51017,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 272 /* EnumMember */: - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: + case 273 /* EnumMember */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 272 /* EnumMember */) { + if (node.kind === 273 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -50761,11 +51038,11 @@ var ts; return undefined; } function isFunctionType(type) { - return type.flags & 65536 /* Object */ && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 131072 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; } - function getTypeReferenceSerializationKind(typeName, location) { + function getTypeReferenceSerializationKind(typeNameIn, location) { // ensure both `typeName` and `location` are parse tree nodes. - typeName = ts.getParseTreeNode(typeName, ts.isEntityName); + var typeName = ts.getParseTreeNode(typeNameIn, ts.isEntityName); if (!typeName) return ts.TypeReferenceSerializationKind.Unknown; if (location) { @@ -50789,31 +51066,31 @@ var ts; } // We might not be able to resolve type symbol so use unknown type in that case (eg error case) if (!typeSymbol) { - return ts.TypeReferenceSerializationKind.ObjectType; - } - var type = getDeclaredTypeOfSymbol(typeSymbol); - if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 1 /* Any */) { + var type = getDeclaredTypeOfSymbol(typeSymbol); + if (type === errorType) { + return ts.TypeReferenceSerializationKind.Unknown; + } + else if (type.flags & 3 /* AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 2048 /* Void */ | 12288 /* Nullable */ | 16384 /* Never */)) { + else if (isTypeAssignableToKind(type, 4096 /* Void */ | 24576 /* Nullable */ | 32768 /* Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 136 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 272 /* BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 84 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 168 /* NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 34 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 68 /* StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 1536 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 3072 /* ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -50826,8 +51103,8 @@ var ts; return ts.TypeReferenceSerializationKind.ObjectType; } } - function createTypeOfDeclaration(declaration, enclosingDeclaration, flags, tracker, addUndefined) { - declaration = ts.getParseTreeNode(declaration, ts.isVariableLikeOrAccessor); + function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { + var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { return ts.createToken(119 /* AnyKeyword */); } @@ -50835,8 +51112,8 @@ var ts; var symbol = getSymbolOfNode(declaration); var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) - : unknownType; - if (type.flags & 1024 /* UniqueESSymbol */ && + : errorType; + if (type.flags & 2048 /* UniqueESSymbol */ && type.symbol === symbol) { flags |= 1048576 /* AllowUniqueESSymbolType */; } @@ -50845,16 +51122,16 @@ var ts; } return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); } - function createReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, tracker) { - signatureDeclaration = ts.getParseTreeNode(signatureDeclaration, ts.isFunctionLike); + function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { + var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { return ts.createToken(119 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); } - function createTypeOfExpression(expr, enclosingDeclaration, flags, tracker) { - expr = ts.getParseTreeNode(expr, ts.isExpression); + function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { + var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { return ts.createToken(119 /* AnyKeyword */); } @@ -50880,9 +51157,9 @@ var ts; } return resolveName(location, reference.escapedText, 67216319 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } - function getReferencedValueDeclaration(reference) { - if (!ts.isGeneratedIdentifier(reference)) { - reference = ts.getParseTreeNode(reference, ts.isIdentifier); + function getReferencedValueDeclaration(referenceIn) { + if (!ts.isGeneratedIdentifier(referenceIn)) { + var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier); if (reference) { var symbol = getReferencedValueSymbol(reference); if (symbol) { @@ -50895,7 +51172,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 8388608 /* FreshLiteral */); + return !!(type.flags & 192 /* StringOrNumberLiteral */ && type.flags & 33554432 /* FreshLiteral */); } return false; } @@ -50940,7 +51217,7 @@ var ts; }, getNodeCheckFlags: function (node) { node = ts.getParseTreeNode(node); - return node ? getNodeCheckFlags(node) : undefined; + return node ? getNodeCheckFlags(node) : 0; }, isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, @@ -50953,8 +51230,8 @@ var ts; createLiteralConstValue: createLiteralConstValue, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, - getConstantValue: function (node) { - node = ts.getParseTreeNode(node, canHaveConstantValue); + getConstantValue: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue); return node ? getConstantValue(node) : undefined; }, collectLinkedAliases: collectLinkedAliases, @@ -50967,20 +51244,20 @@ var ts; getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName, getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol, isLiteralConstDeclaration: isLiteralConstDeclaration, - isLateBound: function (node) { - node = ts.getParseTreeNode(node, ts.isDeclaration); + isLateBound: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); return !!(symbol && ts.getCheckFlags(symbol) & 1024 /* Late */); }, getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { - accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); - var otherKind = accessor.kind === 156 /* SetAccessor */ ? 155 /* GetAccessor */ : 156 /* SetAccessor */; + accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 + var otherKind = accessor.kind === 157 /* SetAccessor */ ? 156 /* GetAccessor */ : 157 /* 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 === 156 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 155 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 157 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 156 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -50990,7 +51267,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 206 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 267 /* HeritageClause */; + return node.parent && node.parent.kind === 207 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 268 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -51002,7 +51279,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 = 67901928 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 184 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 185 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -51053,7 +51330,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 273 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 274 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -51068,12 +51345,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 238 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); - var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); + var specifier = declaration.kind === 239 /* 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, 273 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 274 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -51104,7 +51381,7 @@ var ts; }); } } - // We do global augmentations seperately from module augmentations (and before creating global types) because they + // We do global augmentations separately from module augmentations (and before creating global types) because they // 1. Affect global types. We won't have the correct global types until global augmentations are merged. Also, // 2. Module augmentation instantiation requires creating the type of a module, which, in turn, can require // checking for an export or property on the module (if export=) which, in turn, can fall back to the @@ -51127,7 +51404,7 @@ var ts; addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); - getSymbolLinks(unknownSymbol).type = unknownType; + getSymbolLinks(unknownSymbol).type = errorType; // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); @@ -51199,7 +51476,7 @@ var ts; case 16384 /* AsyncValues */: return "__asyncValues"; case 32768 /* ExportStar */: return "__exportStar"; case 65536 /* MakeTemplateObject */: return "__makeTemplateObject"; - default: ts.Debug.fail("Unrecognized helper"); + default: return ts.Debug.fail("Unrecognized helper"); } } function resolveHelpersModule(node, errorNode) { @@ -51217,14 +51494,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 153 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 154 /* 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 === 155 /* GetAccessor */ || node.kind === 156 /* SetAccessor */) { + else if (node.kind === 156 /* GetAccessor */ || node.kind === 157 /* 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); @@ -51242,16 +51519,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 132 /* ReadonlyKeyword */) { - if (node.kind === 150 /* PropertySignature */ || node.kind === 152 /* MethodSignature */) { + if (node.kind === 151 /* PropertySignature */ || node.kind === 153 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 159 /* IndexSignature */) { + if (node.kind === 160 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 76 /* ConstKeyword */: - if (node.kind !== 237 /* EnumDeclaration */ && node.parent.kind === 234 /* ClassDeclaration */) { + if (node.kind !== 238 /* EnumDeclaration */ && node.parent.kind === 235 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); } break; @@ -51271,7 +51548,7 @@ 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 === 239 /* ModuleBlock */ || node.parent.kind === 273 /* SourceFile */) { + else if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -51294,10 +51571,10 @@ 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 === 239 /* ModuleBlock */ || node.parent.kind === 273 /* SourceFile */) { + else if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 148 /* Parameter */) { + else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -51310,7 +51587,7 @@ var ts; if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 151 /* PropertyDeclaration */ && node.kind !== 150 /* PropertySignature */ && node.kind !== 159 /* IndexSignature */ && node.kind !== 148 /* Parameter */) { + else if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */ && node.kind !== 160 /* IndexSignature */ && node.kind !== 149 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report 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); } @@ -51330,17 +51607,17 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 148 /* Parameter */) { + else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; case 79 /* DefaultKeyword */: - var container = node.parent.kind === 273 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 238 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -51352,13 +51629,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 148 /* Parameter */) { + else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 239 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 240 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -51368,14 +51645,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 234 /* ClassDeclaration */) { - if (node.kind !== 153 /* MethodDeclaration */ && - node.kind !== 151 /* PropertyDeclaration */ && - node.kind !== 155 /* GetAccessor */ && - node.kind !== 156 /* SetAccessor */) { + if (node.kind !== 235 /* ClassDeclaration */) { + if (node.kind !== 154 /* MethodDeclaration */ && + node.kind !== 152 /* PropertyDeclaration */ && + node.kind !== 156 /* GetAccessor */ && + node.kind !== 157 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 234 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 235 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -51394,7 +51671,7 @@ var ts; else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 148 /* Parameter */) { + else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -51402,12 +51679,12 @@ var ts; break; } } - if (node.kind === 154 /* Constructor */) { + if (node.kind === 155 /* 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"); + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217 } else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); @@ -51415,20 +51692,21 @@ var ts; else if (flags & 64 /* Readonly */) { return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly"); } - return; + return false; } - else if ((node.kind === 243 /* ImportDeclaration */ || node.kind === 242 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 244 /* ImportDeclaration */ || node.kind === 243 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 148 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 149 /* Parameter */ && (flags & 92 /* 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 === 148 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { return checkGrammarAsyncModifier(node, lastAsync); } + return false; } /** * true | false: Early return this value from checkGrammarModifiers. @@ -51443,37 +51721,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 154 /* Constructor */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 159 /* IndexSignature */: - case 238 /* ModuleDeclaration */: - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 249 /* ExportDeclaration */: - case 248 /* ExportAssignment */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 148 /* Parameter */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 155 /* Constructor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 160 /* IndexSignature */: + case 239 /* ModuleDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 250 /* ExportDeclaration */: + case 249 /* ExportAssignment */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 149 /* Parameter */: return false; default: - if (node.parent.kind === 239 /* ModuleBlock */ || node.parent.kind === 273 /* SourceFile */) { + if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { return false; } switch (node.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 235 /* InterfaceDeclaration */: - case 213 /* VariableStatement */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 214 /* VariableStatement */: + case 237 /* TypeAliasDeclaration */: return true; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); default: ts.Debug.fail(); @@ -51486,10 +51764,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 153 /* MethodDeclaration */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -51499,6 +51777,7 @@ var ts; if (list && list.hasTrailingComma) { return grammarErrorAtPos(list[0], list.end - ",".length, ",".length, diag); } + return false; } function checkGrammarTypeParameterList(typeParameters, file) { if (typeParameters && typeParameters.length === 0) { @@ -51506,6 +51785,7 @@ var ts; var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); } + return false; } function checkGrammarParameterList(parameters) { var seenOptionalParameter = false; @@ -51586,10 +51866,10 @@ var ts; } if (parameter.type.kind !== 137 /* StringKeyword */ && parameter.type.kind !== 134 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); - if (type.flags & 2 /* String */ || type.flags & 4 /* Number */) { + 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(getTypeFromTypeNode(node.type))); } - if (type.flags & 131072 /* Union */ && allTypesAssignableToKind(type, 32 /* StringLiteral */, /*strict*/ true)) { + if (type.flags & 262144 /* Union */ && allTypesAssignableToKind(type, 64 /* StringLiteral */, /*strict*/ true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); @@ -51597,6 +51877,7 @@ var ts; if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); } + return false; } function checkGrammarIndexSignature(node) { // Prevent cascading error by short-circuit @@ -51609,6 +51890,7 @@ var ts; var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); } + return false; } function checkGrammarTypeArguments(node, typeArguments) { return checkGrammarForDisallowedTrailingComma(typeArguments) || @@ -51618,11 +51900,12 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 205 /* OmittedExpression */) { + if (arg.kind === 206 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } + return false; } function checkGrammarArguments(args) { return checkGrammarForOmittedArgument(args); @@ -51636,7 +51919,7 @@ var ts; var listType = ts.tokenToString(node.token); return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); } - return ts.forEach(types, checkGrammarExpressionWithTypeArguments); + return ts.some(types, checkGrammarExpressionWithTypeArguments); } function checkGrammarExpressionWithTypeArguments(node) { return checkGrammarTypeArguments(node, node.typeArguments); @@ -51694,19 +51977,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 146 /* ComputedPropertyName */) { + if (node.kind !== 147 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 199 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 200 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* 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 === 233 /* FunctionDeclaration */ || - node.kind === 191 /* FunctionExpression */ || - node.kind === 153 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 234 /* FunctionDeclaration */ || + node.kind === 192 /* FunctionExpression */ || + node.kind === 154 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -51716,9 +52000,7 @@ var ts; } } function checkGrammarForInvalidQuestionMark(questionToken, message) { - if (questionToken) { - return grammarErrorOnNode(questionToken, message); - } + return !!questionToken && grammarErrorOnNode(questionToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { var Flags; @@ -51731,24 +52013,24 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 271 /* SpreadAssignment */) { + if (prop.kind === 272 /* SpreadAssignment */) { continue; } var name = prop.name; - if (name.kind === 146 /* ComputedPropertyName */) { + if (name.kind === 147 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 270 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 271 /* 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.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { - for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { + for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 120 /* AsyncKeyword */ || prop.kind !== 153 /* MethodDeclaration */) { + if (mod.kind !== 120 /* AsyncKeyword */ || prop.kind !== 154 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -51763,25 +52045,25 @@ 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 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name); } // falls through - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: currentKind = 1 /* Property */; break; - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: currentKind = 2 /* GetAccessor */; break; - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: currentKind = 4 /* SetAccessor */; break; default: - ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); + throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); } var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { @@ -51814,7 +52096,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 263 /* JsxSpreadAttribute */) { + if (attr.kind === 264 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -51824,7 +52106,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 264 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 265 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -51833,12 +52115,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 221 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 222 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 232 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 233 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -51853,20 +52135,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 220 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 221 /* 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 === 220 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 221 /* 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 === 220 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 221 /* 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); @@ -51893,11 +52175,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 155 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 156 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 156 /* SetAccessor */) { + else if (kind === 157 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -51914,16 +52196,17 @@ var ts; } } } + return false; } /** Does the accessor have the right number of parameters? * A get accessor has no parameters or a single `this` parameter. * 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 === 155 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 156 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 155 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 156 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -51934,7 +52217,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: var decl = parent; if (decl.name.kind !== 71 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -51946,13 +52229,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(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 150 /* PropertySignature */: + case 151 /* PropertySignature */: if (!ts.hasModifier(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); } @@ -51971,8 +52254,8 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 153 /* MethodDeclaration */) { - if (node.parent.kind === 183 /* ObjectLiteralExpression */) { + if (node.kind === 154 /* MethodDeclaration */) { + if (node.parent.kind === 184 /* 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 === 120 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -51997,14 +52280,14 @@ var ts; if (node.flags & 4194304 /* 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 === 153 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 154 /* 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 === 235 /* InterfaceDeclaration */) { + else if (node.parent.kind === 236 /* 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 === 165 /* TypeLiteral */) { + else if (node.parent.kind === 166 /* 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); } } @@ -52015,11 +52298,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 227 /* LabeledStatement */: + case 228 /* 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 === 222 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 223 /* 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); @@ -52027,8 +52310,8 @@ var ts; return false; } break; - case 226 /* SwitchStatement */: - if (node.kind === 223 /* BreakStatement */ && !node.label) { + case 227 /* SwitchStatement */: + if (node.kind === 224 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -52043,13 +52326,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 223 /* BreakStatement */ + var message = node.kind === 224 /* 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 === 223 /* BreakStatement */ + var message = node.kind === 224 /* 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); @@ -52062,7 +52345,7 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - if (node.name.kind === 180 /* ArrayBindingPattern */ || node.name.kind === 179 /* ObjectBindingPattern */) { + if (node.name.kind === 181 /* ArrayBindingPattern */ || node.name.kind === 180 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -52076,11 +52359,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 197 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + expr.kind === 198 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 220 /* ForInStatement */ && node.parent.parent.kind !== 221 /* ForOfStatement */) { + if (node.parent.parent.kind !== 221 /* ForInStatement */ && node.parent.parent.kind !== 222 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -52109,7 +52392,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 213 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 214 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -52140,6 +52423,7 @@ var ts; } } } + return false; } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 71 /* Identifier */) { @@ -52156,6 +52440,7 @@ var ts; } } } + return false; } function checkGrammarVariableDeclarationList(declarationList) { var declarations = declarationList.declarations; @@ -52165,18 +52450,19 @@ var ts; if (!declarationList.declarations.length) { return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); } + return false; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 216 /* IfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 225 /* WithStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 217 /* IfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 226 /* WithStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: return false; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -52216,6 +52502,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2)); return true; } + return false; } function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile); @@ -52223,6 +52510,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); return true; } + return false; } function grammarErrorOnNode(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); @@ -52230,11 +52518,12 @@ var ts; diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2)); return true; } + return false; } function checkGrammarConstructorTypeParameters(node) { - var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - if (ts.isNodeArray(typeParameters)) { - var pos = typeParameters.pos, end = typeParameters.end; + var jsdocTypeParameters = ts.isInJavaScriptFile(node) && ts.getJSDocTypeParameterDeclarations(node); + if (node.typeParameters || jsdocTypeParameters && jsdocTypeParameters.length) { + var _a = node.typeParameters || jsdocTypeParameters && jsdocTypeParameters[0] || node, pos = _a.pos, end = _a.end; return grammarErrorAtPos(node, pos, end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); } } @@ -52250,7 +52539,7 @@ var ts; return true; } } - else if (node.parent.kind === 235 /* InterfaceDeclaration */) { + else if (node.parent.kind === 236 /* 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; } @@ -52258,7 +52547,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 165 /* TypeLiteral */) { + else if (node.parent.kind === 166 /* 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; } @@ -52287,13 +52576,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 235 /* InterfaceDeclaration */ || - node.kind === 236 /* TypeAliasDeclaration */ || - node.kind === 243 /* ImportDeclaration */ || - node.kind === 242 /* ImportEqualsDeclaration */ || - node.kind === 249 /* ExportDeclaration */ || - node.kind === 248 /* ExportAssignment */ || - node.kind === 241 /* NamespaceExportDeclaration */ || + if (node.kind === 236 /* InterfaceDeclaration */ || + node.kind === 237 /* TypeAliasDeclaration */ || + node.kind === 244 /* ImportDeclaration */ || + node.kind === 243 /* ImportEqualsDeclaration */ || + node.kind === 250 /* ExportDeclaration */ || + node.kind === 249 /* ExportAssignment */ || + node.kind === 242 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -52302,12 +52591,13 @@ 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 === 213 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 214 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } } } + return false; } function checkGrammarSourceFile(node) { return !!(node.flags & 4194304 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); @@ -52328,7 +52618,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 === 212 /* Block */ || node.parent.kind === 239 /* ModuleBlock */ || node.parent.kind === 273 /* SourceFile */) { + if (node.parent.kind === 213 /* Block */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -52341,6 +52631,7 @@ var ts; // Debug.assert(isStatement(node.parent)); } } + return false; } function checkGrammarNumericLiteral(node) { // Grammar checking @@ -52349,10 +52640,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, 177 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 178 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 272 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 273 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -52361,6 +52652,7 @@ var ts; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + return false; } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); @@ -52369,6 +52661,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), /*length*/ 0, message, arg0, arg1, arg2)); return true; } + return false; } function getAmbientModules() { if (!ambientModulesCache) { @@ -52398,14 +52691,15 @@ var ts; if (ts.isSpreadElement(nodeArguments[0])) { return grammarErrorOnNode(nodeArguments[0], ts.Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element); } + return false; } } ts.createTypeChecker = createTypeChecker; /** 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 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -52413,14 +52707,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 244 /* ImportClause */: // For default import - case 242 /* ImportEqualsDeclaration */: - case 245 /* NamespaceImport */: - case 247 /* ImportSpecifier */: // For rename import `x as y` + case 245 /* ImportClause */: // For default import + case 243 /* ImportEqualsDeclaration */: + case 246 /* NamespaceImport */: + case 248 /* ImportSpecifier */: // For rename import `x as y` return true; case 71 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 247 /* ImportSpecifier */; + return decl.parent.kind === 248 /* ImportSpecifier */; default: return false; } @@ -52482,7 +52776,7 @@ var ts; // the original node. We also need to exclude specific properties and only include own- // properties (to skip members already defined on the shared prototype). if (node === undefined) { - return undefined; + return node; } var clone = createSynthesizedNode(node.kind); clone.flags |= node.flags; @@ -52587,7 +52881,6 @@ var ts; return name; } ts.createUniqueName = createUniqueName; - /** Create a unique name based on the supplied text. */ function createOptimisticUniqueName(text) { var name = createIdentifier(text); name.autoGenerateFlags = 3 /* Unique */ | 16 /* Optimistic */; @@ -52683,7 +52976,7 @@ var ts; ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(145 /* QualifiedName */); + var node = createSynthesizedNode(146 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -52698,12 +52991,12 @@ var ts; ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */) || - expression.kind === 301 /* CommaListExpression */ ? + expression.kind === 302 /* CommaListExpression */ ? createParen(expression) : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(146 /* ComputedPropertyName */); + var node = createSynthesizedNode(147 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -52716,7 +53009,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(147 /* TypeParameter */); + var node = createSynthesizedNode(148 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -52732,7 +53025,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(148 /* Parameter */); + var node = createSynthesizedNode(149 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -52756,7 +53049,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(149 /* Decorator */); + var node = createSynthesizedNode(150 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -52769,7 +53062,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(150 /* PropertySignature */); + var node = createSynthesizedNode(151 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -52789,7 +53082,7 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(151 /* PropertyDeclaration */); + var node = createSynthesizedNode(152 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -52813,7 +53106,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(152 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(153 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -52830,7 +53123,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(153 /* MethodDeclaration */); + var node = createSynthesizedNode(154 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -52858,7 +53151,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(154 /* Constructor */); + var node = createSynthesizedNode(155 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -52878,7 +53171,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(155 /* GetAccessor */); + var node = createSynthesizedNode(156 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -52901,7 +53194,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(156 /* SetAccessor */); + var node = createSynthesizedNode(157 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -52922,7 +53215,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(157 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(158 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -52930,7 +53223,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(158 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(159 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -52938,7 +53231,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(159 /* IndexSignature */); + var node = createSynthesizedNode(160 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -52978,7 +53271,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(160 /* TypePredicate */); + var node = createSynthesizedNode(161 /* TypePredicate */); node.parameterName = asName(parameterName); node.type = type; return node; @@ -52992,7 +53285,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(161 /* TypeReference */); + var node = createSynthesizedNode(162 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -53006,7 +53299,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(163 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -53014,7 +53307,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(163 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(164 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -53022,7 +53315,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(164 /* TypeQuery */); + var node = createSynthesizedNode(165 /* TypeQuery */); node.exprName = exprName; return node; } @@ -53034,7 +53327,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(165 /* TypeLiteral */); + var node = createSynthesizedNode(166 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -53046,7 +53339,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(166 /* ArrayType */); + var node = createSynthesizedNode(167 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -53058,7 +53351,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(167 /* TupleType */); + var node = createSynthesizedNode(168 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -53070,7 +53363,7 @@ var ts; } ts.updateTypleTypeNode = updateTypleTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(168 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(169 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -53078,7 +53371,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(170 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -53097,7 +53390,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(170 /* ConditionalType */); + var node = createSynthesizedNode(171 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -53115,7 +53408,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(171 /* InferType */); + var node = createSynthesizedNode(172 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -53127,7 +53420,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(178 /* ImportType */); + var node = createSynthesizedNode(179 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -53145,7 +53438,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(172 /* ParenthesizedType */); + var node = createSynthesizedNode(173 /* ParenthesizedType */); node.type = type; return node; } @@ -53157,11 +53450,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(173 /* ThisType */); + return createSynthesizedNode(174 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(174 /* TypeOperator */); + var node = createSynthesizedNode(175 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -53172,7 +53465,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(175 /* IndexedAccessType */); + var node = createSynthesizedNode(176 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -53186,7 +53479,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(176 /* MappedType */); + var node = createSynthesizedNode(177 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -53204,7 +53497,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(177 /* LiteralType */); + var node = createSynthesizedNode(178 /* LiteralType */); node.literal = literal; return node; } @@ -53217,7 +53510,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(179 /* ObjectBindingPattern */); + var node = createSynthesizedNode(180 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -53229,7 +53522,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(180 /* ArrayBindingPattern */); + var node = createSynthesizedNode(181 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -53241,7 +53534,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(181 /* BindingElement */); + var node = createSynthesizedNode(182 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -53260,7 +53553,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(182 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(183 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -53274,7 +53567,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(183 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(184 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -53288,9 +53581,9 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(184 /* PropertyAccessExpression */); + var node = createSynthesizedNode(185 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); - node.name = asName(name); + node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); return node; } @@ -53305,7 +53598,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(185 /* ElementAccessExpression */); + var node = createSynthesizedNode(186 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -53319,7 +53612,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(186 /* CallExpression */); + var node = createSynthesizedNode(187 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -53335,7 +53628,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187 /* NewExpression */); + var node = createSynthesizedNode(188 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -53351,7 +53644,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(188 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(189 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -53374,7 +53667,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(189 /* TypeAssertionExpression */); + var node = createSynthesizedNode(190 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -53388,7 +53681,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(190 /* ParenthesizedExpression */); + var node = createSynthesizedNode(191 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -53400,7 +53693,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(191 /* FunctionExpression */); + var node = createSynthesizedNode(192 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -53424,7 +53717,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(192 /* ArrowFunction */); + var node = createSynthesizedNode(193 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -53458,7 +53751,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(193 /* DeleteExpression */); + var node = createSynthesizedNode(194 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53470,7 +53763,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(194 /* TypeOfExpression */); + var node = createSynthesizedNode(195 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53482,7 +53775,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(195 /* VoidExpression */); + var node = createSynthesizedNode(196 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53494,7 +53787,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(196 /* AwaitExpression */); + var node = createSynthesizedNode(197 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53506,7 +53799,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(197 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(198 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -53519,7 +53812,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(198 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(199 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -53532,7 +53825,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(199 /* BinaryExpression */); + var node = createSynthesizedNode(200 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -53549,7 +53842,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(200 /* ConditionalExpression */); + var node = createSynthesizedNode(201 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -53579,7 +53872,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(201 /* TemplateExpression */); + var node = createSynthesizedNode(202 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -53617,7 +53910,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(202 /* YieldExpression */); + var node = createSynthesizedNode(203 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -53631,7 +53924,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(203 /* SpreadElement */); + var node = createSynthesizedNode(204 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -53643,7 +53936,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(204 /* ClassExpression */); + var node = createSynthesizedNode(205 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -53664,11 +53957,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(205 /* OmittedExpression */); + return createSynthesizedNode(206 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(206 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(207 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -53682,7 +53975,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(207 /* AsExpression */); + var node = createSynthesizedNode(208 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -53696,7 +53989,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(208 /* NonNullExpression */); + var node = createSynthesizedNode(209 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -53708,7 +54001,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(209 /* MetaProperty */); + var node = createSynthesizedNode(210 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -53722,7 +54015,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(210 /* TemplateSpan */); + var node = createSynthesizedNode(211 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -53736,12 +54029,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(211 /* SemicolonClassElement */); + return createSynthesizedNode(212 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(212 /* Block */); + var block = createSynthesizedNode(213 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -53750,7 +54043,7 @@ var ts; ts.createBlock = createBlock; /* @internal */ function createExpressionStatement(expression) { - var node = createSynthesizedNode(215 /* ExpressionStatement */); + var node = createSynthesizedNode(216 /* ExpressionStatement */); node.expression = expression; return node; } @@ -53762,7 +54055,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(213 /* VariableStatement */); + var node = createSynthesizedNode(214 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -53777,7 +54070,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(214 /* EmptyStatement */); + return createSynthesizedNode(215 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression) { @@ -53791,7 +54084,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(216 /* IfStatement */); + var node = createSynthesizedNode(217 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -53807,7 +54100,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(217 /* DoStatement */); + var node = createSynthesizedNode(218 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -53821,7 +54114,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(218 /* WhileStatement */); + var node = createSynthesizedNode(219 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -53835,7 +54128,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(219 /* ForStatement */); + var node = createSynthesizedNode(220 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -53853,7 +54146,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(220 /* ForInStatement */); + var node = createSynthesizedNode(221 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -53869,7 +54162,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(221 /* ForOfStatement */); + var node = createSynthesizedNode(222 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -53887,7 +54180,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(222 /* ContinueStatement */); + var node = createSynthesizedNode(223 /* ContinueStatement */); node.label = asName(label); return node; } @@ -53899,7 +54192,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(223 /* BreakStatement */); + var node = createSynthesizedNode(224 /* BreakStatement */); node.label = asName(label); return node; } @@ -53911,7 +54204,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(224 /* ReturnStatement */); + var node = createSynthesizedNode(225 /* ReturnStatement */); node.expression = expression; return node; } @@ -53923,7 +54216,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(225 /* WithStatement */); + var node = createSynthesizedNode(226 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -53937,7 +54230,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(226 /* SwitchStatement */); + var node = createSynthesizedNode(227 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -53951,7 +54244,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(227 /* LabeledStatement */); + var node = createSynthesizedNode(228 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -53965,7 +54258,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(228 /* ThrowStatement */); + var node = createSynthesizedNode(229 /* ThrowStatement */); node.expression = expression; return node; } @@ -53977,7 +54270,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(229 /* TryStatement */); + var node = createSynthesizedNode(230 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -53993,11 +54286,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(230 /* DebuggerStatement */); + return createSynthesizedNode(231 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(231 /* VariableDeclaration */); + var node = createSynthesizedNode(232 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -54013,7 +54306,8 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { - var node = createSynthesizedNode(232 /* VariableDeclarationList */); + if (flags === void 0) { flags = 0 /* None */; } + var node = createSynthesizedNode(233 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -54026,7 +54320,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(233 /* FunctionDeclaration */); + var node = createSynthesizedNode(234 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -54052,7 +54346,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(234 /* ClassDeclaration */); + var node = createSynthesizedNode(235 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54074,7 +54368,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235 /* InterfaceDeclaration */); + var node = createSynthesizedNode(236 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54096,7 +54390,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(236 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(237 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54116,7 +54410,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(237 /* EnumDeclaration */); + var node = createSynthesizedNode(238 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54134,7 +54428,8 @@ var ts; } ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { - var node = createSynthesizedNode(238 /* ModuleDeclaration */); + if (flags === void 0) { flags = 0 /* None */; } + var node = createSynthesizedNode(239 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -54153,7 +54448,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(239 /* ModuleBlock */); + var node = createSynthesizedNode(240 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -54165,7 +54460,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(240 /* CaseBlock */); + var node = createSynthesizedNode(241 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -54177,7 +54472,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(241 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(242 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -54189,7 +54484,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(242 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(243 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54207,7 +54502,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(243 /* ImportDeclaration */); + var node = createSynthesizedNode(244 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -54225,7 +54520,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(244 /* ImportClause */); + var node = createSynthesizedNode(245 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -54239,7 +54534,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(245 /* NamespaceImport */); + var node = createSynthesizedNode(246 /* NamespaceImport */); node.name = name; return node; } @@ -54251,7 +54546,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(246 /* NamedImports */); + var node = createSynthesizedNode(247 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -54263,7 +54558,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(247 /* ImportSpecifier */); + var node = createSynthesizedNode(248 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -54277,7 +54572,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(248 /* ExportAssignment */); + var node = createSynthesizedNode(249 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -54294,7 +54589,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(249 /* ExportDeclaration */); + var node = createSynthesizedNode(250 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -54312,7 +54607,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(250 /* NamedExports */); + var node = createSynthesizedNode(251 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -54324,7 +54619,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(251 /* ExportSpecifier */); + var node = createSynthesizedNode(252 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -54339,7 +54634,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(253 /* ExternalModuleReference */); + var node = createSynthesizedNode(254 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -54352,7 +54647,7 @@ var ts; ts.updateExternalModuleReference = updateExternalModuleReference; // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(254 /* JsxElement */); + var node = createSynthesizedNode(255 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -54368,7 +54663,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(255 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(256 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -54384,7 +54679,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256 /* JsxOpeningElement */); + var node = createSynthesizedNode(257 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -54400,7 +54695,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(257 /* JsxClosingElement */); + var node = createSynthesizedNode(258 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -54412,7 +54707,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(258 /* JsxFragment */); + var node = createSynthesizedNode(259 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -54428,7 +54723,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(261 /* JsxAttribute */); + var node = createSynthesizedNode(262 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -54442,7 +54737,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(262 /* JsxAttributes */); + var node = createSynthesizedNode(263 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -54454,7 +54749,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(263 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(264 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -54466,7 +54761,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(264 /* JsxExpression */); + var node = createSynthesizedNode(265 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -54480,7 +54775,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(265 /* CaseClause */); + var node = createSynthesizedNode(266 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -54494,7 +54789,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(266 /* DefaultClause */); + var node = createSynthesizedNode(267 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -54506,7 +54801,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(267 /* HeritageClause */); + var node = createSynthesizedNode(268 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -54519,7 +54814,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(268 /* CatchClause */); + var node = createSynthesizedNode(269 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -54534,7 +54829,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(269 /* PropertyAssignment */); + var node = createSynthesizedNode(270 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -54549,7 +54844,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(270 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(271 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -54563,8 +54858,8 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(271 /* SpreadAssignment */); - node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; + var node = createSynthesizedNode(272 /* SpreadAssignment */); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } ts.createSpreadAssignment = createSpreadAssignment; @@ -54576,7 +54871,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(272 /* EnumMember */); + var node = createSynthesizedNode(273 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -54596,7 +54891,7 @@ var ts; (referencedFiles !== undefined && node.referencedFiles !== referencedFiles) || (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(273 /* SourceFile */); + var updated = createSynthesizedNode(274 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -54635,6 +54930,8 @@ var ts; updated.parseDiagnostics = node.parseDiagnostics; if (node.bindDiagnostics !== undefined) updated.bindDiagnostics = node.bindDiagnostics; + if (node.bindSuggestionDiagnostics !== undefined) + updated.bindSuggestionDiagnostics = node.bindSuggestionDiagnostics; if (node.lineMap !== undefined) updated.lineMap = node.lineMap; if (node.classifiableNames !== undefined) @@ -54677,7 +54974,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(299 /* NotEmittedStatement */); + var node = createSynthesizedNode(300 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -54689,7 +54986,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(303 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(304 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -54701,7 +54998,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(302 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(303 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -54716,7 +55013,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(300 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(301 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -54732,7 +55029,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 301 /* CommaListExpression */) { + if (node.kind === 302 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { @@ -54742,7 +55039,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(301 /* CommaListExpression */); + var node = createSynthesizedNode(302 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -54755,20 +55052,20 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(274 /* Bundle */); + var node = ts.createNode(275 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text) { - var node = ts.createNode(275 /* UnparsedSource */); + var node = ts.createNode(276 /* UnparsedSource */); node.text = text; return node; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration) { - var node = ts.createNode(276 /* InputFiles */); + var node = ts.createNode(277 /* InputFiles */); node.javascriptText = javascript; node.declarationText = declaration; return node; @@ -54861,6 +55158,7 @@ var ts; return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(/*propertyName*/ undefined, exportName)])); } ts.createExternalModuleExport = createExternalModuleExport; + // Utilities function asName(name) { return ts.isString(name) ? createIdentifier(name) : name; } @@ -54906,7 +55204,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 === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -55391,7 +55689,7 @@ var ts; // Utilities function createForOfBindingStatement(node, boundValue) { if (ts.isVariableDeclarationList(node)) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); + var firstDeclaration = ts.first(node.declarations); var updatedDeclaration = ts.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, /*typeNode*/ undefined, boundValue); return ts.setTextRange(ts.createVariableStatement( @@ -55417,7 +55715,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 227 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -55435,19 +55733,20 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; } } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { + if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } var callee = skipOuterExpressions(expression, 7 /* All */); var thisArg; var target; @@ -55467,7 +55766,7 @@ var ts; } else { switch (callee.kind) { - case 184 /* PropertyAccessExpression */: { + case 185 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -55480,7 +55779,7 @@ var ts; } break; } - case 185 /* ElementAccessExpression */: { + case 186 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -55537,14 +55836,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 269 /* PropertyAssignment */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); + case 270 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -55558,7 +55857,8 @@ var ts; /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, getAccessor.parameters, - /*type*/ undefined, getAccessor.body); + /*type*/ undefined, getAccessor.body // TODO: GH#18217 + ); ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -55569,7 +55869,8 @@ var ts; /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, setAccessor.parameters, - /*type*/ undefined, setAccessor.body); + /*type*/ undefined, setAccessor.body // TODO: GH#18217 + ); ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); @@ -55600,7 +55901,8 @@ var ts; return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, /*name*/ undefined, /*typeParameters*/ undefined, method.parameters, - /*type*/ undefined, method.body), + /*type*/ undefined, method.body // TODO: GH#18217 + ), /*location*/ method), /*original*/ method)), /*location*/ method), @@ -55683,6 +55985,7 @@ var ts; } ts.getDeclarationName = getDeclarationName; function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (emitFlags === void 0) { emitFlags = 0; } var nodeName = ts.getNameOfDeclaration(node); if (nodeName && ts.isIdentifier(nodeName) && !ts.isGeneratedIdentifier(nodeName)) { var name = ts.getMutableClone(nodeName); @@ -55726,7 +56029,7 @@ var ts; function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); ts.setTextRange(qualifiedName, name); - var emitFlags; + var emitFlags = 0; if (!allowSourceMaps) emitFlags |= 48 /* NoSourceMap */; if (!allowComments) @@ -55741,7 +56044,8 @@ var ts; } ts.convertToFunctionBody = convertToFunctionBody; function convertFunctionDeclarationToExpression(node) { - ts.Debug.assert(!!node.body); + if (!node.body) + return ts.Debug.fail(); var updated = ts.createFunctionExpression(node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body); ts.setOriginalNode(updated, node); ts.setTextRange(updated, node); @@ -55801,15 +56105,9 @@ var ts; return statementOffset; } ts.addStandardPrologue = addStandardPrologue; - /** - * Add just the custom prologue-directives into target statement-array. - * The function needs to be called during each transformation step. - * This function needs to be called whenever we transform the statement - * list of a source file, namespace, or function-like body. - */ function addCustomPrologue(target, source, statementOffset, visitor) { var numStatements = source.length; - while (statementOffset < numStatements) { + while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); @@ -55868,7 +56166,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 === 190 /* ParenthesizedExpression */) { + if (skipped.kind === 191 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -55902,8 +56200,8 @@ 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(199 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(199 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(200 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(200 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -55912,7 +56210,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 202 /* YieldExpression */) { + && operand.kind === 203 /* YieldExpression */) { return false; } return true; @@ -56000,7 +56298,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 199 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -56015,7 +56313,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(200 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(201 /* ConditionalExpression */, 55 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -56029,8 +56327,8 @@ var ts; // so in case when comma expression is introduced as a part of previous transformations // if should be wrapped in parens since comma operator has the lowest precedence var emittedExpression = ts.skipPartiallyEmittedExpressions(e); - return emittedExpression.kind === 199 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ || - emittedExpression.kind === 301 /* CommaListExpression */ + return emittedExpression.kind === 200 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ || + emittedExpression.kind === 302 /* CommaListExpression */ ? ts.createParen(e) : e; } @@ -56048,9 +56346,9 @@ var ts; */ function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 204 /* ClassExpression */ || - check.kind === 191 /* FunctionExpression */ || - check.kind === 301 /* CommaListExpression */ || + return (check.kind === 205 /* ClassExpression */ || + check.kind === 192 /* FunctionExpression */ || + check.kind === 302 /* CommaListExpression */ || ts.isBinaryExpression(check) && check.operatorToken.kind === 26 /* CommaToken */) ? ts.createParen(e) : e; @@ -56065,9 +56363,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 186 /* CallExpression */: + case 187 /* CallExpression */: return ts.createParen(expression); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -56090,7 +56388,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 187 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 188 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -56128,7 +56426,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(199 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(200 /* BinaryExpression */, 26 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -56139,29 +56437,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 191 /* FunctionExpression */ || kind === 192 /* ArrowFunction */) { + if (kind === 192 /* FunctionExpression */ || kind === 193 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 183 /* ObjectLiteralExpression */ || leftmostExpressionKind === 191 /* FunctionExpression */) { + if (leftmostExpressionKind === 184 /* ObjectLiteralExpression */ || leftmostExpressionKind === 192 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 170 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 171 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 168 /* UnionType */: - case 169 /* IntersectionType */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -56169,9 +56467,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 164 /* TypeQuery */: - case 174 /* TypeOperator */: - case 171 /* InferType */: + case 165 /* TypeQuery */: + case 175 /* TypeOperator */: + case 172 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -56197,25 +56495,25 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: node = node.operand; continue; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: node = node.left; continue; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: node = node.condition; continue; - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 185 /* ElementAccessExpression */: - case 184 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: + case 185 /* PropertyAccessExpression */: node = node.expression; continue; - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -56223,7 +56521,7 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 183 /* ObjectLiteralExpression */) { + if (!ts.isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 184 /* ObjectLiteralExpression */) { return ts.setTextRange(ts.createParen(body), body); } return body; @@ -56239,13 +56537,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: - case 208 /* NonNullExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: + case 209 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -56270,7 +56568,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 208 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 209 /* NonNullExpression */) { node = node.expression; } return node; @@ -56278,11 +56576,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 190 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 189 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 207 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 208 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 300 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 191 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 190 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 208 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 209 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 301 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -56300,7 +56598,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 190 /* ParenthesizedExpression */ + return node.kind === 191 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -56365,10 +56663,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 243 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 244 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 249 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 250 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -56383,7 +56681,7 @@ var ts; * Otherwise, a new StringLiteral node representing the module name will be returned. */ function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) { - var moduleName = ts.getExternalModuleName(importNode); + var moduleName = ts.getExternalModuleName(importNode); // TODO: GH#18217 if (moduleName.kind === 9 /* StringLiteral */) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) @@ -56441,8 +56739,9 @@ var ts; // `1` in `({ a: b = 1 } = ...)` // `1` in `({ a: {b} = 1 } = ...)` // `1` in `({ a: [b] = 1 } = ...)` - return ts.isAssignmentExpression(bindingElement.initializer, /*excludeCompoundAssignment*/ true) - ? bindingElement.initializer.right + var initializer = bindingElement.initializer; + return ts.isAssignmentExpression(initializer, /*excludeCompoundAssignment*/ true) + ? initializer.right : undefined; } if (ts.isShorthandPropertyAssignment(bindingElement)) { @@ -56486,7 +56785,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -56498,11 +56797,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -56534,12 +56833,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 148 /* Parameter */: - case 181 /* BindingElement */: + case 149 /* Parameter */: + case 182 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 203 /* SpreadElement */: - case 271 /* SpreadAssignment */: + case 204 /* SpreadElement */: + case 272 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -56551,7 +56850,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 181 /* BindingElement */: + case 182 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -56563,7 +56862,7 @@ var ts; : propertyName; } break; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -56575,7 +56874,7 @@ var ts; : propertyName; } break; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -56593,13 +56892,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: - case 182 /* ArrayLiteralExpression */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: + case 183 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -56639,11 +56938,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 180 /* ArrayBindingPattern */: - case 182 /* ArrayLiteralExpression */: + case 181 /* ArrayBindingPattern */: + case 183 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 179 /* ObjectBindingPattern */: - case 183 /* ObjectLiteralExpression */: + case 180 /* ObjectBindingPattern */: + case 184 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -56804,272 +57103,272 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 144 /* LastToken */) || kind === 173 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 174 /* ThisType */) { return node; } switch (kind) { // Names case 71 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 148 /* Parameter */: + case 149 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 149 /* Decorator */: + case 150 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 150 /* PropertySignature */: + case 151 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 152 /* MethodSignature */: + case 153 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 154 /* Constructor */: + case 155 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 157 /* CallSignature */: + case 158 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 162 /* FunctionType */: + case 163 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* ConstructorType */: + case 164 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 165 /* TypeLiteral */: + case 166 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 167 /* TupleType */: + case 168 /* TupleType */: return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 168 /* UnionType */: + case 169 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 169 /* IntersectionType */: + case 170 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 171 /* InferType */: + case 172 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 178 /* ImportType */: + case 179 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* TypeOperator */: + case 175 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 176 /* MappedType */: + case 177 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 177 /* LiteralType */: + case 178 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 194 /* TypeOfExpression */: + case 195 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 207 /* AsExpression */: + case 208 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 212 /* Block */: + case 213 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 222 /* ContinueStatement */: + case 223 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 223 /* BreakStatement */: + case 224 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 246 /* NamedImports */: + case 247 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 250 /* NamedExports */: + case 251 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 251 /* ExportSpecifier */: + case 252 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 254 /* JsxElement */: + case 255 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 256 /* JsxOpeningElement */: + case 257 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 263 /* JsxSpreadAttribute */: + case 264 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 265 /* CaseClause */: + case 266 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 272 /* EnumMember */: + case 273 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 273 /* SourceFile */: + case 274 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -57111,58 +57410,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 144 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 160 /* TypePredicate */ && kind <= 177 /* LiteralType */)) { + if ((kind >= 161 /* TypePredicate */ && kind <= 178 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 211 /* SemicolonClassElement */: - case 214 /* EmptyStatement */: - case 205 /* OmittedExpression */: - case 230 /* DebuggerStatement */: - case 299 /* NotEmittedStatement */: + case 212 /* SemicolonClassElement */: + case 215 /* EmptyStatement */: + case 206 /* OmittedExpression */: + case 231 /* DebuggerStatement */: + case 300 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 148 /* Parameter */: + case 149 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149 /* Decorator */: + case 150 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 150 /* PropertySignature */: + case 151 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57171,12 +57470,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 154 /* Constructor */: + case 155 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57184,7 +57483,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57192,49 +57491,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 181 /* BindingElement */: + case 182 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 186 /* CallExpression */: + case 187 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 187 /* NewExpression */: + case 188 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -57242,123 +57541,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 190 /* ParenthesizedExpression */: - case 193 /* DeleteExpression */: - case 194 /* TypeOfExpression */: - case 195 /* VoidExpression */: - case 196 /* AwaitExpression */: - case 202 /* YieldExpression */: - case 203 /* SpreadElement */: - case 208 /* NonNullExpression */: + case 191 /* ParenthesizedExpression */: + case 194 /* DeleteExpression */: + case 195 /* TypeOfExpression */: + case 196 /* VoidExpression */: + case 197 /* AwaitExpression */: + case 203 /* YieldExpression */: + case 204 /* SpreadElement */: + case 209 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 207 /* AsExpression */: + case 208 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 212 /* Block */: + case 213 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 216 /* IfStatement */: + case 217 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 217 /* DoStatement */: + case 218 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 218 /* WhileStatement */: - case 225 /* WithStatement */: + case 219 /* WhileStatement */: + case 226 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 219 /* ForStatement */: + case 220 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 224 /* ReturnStatement */: - case 228 /* ThrowStatement */: + case 225 /* ReturnStatement */: + case 229 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 229 /* TryStatement */: + case 230 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57367,7 +57666,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57375,139 +57674,139 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 244 /* ImportClause */: + case 245 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 246 /* NamedImports */: - case 250 /* NamedExports */: + case 247 /* NamedImports */: + case 251 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 254 /* JsxElement */: + case 255 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 255 /* JsxSelfClosingElement */: - case 256 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 263 /* JsxSpreadAttribute */: + case 264 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 265 /* CaseClause */: + case 266 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 268 /* CatchClause */: + case 269 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 272 /* EnumMember */: + case 273 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 273 /* SourceFile */: + case 274 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -57521,8 +57820,8 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements) - : ts.prependRange(statements, declarations); + ? ts.setTextRange(ts.createNodeArray(ts.prependStatements(statements.slice(), declarations)), statements) + : ts.prependStatements(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; /** @@ -57580,7 +57879,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 206 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 207 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -57630,7 +57929,7 @@ var ts; }); Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, { __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 65536 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 131072 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { return this.checker.typeToString(this); } }, }); var nodeConstructors = [ @@ -57680,12 +57979,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName && e.propertyName.escapedText === "default" /* Default */; + return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* Default */; } function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 273 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 274 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -57715,7 +58014,7 @@ var ts; ts.getImportNeedsImportStarHelper = getImportNeedsImportStarHelper; function getImportNeedsImportDefaultHelper(node) { // Import default is needed if there's a default import or a default ref and no other refs (meaning an import star helper wasn't requested) - return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings))); + return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (!!node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings))); // TODO: GH#18217 } ts.getImportNeedsImportDefaultHelper = getImportNeedsImportDefaultHelper; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { @@ -57731,7 +58030,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -57739,13 +58038,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 242 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 253 /* ExternalModuleReference */) { + case 243 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -57775,13 +58074,13 @@ var ts; } } break; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -57789,7 +58088,7 @@ var ts; } } break; - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -57809,7 +58108,7 @@ var ts; } } break; - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -57942,7 +58241,7 @@ var ts; var flattenContext = { context: context, level: level, - downlevelIteration: context.getCompilerOptions().downlevelIteration, + downlevelIteration: !!context.getCompilerOptions().downlevelIteration, hoistTempVariables: true, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -58003,7 +58302,7 @@ var ts; } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; function bindingOrAssignmentElementAssignsToName(element, escapedName) { - var target = ts.getTargetOfBindingOrAssignmentElement(element); + var target = ts.getTargetOfBindingOrAssignmentElement(element); // TODO: GH#18217 if (ts.isBindingOrAssignmentPattern(target)) { return bindingOrAssignmentPatternAssignsToName(target, escapedName); } @@ -58034,13 +58333,14 @@ var ts; * @param level Indicates the extent to which flattening should occur. */ function flattenDestructuringBinding(node, visitor, context, level, rval, hoistTempVariables, skipInitializer) { + if (hoistTempVariables === void 0) { hoistTempVariables = false; } var pendingExpressions; var pendingDeclarations = []; var declarations = []; var flattenContext = { context: context, level: level, - downlevelIteration: context.getCompilerOptions().downlevelIteration, + downlevelIteration: !!context.getCompilerOptions().downlevelIteration, hoistTempVariables: hoistTempVariables, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -58068,7 +58368,7 @@ var ts; } else { context.hoistVariableDeclaration(temp); - var pendingDeclaration = ts.lastOrUndefined(pendingDeclarations); + var pendingDeclaration = ts.last(pendingDeclarations); pendingDeclaration.pendingExpressions = ts.append(pendingDeclaration.pendingExpressions, ts.createAssignment(temp, pendingDeclaration.value)); ts.addRange(pendingDeclaration.pendingExpressions, pendingExpressions); pendingDeclaration.value = temp; @@ -58122,7 +58422,7 @@ var ts; value = ts.createVoidZero(); } } - var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element); + var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element); // TODO: GH#18217 if (ts.isObjectBindingOrAssignmentPattern(bindingTarget)) { flattenObjectBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location); } @@ -58130,7 +58430,7 @@ var ts; flattenArrayBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location); } else { - flattenContext.emitBindingOrAssignment(bindingTarget, value, location, /*original*/ element); + flattenContext.emitBindingOrAssignment(bindingTarget, value, location, /*original*/ element); // TODO: GH#18217 } } /** @@ -58182,7 +58482,7 @@ var ts; flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern); bindingElements = undefined; } - var rhsValue = createRestCall(flattenContext.context, value, elements, computedTempVariables, pattern); + var rhsValue = createRestCall(flattenContext.context, value, elements, computedTempVariables, pattern); // TODO: GH#18217 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element); } } @@ -58424,8 +58724,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(184 /* PropertyAccessExpression */); - context.enableSubstitution(185 /* ElementAccessExpression */); + context.enableSubstitution(185 /* PropertyAccessExpression */); + context.enableSubstitution(186 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -58454,14 +58754,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 274 /* Bundle */) { + if (node.kind === 275 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 276 /* InputFiles */) { + if (prepend.kind === 277 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText); } return prepend; @@ -58508,15 +58808,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 273 /* SourceFile */: - case 240 /* CaseBlock */: - case 239 /* ModuleBlock */: - case 212 /* Block */: + case 274 /* SourceFile */: + case 241 /* CaseBlock */: + case 240 /* ModuleBlock */: + case 213 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 234 /* ClassDeclaration */: - case 233 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 234 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -58528,7 +58828,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 === 234 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 235 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } break; } @@ -58572,10 +58872,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 248 /* ExportAssignment */: - case 249 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 249 /* ExportAssignment */: + case 250 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -58596,13 +58896,13 @@ var ts; return node; } switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return visitImportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitExportAssignment(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -58622,11 +58922,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 249 /* ExportDeclaration */ || - node.kind === 243 /* ImportDeclaration */ || - node.kind === 244 /* ImportClause */ || - (node.kind === 242 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 253 /* ExternalModuleReference */)) { + if (node.kind === 250 /* ExportDeclaration */ || + node.kind === 244 /* ImportDeclaration */ || + node.kind === 245 /* ImportClause */ || + (node.kind === 243 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 254 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -58656,19 +58956,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 154 /* Constructor */: + case 155 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 151 /* PropertyDeclaration */: - case 159 /* IndexSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 153 /* MethodDeclaration */: + case 152 /* PropertyDeclaration */: + case 160 /* IndexSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 154 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 211 /* SemicolonClassElement */: + case 212 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -58707,52 +59007,53 @@ var ts; case 124 /* DeclareKeyword */: case 132 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 166 /* ArrayType */: - case 167 /* TupleType */: - case 165 /* TypeLiteral */: - case 160 /* TypePredicate */: - case 147 /* TypeParameter */: + case 167 /* ArrayType */: + case 168 /* TupleType */: + case 166 /* TypeLiteral */: + case 161 /* TypePredicate */: + case 148 /* TypeParameter */: case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 122 /* BooleanKeyword */: case 137 /* StringKeyword */: case 134 /* NumberKeyword */: case 131 /* NeverKeyword */: case 105 /* VoidKeyword */: case 138 /* SymbolKeyword */: - case 163 /* ConstructorType */: - case 162 /* FunctionType */: - case 164 /* TypeQuery */: - case 161 /* TypeReference */: - case 168 /* UnionType */: - case 169 /* IntersectionType */: - case 170 /* ConditionalType */: - case 172 /* ParenthesizedType */: - case 173 /* ThisType */: - case 174 /* TypeOperator */: - case 175 /* IndexedAccessType */: - case 176 /* MappedType */: - case 177 /* LiteralType */: + case 164 /* ConstructorType */: + case 163 /* FunctionType */: + case 165 /* TypeQuery */: + case 162 /* TypeReference */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: + case 171 /* ConditionalType */: + case 173 /* ParenthesizedType */: + case 174 /* ThisType */: + case 175 /* TypeOperator */: + case 176 /* IndexedAccessType */: + case 177 /* MappedType */: + case 178 /* LiteralType */: // TypeScript type nodes are elided. - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: // TypeScript index signatures are elided. - case 149 /* Decorator */: + case 150 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 151 /* PropertyDeclaration */: + case 152 /* 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 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 154 /* Constructor */: + case 155 /* Constructor */: return visitConstructor(node); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -58763,7 +59064,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -58774,35 +59075,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 148 /* Parameter */: + case 149 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -58812,35 +59113,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return visitCallExpression(node); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return visitNewExpression(node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -58849,7 +59150,8 @@ var ts; } function visitSourceFile(node) { var alwaysStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") && - !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015); + !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015) && + !ts.isJsonSourceFile(node); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); } /** @@ -58956,7 +59258,7 @@ var ts; statement.pos = closingBraceLocation.pos; ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); statements.push(statement); - ts.prependRange(statements, context.endLexicalEnvironment()); + ts.prependStatements(statements, context.endLexicalEnvironment()); var iife = ts.createImmediatelyInvokedArrowFunction(statements); ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); var varStatement = ts.createVariableStatement( @@ -59321,7 +59623,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 215 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -59392,7 +59694,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 151 /* PropertyDeclaration */ + return member.kind === 152 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -59530,12 +59832,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -59688,7 +59990,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 151 /* PropertyDeclaration */ + ? member.kind === 152 /* 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`. ? ts.createVoidZero() @@ -59811,10 +60113,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */ - || kind === 151 /* PropertyDeclaration */; + return kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */ + || kind === 152 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -59824,7 +60126,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 153 /* MethodDeclaration */; + return node.kind === 154 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -59835,12 +60137,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return true; } return false; @@ -59852,15 +60154,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 151 /* PropertyDeclaration */: - case 148 /* Parameter */: - case 155 /* GetAccessor */: + case 152 /* PropertyDeclaration */: + case 149 /* Parameter */: + case 156 /* GetAccessor */: return serializeTypeNode(node.type); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 153 /* MethodDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 154 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -59897,7 +60199,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 155 /* GetAccessor */) { + if (container && node.kind === 156 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -59947,22 +60249,22 @@ var ts; case 95 /* NullKeyword */: case 131 /* NeverKeyword */: return ts.createVoidZero(); - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 162 /* FunctionType */: - case 163 /* ConstructorType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: return ts.createIdentifier("Function"); - case 166 /* ArrayType */: - case 167 /* TupleType */: + case 167 /* ArrayType */: + case 168 /* TupleType */: return ts.createIdentifier("Array"); - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: case 122 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); case 137 /* StringKeyword */: return ts.createIdentifier("String"); case 135 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 177 /* LiteralType */: + case 178 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -59980,18 +60282,19 @@ var ts; return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return serializeTypeReferenceNode(node); - case 169 /* IntersectionType */: - case 168 /* UnionType */: + case 170 /* IntersectionType */: + case 169 /* UnionType */: return serializeUnionOrIntersectionType(node); - case 164 /* TypeQuery */: - case 174 /* TypeOperator */: - case 175 /* IndexedAccessType */: - case 176 /* MappedType */: - case 165 /* TypeLiteral */: + case 165 /* TypeQuery */: + case 175 /* TypeOperator */: + case 176 /* IndexedAccessType */: + case 177 /* MappedType */: + case 166 /* TypeLiteral */: case 119 /* AnyKeyword */: - case 173 /* ThisType */: + case 142 /* UnknownKeyword */: + case 174 /* ThisType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -60004,7 +60307,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 172 /* ParenthesizedType */) { + while (typeNode.kind === 173 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -60043,7 +60346,8 @@ var ts; * @param node The type reference node. */ function serializeTypeReferenceNode(node) { - switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) { + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, /*useFallback*/ true); var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -60069,8 +60373,9 @@ var ts; case ts.TypeReferenceSerializationKind.Promise: return ts.createIdentifier("Promise"); case ts.TypeReferenceSerializationKind.ObjectType: - default: return ts.createIdentifier("Object"); + default: + return ts.Debug.assertNever(kind); } } /** @@ -60093,7 +60398,7 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } return name; - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -60579,7 +60884,7 @@ var ts; var statements = []; startLexicalEnvironment(); var members = ts.map(node.members, transformEnumMember); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); ts.addRange(statements, members); currentNamespaceContainerName = savedCurrentNamespaceLocalName; return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ node.members), @@ -60628,7 +60933,7 @@ var ts; * @param node The module declaration node. */ function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules); } /** * Determines whether an exported declaration will have a qualified export name (e.g. `f.x` @@ -60678,12 +60983,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentScope.kind === 273 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentScope.kind === 274 /* 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 === 237 /* EnumDeclaration */) { + if (node.kind === 238 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -60802,7 +61107,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 239 /* ModuleBlock */) { + if (body.kind === 240 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -60820,7 +61125,7 @@ var ts; var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; statementsLocation = ts.moveRangePos(moduleBlock.statements, -1); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; @@ -60848,13 +61153,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 (body.kind !== 239 /* ModuleBlock */) { + if (body.kind !== 240 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 238 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -60895,7 +61200,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 245 /* NamespaceImport */) { + if (node.kind === 246 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -61127,16 +61432,16 @@ var ts; // 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(71 /* Identifier */); - context.enableSubstitution(270 /* ShorthandPropertyAssignment */); + context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(238 /* ModuleDeclaration */); + context.enableEmitNotification(239 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 238 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 239 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 237 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 238 /* EnumDeclaration */; } /** * Hook for node emit. @@ -61197,9 +61502,9 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -61219,7 +61524,7 @@ var ts; // constructor references in static property initializers. var declaration = resolver.getReferencedValueDeclaration(node); if (declaration) { - var classAlias = classAliases[declaration.id]; + var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { var clone_1 = ts.getSynthesizedClone(classAlias); ts.setSourceMapRange(clone_1, node); @@ -61237,9 +61542,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 !== 273 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 238 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 237 /* EnumDeclaration */); + if (container && container.kind !== 274 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 239 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 238 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -61374,15 +61679,15 @@ var ts; case 120 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return visitAwaitExpression(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -61391,27 +61696,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 212 /* Block */: - case 226 /* SwitchStatement */: - case 240 /* CaseBlock */: - case 265 /* CaseClause */: - case 266 /* DefaultClause */: - case 229 /* TryStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 216 /* IfStatement */: - case 225 /* WithStatement */: - case 227 /* LabeledStatement */: + case 213 /* Block */: + case 227 /* SwitchStatement */: + case 241 /* CaseBlock */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: + case 230 /* TryStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 217 /* IfStatement */: + case 226 /* WithStatement */: + case 228 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -61421,7 +61726,7 @@ var ts; } function visitCatchClauseInAsyncBody(node) { var catchClauseNames = ts.createUnderscoreEscapedMap(); - recordDeclarationName(node.variableDeclaration, catchClauseNames); + recordDeclarationName(node.variableDeclaration, catchClauseNames); // TODO: GH#18217 // names declared in a catch variable are block scoped var catchClauseUnshadowedNames; catchClauseNames.forEach(function (_, escapedName) { @@ -61461,8 +61766,9 @@ var ts; : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, ts.liftToBlock)); } function visitForStatementInAsyncBody(node) { - return ts.updateFor(node, isVariableDeclarationListWithCollidingName(node.initializer) - ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ false) + var initializer = node.initializer; // TODO: GH#18217 + return ts.updateFor(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, ts.liftToBlock)); } /** @@ -61554,10 +61860,10 @@ var ts; } } function isVariableDeclarationListWithCollidingName(node) { - return node + return !!node && ts.isVariableDeclarationList(node) && !(node.flags & 3 /* BlockScoped */) - && ts.forEach(node.declarations, collidesWithParameterName); + && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { hoistVariableDeclarationList(node); @@ -61611,7 +61917,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 === 192 /* ArrowFunction */; + var isArrowFunction = node.kind === 193 /* 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 @@ -61629,7 +61935,7 @@ var ts; var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.createBlock(statements, /*multiLine*/ true); ts.setTextRange(block, node.body); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. @@ -61684,15 +61990,15 @@ 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(186 /* CallExpression */); - context.enableSubstitution(184 /* PropertyAccessExpression */); - context.enableSubstitution(185 /* ElementAccessExpression */); + context.enableSubstitution(187 /* CallExpression */); + context.enableSubstitution(185 /* PropertyAccessExpression */); + context.enableSubstitution(186 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(234 /* ClassDeclaration */); - context.enableEmitNotification(153 /* MethodDeclaration */); - context.enableEmitNotification(155 /* GetAccessor */); - context.enableEmitNotification(156 /* SetAccessor */); - context.enableEmitNotification(154 /* Constructor */); + context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(154 /* MethodDeclaration */); + context.enableEmitNotification(156 /* GetAccessor */); + context.enableEmitNotification(157 /* SetAccessor */); + context.enableEmitNotification(155 /* Constructor */); } } /** @@ -61732,11 +62038,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -61768,11 +62074,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 234 /* ClassDeclaration */ - || kind === 154 /* Constructor */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */; + return kind === 235 /* ClassDeclaration */ + || kind === 155 /* Constructor */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */; } function createSuperAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -61867,45 +62173,47 @@ var ts; return node; } switch (node.kind) { - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return visitAwaitExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return visitYieldExpression(node); - case 227 /* LabeledStatement */: + case 225 /* ReturnStatement */: + return visitReturnStatement(node); + case 228 /* LabeledStatement */: return visitLabeledStatement(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return visitVoidExpression(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return visitConstructorDeclaration(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: return visitGetAccessorDeclaration(node); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return visitArrowFunction(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return visitParameter(node); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return visitExpressionStatement(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -61930,10 +62238,16 @@ var ts; } return ts.visitEachChild(node, visitor, context); } + function visitReturnStatement(node) { + if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + return ts.updateReturn(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : ts.createVoidZero())); + } + return ts.visitEachChild(node, visitor, context); + } function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 221 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 222 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -61945,7 +62259,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 === 271 /* SpreadAssignment */) { + if (e.kind === 272 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -61954,7 +62268,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 269 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 270 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -61972,7 +62286,7 @@ var ts; // If the first element is a spread element, then the first argument to __assign is {}: // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 183 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 184 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -62106,7 +62420,7 @@ var ts; ]), node.expression), 2097152 /* NoHoisting */), /*condition*/ ts.createComma(ts.createAssignment(result, createDownlevelAwait(callNext)), ts.createLogicalNot(getDone)), /*incrementor*/ undefined, - /*statement*/ convertForOfStatementHead(node, createDownlevelAwait(getValue))), + /*statement*/ convertForOfStatementHead(node, getValue)), /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) @@ -62228,7 +62542,7 @@ var ts; /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset)))))); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.updateBlock(node.body, statements); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. @@ -62256,7 +62570,7 @@ var ts; var leadingStatements = endLexicalEnvironment(); if (statementOffset > 0 || ts.some(statements) || ts.some(leadingStatements)) { var block = ts.convertToFunctionBody(body, /*multiLine*/ true); - ts.prependRange(statements, leadingStatements); + ts.prependStatements(statements, leadingStatements); ts.addRange(statements, block.statements.slice(statementOffset)); return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(statements), block.statements)); } @@ -62285,15 +62599,15 @@ 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(186 /* CallExpression */); - context.enableSubstitution(184 /* PropertyAccessExpression */); - context.enableSubstitution(185 /* ElementAccessExpression */); + context.enableSubstitution(187 /* CallExpression */); + context.enableSubstitution(185 /* PropertyAccessExpression */); + context.enableSubstitution(186 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(234 /* ClassDeclaration */); - context.enableEmitNotification(153 /* MethodDeclaration */); - context.enableEmitNotification(155 /* GetAccessor */); - context.enableEmitNotification(156 /* SetAccessor */); - context.enableEmitNotification(154 /* Constructor */); + context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(154 /* MethodDeclaration */); + context.enableEmitNotification(156 /* GetAccessor */); + context.enableEmitNotification(157 /* SetAccessor */); + context.enableEmitNotification(155 /* Constructor */); } } /** @@ -62333,11 +62647,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -62369,11 +62683,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 234 /* ClassDeclaration */ - || kind === 154 /* Constructor */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */; + return kind === 235 /* ClassDeclaration */ + || kind === 155 /* Constructor */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */; } function createSuperAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -62482,13 +62796,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 254 /* JsxElement */: + case 255 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -62498,13 +62812,13 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return visitJsxExpression(node); - case 254 /* JsxElement */: + case 255 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -62545,14 +62859,16 @@ var ts; objectProperties = ts.createAssignHelper(context, segments); } } - var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location); + var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217 + tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location); if (isChild) { ts.startOnNewLine(element); } return element; } function visitJsxOpeningFragment(node, children, isChild, location) { - var element = ts.createExpressionForJsxFragment(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, ts.mapDefined(children, transformJsxChildToExpression), node, location); + var element = ts.createExpressionForJsxFragment(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217 + ts.mapDefined(children, transformJsxChildToExpression), node, location); if (isChild) { ts.startOnNewLine(element); } @@ -62577,7 +62893,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 264 /* JsxExpression */) { + else if (node.kind === 265 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -62671,7 +62987,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 254 /* JsxElement */) { + if (node.kind === 255 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -62977,7 +63293,7 @@ var ts; return node; } switch (node.kind) { - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -63209,14 +63525,14 @@ var ts; hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ - && node.kind === 224 /* ReturnStatement */ + return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 + && node.kind === 225 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 212 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 213 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -63244,63 +63560,63 @@ var ts; switch (node.kind) { case 115 /* StaticKeyword */: return undefined; // elide static keyword - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return visitClassDeclaration(node); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return visitClassExpression(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return visitParameter(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return visitArrowFunction(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return visitVariableDeclaration(node); case 71 /* Identifier */: return visitIdentifier(node); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return visitSwitchStatement(node); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return visitCaseBlock(node); - case 212 /* Block */: + case 213 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return visitLabeledStatement(node); - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return visitExpressionStatement(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitCatchClause(node); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return visitCallExpression(node); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return visitNewExpression(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 13 /* NoSubstitutionTemplateLiteral */: case 14 /* TemplateHead */: @@ -63311,28 +63627,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return visitTemplateExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return visitYieldExpression(node); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return visitSpreadElement(node); case 97 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 99 /* ThisKeyword */: return visitThisKeyword(node); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return visitMetaProperty(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -63349,7 +63665,7 @@ var ts; if (taggedTemplateStringDeclarations) { statements.push(ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList(taggedTemplateStringDeclarations))); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -63419,13 +63735,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 === 223 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 224 /* 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; - if (!node.label) { - if (node.kind === 223 /* BreakStatement */) { + var label = node.label; + if (!label) { + if (node.kind === 224 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -63436,13 +63753,13 @@ var ts; } } else { - if (node.kind === 223 /* BreakStatement */) { - labelMarker = "break-" + node.label.escapedText; - setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(node.label), labelMarker); + if (node.kind === 224 /* BreakStatement */) { + labelMarker = "break-" + label.escapedText; + setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + node.label.escapedText; - setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(node.label), labelMarker); + labelMarker = "continue-" + label.escapedText; + setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(label), labelMarker); } } var returnExpression = ts.createLiteral(labelMarker); @@ -63603,7 +63920,7 @@ var ts; statement.pos = closingBraceLocation.pos; ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); statements.push(statement); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); ts.setEmitFlags(block, 1536 /* NoComments */); return block; @@ -63661,7 +63978,7 @@ var ts; // `super` call. // If this is the case, we do not include the synthetic `...args` parameter and // will instead use the `arguments` object in ES5/3. - return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) + return ts.visitParameterList(constructor && !hasSynthesizedSuper ? constructor.parameters : undefined, visitor, context) || []; } /** @@ -63697,7 +64014,7 @@ var ts; } // 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 !== 95 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { @@ -63716,7 +64033,7 @@ var ts; && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createFileLevelUniqueName("_this"))); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); if (constructor) { prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); } @@ -63736,11 +64053,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 224 /* ReturnStatement */) { + if (statement.kind === 225 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 216 /* IfStatement */) { + else if (statement.kind === 217 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -63748,7 +64065,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 212 /* Block */) { + else if (statement.kind === 213 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -63806,7 +64123,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 215 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -63816,8 +64133,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 199 /* BinaryExpression */ - || superCallExpression.left.kind !== 186 /* CallExpression */) { + if (superCallExpression.kind !== 200 /* BinaryExpression */ + || superCallExpression.left.kind !== 187 /* CallExpression */) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } // Shift comments from the original super call to the return statement. @@ -64014,7 +64331,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 192 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 193 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -64034,22 +64351,22 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return statements; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 154 /* Constructor */: + case 155 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 192 /* 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 = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 93 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); @@ -64080,20 +64397,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 211 /* SemicolonClassElement */: + case 212 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 154 /* Constructor */: + case 155 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -64163,7 +64480,7 @@ var ts; // arguments are both mapped contiguously to the accessor name. var target = ts.getMutableClone(receiver); ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); - ts.setSourceMapRange(target, firstAccessor.name); + ts.setSourceMapRange(target, firstAccessor.name); // TODO: GH#18217 var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 16 /* NoLeadingSourceMap */); ts.setSourceMapRange(propertyName, firstAccessor.name); @@ -64285,7 +64602,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 === 233 /* FunctionDeclaration */ || node.kind === 191 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 234 /* FunctionDeclaration */ || node.kind === 192 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -64333,7 +64650,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 192 /* ArrowFunction */); + ts.Debug.assert(node.kind === 193 /* 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 @@ -64359,7 +64676,7 @@ var ts; closeBraceLocation = body; } var lexicalEnvironment = context.endLexicalEnvironment(); - ts.prependRange(statements, lexicalEnvironment); + ts.prependStatements(statements, lexicalEnvironment); prependCaptureNewTargetIfNeeded(statements, node, /*copyOnWrite*/ false); // If we added any final generated statements, this must be a multi-line block if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { @@ -64401,9 +64718,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -64422,9 +64739,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -64497,13 +64814,12 @@ var ts; ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 /* ContainsBindingPattern */ - && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. var firstDeclaration = ts.firstOrUndefined(declarations); if (firstDeclaration) { - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, ts.last(declarations).end)); } } return declarationList; @@ -64626,14 +64942,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -64657,11 +64973,12 @@ var ts; } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; - if (ts.isVariableDeclarationList(node.initializer)) { + var initializer = node.initializer; + if (ts.isVariableDeclarationList(initializer)) { if (node.initializer.flags & 3 /* BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } - var firstOriginalDeclaration = ts.firstOrUndefined(node.initializer.declarations); + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. @@ -64670,9 +64987,7 @@ var ts; ts.setOriginalNode(declarationList, node.initializer); // Adjust the source map range for the first declaration to align with the old // emitter. - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(declarations[0].pos, ts.last(declarations).end)); statements.push(ts.createVariableStatement( /*modifiers*/ undefined, declarationList)); } @@ -64683,20 +64998,20 @@ var ts; /*modifiers*/ undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), /*type*/ undefined, boundValue) - ]), ts.moveRangePos(node.initializer, -1)), node.initializer)), ts.moveRangeEnd(node.initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. - var assignment = ts.createAssignment(node.initializer, boundValue); + var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); statements.push(ts.createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); } else { - assignment.end = node.initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(node.initializer, -1))); + assignment.end = initializer.end; + statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -64818,7 +65133,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 146 /* ComputedPropertyName */) { + if (property.name.kind === 147 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -64890,11 +65205,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 232 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 233 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -64940,7 +65255,7 @@ var ts; if (loopOutParameters.length) { copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_4); } - ts.prependRange(statements_4, lexicalEnvironment); + ts.prependStatements(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, /*multiline*/ true); } if (ts.isBlock(loopBody)) { @@ -65174,20 +65489,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -65298,7 +65613,7 @@ var ts; var body = node.transformFlags & (32768 /* ContainsCapturedLexicalThis */ | 128 /* ContainsES2015 */) ? transformFunctionBody(node) : visitFunctionBodyDownLevel(node); - if (node.kind === 155 /* GetAccessor */) { + if (node.kind === 156 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -65340,7 +65655,7 @@ var ts; function visitArrayLiteralExpression(node) { if (node.transformFlags & 64 /* ES2015 */) { // We are here because we contain a SpreadElementExpression. - return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, !!node.multiLine, /*hasTrailingComma*/ !!node.elements.hasTrailingComma); } return ts.visitEachChild(node, visitor, context); } @@ -65395,11 +65710,11 @@ var ts; var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock); // The class statements are the statements generated by visiting the first statement with initializer of the // body (1), while all other statements are added to remainingStatements (2) - var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.firstOrUndefined(stmt.declarationList.declarations).initializer; }; + var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.first(stmt.declarationList.declarations).initializer; }; var bodyStatements = ts.visitNodes(body.statements, visitor, ts.isStatement); var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer); var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); }); - var varStatement = ts.cast(ts.firstOrUndefined(classStatements), ts.isVariableStatement); + var varStatement = ts.cast(ts.first(classStatements), ts.isVariableStatement); // We know there is only one variable declaration here as we verified this in an // earlier call to isTypeScriptClassWrapper var variable = varStatement.declarationList.declarations[0]; @@ -65576,7 +65891,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 182 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -65839,13 +66154,13 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(99 /* ThisKeyword */); - context.enableEmitNotification(154 /* Constructor */); - context.enableEmitNotification(153 /* MethodDeclaration */); - context.enableEmitNotification(155 /* GetAccessor */); - context.enableEmitNotification(156 /* SetAccessor */); - context.enableEmitNotification(192 /* ArrowFunction */); - context.enableEmitNotification(191 /* FunctionExpression */); - context.enableEmitNotification(233 /* FunctionDeclaration */); + context.enableEmitNotification(155 /* Constructor */); + context.enableEmitNotification(154 /* MethodDeclaration */); + context.enableEmitNotification(156 /* GetAccessor */); + context.enableEmitNotification(157 /* SetAccessor */); + context.enableEmitNotification(193 /* ArrowFunction */); + context.enableEmitNotification(192 /* FunctionExpression */); + context.enableEmitNotification(234 /* FunctionDeclaration */); } } /** @@ -65885,14 +66200,13 @@ var ts; * @param node An original source tree node. */ function isNameOfDeclarationWithCollidingName(node) { - var parent = node.parent; - switch (parent.kind) { - case 181 /* BindingElement */: - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: - case 231 /* VariableDeclaration */: - return parent.name === node - && resolver.isDeclarationWithCollidingName(parent); + switch (node.parent.kind) { + case 182 /* BindingElement */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 232 /* VariableDeclaration */: + return node.parent.name === node + && resolver.isDeclarationWithCollidingName(node.parent); } return false; } @@ -65972,11 +66286,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 215 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 186 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -65984,7 +66298,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 203 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -66037,15 +66351,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(256 /* JsxOpeningElement */); - context.enableEmitNotification(257 /* JsxClosingElement */); - context.enableEmitNotification(255 /* JsxSelfClosingElement */); + context.enableEmitNotification(257 /* JsxOpeningElement */); + context.enableEmitNotification(258 /* JsxClosingElement */); + context.enableEmitNotification(256 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(184 /* PropertyAccessExpression */); - context.enableSubstitution(269 /* PropertyAssignment */); + context.enableSubstitution(185 /* PropertyAccessExpression */); + context.enableSubstitution(270 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -66064,9 +66378,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 256 /* JsxOpeningElement */: - case 257 /* JsxClosingElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 258 /* JsxClosingElement */: + case 256 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -66123,7 +66437,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */) { + if (token !== undefined && token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -66308,6 +66622,7 @@ var ts; case 4 /* Yield */: return "yield"; case 5 /* YieldStar */: return "yield*"; case 7 /* Endfinally */: return "endfinally"; + default: return undefined; // TODO: GH#18217 } } function transformGenerators(context) { @@ -66397,13 +66712,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 217 /* DoStatement */: + case 218 /* DoStatement */: return visitDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return visitWhileStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return visitSwitchStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -66416,24 +66731,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatement(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatement(node); - case 223 /* BreakStatement */: + case 224 /* BreakStatement */: return visitBreakStatement(node); - case 222 /* ContinueStatement */: + case 223 /* ContinueStatement */: return visitContinueStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -66454,21 +66769,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitBinaryExpression(node); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return visitConditionalExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return visitYieldExpression(node); - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return visitCallExpression(node); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -66481,9 +66796,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -66615,7 +66930,7 @@ var ts; var statementOffset = ts.addPrologue(statements, body.statements, /*ensureUseStrict*/ false, visitor); transformAndEmitStatements(body.statements, statementOffset); var buildResult = build(); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); statements.push(ts.createReturn(buildResult)); // Restore previous generator state inGeneratorFunctionBody = savedInGeneratorFunctionBody; @@ -66671,13 +66986,14 @@ var ts; * @param node The node to visit. */ function visitBinaryExpression(node) { - switch (ts.getExpressionAssociativity(node)) { + var assoc = ts.getExpressionAssociativity(node); + switch (assoc) { case 0 /* Left */: return visitLeftAssociativeBinaryExpression(node); case 1 /* Right */: return visitRightAssociativeBinaryExpression(node); default: - ts.Debug.fail("Unknown associativity."); + return ts.Debug.assertNever(assoc); } } function isCompoundAssignment(kind) { @@ -66710,7 +67026,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -66722,7 +67038,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -67098,35 +67414,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 212 /* Block */: + case 213 /* Block */: return transformAndEmitBlock(node); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return transformAndEmitIfStatement(node); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return transformAndEmitDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return transformAndEmitForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 222 /* ContinueStatement */: + case 223 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 223 /* BreakStatement */: + case 224 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return transformAndEmitWithStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -67556,7 +67872,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 266 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 267 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -67569,7 +67885,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 265 /* CaseClause */) { + if (clause.kind === 266 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -67685,7 +68001,7 @@ var ts; beginExceptionBlock(); transformAndEmitEmbeddedStatement(node.tryBlock); if (node.catchClause) { - beginCatchBlock(node.catchClause.variableDeclaration); + beginCatchBlock(node.catchClause.variableDeclaration); // TODO: GH#18217 transformAndEmitEmbeddedStatement(node.catchClause.block); } if (node.finallyBlock) { @@ -67699,7 +68015,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 16777216 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 16777216 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -67800,7 +68116,8 @@ var ts; */ function endBlock() { var block = peekBlock(); - ts.Debug.assert(block !== undefined, "beginBlock was never called."); + if (block === undefined) + return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; blockActions[index] = 1 /* Close */; blockOffsets[index] = operations ? operations.length : 0; @@ -68133,7 +68450,7 @@ var ts; * @param label A label. */ function createLabel(label) { - if (label > 0) { + if (label !== undefined && label > 0) { if (labelExpressions === undefined) { labelExpressions = []; } @@ -68772,7 +69089,7 @@ var ts; name: "typescript:generator", scoped: false, priority: 6, - text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" + text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; })(ts || (ts = {})); /*@internal*/ @@ -68797,11 +69114,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(199 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(197 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(198 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(270 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(273 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(200 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(198 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(199 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(274 /* 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. @@ -68851,7 +69168,7 @@ var ts; ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { // If we have any `export * from ...` declarations @@ -69045,7 +69362,7 @@ var ts; if (ts.isImportEqualsDeclaration(node) || ts.isExportDeclaration(node) || !ts.getExternalModuleNameLiteral(node, currentSourceFile, host, resolver, compilerOptions)) { return undefined; } - var name = ts.getLocalNameForExternalImport(node, currentSourceFile); + var name = ts.getLocalNameForExternalImport(node, currentSourceFile); // TODO: GH#18217 var expr = getHelperExpressionForImport(node, name); if (expr === name) { return undefined; @@ -69074,7 +69391,7 @@ var ts; addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); // End the lexical environment for the module body // and merge any new lexical declarations. - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var body = ts.createBlock(statements, /*multiLine*/ true); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { // If we have any `export * from ...` declarations @@ -69123,23 +69440,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return visitImportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return visitExportDeclaration(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitExportAssignment(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatement(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return visitClassDeclaration(node); - case 302 /* MergeDeclarationMarker */: + case 303 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 303 /* EndOfDeclarationMarker */: + case 304 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -69166,24 +69483,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -69658,7 +69975,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 213 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -69713,10 +70030,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 246 /* NamedImports */: + case 247 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -69915,7 +70232,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -69979,10 +70296,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return substituteBinaryExpression(node); - case 198 /* PostfixUnaryExpression */: - case 197 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -70003,7 +70320,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 273 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -70078,7 +70395,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 198 /* PostfixUnaryExpression */ + var expression = node.kind === 199 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -70154,11 +70471,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(270 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(199 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(197 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(198 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(273 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(200 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(198 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(199 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(274 /* 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. @@ -70343,8 +70660,8 @@ var ts; // We emit hoisted variables early to align roughly with our previous emit output. // Two key differences in this approach are: // - Temporary variables will appear at the top rather than at the bottom of the file - ts.prependRange(statements, endLexicalEnvironment()); - var exportStarFunction = addExportStarIfNeeded(statements); + ts.prependStatements(statements, endLexicalEnvironment()); + var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217 var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), ts.createPropertyAssignment("execute", ts.createFunctionExpression( @@ -70379,7 +70696,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 249 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 250 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -70404,7 +70721,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 249 /* ExportDeclaration */) { + if (externalImport.kind !== 250 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -70480,21 +70797,21 @@ var ts; var statements = []; for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; - var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); + var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -70544,15 +70861,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return visitImportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -70566,7 +70883,7 @@ var ts; function visitImportDeclaration(node) { var statements; if (node.importClause) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); // TODO: GH#18217 } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -70586,7 +70903,7 @@ var ts; function visitImportEqualsDeclaration(node) { ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); var statements; - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); // TODO: GH#18217 if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); @@ -70728,7 +71045,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 === 273 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 274 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -70792,7 +71109,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 === 213 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -70854,10 +71171,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 246 /* NamedImports */: + case 247 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -71037,43 +71354,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatement(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return visitClassDeclaration(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatement(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatement(node); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return visitDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return visitWhileStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return visitLabeledStatement(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return visitWithStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return visitSwitchStatement(node); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return visitCaseBlock(node); - case 265 /* CaseClause */: + case 266 /* CaseClause */: return visitCaseClause(node); - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: return visitDefaultClause(node); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return visitTryStatement(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitCatchClause(node); - case 212 /* Block */: + case 213 /* Block */: return visitBlock(node); - case 302 /* MergeDeclarationMarker */: + case 303 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 303 /* EndOfDeclarationMarker */: + case 304 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -71087,7 +71404,7 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateFor(node, 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 = ts.updateFor(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)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -71131,9 +71448,6 @@ var ts; * @param node The node to visit. */ function visitForInitializer(node) { - if (!node) { - return node; - } if (shouldHoistForInitializer(node)) { var expressions = void 0; for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { @@ -71259,7 +71573,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 199 /* BinaryExpression */) { + && node.kind === 200 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -71324,7 +71638,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 273 /* SourceFile */; + return container !== undefined && container.kind === 274 /* SourceFile */; } else { return false; @@ -71357,7 +71671,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -71405,7 +71719,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -71441,10 +71755,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return substituteBinaryExpression(node); - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -71537,14 +71851,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 198 /* PostfixUnaryExpression */ + var expression = node.kind === 199 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(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 === 198 /* PostfixUnaryExpression */) { + if (node.kind === 199 /* PostfixUnaryExpression */) { expression = node.operator === 43 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -71566,7 +71880,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 273 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -71605,7 +71919,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(273 /* SourceFile */); + context.enableEmitNotification(274 /* SourceFile */); context.enableSubstitution(71 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -71634,10 +71948,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -71744,7 +72058,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 === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* 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 : @@ -71773,7 +72087,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 === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* 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 : @@ -71817,10 +72131,10 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); + 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 === 231 /* VariableDeclaration */ || node.kind === 181 /* BindingElement */) { + if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* 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 : @@ -71829,8 +72143,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 === 151 /* PropertyDeclaration */ || node.kind === 150 /* PropertySignature */ || - (node.kind === 148 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 152 /* PropertyDeclaration */ || node.kind === 151 /* PropertySignature */ || + (node.kind === 149 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -71839,7 +72153,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 === 234 /* ClassDeclaration */ || node.kind === 148 /* Parameter */) { + else if (node.parent.kind === 235 /* ClassDeclaration */ || node.kind === 149 /* 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 : @@ -71864,7 +72178,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 156 /* SetAccessor */) { + if (node.kind === 157 /* 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.hasModifier(node, 32 /* Static */)) { @@ -71903,26 +72217,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 158 /* ConstructSignature */: + case 159 /* 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 157 /* CallSignature */: + case 158 /* 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 159 /* IndexSignature */: + case 160 /* 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 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -71930,7 +72244,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 === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* 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 : @@ -71944,7 +72258,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 233 /* FunctionDeclaration */: + case 234 /* 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 : @@ -71952,7 +72266,7 @@ var ts; ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; break; default: - ts.Debug.fail("This is unknown kind for signature: " + node.kind); + return ts.Debug.fail("This is unknown kind for signature: " + node.kind); } return { diagnosticMessage: diagnosticMessage, @@ -71969,30 +72283,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 154 /* Constructor */: + case 155 /* 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 158 /* ConstructSignature */: - case 163 /* ConstructorType */: + case 159 /* ConstructSignature */: + case 164 /* 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 157 /* CallSignature */: + case 158 /* 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 159 /* IndexSignature */: + case 160 /* 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 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -72000,7 +72314,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 === 234 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 235 /* 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 : @@ -72013,53 +72327,53 @@ 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 233 /* FunctionDeclaration */: - case 162 /* FunctionType */: + case 234 /* FunctionDeclaration */: + case 163 /* 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; default: - ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* CallSignature */: + case 158 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.hasModifier(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 === 234 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 235 /* 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 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: - ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); + return ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); } return { diagnosticMessage: diagnosticMessage, @@ -72070,7 +72384,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 234 /* ClassDeclaration */) { + if (node.parent.parent.kind === 235 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = node.parent.token === 108 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -72222,16 +72536,16 @@ var ts; } } function transformRoot(node) { - if (node.kind === 273 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 274 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 274 /* Bundle */) { + if (node.kind === 275 /* Bundle */) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { if (sourceFile.isDeclarationFile || ts.isSourceFileJavaScript(sourceFile)) - return; // Omit declaration files from bundle results, too + return undefined; // Omit declaration files from bundle results, too // TODO: GH#18217 hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; enclosingDeclaration = sourceFile; @@ -72253,7 +72567,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 276 /* InputFiles */) { + if (prepend.kind === 277 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText); } })); @@ -72351,7 +72665,7 @@ var ts; return name; } else { - if (name.kind === 180 /* ArrayBindingPattern */) { + if (name.kind === 181 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -72359,7 +72673,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 205 /* OmittedExpression */) { + if (elem.kind === 206 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -72397,7 +72711,7 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 148 /* Parameter */ && + var shouldUseResolverType = node.kind === 149 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { @@ -72406,7 +72720,7 @@ var ts; if (!ts.getParseTreeNode(node)) { return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(119 /* AnyKeyword */); } - if (node.kind === 156 /* SetAccessor */) { + if (node.kind === 157 /* 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 ts.createKeywordTypeNode(119 /* AnyKeyword */); @@ -72417,12 +72731,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 231 /* VariableDeclaration */ || node.kind === 181 /* BindingElement */) { + if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 148 /* Parameter */ - || node.kind === 151 /* PropertyDeclaration */ - || node.kind === 150 /* PropertySignature */) { + if (node.kind === 149 /* Parameter */ + || node.kind === 152 /* PropertyDeclaration */ + || node.kind === 151 /* 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)); @@ -72439,20 +72753,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 238 /* ModuleDeclaration */: - case 235 /* InterfaceDeclaration */: - case 234 /* ClassDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 237 /* EnumDeclaration */: + case 234 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 236 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 238 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 242 /* ImportEqualsDeclaration */: - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: - case 248 /* ExportAssignment */: + case 243 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: + case 249 /* ExportAssignment */: return false; } return false; @@ -72463,7 +72777,7 @@ var ts; } if (ts.isBindingPattern(elem.name)) { // If any child binding pattern element has been marked visible (usually by collect linked aliases), then this is visible - return ts.forEach(elem.name.elements, getBindingNameVisible); + return ts.some(elem.name.elements, getBindingNameVisible); } else { return resolver.isDeclarationVisible(elem); @@ -72471,11 +72785,11 @@ var ts; } function updateParamsList(node, params, modifierMask) { if (ts.hasModifier(node, 8 /* Private */)) { - return undefined; + return undefined; // TODO: GH#18217 } var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); }); if (!newParams) { - return undefined; + return undefined; // TODO: GH#18217 } return ts.createNodeArray(newParams, params.hasTrailingComma); } @@ -72505,8 +72819,8 @@ var ts; } function rewriteModuleSpecifier(parent, input) { if (!input) - return; - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 238 /* ModuleDeclaration */ && parent.kind !== 178 /* ImportType */); + return undefined; // TODO: GH#18217 + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 /* ModuleDeclaration */ && parent.kind !== 179 /* ImportType */); if (input.kind === 9 /* StringLiteral */ && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -72518,7 +72832,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 253 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 254 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -72545,7 +72859,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 245 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 246 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -72650,66 +72964,68 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 165 /* TypeLiteral */ || input.kind === 176 /* MappedType */) && input.parent.kind !== 236 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 177 /* MappedType */) && input.parent.kind !== 237 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 206 /* ExpressionWithTypeArguments */: { + case 207 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 161 /* TypeReference */: { + case 162 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 154 /* Constructor */: { + case 155 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(154 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), + var ctor = ts.createSignatureDeclaration(155 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + // TODO: GH#18217 + isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 153 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(152 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 154 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(153 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 155 /* GetAccessor */: { + case 156 /* GetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 156 /* SetAccessor */: { + case 157 /* SetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 150 /* PropertySignature */: + case 151 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 152 /* MethodSignature */: { + case 153 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 157 /* CallSignature */: { + case 158 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 159 /* IndexSignature */: { + case 160 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); } - case 231 /* VariableDeclaration */: { + case 232 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -72717,13 +73033,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(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 147 /* TypeParameter */: { + case 148 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 170 /* ConditionalType */: { + case 171 /* 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); @@ -72735,13 +73051,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 162 /* FunctionType */: { + case 163 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 163 /* ConstructorType */: { + case 164 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 178 /* ImportType */: { + case 179 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -72770,7 +73086,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 153 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 154 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -72780,7 +73096,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ExportDeclaration */: { + case 250 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -72789,7 +73105,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 248 /* ExportAssignment */: { + case 249 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -72819,10 +73135,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 242 /* ImportEqualsDeclaration */: { + case 243 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 243 /* ImportDeclaration */: { + case 244 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -72843,24 +73159,24 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 236 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 237 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 235 /* InterfaceDeclaration */: { + case 236 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 233 /* FunctionDeclaration */: { + case 234 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type return cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), /*body*/ undefined)); } - case 238 /* ModuleDeclaration */: { + case 239 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 239 /* ModuleBlock */) { + if (inner && inner.kind === 240 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -72874,14 +73190,14 @@ var ts; needsDeclare = false; ts.visitNode(inner, visitDeclarationStatements); // eagerly transform nested namespaces (the nesting doesn't need any elision or painting done) - var id = "" + ts.getOriginalNodeId(inner); + var id = "" + ts.getOriginalNodeId(inner); // TODO: GH#18217 var body = lateStatementReplacementMap.get(id); lateStatementReplacementMap.delete(id); return cleanup(ts.updateModuleDeclaration(input, /*decorators*/ undefined, mods, input.name, body)); } } - case 234 /* ClassDeclaration */: { + case 235 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -72924,7 +73240,7 @@ var ts; var extendsClause_1 = ts.getClassExtendsHeritageClauseElement(input); if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression - var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); + var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); // TODO: GH#18217 getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, @@ -72943,7 +73259,7 @@ var ts; return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 95 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, - /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; + /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 } else { var heritageClauses = transformHeritageClauses(input.heritageClauses); @@ -72951,10 +73267,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 213 /* VariableStatement */: { + case 214 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 237 /* EnumDeclaration */: { + case 238 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -72973,7 +73289,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 238 /* ModuleDeclaration */) { + if (input.kind === 239 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -72994,7 +73310,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 205 /* OmittedExpression */) { + if (e.kind === 206 /* OmittedExpression */) { return; } if (e.name) { @@ -73048,7 +73364,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 273 /* SourceFile */; + var parentIsFile = node.parent.kind === 274 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1 /* Export */) | 512 /* Default */ | 2 /* Ambient */); additions = 0 /* None */; @@ -73096,7 +73412,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 235 /* InterfaceDeclaration */) { + if (node.kind === 236 /* InterfaceDeclaration */) { return true; } return false; @@ -73116,7 +73432,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 155 /* GetAccessor */ + return accessor.kind === 156 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -73125,51 +73441,51 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 231 /* VariableDeclaration */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 148 /* Parameter */: + case 232 /* VariableDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 149 /* Parameter */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 238 /* ModuleDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 235 /* InterfaceDeclaration */: - case 234 /* ClassDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 237 /* EnumDeclaration */: - case 213 /* VariableStatement */: - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: - case 248 /* ExportAssignment */: + case 234 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 236 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 238 /* EnumDeclaration */: + case 214 /* VariableStatement */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: + case 249 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 158 /* ConstructSignature */: - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 159 /* IndexSignature */: - case 231 /* VariableDeclaration */: - case 147 /* TypeParameter */: - case 206 /* ExpressionWithTypeArguments */: - case 161 /* TypeReference */: - case 170 /* ConditionalType */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 178 /* ImportType */: + case 159 /* ConstructSignature */: + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 160 /* IndexSignature */: + case 232 /* VariableDeclaration */: + case 148 /* TypeParameter */: + case 207 /* ExpressionWithTypeArguments */: + case 162 /* TypeReference */: + case 171 /* ConditionalType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 179 /* ImportType */: return true; } return false; @@ -73245,7 +73561,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(304 /* Count */); + var enabledSyntaxKindFeatures = new Array(305 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -73554,7 +73870,7 @@ var ts; * @param sourceFileOrBundle The input source file or bundle for the program. */ function initialize(filePath, sourceMapFilePath, sourceFileOrBundle, outputSourceMapDataList) { - if (disabled) { + if (disabled || ts.fileExtensionIs(filePath, ".json" /* Json */)) { return; } if (sourceMapData) { @@ -73590,7 +73906,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 273 /* SourceFile */) { // emitting single module file + if (sourceFileOrBundle.kind === 274 /* SourceFile */) { // emitting single module file // For modules or multiple emit files the mapRoot will have directory structure like the sources // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); @@ -73677,7 +73993,7 @@ var ts; * @param pos The position. */ function emitPos(pos) { - if (disabled || ts.positionIsSynthesized(pos)) { + if (disabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(currentSource)) { return; } if (extendedDiagnostics) { @@ -73726,12 +74042,12 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithSourceMap(hint, node, emitCallback) { - if (disabled) { + if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0 /* None */; var range = emitNode && emitNode.sourceMapRange; var _a = range || node, pos = _a.pos, end = _a.end; var source = range && range.source; @@ -73740,7 +74056,7 @@ var ts; source = undefined; if (source) setSourceFile(source); - if (node.kind !== 299 /* NotEmittedStatement */ + if (node.kind !== 300 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -73757,7 +74073,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 299 /* NotEmittedStatement */ + if (node.kind !== 300 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -73775,11 +74091,11 @@ var ts; * @param emitCallback The callback used to emit the token. */ function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { - if (disabled) { + if (disabled || ts.isInJsonFile(node)) { return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0 /* None */; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; tokenPos = skipSourceTrivia(range ? range.pos : tokenPos); if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { @@ -73793,6 +74109,9 @@ var ts; } return tokenPos; } + function isJsonSourceMapSource(sourceFile) { + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + } /** * Set the current source file. * @@ -73804,6 +74123,9 @@ var ts; } currentSource = sourceFile; currentSourceText = currentSource.text; + if (isJsonSourceMapSource(sourceFile)) { + return; + } // Add the file to tsFilePaths // If sourceroot option: Use the relative path corresponding to the common directory path // otherwise source locations relative to map file location @@ -73825,8 +74147,8 @@ var ts; * Gets the text for the source map. */ function getText() { - if (disabled) { - return; + if (disabled || isJsonSourceMapSource(currentSource)) { + return undefined; // TODO: GH#18217 } encodeLastRecordedSourceMapSpan(); return JSON.stringify({ @@ -73843,8 +74165,8 @@ var ts; * Gets the SourceMappingURL for the source map. */ function getSourceMappingURL() { - if (disabled) { - return; + if (disabled || isJsonSourceMapSource(currentSource)) { + return undefined; // TODO: GH#18217 } if (compilerOptions.inlineSourceMap) { // Encode the sourceMap into the sourceMap url @@ -73905,7 +74227,7 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = printerOptions.removeComments; + var disabled = !!printerOptions.removeComments; return { reset: reset, setWriter: setWriter, @@ -73923,7 +74245,7 @@ var ts; if (node) { hasWrittenComment = false; var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0; var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; if ((pos < 0 && end < 0) || (pos === end)) { // Both pos and end are synthesized, so just emit the node without comments. @@ -73933,7 +74255,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 299 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 300 /* 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 === 10 /* JsxText */; @@ -73954,7 +74276,7 @@ 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 === 232 /* VariableDeclarationList */) { + if (node.kind === 233 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -74211,11 +74533,11 @@ var ts; detachedCommentsInfo = undefined; } function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; } function forEachLeadingCommentWithoutDetachedComments(cb) { // get the leading comments from detachedPos - var pos = ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos; + var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); } @@ -74270,6 +74592,7 @@ var ts; * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { @@ -74295,17 +74618,17 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 274 /* Bundle */) { + if (sourceFile.kind === 275 /* Bundle */) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var bundleInfoPath = options.references && jsFilePath && (ts.removeFileExtension(jsFilePath) + infoExtension); + var bundleInfoPath = options.references && jsFilePath ? (ts.removeFileExtension(jsFilePath) + infoExtension) : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: bundleInfoPath }; } else { var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var sourceMapFilePath = ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error var isJs = ts.isSourceFileJavaScript(sourceFile); var declarationFilePath = ((forceDtsPaths || options.declaration) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; @@ -74371,7 +74694,7 @@ var ts; emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), emittedFiles: emittedFilesList, - sourceMaps: sourceMapDataList + sourceMaps: sourceMapDataList, }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, bundleInfoPath = _a.bundleInfoPath; @@ -74458,8 +74781,8 @@ var ts; declarationTransform.dispose(); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 274 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 273 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 275 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 274 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -74478,7 +74801,7 @@ var ts; ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, mapRecorder.getText(), /*writeByteOrderMark*/ false, sourceFiles); } // Write the output file - ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); + ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); // Write bundled offset information if applicable if (bundleInfoPath) { bundleInfo.totalLength = writer.getTextPos(); @@ -74559,9 +74882,9 @@ var ts; break; } switch (node.kind) { - case 273 /* SourceFile */: return printFile(node); - case 274 /* Bundle */: return printBundle(node); - case 275 /* UnparsedSource */: return printUnparsedSource(node); + case 274 /* SourceFile */: return printFile(node); + case 275 /* Bundle */: return printBundle(node); + case 276 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -74662,7 +74985,7 @@ var ts; } } function setWriter(output) { - writer = output; + writer = output; // TODO: GH#18217 comments.setWriter(output); } function reset() { @@ -74720,8 +75043,7 @@ var ts; return getPipelinePhase(currentPhase + 1, hint); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assertDefined(onEmitNode); - onEmitNode(hint, node, getNextPipelinePhase(0 /* Notification */, hint)); + ts.Debug.assertDefined(onEmitNode)(hint, node, getNextPipelinePhase(0 /* Notification */, hint)); } function pipelineEmitWithComments(hint, node) { ts.Debug.assertDefined(emitNodeWithComments); @@ -74733,9 +75055,8 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assertDefined(onEmitSourceMapOfNode); ts.Debug.assert(hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */); - onEmitSourceMapOfNode(hint, node, pipelineEmitWithHint); + ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { if (hint === 0 /* SourceFile */) @@ -74753,235 +75074,235 @@ var ts; case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: return emitLiteral(node); - case 275 /* UnparsedSource */: + case 276 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers case 71 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return emitQualifiedName(node); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return emitTypeParameter(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return emitParameter(node); - case 149 /* Decorator */: + case 150 /* Decorator */: return emitDecorator(node); // Type members - case 150 /* PropertySignature */: + case 151 /* PropertySignature */: return emitPropertySignature(node); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 152 /* MethodSignature */: + case 153 /* MethodSignature */: return emitMethodSignature(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return emitConstructor(node); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return emitAccessorDeclaration(node); - case 157 /* CallSignature */: + case 158 /* CallSignature */: return emitCallSignature(node); - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: return emitConstructSignature(node); - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: return emitIndexSignature(node); // Types - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return emitTypePredicate(node); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return emitTypeReference(node); - case 162 /* FunctionType */: + case 163 /* FunctionType */: return emitFunctionType(node); - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 163 /* ConstructorType */: + case 164 /* ConstructorType */: return emitConstructorType(node); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return emitTypeQuery(node); - case 165 /* TypeLiteral */: + case 166 /* TypeLiteral */: return emitTypeLiteral(node); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return emitArrayType(node); - case 167 /* TupleType */: + case 168 /* TupleType */: return emitTupleType(node); - case 168 /* UnionType */: + case 169 /* UnionType */: return emitUnionType(node); - case 169 /* IntersectionType */: + case 170 /* IntersectionType */: return emitIntersectionType(node); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return emitConditionalType(node); - case 171 /* InferType */: + case 172 /* InferType */: return emitInferType(node); - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return emitParenthesizedType(node); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 173 /* ThisType */: + case 174 /* ThisType */: return emitThisType(); - case 174 /* TypeOperator */: + case 175 /* TypeOperator */: return emitTypeOperator(node); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 176 /* MappedType */: + case 177 /* MappedType */: return emitMappedType(node); - case 177 /* LiteralType */: + case 178 /* LiteralType */: return emitLiteralType(node); - case 178 /* ImportType */: + case 179 /* ImportType */: return emitImportTypeNode(node); - case 278 /* JSDocAllType */: + case 279 /* JSDocAllType */: write("*"); return; - case 279 /* JSDocUnknownType */: + case 280 /* JSDocUnknownType */: write("?"); return; - case 280 /* JSDocNullableType */: + case 281 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 281 /* JSDocNonNullableType */: + case 282 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 282 /* JSDocOptionalType */: + case 283 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: return emitJSDocVariadicType(node); // Binding patterns - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return emitBindingElement(node); // Misc - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return emitTemplateSpan(node); - case 211 /* SemicolonClassElement */: + case 212 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 212 /* Block */: + case 213 /* Block */: return emitBlock(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return emitVariableStatement(node); - case 214 /* EmptyStatement */: + case 215 /* EmptyStatement */: return emitEmptyStatement(); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return emitExpressionStatement(node); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return emitIfStatement(node); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return emitDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return emitWhileStatement(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return emitForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return emitForInStatement(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return emitForOfStatement(node); - case 222 /* ContinueStatement */: + case 223 /* ContinueStatement */: return emitContinueStatement(node); - case 223 /* BreakStatement */: + case 224 /* BreakStatement */: return emitBreakStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return emitReturnStatement(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return emitWithStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return emitSwitchStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return emitLabeledStatement(node); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return emitThrowStatement(node); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return emitTryStatement(node); - case 230 /* DebuggerStatement */: + case 231 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return emitClassDeclaration(node); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return emitModuleBlock(node); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return emitCaseBlock(node); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return emitImportDeclaration(node); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return emitImportClause(node); - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return emitNamespaceImport(node); - case 246 /* NamedImports */: + case 247 /* NamedImports */: return emitNamedImports(node); - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: return emitImportSpecifier(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return emitExportAssignment(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return emitExportDeclaration(node); - case 250 /* NamedExports */: + case 251 /* NamedExports */: return emitNamedExports(node); - case 251 /* ExportSpecifier */: + case 252 /* ExportSpecifier */: return emitExportSpecifier(node); - case 252 /* MissingDeclaration */: + case 253 /* MissingDeclaration */: return; // Module references - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 256 /* JsxOpeningElement */: - case 259 /* JsxOpeningFragment */: + case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 257 /* JsxClosingElement */: - case 260 /* JsxClosingFragment */: + case 258 /* JsxClosingElement */: + case 261 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return emitJsxAttribute(node); - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return emitJsxAttributes(node); - case 263 /* JsxSpreadAttribute */: + case 264 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 265 /* CaseClause */: + case 266 /* CaseClause */: return emitCaseClause(node); - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: return emitDefaultClause(node); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: return emitHeritageClause(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 272 /* EnumMember */: + case 273 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (ignored) // Transformation nodes (ignored) @@ -75016,71 +75337,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return emitCallExpression(node); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return emitNewExpression(node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return emitFunctionExpression(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return emitArrowFunction(node); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return emitDeleteExpression(node); - case 194 /* TypeOfExpression */: + case 195 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return emitVoidExpression(node); - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return emitAwaitExpression(node); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return emitBinaryExpression(node); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return emitConditionalExpression(node); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return emitTemplateExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return emitYieldExpression(node); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return emitSpreadExpression(node); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return emitClassExpression(node); - case 205 /* OmittedExpression */: + case 206 /* OmittedExpression */: return; - case 207 /* AsExpression */: + case 208 /* AsExpression */: return emitAsExpression(node); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: return emitNonNullExpression(node); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 254 /* JsxElement */: + case 255 /* JsxElement */: return emitJsxElement(node); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: return emitCommaList(node); } } @@ -75097,7 +75418,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 274 /* Bundle */ ? node : undefined; + var bundle = node.kind === 275 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -75223,7 +75544,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 283 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 284 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -75285,7 +75606,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 155 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 156 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -75542,7 +75863,7 @@ var ts; increaseIndent(); } var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ ? 32 /* AllowTrailingComma */ : 0 /* None */; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 32 /* AllowTrailingComma */ : 0 /* None */; emitList(node, node.properties, 263122 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); @@ -75682,7 +76003,7 @@ 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 === 197 /* PrefixUnaryExpression */ + return operand.kind === 198 /* PrefixUnaryExpression */ && ((node.operator === 37 /* PlusToken */ && (operand.operator === 37 /* PlusToken */ || operand.operator === 43 /* PlusPlusToken */)) || (node.operator === 38 /* MinusToken */ && (operand.operator === 38 /* MinusToken */ || operand.operator === 44 /* MinusMinusToken */))); } @@ -75802,7 +76123,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 216 /* IfStatement */) { + if (node.elseStatement.kind === 217 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -75865,7 +76186,7 @@ var ts; emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(144 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(145 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -75873,7 +76194,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 232 /* VariableDeclarationList */) { + if (node.kind === 233 /* VariableDeclarationList */) { emit(node); } else { @@ -75988,7 +76309,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); + emitIdentifierName(node.name); // TODO: GH#18217 emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -76168,7 +76489,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 238 /* ModuleDeclaration */) { + while (body.kind === 239 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -76213,7 +76534,7 @@ var ts; if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(142 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(143 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -76265,7 +76586,7 @@ var ts; if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(142 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(143 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -76357,7 +76678,7 @@ var ts; } function emitJsxAttribute(node) { emit(node.name); - emitNodeWithPrefix("=", writePunctuation, node.initializer, emit); + emitNodeWithPrefix("=", writePunctuation, node.initializer, emit); // TODO: GH#18217 } function emitJsxSpreadAttribute(node) { writePunctuation("{..."); @@ -76491,7 +76812,7 @@ var ts; emitSourceFileWorker(node); } function emitSyntheticTripleSlashReferencesIfNeeded(node) { - emitTripleSlashDirectives(node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || []); + emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || []); } function emitTripleSlashDirectivesIfNeeded(node) { if (node.isDeclarationFile) @@ -76719,7 +77040,7 @@ var ts; emitNodeList(emit, parentNode, children, format, start, count); } function emitExpressionList(parentNode, children, format, start, count) { - emitNodeList(emitExpression, parentNode, children, format, start, count); + emitNodeList(emitExpression, parentNode, children, format, start, count); // TODO: GH#18217 } function writeDelimiter(format) { switch (format & 28 /* DelimitersMask */) { @@ -76745,7 +77066,7 @@ var ts; if (isUndefined && format & 8192 /* OptionalIfUndefined */) { return; } - var isEmpty = isUndefined || start >= children.length || count === 0; + var isEmpty = children === undefined || start >= children.length || count === 0; if (isEmpty && format & 16384 /* OptionalIfEmpty */) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); @@ -76758,6 +77079,7 @@ var ts; if (format & 7680 /* BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && !isUndefined) { + // TODO: GH#18217 emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists } } @@ -76777,7 +77099,7 @@ var ts; // Write the opening line terminator or leading whitespace. var mayEmitInterveningComments = (format & 131072 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; - if (shouldWriteLeadingLineTerminator(parentNode, children, format)) { + if (shouldWriteLeadingLineTerminator(parentNode, children, format)) { // TODO: GH#18217 writeLine(); shouldEmitInterveningComments = false; } @@ -76790,7 +77112,7 @@ var ts; } // Emit each child. var previousSibling = void 0; - var shouldDecreaseIndentAfterEmit = void 0; + var shouldDecreaseIndentAfterEmit = false; for (var i = 0; i < count; i++) { var child = children[start + i]; // Write the delimiter if this is not the first node. @@ -76868,6 +77190,7 @@ var ts; } if (format & 7680 /* BracketsMask */) { if (isEmpty && !isUndefined) { + // TODO: GH#18217 emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } writePunctuation(getClosingBracket(format)); @@ -77091,7 +77414,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 190 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 191 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -77156,81 +77479,81 @@ var ts; if (!node) return; switch (node.kind) { - case 212 /* Block */: + case 213 /* Block */: ts.forEach(node.statements, generateNames); break; - case 227 /* LabeledStatement */: - case 225 /* WithStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 228 /* LabeledStatement */: + case 226 /* WithStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: generateNames(node.statement); break; - case 216 /* IfStatement */: + case 217 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 219 /* ForStatement */: - case 221 /* ForOfStatement */: - case 220 /* ForInStatement */: + case 220 /* ForStatement */: + case 222 /* ForOfStatement */: + case 221 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 229 /* TryStatement */: + case 230 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 268 /* CatchClause */: + case 269 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: generateNames(node.declarationList); break; - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: - case 181 /* BindingElement */: - case 234 /* ClassDeclaration */: + case 232 /* VariableDeclaration */: + case 149 /* Parameter */: + case 182 /* BindingElement */: + case 235 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: generateNames(node.importClause); break; - case 244 /* ImportClause */: + case 245 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 246 /* NamedImports */: + case 247 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -77239,12 +77562,12 @@ var ts; if (!node) return; switch (node.kind) { - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -77396,7 +77719,7 @@ var ts; * Generates a unique name for an ImportDeclaration or ExportDeclaration. */ function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); + var expr = ts.getExternalModuleName(node); // TODO: GH#18217 var baseName = ts.isStringLiteral(expr) ? ts.makeIdentifierFromModuleName(expr.text) : "module"; return makeUniqueName(baseName); @@ -77426,21 +77749,21 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - case 248 /* ExportAssignment */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 249 /* ExportAssignment */: return generateNameForExportDefault(); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return generateNameForClassExpression(); - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); @@ -77458,7 +77781,7 @@ var ts; case 3 /* Unique */: return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* Optimistic */), !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); } - ts.Debug.fail("Unsupported GeneratedIdentifierKind."); + return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } /** * Gets the node from which a name should be generated. @@ -77921,8 +78244,8 @@ var ts; if (!outputFingerprints) { outputFingerprints = ts.createMap(); } - var hash = ts.sys.createHash(data); - var mtimeBefore = ts.sys.getModifiedTime(fileName); + var hash = ts.sys.createHash(data); // TODO: GH#18217 + var mtimeBefore = ts.sys.getModifiedTime(fileName); // TODO: GH#18217 if (mtimeBefore) { var fingerprint = outputFingerprints.get(fileName); // If output has not been changed, and the file has no external modification @@ -77934,7 +78257,7 @@ var ts; } } ts.sys.writeFile(fileName, data, writeByteOrderMark); - var mtimeAfter = ts.sys.getModifiedTime(fileName); + var mtimeAfter = ts.sys.getModifiedTime(fileName); // TODO: GH#18217 outputFingerprints.set(fileName, { hash: hash, byteOrderMark: writeByteOrderMark, @@ -78005,7 +78328,7 @@ var ts; function formatDiagnostic(diagnostic, host) { var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); if (diagnostic.file) { - var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; + var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; // TODO: GH#18217 var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; @@ -78052,7 +78375,7 @@ var ts; var context_2 = ""; if (diagnostic.file) { var start = diagnostic.start, length_4 = diagnostic.length, file_9 = diagnostic.file; - var _a = ts.getLineAndCharacterOfPosition(file_9, start), firstLine = _a.line, firstLineChar = _a.character; + var _a = ts.getLineAndCharacterOfPosition(file_9, start), firstLine = _a.line, firstLineChar = _a.character; // TODO: GH#18217 var _b = ts.getLineAndCharacterOfPosition(file_9, start + length_4), lastLine = _b.line, lastLineChar = _b.character; var lastLineInFile = ts.getLineAndCharacterOfPosition(file_9, file_9.text.length).line; var relativeFileName = host ? ts.convertToRelativePath(file_9.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file_9.fileName; @@ -78196,8 +78519,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? - configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -78228,9 +78550,9 @@ var ts; }; } function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) { - var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; + var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; - var host = createProgramOptions.host, oldProgram = createProgramOptions.oldProgram; + var oldProgram = createProgramOptions.oldProgram; var program; var files = []; var commonSourceDirectory; @@ -78257,7 +78579,7 @@ var ts; // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. var sourceFilesFoundSearchingNodeModules = ts.createMap(); ts.performance.mark("beforeProgram"); - host = host || createCompilerHost(options); + var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHost(host); var skipDefaultLib = options.noLib; var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); }); @@ -78285,7 +78607,7 @@ var ts; } else { moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; // TODO: GH#18217 resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -78293,7 +78615,7 @@ var ts; resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile); }; } else { - var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; + var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; // TODO: GH#18217 resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, loader_2); }; } // Map from a stringified PackageId to the source file with that id. @@ -78384,6 +78706,7 @@ var ts; getOptionsDiagnostics: getOptionsDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getSemanticDiagnostics: getSemanticDiagnostics, + getSuggestionDiagnostics: getSuggestionDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, getTypeChecker: getTypeChecker, getClassifiableNames: getClassifiableNames, @@ -78427,7 +78750,7 @@ var ts; } else if (options.composite) { // Project compilations never infer their root from the input source paths - commonSourceDirectory = ts.getDirectoryPath(ts.normalizeSlashes(options.configFilePath)); + commonSourceDirectory = ts.getDirectoryPath(ts.normalizeSlashes(options.configFilePath)); // TODO: GH#18217 checkSourceFilesBelongToPath(emittedFiles, commonSourceDirectory); } else { @@ -78548,7 +78871,7 @@ var ts; // `result[i]` is either a `ResolvedModuleFull` or a marker. // If it is the former, we can leave it as is. if (result[i] === predictedToResolveToAmbientModuleMarker) { - result[i] = undefined; + result[i] = undefined; // TODO: GH#18217 } } else { @@ -78561,7 +78884,7 @@ var ts; // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) { - var resolutionToFile = ts.getResolvedModule(oldProgramState.oldSourceFile, moduleName); + var resolutionToFile = ts.getResolvedModule(oldProgramState.oldSourceFile, moduleName); // TODO: GH#18217 var resolvedFile = resolutionToFile && oldProgramState.program && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) { // In the old program, we resolved to an ambient module that was in the same @@ -78657,7 +78980,7 @@ var ts; var oldSourceFile = oldSourceFiles_2[_i]; var newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.path, options.target, /*onError*/ undefined, shouldCreateNewSourceFile) - : host.getSourceFile(oldSourceFile.fileName, options.target, /*onError*/ undefined, shouldCreateNewSourceFile); + : host.getSourceFile(oldSourceFile.fileName, options.target, /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 if (!newSourceFile) { return oldProgram.structureIsReused = 0 /* Not */; } @@ -78843,7 +79166,7 @@ var ts; return nodes; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules.get(file.path); + return !!sourceFilesFoundSearchingNodeModules.get(file.path); } function isSourceFileDefaultLibrary(file) { if (file.hasNoDefaultLib) { @@ -78859,7 +79182,7 @@ var ts; return equalityComparer(file.fileName, getDefaultLibraryFileName()); } else { - return ts.forEach(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); }); + return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); }); } } function getDiagnosticsProducingTypeChecker() { @@ -78912,7 +79235,8 @@ var ts; var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(options, customTransformers); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, // TODO: GH#18217 + emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -79003,11 +79327,24 @@ var ts; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); - if (isCheckJs) { - diagnostics = ts.concatenate(diagnostics, sourceFile.jsDocDiagnostics); + var diagnostics; + for (var _i = 0, _a = [bindDiagnostics, checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile, isCheckJs ? sourceFile.jsDocDiagnostics : undefined]; _i < _a.length; _i++) { + var diags = _a[_i]; + if (diags) { + for (var _b = 0, diags_1 = diags; _b < diags_1.length; _b++) { + var diag = diags_1[_b]; + if (shouldReportDiagnostic(diag)) { + diagnostics = ts.append(diagnostics, diag); + } + } + } } - return ts.filter(diagnostics, shouldReportDiagnostic); + return diagnostics; + }); + } + function getSuggestionDiagnostics(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken); }); } /** @@ -79017,7 +79354,7 @@ var ts; var file = diagnostic.file, start = diagnostic.start; if (file) { var lineStarts = ts.getLineStarts(file); - var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line; + var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line; // TODO: GH#18217 while (line > 0) { var previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]); var result = ignoreDiagnosticCommentRegEx.exec(previousLineText); @@ -79044,22 +79381,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 148 /* Parameter */: - case 151 /* PropertyDeclaration */: + case 149 /* Parameter */: + case 152 /* PropertyDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: - case 231 /* VariableDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: + case 232 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -79067,41 +79404,41 @@ var ts; } } switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 108 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 207 /* AsExpression */: + case 208 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -79114,28 +79451,28 @@ 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_to_remove_this_warning)); } switch (parent.kind) { - case 234 /* ClassDeclaration */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: + case 235 /* ClassDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 213 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 214 /* VariableStatement */); } break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -79147,18 +79484,18 @@ var ts; return; } break; - case 148 /* Parameter */: + case 149 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 206 /* ExpressionWithTypeArguments */: - case 255 /* JsxSelfClosingElement */: - case 256 /* JsxOpeningElement */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 207 /* ExpressionWithTypeArguments */: + case 256 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -79224,7 +79561,7 @@ var ts; if (cachedResult) { return cachedResult; } - var result = getDiagnostics(sourceFile, cancellationToken) || ts.emptyArray; + var result = getDiagnostics(sourceFile, cancellationToken) || ts.emptyArray; // TODO: GH#18217 if (sourceFile) { if (!cache.perFile) { cache.perFile = ts.createMap(); @@ -79404,7 +79741,8 @@ var ts; } /** This has side effects through `findSourceFile`. */ function processSourceFile(fileName, isDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId); }, function (diagnostic) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; @@ -79496,7 +79834,7 @@ var ts; if (fileFromPackageId) { // Some other SourceFile already exists with this package name and version. // Instead of creating a duplicate, just redirect to the existing one. - var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path); + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path); // TODO: GH#18217 redirectTargetsSet.set(fileFromPackageId.path, true); filesByName.set(path, dupFile); sourceFileToPackageName.set(path, packageId.name); @@ -79591,7 +79929,7 @@ var ts; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -79601,7 +79939,8 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 + ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -79614,7 +79953,7 @@ var ts; } } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); + fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -79718,7 +80057,7 @@ var ts; } function parseProjectReferenceConfigFile(ref) { // The actual filename (i.e. add "/tsconfig.json" if necessary) - var refPath = resolveProjectReferencePath(host, ref); + var refPath = resolveProjectReferencePath(host, ref); // TODO: GH#18217 // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); var sourceFile = host.getSourceFile(refPath, 100 /* JSON */); @@ -79729,13 +80068,13 @@ var ts; return { commandLine: commandLine, sourceFile: sourceFile }; } function addProjectReferenceRedirects(referencedProject, target) { - var rootDir = ts.normalizePath(referencedProject.options.rootDir || ts.getDirectoryPath(referencedProject.options.configFilePath)); + var rootDir = ts.normalizePath(referencedProject.options.rootDir || ts.getDirectoryPath(referencedProject.options.configFilePath)); // TODO: GH#18217 target.set(rootDir, getDeclarationOutputDirectory(referencedProject)); } function getDeclarationOutputDirectory(proj) { return proj.options.declarationDir || proj.options.outDir || - ts.getDirectoryPath(proj.options.configFilePath); + ts.getDirectoryPath(proj.options.configFilePath); // TODO: GH#18217 } function verifyCompilerOptions() { if (options.strictPropertyInitialization && !options.strictNullChecks) { @@ -79990,9 +80329,9 @@ var ts; if (ts.isObjectLiteralExpression(pathProp.initializer)) { for (var _a = 0, _b = ts.getPropertyAssignment(pathProp.initializer, key); _a < _b.length; _a++) { var keyProps = _b[_a]; - if (ts.isArrayLiteralExpression(keyProps.initializer) && - keyProps.initializer.elements.length > valueIndex) { - programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, keyProps.initializer.elements[valueIndex], message, arg0, arg1, arg2)); + var initializer = keyProps.initializer; + if (ts.isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) { + programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, arg0, arg1, arg2)); needCompilerDiagnostic = false; } } @@ -80053,7 +80392,7 @@ var ts; if (_referencesArrayLiteralSyntax === undefined) { _referencesArrayLiteralSyntax = null; // tslint:disable-line:no-null-keyword if (options.configFile) { - var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); + var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); // TODO: GH#18217 for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "references"); _i < _a.length; _i++) { var prop = _a[_i]; if (ts.isArrayLiteralExpression(prop.initializer)) { @@ -80095,6 +80434,7 @@ var ts; return false; } programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, arrayLiteral.elements[index], message, arg0, arg1, arg2)); + return false; // TODO: GH#18217 This function always returns `false`!` } function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(toPath(emitFileName), true); @@ -80114,6 +80454,10 @@ var ts; if (out) { return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Dts */); } + // If declarationDir is specified, return if its a file in that directory + if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { + return true; + } // If --outDir, check if file is in that directory if (options.outDir) { return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); @@ -80121,8 +80465,8 @@ var ts; if (ts.fileExtensionIsOneOf(filePath, ts.supportedJavascriptExtensions) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) { // Otherwise just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath(ts.combinePaths(filePathWithoutExtension, ".ts" /* Ts */)) || - !!getSourceFileByPath(ts.combinePaths(filePathWithoutExtension, ".tsx" /* Tsx */)); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Tsx */)); } return false; } @@ -80247,7 +80591,7 @@ var ts; if (!resolvedTypeReferenceDirective) { return; } - var fileName = resolvedTypeReferenceDirective.resolvedFileName; + var fileName = resolvedTypeReferenceDirective.resolvedFileName; // TODO: GH#18217 var typeFilePath = ts.toPath(fileName, sourceFileDirectory, getCanonicalFileName); addReferencedFile(typeFilePath); }); @@ -80279,7 +80623,7 @@ var ts; for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var version_1 = sourceFile.version; - var oldInfo = useOldState && oldState.fileInfos.get(sourceFile.path); + var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.path) : undefined; if (referencedMap) { var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName); if (newReferences) { @@ -80342,7 +80686,8 @@ var ts; return false; } var info = state.fileInfos.get(sourceFile.path); - ts.Debug.assert(!!info); + if (!info) + return ts.Debug.fail(); var prevSignature = info.signature; var latestSignature; if (sourceFile.isDeclarationFile) { @@ -80354,7 +80699,7 @@ var ts; latestSignature = computeHash(emitOutput.outputFiles[0].text); } else { - latestSignature = prevSignature; + latestSignature = prevSignature; // TODO: GH#18217 } } cacheToUpdateSignature.set(sourceFile.path, latestSignature); @@ -80489,8 +80834,9 @@ var ts; if (!seenFileNamesMap.has(currentPath)) { var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath); seenFileNamesMap.set(currentPath, currentSourceFile); - if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash)) { - queue.push.apply(queue, getReferencedByPaths(state, currentPath)); + if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash)) { // TODO: GH#18217 + queue.push.apply(// TODO: GH#18217 + queue, getReferencedByPaths(state, currentPath)); } } } @@ -80505,7 +80851,7 @@ var ts; (function (ts) { function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps - return map1 === map2 || map1 && map2 && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); + return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); } /** * Create the state so that we can iterate on changedFiles/affected files @@ -80533,7 +80879,7 @@ var ts; } // Update changed files and copy semantic diagnostics if we can var referencedMap = state.referencedMap; - var oldReferencedMap = useOldState && oldState.referencedMap; + var oldReferencedMap = useOldState ? oldState.referencedMap : undefined; state.fileInfos.forEach(function (info, sourceFilePath) { var oldInfo; var newReferences; @@ -80577,7 +80923,7 @@ var ts; var affectedFiles = state.affectedFiles; if (affectedFiles) { var seenAffectedFiles = state.seenAffectedFiles, semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile; - var affectedFilesIndex = state.affectedFilesIndex; + var affectedFilesIndex = state.affectedFilesIndex; // TODO: GH#18217 while (affectedFilesIndex < affectedFiles.length) { var affectedFile = affectedFiles[affectedFilesIndex]; if (!seenAffectedFiles.has(affectedFile.path)) { @@ -80690,7 +81036,7 @@ var ts; // Return same program if underlying program doesnt change var oldState = oldProgram && oldProgram.getState(); if (oldState && newProgram === oldState.program && configFileParsingDiagnostics === newProgram.getConfigFileParsingDiagnostics()) { - newProgram = undefined; + newProgram = undefined; // TODO: GH#18217 oldState = undefined; return oldProgram; } @@ -80704,7 +81050,7 @@ var ts; var computeHash = host.createHash || ts.identity; var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); // To ensure that we arent storing any references to old program or new program without state - newProgram = undefined; + newProgram = undefined; // TODO: GH#18217 oldProgram = undefined; oldState = undefined; var result = { @@ -80765,7 +81111,7 @@ var ts; if (!targetSourceFile) { // Emit and report any errors we ran into. var sourceMaps = []; - var emitSkipped = void 0; + var emitSkipped = false; var diagnostics = void 0; var emittedFiles = []; var affectedEmitResult = void 0; @@ -80885,7 +81231,7 @@ var ts; var filesWithInvalidatedResolutions; var filesWithInvalidatedNonRelativeUnresolvedImports; var allFilesHaveInvalidatedResolution = false; - var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); + 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. // The key in the map is source file's path. @@ -80906,7 +81252,7 @@ var ts; var customFailedLookupPaths = ts.createMap(); var directoryWatchesOfFailedLookups = ts.createMap(); var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory())); - var rootPath = rootDir && resolutionHost.toPath(rootDir); + var rootPath = (rootDir && resolutionHost.toPath(rootDir)); // TODO: GH#18217 // TypeRoot watches for the types that get added as part of getAutomaticTypeDirectiveNames var typeRootsWatches = ts.createMap(); return { @@ -80964,7 +81310,7 @@ var ts; } // Invalidated if file has unresolved imports var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path); - return value && !!value.length; + return !!value && !!value.length; } function createHasInvalidatedResolution(forceAllFilesAsInvalidated) { if (allFilesHaveInvalidatedResolution || forceAllFilesAsInvalidated) { @@ -80974,7 +81320,7 @@ var ts; } var collected = filesWithInvalidatedResolutions; filesWithInvalidatedResolutions = undefined; - return function (path) { return (collected && collected.has(path)) || + return function (path) { return (!!collected && collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } function clearPerDirectoryResolutions() { @@ -81055,7 +81401,7 @@ var ts; } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); - resolvedModules.push(getResolutionWithResolvedFileName(resolution)); + resolvedModules.push(getResolutionWithResolvedFileName(resolution)); // TODO: GH#18217 } // Stop watching and remove the unused name resolutionsInFile.forEach(function (resolution, name) { @@ -81126,7 +81472,7 @@ var ts; } function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) { if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { - return { dir: rootDir, dirPath: rootPath }; + return { dir: rootDir, dirPath: rootPath }; // TODO: GH#18217 } return getDirectoryToWatchFromFailedLookupLocationDirectory(ts.getDirectoryPath(ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())), ts.getDirectoryPath(failedLookupLocationPath)); } @@ -81141,19 +81487,20 @@ var ts; return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath }, ts.getDirectoryPath(dirPath)); } // Use some ancestor of the root directory - var subDirectory; + var subDirectoryPath, subDirectory; if (rootPath !== undefined) { while (!isInDirectoryPath(dirPath, rootPath)) { var parentPath = ts.getDirectoryPath(dirPath); if (parentPath === dirPath) { break; } - subDirectory = dirPath.slice(parentPath.length + ts.directorySeparator.length); + subDirectoryPath = dirPath; + subDirectory = dir; dirPath = parentPath; dir = ts.getDirectoryPath(dir); } } - return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath, subDirectory: subDirectory }, dirPath); + return filterFSRootDirectoriesToWatch({ dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath }, dirPath); } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -81173,7 +81520,7 @@ var ts; for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) { var failedLookupLocation = failedLookupLocations_1[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, ignore = _a.ignore, subDirectory = _a.subDirectory; + var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, ignore = _a.ignore; if (!ignore) { // If the failed lookup location path is not one of the supported extensions, // store it in the custom path @@ -81185,27 +81532,21 @@ var ts; setAtRoot = true; } else { - setDirectoryWatcher(dir, dirPath, subDirectory); + setDirectoryWatcher(dir, dirPath); } } } if (setAtRoot) { - setDirectoryWatcher(rootDir, rootPath); + setDirectoryWatcher(rootDir, rootPath); // TODO: GH#18217 } } - function setDirectoryWatcher(dir, dirPath, subDirectory) { + function setDirectoryWatcher(dir, dirPath) { var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); if (dirWatcher) { dirWatcher.refCount++; } else { - dirWatcher = { watcher: createDirectoryWatcher(dir, dirPath), refCount: 1 }; - directoryWatchesOfFailedLookups.set(dirPath, dirWatcher); - } - if (subDirectory) { - var subDirectoryMap = dirWatcher.subDirectoryMap || (dirWatcher.subDirectoryMap = ts.createMap()); - var existing = subDirectoryMap.get(subDirectory) || 0; - subDirectoryMap.set(subDirectory, existing + 1); + directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath), refCount: 1 }); } } function stopWatchFailedLookupLocationOfResolution(resolution) { @@ -81221,7 +81562,7 @@ var ts; for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) { var failedLookupLocation = failedLookupLocations_2[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore, subDirectory = _a.subDirectory; + var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore; if (!ignore) { var refCount = customFailedLookupPaths.get(failedLookupLocationPath); if (refCount) { @@ -81237,7 +81578,7 @@ var ts; removeAtRoot = true; } else { - removeDirectoryWatcher(dirPath, subDirectory); + removeDirectoryWatcher(dirPath); } } } @@ -81245,29 +81586,11 @@ var ts; removeDirectoryWatcher(rootPath); } } - function removeDirectoryWatcher(dirPath, subDirectory) { + function removeDirectoryWatcher(dirPath) { var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); - if (subDirectory) { - var existing = dirWatcher.subDirectoryMap.get(subDirectory); - if (existing === 1) { - dirWatcher.subDirectoryMap.delete(subDirectory); - } - else { - dirWatcher.subDirectoryMap.set(subDirectory, existing - 1); - } - } // Do not close the watcher yet since it might be needed by other failed lookup locations. dirWatcher.refCount--; } - function inWatchedSubdirectory(dirPath, fileOrDirectoryPath) { - var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); - if (!dirWatcher || !dirWatcher.subDirectoryMap) - return false; - return ts.forEachKey(dirWatcher.subDirectoryMap, function (subDirectory) { - var fullSubDirectory = dirPath + "/" + subDirectory; - return fullSubDirectory === fileOrDirectoryPath || isInDirectoryPath(fullSubDirectory, fileOrDirectoryPath); - }); - } function createDirectoryWatcher(directory, dirPath) { return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) { var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory); @@ -81275,13 +81598,8 @@ var ts; // Since the file existence changed, update the sourceFiles cache cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } - // If the files are added to project root or node_modules directory, always run through the invalidation process - // Otherwise run through invalidation only if adding to the immediate directory - if (!allFilesHaveInvalidatedResolution && - (dirPath === rootPath || isNodeModulesDirectory(dirPath) || ts.getDirectoryPath(fileOrDirectoryPath) === dirPath || inWatchedSubdirectory(dirPath, fileOrDirectoryPath))) { - if (invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) { - resolutionHost.onInvalidatedResolution(); - } + if (!allFilesHaveInvalidatedResolution && invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) { + resolutionHost.onInvalidatedResolution(); } }, 1 /* Recursive */); } @@ -81339,7 +81657,7 @@ var ts; // Resolution is invalidated if the resulting file name is same as the deleted file path function (resolution, getResolutionWithResolvedFileName) { var result = getResolutionWithResolvedFileName(resolution); - return result && resolutionHost.toPath(result.resolvedFileName) === filePath; + return !!result && resolutionHost.toPath(result.resolvedFileName) === filePath; // TODO: GH#18217 }); } function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) { @@ -81395,7 +81713,7 @@ var ts; return rootPath; } var _a = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath), dirPath = _a.dirPath, ignore = _a.ignore; - return !ignore && directoryWatchesOfFailedLookups.has(dirPath) && dirPath; + return !ignore && directoryWatchesOfFailedLookups.has(dirPath) ? dirPath : undefined; } function createTypeRootsWatch(typeRootPath, typeRoot) { // Create new watch and recursive info @@ -81462,7 +81780,7 @@ var ts; getCurrentDirectory: function () { return ts.sys.getCurrentDirectory(); }, getNewLine: function () { return ts.sys.newLine; }, getCanonicalFileName: ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames) - } : undefined; + } : undefined; // TODO: GH#18217 /** * Create a function that reports error by writing to the system and handles the formating of the diagnostic */ @@ -81479,7 +81797,7 @@ var ts; return function (diagnostic) { diagnostics[0] = diagnostic; system.write(ts.formatDiagnosticsWithColorAndContext(diagnostics, host) + host.getNewLine()); - diagnostics[0] = undefined; + diagnostics[0] = undefined; // TODO: GH#18217 }; } ts.createDiagnosticReporter = createDiagnosticReporter; @@ -81539,7 +81857,7 @@ var ts; var host = system; host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(ts.sys, reportDiagnostic, diagnostic); }; var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host); - host.onUnRecoverableConfigFileDiagnostic = undefined; + host.onUnRecoverableConfigFileDiagnostic = undefined; // TODO: GH#18217 return result; } ts.parseConfigFileWithSystem = parseConfigFileWithSystem; @@ -81669,9 +81987,9 @@ var ts; * Creates the watch compiler host from system for config file in watch mode */ function createWatchCompilerHostOfConfigFile(configFileName, optionsToExtend, system, createProgram, reportDiagnostic, reportWatchStatus) { - reportDiagnostic = reportDiagnostic || createDiagnosticReporter(system); - var host = createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus); - host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; + var diagnosticReporter = reportDiagnostic || createDiagnosticReporter(system); + var host = createWatchCompilerHost(system, createProgram, diagnosticReporter, reportWatchStatus); + host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, diagnosticReporter, diagnostic); }; host.configFileName = configFileName; host.optionsToExtend = optionsToExtend; return host; @@ -81691,7 +82009,7 @@ var ts; (function (ts) { function createWatchCompilerHost(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus) { if (ts.isArray(rootFilesOrConfigFileName)) { - return ts.createWatchCompilerHostOfFilesAndCompilerOptions(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus); + return ts.createWatchCompilerHostOfFilesAndCompilerOptions(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus); // TODO: GH#18217 } else { return ts.createWatchCompilerHostOfConfigFile(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus); @@ -81718,7 +82036,7 @@ var ts; var configFileSpecs; var configFileParsingDiagnostics; var hasChangedConfigFileParsingErrors = false; - var cachedDirectoryStructureHost = configFileName && ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames); + var cachedDirectoryStructureHost = configFileName === undefined ? undefined : ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames); if (cachedDirectoryStructureHost && host.onCachedDirectoryStructureHostCreate) { host.onCachedDirectoryStructureHostCreate(cachedDirectoryStructureHost); } @@ -81748,7 +82066,7 @@ var ts; var trace = host.trace && (function (s) { host.trace(s + newLine); }); var watchLogLevel = trace ? compilerOptions.extendedDiagnostics ? ts.WatchLogLevel.Verbose : compilerOptions.diagnostis ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; - var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? trace : ts.noop; + var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? trace : ts.noop; // TODO: GH#18217 var _b = ts.getWatchFactory(watchLogLevel, writeLog), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); @@ -81770,7 +82088,7 @@ var ts; readFile: readFile, trace: trace, directoryExists: directoryStructureHost.directoryExists && (function (path) { return directoryStructureHost.directoryExists(path); }), - getDirectories: directoryStructureHost.getDirectories && (function (path) { return directoryStructureHost.getDirectories(path); }), + getDirectories: (directoryStructureHost.getDirectories && (function (path) { return directoryStructureHost.getDirectories(path); })), realpath: host.realpath && (function (s) { return host.realpath(s); }), getEnvironmentVariable: host.getEnvironmentVariable ? (function (name) { return host.getEnvironmentVariable(name); }) : (function () { return ""; }), onReleaseOldSourceFile: onReleaseOldSourceFile, @@ -82059,12 +82377,12 @@ var ts; watchConfigFileWildCardDirectories(); } function parseConfigFile() { - setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost)); + setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost)); // TODO: GH#18217 } function setConfigFileParsingResult(configFileParseResult) { rootFileNames = configFileParseResult.fileNames; compilerOptions = configFileParseResult.options; - configFileSpecs = configFileParseResult.configFileSpecs; + configFileSpecs = configFileParseResult.configFileSpecs; // TODO: GH#18217 configFileParsingDiagnostics = ts.getConfigFileParsingDiagnostics(configFileParseResult); hasChangedConfigFileParsingErrors = true; } @@ -82303,6 +82621,7 @@ var ts; "es2018.promise": "lib.es2018.promise.d.ts", "es2018.regexp": "lib.es2018.regexp.d.ts", "esnext.array": "lib.esnext.array.d.ts", + "esnext.symbol": "lib.esnext.symbol.d.ts", "esnext.asynciterable": "lib.esnext.asynciterable.d.ts", }), }, @@ -82948,7 +83267,7 @@ var ts; case "string": return ts.map(values, function (v) { return v || ""; }); default: - return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + return ts.mapDefined(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }); } } ts.parseListTypeOption = parseListTypeOption; @@ -83061,6 +83380,7 @@ var ts; } } ts.parseCommandLine = parseCommandLine; + /** @internal */ function getOptionFromName(optionName, allowShort) { if (allowShort === void 0) { allowShort = false; } optionName = optionName.toLowerCase(); @@ -83074,6 +83394,7 @@ var ts; } return optionNameMap.get(optionName); } + ts.getOptionFromName = getOptionFromName; /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ @@ -83233,7 +83554,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 269 /* PropertyAssignment */) { + if (element.kind !== 270 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -83310,13 +83631,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: if (valueExpression.operator !== 38 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -83333,7 +83654,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -83371,6 +83692,7 @@ var ts; var expectedType = ts.isString(option.type) ? option.type : "string"; return typeof value === expectedType; } + return false; } /** * Generate tsconfig configuration when running command line "--init" @@ -83423,7 +83745,7 @@ var ts; } else { if (optionDefinition.type === "list") { - result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); + result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); // TODO: GH#18217 } else { // There is a typeMap associated with this command-line option so use it to map value back to its name @@ -83850,13 +84172,10 @@ var ts; } function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { - return undefined; + return false; } var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption.compileOnSave, basePath, errors); - if (typeof result === "boolean" && result) { - return result; - } - return false; + return typeof result === "boolean" && result; } function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var errors = []; @@ -83885,7 +84204,7 @@ var ts; return options; } function getDefaultTypeAcquisition(configFileName) { - return { enable: configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; + return { enable: !!configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; } function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) { var options = getDefaultTypeAcquisition(configFileName); @@ -84282,7 +84601,7 @@ var ts; if (optionEnumValue === value) { return optionStringValue; } - }); + }); // TODO: GH#18217 } } })(ts || (ts = {})); @@ -84550,36 +84869,36 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 148 /* Parameter */: - case 231 /* VariableDeclaration */: - case 181 /* BindingElement */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 268 /* CatchClause */: - case 261 /* JsxAttribute */: + case 149 /* Parameter */: + case 232 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 269 /* CatchClause */: + case 262 /* JsxAttribute */: return 1 /* Value */; - case 147 /* TypeParameter */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 165 /* TypeLiteral */: + case 148 /* TypeParameter */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 166 /* TypeLiteral */: return 2 /* Type */; - case 296 /* JSDocTypedefTag */: + case 297 /* 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 272 /* EnumMember */: - case 234 /* ClassDeclaration */: + case 273 /* EnumMember */: + case 235 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -84589,26 +84908,26 @@ var ts; else { return 4 /* Namespace */; } - case 237 /* EnumDeclaration */: - case 246 /* NamedImports */: - case 247 /* ImportSpecifier */: - case 242 /* ImportEqualsDeclaration */: - case 243 /* ImportDeclaration */: - case 248 /* ExportAssignment */: - case 249 /* ExportDeclaration */: + case 238 /* EnumDeclaration */: + case 247 /* NamedImports */: + case 248 /* ImportSpecifier */: + case 243 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: + case 249 /* ExportAssignment */: + case 250 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 273 /* SourceFile */: + case 274 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 248 /* ExportAssignment */) { + else if (node.parent.kind === 249 /* ExportAssignment */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -84640,11 +84959,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 145 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 242 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 146 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 243 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 145 /* QualifiedName */) { + while (node.parent.kind === 146 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -84656,27 +84975,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 145 /* QualifiedName */) { - while (root.parent && root.parent.kind === 145 /* QualifiedName */) { + if (root.parent.kind === 146 /* QualifiedName */) { + while (root.parent && root.parent.kind === 146 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 161 /* TypeReference */ && !isLastClause; + return root.parent.kind === 162 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 184 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 184 /* PropertyAccessExpression */) { + if (root.parent.kind === 185 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 185 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 206 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 267 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 207 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 268 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 234 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || - (decl.kind === 235 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); + return (decl.kind === 235 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || + (decl.kind === 236 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); } return false; } @@ -84687,30 +85006,30 @@ var ts; switch (node.kind) { case 99 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 173 /* ThisType */: + case 174 /* ThisType */: return true; } switch (node.parent.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return true; - case 178 /* ImportType */: + case 179 /* ImportType */: return !node.parent.isTypeOf; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 186 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 187 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 187 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 188 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { var target = climbPastPropertyAccess(node); - return target && target.parent && target.parent.kind === kind && target.parent.expression === target; + return !!target && !!target.parent && target.parent.kind === kind && target.parent.expression === target; } function climbPastPropertyAccess(node) { return isRightSideOfPropertyAccess(node) ? node.parent : node; @@ -84718,7 +85037,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 227 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 228 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -84739,15 +85058,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 145 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 238 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 239 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -84757,22 +85076,24 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 269 /* PropertyAssignment */: - case 272 /* EnumMember */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 238 /* ModuleDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 270 /* PropertyAssignment */: + case 273 /* EnumMember */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 239 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return true; - case 177 /* LiteralType */: - return node.parent.parent.kind === 175 /* IndexedAccessType */; + case 178 /* LiteralType */: + return node.parent.parent.kind === 176 /* IndexedAccessType */; + default: + return false; } } ts.isLiteralNameOfPropertyDeclarationOrIndexAccess = isLiteralNameOfPropertyDeclarationOrIndexAccess; @@ -84794,17 +85115,17 @@ var ts; return undefined; } switch (node.kind) { - case 273 /* SourceFile */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 238 /* ModuleDeclaration */: + case 274 /* SourceFile */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 239 /* ModuleDeclaration */: return node; } } @@ -84812,49 +85133,49 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: return "class" /* classElement */; - case 235 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 236 /* TypeAliasDeclaration */: - case 291 /* JSDocCallbackTag */: - case 296 /* JSDocTypedefTag */: + case 236 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 237 /* TypeAliasDeclaration */: + case 292 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 237 /* EnumDeclaration */: return "enum" /* enumElement */; - case 231 /* VariableDeclaration */: + case 238 /* EnumDeclaration */: return "enum" /* enumElement */; + case 232 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 192 /* ArrowFunction */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: return "function" /* functionElement */; - case 155 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 156 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 156 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 157 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return "property" /* memberVariableElement */; - case 159 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 158 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 157 /* CallSignature */: return "call" /* callSignatureElement */; - case 154 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 147 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 272 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 148 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 242 /* ImportEqualsDeclaration */: - case 247 /* ImportSpecifier */: - case 244 /* ImportClause */: - case 251 /* ExportSpecifier */: - case 245 /* NamespaceImport */: + case 160 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 159 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 158 /* CallSignature */: return "call" /* callSignatureElement */; + case 155 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 148 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 273 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 149 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 243 /* ImportEqualsDeclaration */: + case 248 /* ImportSpecifier */: + case 245 /* ImportClause */: + case 252 /* ExportSpecifier */: + case 246 /* NamespaceImport */: return "alias" /* alias */; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var kind = ts.getSpecialPropertyAssignmentKind(node); var right = node.right; switch (kind) { @@ -84897,7 +85218,7 @@ var ts; return true; case 71 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 148 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 149 /* Parameter */; default: return false; } @@ -84919,6 +85240,10 @@ var ts; return r.pos <= pos && pos <= r.end; } ts.rangeContainsPosition = rangeContainsPosition; + function rangeContainsPositionExclusive(r, pos) { + return r.pos < pos && pos < r.end; + } + ts.rangeContainsPositionExclusive = rangeContainsPositionExclusive; function startEndContainsRange(start, end, range) { return start <= range.pos && end >= range.end; } @@ -84946,46 +85271,46 @@ var ts; } ts.positionBelongsToNode = positionBelongsToNode; function isCompletedNode(n, sourceFile) { - if (ts.nodeIsMissing(n)) { + if (n === undefined || ts.nodeIsMissing(n)) { return false; } switch (n.kind) { - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 183 /* ObjectLiteralExpression */: - case 179 /* ObjectBindingPattern */: - case 165 /* TypeLiteral */: - case 212 /* Block */: - case 239 /* ModuleBlock */: - case 240 /* CaseBlock */: - case 246 /* NamedImports */: - case 250 /* NamedExports */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 184 /* ObjectLiteralExpression */: + case 180 /* ObjectBindingPattern */: + case 166 /* TypeLiteral */: + case 213 /* Block */: + case 240 /* ModuleBlock */: + case 241 /* CaseBlock */: + case 247 /* NamedImports */: + case 251 /* NamedExports */: return nodeEndsWith(n, 18 /* CloseBraceToken */, sourceFile); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 187 /* NewExpression */: + case 188 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 186 /* CallExpression */: - case 190 /* ParenthesizedExpression */: - case 172 /* ParenthesizedType */: + case 187 /* CallExpression */: + case 191 /* ParenthesizedExpression */: + case 173 /* ParenthesizedType */: return nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile); - case 162 /* FunctionType */: - case 163 /* ConstructorType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 158 /* ConstructSignature */: - case 157 /* CallSignature */: - case 192 /* ArrowFunction */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 159 /* ConstructSignature */: + case 158 /* CallSignature */: + case 193 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -84995,65 +85320,65 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 20 /* CloseParenToken */, sourceFile); - case 238 /* ModuleDeclaration */: - return n.body && isCompletedNode(n.body, sourceFile); - case 216 /* IfStatement */: + case 239 /* ModuleDeclaration */: + return !!n.body && isCompletedNode(n.body, sourceFile); + case 217 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 25 /* SemicolonToken */, sourceFile); - case 182 /* ArrayLiteralExpression */: - case 180 /* ArrayBindingPattern */: - case 185 /* ElementAccessExpression */: - case 146 /* ComputedPropertyName */: - case 167 /* TupleType */: + case 183 /* ArrayLiteralExpression */: + case 181 /* ArrayBindingPattern */: + case 186 /* ElementAccessExpression */: + case 147 /* ComputedPropertyName */: + case 168 /* TupleType */: return nodeEndsWith(n, 22 /* CloseBracketToken */, sourceFile); - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 218 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 219 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 217 /* DoStatement */: + case 218 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; return hasChildOfKind(n, 106 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 194 /* TypeOfExpression */: - case 193 /* DeleteExpression */: - case 195 /* VoidExpression */: - case 202 /* YieldExpression */: - case 203 /* SpreadElement */: + case 195 /* TypeOfExpression */: + case 194 /* DeleteExpression */: + case 196 /* VoidExpression */: + case 203 /* YieldExpression */: + case 204 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 249 /* ExportDeclaration */: - case 243 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -85066,11 +85391,11 @@ var ts; function nodeEndsWith(n, expectedLastToken, sourceFile) { var children = n.getChildren(sourceFile); if (children.length) { - var last_2 = ts.lastOrUndefined(children); - if (last_2.kind === expectedLastToken) { + var lastChild = ts.last(children); + if (lastChild.kind === expectedLastToken) { return true; } - else if (last_2.kind === 25 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 25 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -85130,6 +85455,7 @@ var ts; ts.getTouchingToken = getTouchingToken; /** Returns a token if position is in [start-of-leading-trivia, end) */ function getTokenAtPosition(sourceFile, position, includeJsDocComment, includeEndPosition) { + if (includeEndPosition === void 0) { includeEndPosition = false; } return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includePrecedingTokenAtEndPosition*/ undefined, includeEndPosition, includeJsDocComment); } ts.getTokenAtPosition = getTokenAtPosition; @@ -85244,7 +85570,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 273 /* SourceFile */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 274 /* SourceFile */ || 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. @@ -85284,7 +85610,7 @@ var ts; function isInString(sourceFile, position, previousToken) { if (previousToken === void 0) { previousToken = findPrecedingToken(position, sourceFile); } if (previousToken && ts.isStringTextContainingNode(previousToken)) { - var start = previousToken.getStart(); + var start = previousToken.getStart(sourceFile); var end = previousToken.getEnd(); // To be "in" one of these literals, the position has to be: // 1. entirely within the token text. @@ -85316,17 +85642,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 264 /* JsxExpression */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 265 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 264 /* JsxExpression */) { + if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 265 /* JsxExpression */) { return true; } //
|
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 257 /* JsxClosingElement */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 258 /* JsxClosingElement */) { return true; } return false; @@ -85344,10 +85670,11 @@ var ts; var tokenKind = token.kind; var remainingMatchingTokens = 0; while (true) { - token = findPrecedingToken(token.getFullStart(), sourceFile); - if (!token) { + var preceding = findPrecedingToken(token.getFullStart(), sourceFile); + if (!preceding) { return undefined; } + token = preceding; if (token.kind === matchingTokenKind) { if (remainingMatchingTokens === 0) { return token; @@ -85360,21 +85687,24 @@ var ts; } } ts.findPrecedingMatchingToken = findPrecedingMatchingToken; - function isPossiblyTypeArgumentPosition(token, sourceFile) { + function isPossiblyTypeArgumentPosition(tokenIn, sourceFile) { + var token = tokenIn; // This function determines if the node could be type argument position // Since during editing, when type argument list is not complete, // the tree could be of any shape depending on the tokens parsed before current node, // scanning of the previous identifier followed by "<" before current node would give us better result // Note that we also balance out the already provided type arguments, arrays, object literals while doing so var remainingLessThanTokens = 0; + var nTypeArguments = 0; while (token) { switch (token.kind) { case 27 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); - var tokenIsIdentifier = token && ts.isIdentifier(token); - if (!remainingLessThanTokens || !tokenIsIdentifier) { - return tokenIsIdentifier; + if (!token || !ts.isIdentifier(token)) + return undefined; + if (!remainingLessThanTokens) { + return { called: token, nTypeArguments: nTypeArguments }; } remainingLessThanTokens--; break; @@ -85392,24 +85722,26 @@ var ts; // Skip until the matching open brace token token = findPrecedingMatchingToken(token, 17 /* OpenBraceToken */, sourceFile); if (!token) - return false; + return undefined; break; case 20 /* CloseParenToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token token = findPrecedingMatchingToken(token, 19 /* OpenParenToken */, sourceFile); if (!token) - return false; + return undefined; break; case 22 /* CloseBracketToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token token = findPrecedingMatchingToken(token, 21 /* OpenBracketToken */, sourceFile); if (!token) - return false; + return undefined; break; // Valid tokens in a type name. Skip. case 26 /* CommaToken */: + nTypeArguments++; + break; case 36 /* EqualsGreaterThanToken */: case 71 /* Identifier */: case 9 /* StringLiteral */: @@ -85429,11 +85761,11 @@ var ts; break; } // Invalid token in type - return false; + return undefined; } token = findPrecedingToken(token.getFullStart(), sourceFile); } - return false; + return undefined; } ts.isPossiblyTypeArgumentPosition = isPossiblyTypeArgumentPosition; /** @@ -85483,10 +85815,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 161 /* TypeReference */ || node.kind === 186 /* CallExpression */) { + if (node.kind === 162 /* TypeReference */ || node.kind === 187 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 234 /* ClassDeclaration */ || node.kind === 235 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 235 /* ClassDeclaration */ || node.kind === 236 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -85509,9 +85841,9 @@ var ts; return 17 /* FirstPunctuation */ <= kind && kind <= 70 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; - function isInsideTemplateLiteral(node, position) { + function isInsideTemplateLiteral(node, position, sourceFile) { return ts.isTemplateLiteralKind(node.kind) - && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); + && (node.getStart(sourceFile) < position && position < node.end) || (!!node.isUnterminated && position === node.end); } ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { @@ -85531,18 +85863,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 182 /* ArrayLiteralExpression */ || - node.kind === 183 /* ObjectLiteralExpression */) { + if (node.kind === 183 /* ArrayLiteralExpression */ || + node.kind === 184 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 199 /* BinaryExpression */ && + if (node.parent.kind === 200 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 58 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 221 /* ForOfStatement */ && + if (node.parent.kind === 222 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -85550,7 +85882,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 269 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 270 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -85604,6 +85936,7 @@ var ts; 105 /* VoidKeyword */, 140 /* UndefinedKeyword */, 141 /* UniqueKeyword */, + 142 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -85636,11 +85969,11 @@ var ts; } ts.repeatString = repeatString; function skipConstraint(type) { - return type.isTypeParameter() ? type.getConstraint() : type; + return type.isTypeParameter() ? type.getConstraint() : type; // TODO: GH#18217 } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 146 /* ComputedPropertyName */ + return name.kind === 147 /* ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteral(name.expression) ? name.expression.text : undefined : ts.getTextOfIdentifierOrLiteral(name); @@ -85662,16 +85995,16 @@ var ts; return ts.createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host)); } ts.hostGetCanonicalFileName = hostGetCanonicalFileName; - function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier) { - return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier) : undefined; + function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, preferences) { + return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, preferences) : undefined; } ts.makeImportIfNecessary = makeImportIfNecessary; - function makeImport(defaultImport, namedImports, moduleSpecifier) { + function makeImport(defaultImport, namedImports, moduleSpecifier, preferences) { return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, defaultImport || namedImports ? ts.createImportClause(defaultImport, namedImports && namedImports.length ? ts.createNamedImports(namedImports) : undefined) - : undefined, typeof moduleSpecifier === "string" ? ts.createLiteral(moduleSpecifier) : moduleSpecifier); + : undefined, typeof moduleSpecifier === "string" ? ts.createLiteral(moduleSpecifier, preferences.quotePreference === "single") : moduleSpecifier); } ts.makeImport = makeImport; function symbolNameNoDefault(symbol) { @@ -85700,6 +86033,37 @@ var ts; return propSymbol; } ts.getPropertySymbolFromBindingElement = getPropertySymbolFromBindingElement; + /** + * Find symbol of the given property-name and add the symbol to the given result array + * @param symbol a symbol to start searching for the given propertyName + * @param propertyName a name of property to search for + * @param result an array of symbol of found property symbols + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. + * The value of previousIterationSymbol is undefined when the function is first called. + */ + function getPropertySymbolsFromBaseTypes(symbol, propertyName, checker, cb) { + var seen = ts.createMap(); + return recur(symbol); + function recur(symbol) { + // Use `addToSeen` to ensure we don't infinitely recurse in this situation: + // interface C extends C { + // /*findRef*/propName: string; + // } + if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) + return; + return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { + var type = checker.getTypeAtLocation(typeReference); + var propertySymbol = type && type.symbol && checker.getPropertyOfType(type, propertyName); + // Visit the typeReference as well to see if it directly or indirectly uses that property + return type && propertySymbol && (ts.firstDefined(checker.getRootSymbols(propertySymbol), cb) || recur(type.symbol)); + }); }); + } + } + ts.getPropertySymbolsFromBaseTypes = getPropertySymbolsFromBaseTypes; + function isMemberSymbolInBaseType(memberSymbol, checker) { + return getPropertySymbolsFromBaseTypes(memberSymbol.parent, memberSymbol.name, checker, function (_) { return true; }) || false; + } + ts.isMemberSymbolInBaseType = isMemberSymbolInBaseType; var NodeSet = /** @class */ (function () { function NodeSet() { this.map = ts.createMap(); @@ -85719,12 +86083,27 @@ var ts; return NodeSet; }()); ts.NodeSet = NodeSet; + function getParentNodeInSpan(node, file, span) { + if (!node) + return undefined; + while (node.parent) { + if (ts.isSourceFile(node.parent) || !spanContainsNode(span, node.parent, file)) { + return node; + } + node = node.parent; + } + } + ts.getParentNodeInSpan = getParentNodeInSpan; + function spanContainsNode(span, node, file) { + return ts.textSpanContainsPosition(span, node.getStart(file)) && + node.getEnd() <= ts.textSpanEnd(span); + } })(ts || (ts = {})); // Display-part writer helpers /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 148 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 149 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -85897,18 +86276,21 @@ var ts; } ts.mapToDisplayParts = mapToDisplayParts; function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { + if (flags === void 0) { flags = 0 /* None */; } return mapToDisplayParts(function (writer) { - typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, writer); + typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.typeToDisplayParts = typeToDisplayParts; function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { + if (flags === void 0) { flags = 0 /* None */; } return mapToDisplayParts(function (writer) { typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + if (flags === void 0) { flags = 0 /* None */; } flags |= 16384 /* UseAliasDefinedOutsideCurrentScope */ | 1024 /* MultilineObjectLiterals */ | 32 /* WriteTypeArgumentsOfSignature */ | 8192 /* OmitParameterModifiers */; return mapToDisplayParts(function (writer) { typechecker.writeSignature(signature, enclosingDeclaration, flags, /*signatureKind*/ undefined, writer); @@ -85916,8 +86298,8 @@ var ts; } ts.signatureToDisplayParts = signatureToDisplayParts; function isImportOrExportSpecifierName(location) { - return location.parent && - (location.parent.kind === 247 /* ImportSpecifier */ || location.parent.kind === 251 /* ExportSpecifier */) && + return !!location.parent && + (location.parent.kind === 248 /* ImportSpecifier */ || location.parent.kind === 252 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -85944,7 +86326,7 @@ var ts; scriptKinds[_i - 2] = arguments[_i]; } var scriptKind = getScriptKind(fileName, host); - return ts.forEach(scriptKinds, function (k) { return k === scriptKind; }); + return ts.some(scriptKinds, function (k) { return k === scriptKind; }); } ts.scriptKindIs = scriptKindIs; function getScriptKind(fileName, host) { @@ -86037,9 +86419,9 @@ var ts; return node.forEachChild(function (child) { return child; }); } /* @internal */ - function getUniqueName(baseName, fileText) { + function getUniqueName(baseName, sourceFile) { var nameText = baseName; - for (var i = 1; ts.stringContains(fileText, nameText); i++) { + for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { nameText = baseName + "_" + i; } return nameText; @@ -86060,7 +86442,7 @@ var ts; for (var _b = 0, textChanges_1 = textChanges_2; _b < textChanges_1.length; _b++) { var change = textChanges_1[_b]; var span = change.span, newText = change.newText; - var index = newText.indexOf(name); + var index = indexInTextChange(newText, name); if (index !== -1) { lastPos = span.start + delta + index; // If the reference comes first, return immediately. @@ -86077,6 +86459,17 @@ var ts; return lastPos; } ts.getRenameLocation = getRenameLocation; + function indexInTextChange(change, name) { + if (ts.startsWith(change, name)) + return 0; + // Add a " " to avoid references inside words + var idx = change.indexOf(" " + name); + if (idx === -1) + idx = change.indexOf("." + name); + if (idx === -1) + idx = change.indexOf('"' + name); + return idx === -1 ? -1 : idx + 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -86356,6 +86749,8 @@ var ts; case 9 /* text */: case 17 /* parameterName */: return ts.TokenClass.Identifier; + default: + return undefined; // TODO: GH#18217 Debug.assertNever(type); } } /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ @@ -86506,10 +86901,10 @@ 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 238 /* ModuleDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 233 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 234 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -86603,6 +86998,7 @@ var ts; case 22 /* jsxAttribute */: return "jsx attribute" /* jsxAttribute */; case 23 /* jsxText */: return "jsx text" /* jsxText */; case 24 /* jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* jsxAttributeStringLiteralValue */; + default: return undefined; // TODO: GH#18217 throw Debug.assertNever(type); } } function convertClassificationsToSpans(classifications) { @@ -86720,18 +87116,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 292 /* JSDocParameterTag */: + case 293 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 295 /* JSDocTemplateTag */: + case 296 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 294 /* JSDocTypeTag */: + case 295 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 293 /* JSDocReturnTag */: + case 294 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -86818,22 +87214,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 256 /* JsxOpeningElement */: + case 257 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -86859,19 +87255,20 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { + var parent = token.parent; if (tokenKind === 58 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 231 /* VariableDeclaration */ || - token.parent.kind === 151 /* PropertyDeclaration */ || - token.parent.kind === 148 /* Parameter */ || - token.parent.kind === 261 /* JsxAttribute */) { + if (parent.kind === 232 /* VariableDeclaration */ || + parent.kind === 152 /* PropertyDeclaration */ || + parent.kind === 149 /* Parameter */ || + parent.kind === 262 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 199 /* BinaryExpression */ || - token.parent.kind === 197 /* PrefixUnaryExpression */ || - token.parent.kind === 198 /* PostfixUnaryExpression */ || - token.parent.kind === 200 /* ConditionalExpression */) { + if (parent.kind === 200 /* BinaryExpression */ || + parent.kind === 198 /* PrefixUnaryExpression */ || + parent.kind === 199 /* PostfixUnaryExpression */ || + parent.kind === 201 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -86881,7 +87278,8 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 261 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + // TODO: GH#18217 + return token.parent.kind === 262 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 12 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -86897,32 +87295,32 @@ var ts; else if (tokenKind === 71 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 148 /* Parameter */: + case 149 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -87006,7 +87404,7 @@ var ts; // Determine the path to the directory containing the script relative to the root directory it is contained within var relativeDirectory = ts.firstDefined(rootDirs, function (rootDirectory) { return ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase) ? scriptPath.substr(rootDirectory.length) : undefined; - }); + }); // TODO: GH#18217 // Now find a path for each potential directory that is to be merged with the one containing the script return ts.deduplicate(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } @@ -87210,8 +87608,8 @@ var ts; // after the last '/' that appears in the fragment because that's where the replacement span // starts if (fragmentDirectory !== undefined) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(fragmentDirectory); - return nonRelativeModuleNames.map(function (nonRelativeModuleName) { return ts.removePrefix(nonRelativeModuleName, moduleNameWithSeperator_1); }); + var moduleNameWithSeparator_1 = ts.ensureTrailingDirectorySeparator(fragmentDirectory); + return nonRelativeModuleNames.map(function (nonRelativeModuleName) { return ts.removePrefix(nonRelativeModuleName, moduleNameWithSeparator_1); }); } return nonRelativeModuleNames; } @@ -87321,7 +87719,7 @@ var ts; } return result; } - // Replace everything after the last directory seperator that appears + // Replace everything after the last directory separator that appears function getDirectoryFragmentTextSpan(text, textStart) { var index = Math.max(text.lastIndexOf(ts.directorySeparator), text.lastIndexOf("\\")); var offset = index !== -1 ? index + 1 : 0; @@ -87366,7 +87764,7 @@ var ts; return ts.directoryProbablyExists(path, host); } catch ( /*ignore*/_a) { /*ignore*/ } - return undefined; + return false; } function tryIOAndConsumeErrors(host, toApply) { var args = []; @@ -87414,7 +87812,7 @@ var ts; } var contextToken = ts.findPrecedingToken(position, sourceFile); if (triggerCharacter && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) - return undefined; + return undefined; // TODO: GH#18217 if (ts.isInString(sourceFile, position, contextToken)) { return !contextToken || !ts.isStringLiteralLike(contextToken) ? undefined @@ -87424,7 +87822,7 @@ var ts; && (contextToken.kind === 72 /* BreakKeyword */ || contextToken.kind === 77 /* ContinueKeyword */ || contextToken.kind === 71 /* Identifier */)) { return getLabelCompletionAtPosition(contextToken.parent); } - var completionData = getCompletionData(program, log, sourceFile, position, preferences, /*detailsEntryId*/ undefined); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined); if (!completionData) { return undefined; } @@ -87494,9 +87892,9 @@ var ts; }] }; } var entries = []; - if (ts.isSourceFileJavaScript(sourceFile)) { + if (isUncheckedFile(sourceFile, compilerOptions)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap); - getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); + getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217 } else { if ((!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { @@ -87514,6 +87912,9 @@ var ts; } return { isGlobalCompletion: isInSnippetScope, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; } + function isUncheckedFile(sourceFile, compilerOptions) { + return ts.isSourceFileJavaScript(sourceFile) && !ts.isCheckJsEnabledForFile(sourceFile, compilerOptions); + } function isMemberCompletionKind(kind) { switch (kind) { case 0 /* ObjectPropertyDeclaration */: @@ -87632,7 +88033,7 @@ var ts; continue; } // Latter case tests whether this is a global variable. - if (!origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }))) { + if (!origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }))) { // TODO: GH#18217 uniques.set(name, true); } entries.push(entry); @@ -87678,11 +88079,11 @@ var ts; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { switch (node.parent.kind) { - case 177 /* LiteralType */: + case 178 /* LiteralType */: switch (node.parent.parent.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(node.parent), typeChecker), isNewIdentifier: false }; - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -87690,12 +88091,12 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(node.parent.parent.objectType)); - case 178 /* ImportType */: + case 179 /* ImportType */: return { kind: 0 /* Paths */, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; default: return undefined; } - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(node.parent.parent) && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -87712,7 +88113,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(node.parent.parent)); } return fromContextualType(); - case 185 /* ElementAccessExpression */: { + case 186 /* ElementAccessExpression */: { var _a = node.parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -87725,19 +88126,19 @@ var ts; } return undefined; } - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: if (!ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(node.parent)) { - var argumentInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: - case 253 /* ExternalModuleReference */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: + case 254 /* 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*/"); @@ -87763,7 +88164,7 @@ var ts; if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) return; var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); - isNewIdentifier = isNewIdentifier || !!(type.flags & 2 /* String */); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); return getStringLiteralTypes(type, checker, uniques); }); return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; @@ -87778,12 +88179,13 @@ var ts; type = ts.skipConstraint(type); return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, typeChecker, uniques); }) - : type.isStringLiteral() && !(type.flags & 256 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) + : type.isStringLiteral() && !(type.flags & 512 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { - var completionData = getCompletionData(program, log, sourceFile, position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); + var compilerOptions = program.getCompilerOptions(); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); if (!completionData) { return { type: "none" }; } @@ -87797,7 +88199,7 @@ var ts; // completion entry. return ts.firstDefined(symbols, function (symbol) { var origin = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; - var info = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, origin, completionKind); + var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target, origin, completionKind); return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source ? { type: "symbol", symbol: symbol, location: location, symbolToOriginInfoMap: symbolToOriginInfoMap, previousToken: previousToken, isJsxInitializer: isJsxInitializer } : undefined; @@ -87819,7 +88221,7 @@ var ts; var stringLiteralCompletions = !contextToken || !ts.isStringLiteralLike(contextToken) ? undefined : getStringLiteralCompletionEntries(sourceFile, contextToken, position, typeChecker, compilerOptions, host); - return stringLiteralCompletions && stringLiteralCompletionDetails(name, contextToken, stringLiteralCompletions, sourceFile, typeChecker, cancellationToken); + return stringLiteralCompletions && stringLiteralCompletionDetails(name, contextToken, stringLiteralCompletions, sourceFile, typeChecker, cancellationToken); // TODO: GH#18217 } // Compute all the completion symbols again. var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); @@ -87840,7 +88242,7 @@ var ts; 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, previousToken, formatContext, getCanonicalFileName, program.getSourceFiles(), preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; - return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); + return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "none": // Didn't find a symbol with this name. See if we can find a keyword instead. @@ -87879,7 +88281,7 @@ var ts; return { codeActions: undefined, sourceDisplay: undefined }; } var moduleSymbol = symbolOriginInfo.moduleSymbol; - var exportedSymbol = ts.skipAlias(symbol.exportSymbol || symbol, checker); + var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, checker, compilerOptions, allSourceFiles, formatContext, getCanonicalFileName, previousToken, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } @@ -87905,12 +88307,15 @@ var ts; CompletionKind[CompletionKind["None"] = 5] = "None"; })(CompletionKind || (CompletionKind = {})); function getRecommendedCompletion(currentToken, position, sourceFile, checker) { - var ty = getContextualType(currentToken, position, sourceFile, checker); - var symbol = ty && ty.symbol; - // Don't include make a recommended completion for an abstract class - return symbol && (symbol.flags & 384 /* Enum */ || symbol.flags & 32 /* Class */ && !ts.isAbstractConstructorSymbol(symbol)) - ? getFirstSymbolInChain(symbol, currentToken, checker) - : undefined; + var contextualType = getContextualType(currentToken, position, sourceFile, checker); + // For a union, return the first one with a recommended completion. + return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { + var symbol = type && type.symbol; + // Don't include make a recommended completion for an abstract class + return symbol && (symbol.flags & (8 /* EnumMember */ | 384 /* Enum */ | 32 /* Class */) && !ts.isAbstractConstructorSymbol(symbol)) + ? getFirstSymbolInChain(symbol, currentToken, checker) + : undefined; + }); } function getContextualType(currentToken, position, sourceFile, checker) { var parent = currentToken.parent; @@ -87919,11 +88324,11 @@ var ts; return getContextualTypeFromParent(currentToken, checker); case 58 /* EqualsToken */: switch (parent.kind) { - case 231 /* VariableDeclaration */: - return checker.getContextualType(parent.initializer); - case 199 /* BinaryExpression */: + case 232 /* VariableDeclaration */: + return checker.getContextualType(parent.initializer); // TODO: GH#18217 + case 200 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -87933,9 +88338,9 @@ var ts; case 73 /* CaseKeyword */: return getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 17 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 254 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 255 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: - var argInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(currentToken, position, sourceFile); + var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(currentToken, position, sourceFile); return argInfo // At `,`, treat this as the next argument after the comma. ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (currentToken.kind === 26 /* CommaToken */ ? 1 : 0)) @@ -87948,15 +88353,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 187 /* NewExpression */: + case 188 /* NewExpression */: return checker.getContextualType(parent); - case 199 /* BinaryExpression */: { + case 200 /* 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 265 /* CaseClause */: + case 266 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -87972,9 +88377,9 @@ 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 === 273 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 274 /* SourceFile */; }); } - function getCompletionData(program, log, sourceFile, position, preferences, detailsEntryId) { + function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); // TODO: GH#15853 @@ -88024,11 +88429,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 277 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 278 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 297 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 298 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -88046,7 +88451,7 @@ var ts; } } start = ts.timestamp(); - var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); + var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 log("getCompletionData: Get previous token 1: " + (ts.timestamp() - start)); // The decision to provide completion depends on the contextToken, which is determined through the previousToken. // Note: 'previousToken' (and thus 'contextToken') can be undefined if we are the beginning of the file @@ -88055,7 +88460,7 @@ var ts; // Skip this partial identifier and adjust the contextToken to the token that precedes it. if (contextToken && position <= contextToken.end && (ts.isIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) { var start_4 = ts.timestamp(); - contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_4)); } // Find the node where completion is requested on. @@ -88078,14 +88483,15 @@ var ts; if (contextToken.kind === 23 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; break; - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: node = parent.left; break; - case 178 /* ImportType */: + case 179 /* ImportType */: + case 210 /* MetaProperty */: node = parent; break; default: @@ -88098,7 +88504,7 @@ var ts; // // 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 === 184 /* PropertyAccessExpression */) { + if (parent && parent.kind === 185 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -88106,39 +88512,39 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 29 /* GreaterThanToken */: - if (currentToken.parent.kind === 254 /* JsxElement */ || currentToken.parent.kind === 256 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 255 /* JsxElement */ || currentToken.parent.kind === 257 /* JsxOpeningElement */) { location = currentToken; } break; case 41 /* SlashToken */: - if (currentToken.parent.kind === 255 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 256 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: if (contextToken.kind === 41 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (!(parent.left.flags & 32768 /* ThisNodeHasError */)) { // It has a left-hand side, so we're not in an opening JSX tag. break; } // falls through - case 255 /* JsxSelfClosingElement */: - case 254 /* JsxElement */: - case 256 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: + case 255 /* JsxElement */: + case 257 /* JsxOpeningElement */: if (contextToken.kind === 27 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: switch (previousToken.kind) { case 58 /* EqualsToken */: isJsxInitializer = true; @@ -88189,12 +88595,14 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 292 /* JSDocParameterTag */: - case 297 /* JSDocPropertyTag */: - case 293 /* JSDocReturnTag */: - case 294 /* JSDocTypeTag */: - case 296 /* JSDocTypedefTag */: + case 293 /* JSDocParameterTag */: + case 298 /* JSDocPropertyTag */: + case 294 /* JSDocReturnTag */: + case 295 /* JSDocTypeTag */: + case 297 /* JSDocTypedefTag */: return true; + default: + return false; } } function getTypeScriptMemberSymbols() { @@ -88225,20 +88633,25 @@ 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.some(function (d) { return d.kind !== 273 /* SourceFile */ && d.kind !== 238 /* ModuleDeclaration */ && d.kind !== 237 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 274 /* SourceFile */ && d.kind !== 239 /* ModuleDeclaration */ && d.kind !== 238 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; } } } + if (ts.isMetaProperty(node) && (node.keywordToken === 94 /* NewKeyword */ || node.keywordToken === 91 /* ImportKeyword */)) { + var completion = (node.keywordToken === 94 /* NewKeyword */) ? "target" : "meta"; + symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); + return; + } if (!isTypeLocation) { addTypeProperties(typeChecker.getTypeAtLocation(node)); } } function addTypeProperties(type) { isNewIdentifierLocation = hasIndexSignature(type); - if (ts.isSourceFileJavaScript(sourceFile)) { + 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 // each individual type has. This is because we're going to add all identifiers @@ -88249,7 +88662,7 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 178 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 179 /* ImportType */ ? node : node.parent, type, symbol)) { addPropertySymbol(symbol); } } @@ -88259,7 +88672,7 @@ var ts; // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. var symbolSymbol = ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - var leftName = name.kind === 146 /* ComputedPropertyName */ ? getLeftMostName(name.expression) : undefined; + var leftName = name.kind === 147 /* ComputedPropertyName */ ? getLeftMostName(name.expression) : undefined; return leftName && typeChecker.getSymbolAtLocation(leftName); }); if (symbolSymbol) { @@ -88348,7 +88761,7 @@ var ts; var symbolMeanings = 67901928 /* Type */ | 67216319 /* Value */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 273 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 274 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker, /*isForAccess*/ true); _i < _a.length; _i++) { @@ -88377,17 +88790,17 @@ var ts; if (ts.programContainsEs6Modules(program)) return true; // For JS, stay on the safe side. - if (ts.isSourceFileJavaScript(sourceFile)) + if (isUncheckedFile) return false; // If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK. return ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions()); } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 273 /* SourceFile */: - case 201 /* TemplateExpression */: - case 264 /* JsxExpression */: - case 212 /* Block */: + case 274 /* SourceFile */: + case 202 /* TemplateExpression */: + case 265 /* JsxExpression */: + case 213 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -88424,22 +88837,22 @@ var ts; function isContextTokenValueLocation(contextToken) { return contextToken && contextToken.kind === 103 /* TypeOfKeyword */ && - (contextToken.parent.kind === 164 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + (contextToken.parent.kind === 165 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 56 /* ColonToken */: - return parentKind === 151 /* PropertyDeclaration */ || - parentKind === 150 /* PropertySignature */ || - parentKind === 148 /* Parameter */ || - parentKind === 231 /* VariableDeclaration */ || + return parentKind === 152 /* PropertyDeclaration */ || + parentKind === 151 /* PropertySignature */ || + parentKind === 149 /* Parameter */ || + parentKind === 232 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 58 /* EqualsToken */: - return parentKind === 236 /* TypeAliasDeclaration */; + return parentKind === 237 /* TypeAliasDeclaration */; case 118 /* AsKeyword */: - return parentKind === 207 /* AsExpression */; + return parentKind === 208 /* AsExpression */; } } return false; @@ -88457,14 +88870,21 @@ var ts; // symbol can be referenced at locations where type is allowed return exportedSymbols.some(symbolCanBeReferencedAtTypeLocation); } + return false; } function getSymbolsFromOtherSourceFileExports(symbols, tokenText, target) { var tokenTextLowerCase = tokenText.toLowerCase(); + var seenResolvedModules = ts.createMap(); ts.codefix.forEachExternalModuleToImportFrom(typeChecker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { // Perf -- ignore other modules if this is a request for details if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { return; } + 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))) { + return; + } for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) { var symbol = _a[_i]; // Don't add a completion for a re-export, only for the original. @@ -88473,7 +88893,7 @@ var ts; // // If `symbol.parent !== ...`, this comes from an `export * from "foo"` re-export. Those don't create new symbols. // If `some(...)`, this comes from an `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). - if (typeChecker.getMergedSymbol(symbol.parent) !== typeChecker.resolveExternalModuleSymbol(moduleSymbol) + if (typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.parent.parent.moduleSpecifier; })) { continue; } @@ -88535,11 +88955,11 @@ var ts; return true; } if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 256 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 257 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 257 /* JsxClosingElement */ || contextToken.parent.kind === 255 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 254 /* JsxElement */; + if (contextToken.parent.kind === 258 /* JsxClosingElement */ || contextToken.parent.kind === 256 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 255 /* JsxElement */; } } return false; @@ -88549,40 +88969,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 186 /* CallExpression */ // func( a, | - || containingNodeKind === 154 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 187 /* NewExpression */ // new C(a, | - || containingNodeKind === 182 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 199 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 162 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 187 /* CallExpression */ // func( a, | + || containingNodeKind === 155 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 188 /* NewExpression */ // new C(a, | + || containingNodeKind === 183 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 200 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 163 /* FunctionType */; // var x: (s: string, list| case 19 /* OpenParenToken */: - return containingNodeKind === 186 /* CallExpression */ // func( | - || containingNodeKind === 154 /* Constructor */ // constructor( | - || containingNodeKind === 187 /* NewExpression */ // new C(a| - || containingNodeKind === 190 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 172 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 187 /* CallExpression */ // func( | + || containingNodeKind === 155 /* Constructor */ // constructor( | + || containingNodeKind === 188 /* NewExpression */ // new C(a| + || containingNodeKind === 191 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 173 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 21 /* OpenBracketToken */: - return containingNodeKind === 182 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 159 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 146 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 183 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 160 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 147 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 129 /* ModuleKeyword */: // module | case 130 /* NamespaceKeyword */: // namespace | return true; case 23 /* DotToken */: - return containingNodeKind === 238 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 239 /* ModuleDeclaration */; // module A.| case 17 /* OpenBraceToken */: - return containingNodeKind === 234 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 235 /* ClassDeclaration */; // class A{ | case 58 /* EqualsToken */: - return containingNodeKind === 231 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 199 /* BinaryExpression */; // x = a| + return containingNodeKind === 232 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 200 /* BinaryExpression */; // x = a| case 14 /* TemplateHead */: - return containingNodeKind === 201 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 202 /* TemplateExpression */; // `aa ${| case 15 /* TemplateMiddle */: - return containingNodeKind === 210 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 211 /* TemplateSpan */; // `aa ${10} dd ${| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: - return containingNodeKind === 151 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 152 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { @@ -88595,24 +89015,12 @@ var ts; return false; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 12 /* RegularExpressionLiteral */ - || ts.isTemplateLiteralKind(contextToken.kind)) { - var start_5 = contextToken.getStart(); - var end = contextToken.getEnd(); - // To be "in" one of these literals, the position has to be: - // 1. entirely within the token text. - // 2. at the end position of an unterminated token. - // 3. at the end of a regular expression (due to trailing flags like '/foo/g'). - if (start_5 < position && position < end) { - return true; - } - if (position === end) { - return !!contextToken.isUnterminated - || contextToken.kind === 12 /* RegularExpressionLiteral */; - } - } - return false; + // To be "in" one of these literals, the position has to be: + // 1. entirely within the token text. + // 2. at the end position of an unterminated token. + // 3. at the end of a regular expression (due to trailing flags like '/foo/g'). + return (ts.isRegularExpressionLiteral(contextToken) || ts.isStringTextContainingNode(contextToken)) && (ts.rangeContainsPositionExclusive(ts.createTextRangeFromSpan(ts.createTextSpanFromNode(contextToken)), position) || + position === contextToken.end && (!!contextToken.isUnterminated || ts.isRegularExpressionLiteral(contextToken))); } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. @@ -88628,7 +89036,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 183 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 184 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; @@ -88637,7 +89045,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 179 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 180 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -88648,12 +89056,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 === 221 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 148 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 222 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 149 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 153 /* MethodDeclaration */ || rootDeclaration.parent.kind === 156 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 154 /* MethodDeclaration */ || rootDeclaration.parent.kind === 157 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -88695,8 +89103,8 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 246 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); + var moduleSpecifier = (namedImportsOrExports.kind === 247 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; completionKind = 3 /* MemberLike */; @@ -88723,7 +89131,7 @@ var ts; if (!ts.isClassLike(decl)) return 1 /* Success */; var classElement = contextToken.parent; - var classElementModifierFlags = ts.isClassElement(classElement) && ts.getModifierFlags(classElement); + var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(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 === 71 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { @@ -88739,7 +89147,7 @@ var ts; 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 type = typeChecker.getTypeAtLocation(baseTypeNode); + var type = typeChecker.getTypeAtLocation(baseTypeNode); // TODO: GH#18217 return typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); }); symbols = filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags); @@ -88774,13 +89182,14 @@ var ts; */ function tryGetConstructorLikeCompletionContainer(contextToken) { if (contextToken) { + var parent = contextToken.parent; switch (contextToken.kind) { case 19 /* OpenParenToken */: case 26 /* CommaToken */: - return ts.isConstructorDeclaration(contextToken.parent) && contextToken.parent; + return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { - return contextToken.parent.parent; + return parent.parent; } } } @@ -88797,6 +89206,7 @@ var ts; return true; } prev_1 = node; + return false; }); return container && container; } @@ -88808,14 +89218,14 @@ var ts; case 28 /* LessThanSlashToken */: case 41 /* SlashToken */: case 71 /* Identifier */: - case 184 /* PropertyAccessExpression */: - case 262 /* JsxAttributes */: - case 261 /* JsxAttribute */: - case 263 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 255 /* JsxSelfClosingElement */ || parent.kind === 256 /* JsxOpeningElement */)) { + case 185 /* PropertyAccessExpression */: + case 263 /* JsxAttributes */: + case 262 /* JsxAttribute */: + case 264 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 256 /* JsxSelfClosingElement */ || parent.kind === 257 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 261 /* JsxAttribute */) { + else if (parent.kind === 262 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -88827,7 +89237,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent && ((parent.kind === 261 /* JsxAttribute */) || (parent.kind === 263 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 262 /* JsxAttribute */) || (parent.kind === 264 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -88837,8 +89247,8 @@ var ts; break; case 18 /* CloseBraceToken */: if (parent && - parent.kind === 264 /* JsxExpression */ && - parent.parent && parent.parent.kind === 261 /* JsxAttribute */) { + parent.kind === 265 /* JsxExpression */ && + parent.parent && parent.parent.kind === 262 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -88846,7 +89256,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 263 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 264 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -88862,53 +89272,53 @@ var ts; * @returns true if we are certain that the currently edited location must define a new location; false otherwise. */ function isSolelyIdentifierDefinitionLocation(contextToken) { - var containingNodeKind = contextToken.parent.kind; + var parent = contextToken.parent; + var containingNodeKind = parent.kind; switch (contextToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 231 /* VariableDeclaration */ || - containingNodeKind === 232 /* VariableDeclarationList */ || - containingNodeKind === 213 /* VariableStatement */ || - containingNodeKind === 237 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 232 /* VariableDeclaration */ || + containingNodeKind === 233 /* VariableDeclarationList */ || + containingNodeKind === 214 /* VariableStatement */ || + containingNodeKind === 238 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 235 /* InterfaceDeclaration */ || // interface A= contextToken.pos); + (ts.isClassLike(parent) && + !!parent.typeParameters && + parent.typeParameters.end >= contextToken.pos); case 23 /* DotToken */: - return containingNodeKind === 180 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 181 /* ArrayBindingPattern */; // var [.| case 56 /* ColonToken */: - return containingNodeKind === 181 /* BindingElement */; // var {x :html| + return containingNodeKind === 182 /* BindingElement */; // var {x :html| case 21 /* OpenBracketToken */: - return containingNodeKind === 180 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 181 /* ArrayBindingPattern */; // var [x| case 19 /* OpenParenToken */: - return containingNodeKind === 268 /* CatchClause */ || + return containingNodeKind === 269 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 17 /* OpenBraceToken */: - return containingNodeKind === 237 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 238 /* EnumDeclaration */; // enum a { | case 27 /* LessThanToken */: - return containingNodeKind === 234 /* ClassDeclaration */ || // class A< | - containingNodeKind === 204 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 235 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 236 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 235 /* ClassDeclaration */ || // class A< | + containingNodeKind === 205 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 237 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 115 /* StaticKeyword */: - return containingNodeKind === 151 /* PropertyDeclaration */ && !ts.isClassLike(contextToken.parent.parent); + return containingNodeKind === 152 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 24 /* DotDotDotToken */: - return containingNodeKind === 148 /* Parameter */ || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 180 /* ArrayBindingPattern */); // var [...z| + return containingNodeKind === 149 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 181 /* ArrayBindingPattern */); // var [...z| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: - return containingNodeKind === 148 /* Parameter */ && !ts.isConstructorDeclaration(contextToken.parent.parent); + return containingNodeKind === 149 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 118 /* AsKeyword */: - return containingNodeKind === 247 /* ImportSpecifier */ || - containingNodeKind === 251 /* ExportSpecifier */ || - containingNodeKind === 245 /* NamespaceImport */; + return containingNodeKind === 248 /* ImportSpecifier */ || + containingNodeKind === 252 /* ExportSpecifier */ || + containingNodeKind === 246 /* NamespaceImport */; case 125 /* GetKeyword */: case 136 /* SetKeyword */: if (isFromObjectTypeDeclaration(contextToken)) { @@ -88969,7 +89379,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 154 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 155 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -88992,12 +89402,12 @@ 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 !== 269 /* PropertyAssignment */ && - m.kind !== 270 /* ShorthandPropertyAssignment */ && - m.kind !== 181 /* BindingElement */ && - m.kind !== 153 /* MethodDeclaration */ && - m.kind !== 155 /* GetAccessor */ && - m.kind !== 156 /* SetAccessor */) { + if (m.kind !== 270 /* PropertyAssignment */ && + m.kind !== 271 /* ShorthandPropertyAssignment */ && + m.kind !== 182 /* BindingElement */ && + m.kind !== 154 /* MethodDeclaration */ && + m.kind !== 156 /* GetAccessor */ && + m.kind !== 157 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -89005,7 +89415,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 181 /* BindingElement */ && m.propertyName) { + if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 71 /* Identifier */) { existingName = m.propertyName.escapedText; @@ -89018,7 +89428,7 @@ var ts; var name = ts.getNameOfDeclaration(m); existingName = ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } - existingMemberNames.set(existingName, true); + existingMemberNames.set(existingName, true); // TODO: GH#18217 } return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); } @@ -89032,10 +89442,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 !== 151 /* PropertyDeclaration */ && - m.kind !== 153 /* MethodDeclaration */ && - m.kind !== 155 /* GetAccessor */ && - m.kind !== 156 /* SetAccessor */) { + if (m.kind !== 152 /* PropertyDeclaration */ && + m.kind !== 154 /* MethodDeclaration */ && + m.kind !== 156 /* GetAccessor */ && + m.kind !== 157 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -89075,7 +89485,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 261 /* JsxAttribute */) { + if (attr.kind === 262 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } } @@ -89119,7 +89529,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 72 /* FirstKeyword */; i <= 144 /* LastKeyword */; i++) { + for (var i = 72 /* FirstKeyword */; i <= 145 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -89220,7 +89630,7 @@ var ts; } // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. var filteredTypes = isForAccess ? type.types : type.types.filter(function (memberType) { - return !(memberType.flags & 16382 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker)); + return !(memberType.flags & 32764 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker)); }); return ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(filteredTypes), "getAllPossiblePropertiesOfTypes() should all be defined"); } @@ -89231,7 +89641,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 298 /* SyntaxList */: + case 299 /* 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); @@ -89255,7 +89665,7 @@ var ts; if (!isFromObjectTypeDeclaration(contextToken)) return undefined; var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) + return (isValidKeyword(contextToken.kind) || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -89278,7 +89688,7 @@ var ts; return isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return contextToken.kind === 27 /* LessThanToken */ && contextToken.parent.kind !== 199 /* BinaryExpression */; + return contextToken.kind === 27 /* LessThanToken */ && contextToken.parent.kind !== 200 /* BinaryExpression */; case "/": return ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) @@ -89291,8 +89701,8 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 201 /* TemplateExpression */: - case 188 /* TaggedTemplateExpression */: + case 202 /* TemplateExpression */: + case 189 /* TaggedTemplateExpression */: return true; default: return false; @@ -89337,7 +89747,7 @@ var ts; if (!sourceFilesSet.has(fileName)) { ts.Debug.assert(program.redirectTargetsSet.has(fileName)); var redirectTarget_1 = program.getSourceFile(fileName); - var redirect = ts.find(sourceFilesToSearch, function (f) { return f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget_1; }); + var redirect = ts.find(sourceFilesToSearch, function (f) { return !!f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget_1; }); fileName = redirect.fileName; ts.Debug.assert(sourceFilesSet.has(fileName)); } @@ -89383,6 +89793,8 @@ var ts; return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); case 120 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); + case 116 /* YieldKeyword */: + return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) ? highlightSpans(getModifierOccurrences(node.kind, node.parent)) @@ -89410,7 +89822,7 @@ var ts; } else if (ts.isTryStatement(node)) { // Exceptions thrown within a try block lacking a catch clause are "owned" in the current context. - return ts.concatenate(node.catchClause ? aggregateOwnedThrowStatements(node.catchClause) : node.tryBlock && aggregateOwnedThrowStatements(node.tryBlock), aggregateOwnedThrowStatements(node.finallyBlock)); + return ts.concatenate(node.catchClause ? aggregateOwnedThrowStatements(node.catchClause) : node.tryBlock && aggregateOwnedThrowStatements(node.tryBlock), node.finallyBlock && aggregateOwnedThrowStatements(node.finallyBlock)); } // Do not cross function boundaries. return ts.isFunctionLike(node) ? undefined : flatMapChildren(node, aggregateOwnedThrowStatements); @@ -89424,7 +89836,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 273 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 274 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -89451,26 +89863,26 @@ var ts; } function ownsBreakOrContinueStatement(owner, statement) { var actualOwner = getBreakOrContinueOwner(statement); - return actualOwner && actualOwner === owner; + return !!actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 226 /* SwitchStatement */: - if (statement.kind === 222 /* ContinueStatement */) { + case 227 /* SwitchStatement */: + if (statement.kind === 223 /* ContinueStatement */) { return false; } // falls through - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 218 /* WhileStatement */: - case 217 /* DoStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 219 /* WhileStatement */: + case 218 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. // TODO: GH#20090 - return (ts.isFunctionLike(node) && "quit"); + return ts.isFunctionLike(node) && "quit"; } }); } @@ -89488,11 +89900,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 239 /* ModuleBlock */: - case 273 /* SourceFile */: - case 212 /* Block */: - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 240 /* ModuleBlock */: + case 274 /* SourceFile */: + case 213 /* Block */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return declaration.members.concat([declaration]); @@ -89500,13 +89912,12 @@ var ts; else { return container.statements; } - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 233 /* FunctionDeclaration */: { + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 234 /* FunctionDeclaration */: return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - } - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: 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. @@ -89539,7 +89950,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 88 /* ForKeyword */, 106 /* WhileKeyword */, 81 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 217 /* DoStatement */) { + if (loopNode.kind === 218 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { @@ -89559,13 +89970,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -89641,16 +90052,35 @@ var ts; pushKeywordIf(keywords, modifier, 120 /* AsyncKeyword */); }); } - ts.forEachChild(func, aggregate); + ts.forEachChild(func, function (child) { + traverseWithoutCrossingFunction(child, function (node) { + if (ts.isAwaitExpression(node)) { + pushKeywordIf(keywords, node.getFirstToken(), 121 /* AwaitKeyword */); + } + }); + }); return keywords; - function aggregate(node) { - if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 121 /* AwaitKeyword */); - } - // Do not cross function boundaries. - if (!ts.isFunctionLike(node) && !ts.isClassLike(node) && !ts.isInterfaceDeclaration(node) && !ts.isModuleDeclaration(node) && !ts.isTypeAliasDeclaration(node) && !ts.isTypeNode(node)) { - ts.forEachChild(node, aggregate); - } + } + function getYieldOccurrences(node) { + var func = ts.getContainingFunction(node); + if (!func) { + return undefined; + } + var keywords = []; + ts.forEachChild(func, function (child) { + traverseWithoutCrossingFunction(child, function (node) { + if (ts.isYieldExpression(node)) { + pushKeywordIf(keywords, node.getFirstToken(), 116 /* YieldKeyword */); + } + }); + }); + return keywords; + } + // Do not cross function/class/interface/module/type boundaries. + function traverseWithoutCrossingFunction(node, cb) { + cb(node); + if (!ts.isFunctionLike(node) && !ts.isClassLike(node) && !ts.isInterfaceDeclaration(node) && !ts.isModuleDeclaration(node) && !ts.isTypeAliasDeclaration(node) && !ts.isTypeNode(node)) { + ts.forEachChild(node, function (child) { return traverseWithoutCrossingFunction(child, cb); }); } } function getIfElseOccurrences(ifStatement, sourceFile) { @@ -89720,6 +90150,11 @@ var ts; var ts; (function (ts) { function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { + return createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory); + } + ts.createDocumentRegistry = createDocumentRegistry; + /*@internal*/ + function createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory, externalCache) { if (currentDirectory === void 0) { currentDirectory = ""; } // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. @@ -89733,7 +90168,7 @@ var ts; if (!bucket && createIfMissing) { buckets.set(key, bucket = ts.createMap()); } - return bucket; + return bucket; // TODO: GH#18217 } function reportStats() { var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { @@ -89742,8 +90177,7 @@ var ts; entries.forEach(function (entry, name) { sourceFiles.push({ name: name, - refCount: entry.languageServiceRefCount, - references: entry.owners.slice(0) + refCount: entry.languageServiceRefCount }); }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); @@ -89774,13 +90208,26 @@ var ts; var bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ true); var entry = bucket.get(path); var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings.target; + if (!entry && externalCache) { + var sourceFile = externalCache.getDocument(key, path); + if (sourceFile) { + ts.Debug.assert(acquiring); + entry = { + sourceFile: sourceFile, + languageServiceRefCount: 0 + }; + bucket.set(path, entry); + } + } if (!entry) { // Have never seen this file with these settings. Create a new source file for it. - var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, /*setNodeParents*/ false, scriptKind); + var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, /*setNodeParents*/ false, scriptKind); // TODO: GH#18217 + if (externalCache) { + externalCache.setDocument(key, path, sourceFile); + } entry = { sourceFile: sourceFile, languageServiceRefCount: 1, - owners: [] }; bucket.set(path, entry); } @@ -89789,7 +90236,10 @@ var ts; // the script snapshot. If so, update it appropriately. Otherwise, we can just // return it as is. if (entry.sourceFile.version !== version) { - entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); + entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); // TODO: GH#18217 + if (externalCache) { + externalCache.setDocument(key, path, entry.sourceFile); + } } // If we're acquiring, then this is the first time this LS is asking for this document. // Increase our ref count so we know there's another LS using the document. If we're @@ -89800,6 +90250,7 @@ var ts; entry.languageServiceRefCount++; } } + ts.Debug.assert(entry.languageServiceRefCount !== 0); return entry.sourceFile; } function releaseDocument(fileName, compilationSettings) { @@ -89817,6 +90268,13 @@ var ts; bucket.delete(path); } } + function getLanguageServiceRefCounts(path) { + return ts.arrayFrom(buckets.entries(), function (_a) { + var key = _a[0], bucket = _a[1]; + var entry = bucket.get(path); + return [key, entry && entry.languageServiceRefCount]; + }); + } return { acquireDocument: acquireDocument, acquireDocumentWithKey: acquireDocumentWithKey, @@ -89824,11 +90282,12 @@ var ts; updateDocumentWithKey: updateDocumentWithKey, releaseDocument: releaseDocument, releaseDocumentWithKey: releaseDocumentWithKey, + getLanguageServiceRefCounts: getLanguageServiceRefCounts, reportStats: reportStats, getKeyForCompilationSettings: getKeyForCompilationSettings }; } - ts.createDocumentRegistry = createDocumentRegistry; + ts.createDocumentRegistryInternal = createDocumentRegistryInternal; })(ts || (ts = {})); /* Code for finding imports of an exported symbol. Used only by FindAllReferences. */ /* @internal */ @@ -89891,10 +90350,10 @@ var ts; } cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 231 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 232 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 71 /* Identifier */) { directImports.push(name); @@ -89907,12 +90366,12 @@ var ts; break; case 71 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */)); break; - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 245 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 246 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name); } else if (ts.isDefaultImport(direct)) { @@ -89926,7 +90385,7 @@ var ts; directImports.push(direct); } break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -89936,7 +90395,7 @@ var ts; directImports.push(direct); } break; - case 178 /* ImportType */: + case 179 /* ImportType */: directImports.push(direct); break; default: @@ -89952,7 +90411,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 273 /* SourceFile */ || sourceFileLike.kind === 238 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 274 /* SourceFile */ || sourceFileLike.kind === 239 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -89965,7 +90424,7 @@ var ts; ts.Debug.assert(!isAvailableThroughGlobal); var isNew = markSeenIndirectUser(sourceFileLike); if (isNew) { - indirectUserDeclarations.push(sourceFileLike); + indirectUserDeclarations.push(sourceFileLike); // TODO: GH#18217 } return isNew; } @@ -90007,7 +90466,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 242 /* ImportEqualsDeclaration */) { + if (decl.kind === 243 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -90017,7 +90476,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 178 /* ImportType */) { + if (decl.kind === 179 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -90032,7 +90491,7 @@ var ts; if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { return; } - if (decl.kind === 249 /* ExportDeclaration */) { + if (decl.kind === 250 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } @@ -90041,12 +90500,12 @@ var ts; return; } var namedBindings = importClause.namedBindings; - if (namedBindings && namedBindings.kind === 245 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 246 /* NamespaceImport */) { handleNamespaceImportLike(namedBindings.name); return; } if (exportKind === 0 /* Named */) { - searchForNamedImport(namedBindings); + searchForNamedImport(namedBindings); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) } else { // `export =` might be imported by a default import if `--allowSyntheticDefaultImports` is on, so this handles both ExportKind.Default and ExportKind.ExportEquals @@ -90095,7 +90554,7 @@ var ts; } } else { - var localSymbol = element.kind === 251 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 252 /* 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); @@ -90110,7 +90569,7 @@ var ts; /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ function findNamespaceReExports(sourceFileLike, name, checker) { var namespaceImportSymbol = checker.getSymbolAtLocation(name); - return forEachPossibleImportOrExportStatement(sourceFileLike, function (statement) { + return !!forEachPossibleImportOrExportStatement(sourceFileLike, function (statement) { if (!ts.isExportDeclaration(statement)) return; var exportClause = statement.exportClause, moduleSpecifier = statement.moduleSpecifier; @@ -90124,7 +90583,7 @@ var ts; for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { var referencingFile = sourceFiles_5[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 273 /* SourceFile */) { + if (searchSourceFile.kind === 274 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -90171,7 +90630,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 === 273 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 274 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -90186,15 +90645,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 249 /* ExportDeclaration */: - case 243 /* ImportDeclaration */: { + case 250 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 242 /* ImportEqualsDeclaration */: { + case 243 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -90216,12 +90675,13 @@ var ts; return comingFromExport ? getExport() : getExport() || getImport(); function getExport() { var parent = node.parent; + var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 184 /* PropertyAccessExpression */) { + if (parent.kind === 185 /* 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(parent.parent) - ? getSpecialPropertyExport(parent.parent, /*useLhsSymbol*/ false) + return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) + ? getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ false) : undefined; } else { @@ -90248,15 +90708,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(parent.parent)) { - return getExportAssignmentExport(parent.parent); + 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(parent.parent)) { - return getSpecialPropertyExport(parent.parent, /*useLhsSymbol*/ true); + else if (ts.isBinaryExpression(grandParent)) { + return getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { return exportInfo(symbol, 0 /* Named */); @@ -90331,15 +90791,18 @@ var ts; else if (ts.isBinaryExpression(decl)) { // `module.exports = class {}` return ts.Debug.assertDefined(decl.right.symbol); } + else if (ts.isSourceFile(decl)) { // json module + return ts.Debug.assertDefined(decl.symbol); + } return ts.Debug.fail(); } // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent, node) { - if (parent.kind === 231 /* VariableDeclaration */) { + if (parent.kind === 232 /* VariableDeclaration */) { var p = parent; return p.name !== node ? undefined : - p.parent.kind === 268 /* CatchClause */ ? undefined : p.parent.parent.kind === 213 /* VariableStatement */ ? p.parent.parent : undefined; + p.parent.kind === 269 /* CatchClause */ ? undefined : p.parent.parent.kind === 214 /* VariableStatement */ ? p.parent.parent : undefined; } else { return parent; @@ -90348,15 +90811,15 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent) ? { isNamedImport: false } : undefined; - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return parent.propertyName ? undefined : { isNamedImport: true }; - case 244 /* ImportClause */: - case 245 /* NamespaceImport */: + case 245 /* ImportClause */: + case 246 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return { isNamedImport: false }; default: @@ -90389,21 +90852,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 186 /* CallExpression */) { + if (node.kind === 187 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 273 /* SourceFile */) { + if (parent.kind === 274 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 239 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 240 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 238 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + return node.kind === 239 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 253 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; + return eq.moduleReference.kind === 254 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -90413,7 +90876,7 @@ var ts; var FindAllReferences; (function (FindAllReferences) { function nodeEntry(node, isInString) { - return { type: "node", node: node, isInString: isInString }; + return { type: "node", node: node.name || node, isInString: isInString }; } FindAllReferences.nodeEntry = nodeEntry; function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position) { @@ -90439,13 +90902,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* 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 === 270 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 271 /* ShorthandPropertyAssignment */) { var result_5 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_5.push(nodeEntry(node)); }); return result_5; @@ -90549,13 +91012,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 183 /* ObjectLiteralExpression */) { + else if (node.kind === 184 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] }; } - else if (node.kind === 204 /* ClassExpression */) { + else if (node.kind === 205 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] @@ -90626,6 +91089,7 @@ var ts; } var moduleReferences = ts.emptyArray; var moduleSourceFile = isModuleSymbol(symbol); + var referencedNode = node; if (moduleSourceFile) { var exportEquals = symbol.exports.get("export=" /* ExportEquals */); // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. @@ -90634,13 +91098,13 @@ var ts; return moduleReferences; // Continue to get references to 'export ='. symbol = ts.skipAlias(exportEquals, checker); - node = undefined; + referencedNode = undefined; } - return ts.concatenate(moduleReferences, getReferencedSymbolsForSymbol(symbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options)); + return ts.concatenate(moduleReferences, getReferencedSymbolsForSymbol(symbol, referencedNode, sourceFiles, sourceFilesSet, checker, cancellationToken, options)); } Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; function isModuleSymbol(symbol) { - return symbol.flags & 1536 /* Module */ && ts.find(symbol.declarations, ts.isSourceFile); + return symbol.flags & 1536 /* Module */ ? ts.find(symbol.declarations, ts.isSourceFile) : undefined; } function getReferencedSymbolsForModule(program, symbol, excludeImportTypeOfExportEquals, sourceFiles, sourceFilesSet) { ts.Debug.assert(!!symbol.valueDeclaration); @@ -90667,10 +91131,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 273 /* SourceFile */: + case 274 /* 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 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push({ type: "node", node: decl.name }); } @@ -90718,7 +91182,7 @@ var ts; searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); } else { - var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.implementations) : [symbol] }); + var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, !!options.implementations) : [symbol] }); // Try to get the smallest valid scope that we can limit our search to; // otherwise we'll need to search globally (i.e. include each file). var scope = getSymbolScope(symbol); @@ -90826,7 +91290,7 @@ var ts; State.prototype.getImportSearches = function (exportSymbol, exportInfo) { if (!this.importTracker) this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); - return this.importTracker(exportSymbol, exportInfo, this.options.isForRename); + return this.importTracker(exportSymbol, exportInfo, !!this.options.isForRename); }; /** @param allSearchSymbols set of additinal symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { @@ -90837,7 +91301,7 @@ var ts; // here appears to be intentional). var _a = searchOptions.text, text = _a === void 0 ? ts.stripQuotes(ts.unescapeLeadingUnderscores((ts.getLocalSymbolForExportDefault(symbol) || symbol).escapedName)) : _a, _b = searchOptions.allSearchSymbols, allSearchSymbols = _b === void 0 ? [symbol] : _b; var escapedText = ts.escapeLeadingUnderscores(text); - var parents = this.options.implementations && location && getParentSymbolsOfPropertyAccess(location, symbol, this.checker); + var parents = this.options.implementations && location ? getParentSymbolsOfPropertyAccess(location, symbol, this.checker) : undefined; return { symbol: symbol, comingFrom: comingFrom, text: text, escapedText: escapedText, parents: parents, allSearchSymbols: allSearchSymbols, includes: function (sym) { return ts.contains(allSearchSymbols, sym); } }; }; /** @@ -90938,13 +91402,14 @@ var ts; } } function getPropertySymbolOfDestructuringAssignment(location, checker) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - checker.getPropertySymbolOfDestructuringAssignment(location); + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) + ? checker.getPropertySymbolOfDestructuringAssignment(location) + : undefined; } function getObjectBindingElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 181 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 182 /* BindingElement */); if (bindingElement && - bindingElement.parent.kind === 179 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 180 /* ObjectBindingPattern */ && ts.isIdentifier(bindingElement.name) && !bindingElement.propertyName) { return bindingElement; @@ -90966,7 +91431,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 === 191 /* FunctionExpression */ || valueDeclaration.kind === 204 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 192 /* FunctionExpression */ || valueDeclaration.kind === 205 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -90976,7 +91441,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 234 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 235 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -90998,14 +91463,14 @@ var ts; return undefined; } var scope; - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; var container = ts.getContainerNode(declaration); if (scope && scope !== container) { // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 273 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 274 /* 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; @@ -91018,23 +91483,32 @@ var ts; // declare module "a" { export type T = number; } // declare module "b" { import { T } from "a"; export const x: T; } // So we must search the whole source file. (Because we will mark the source file as seen, we we won't return to it when searching for imports.) - return exposedByParent ? scope.getSourceFile() : scope; + return exposedByParent ? scope.getSourceFile() : scope; // TODO: GH#18217 } /** Used as a quick check for whether a symbol is used at all in a file (besides its definition). */ function isSymbolReferencedInFile(definition, checker, sourceFile) { - var symbol = checker.getSymbolAtLocation(definition); - if (!symbol) - return true; // Be lenient with invalid code. - return getPossibleSymbolReferenceNodes(sourceFile, symbol.name).some(function (token) { - if (!ts.isIdentifier(token) || token === definition || token.escapedText !== definition.escapedText) - return false; - var referenceSymbol = checker.getSymbolAtLocation(token); - return referenceSymbol === symbol - || checker.getShorthandAssignmentValueSymbol(token.parent) === symbol - || ts.isExportSpecifier(token.parent) && getLocalSymbolForExportSpecifier(token, referenceSymbol, token.parent, checker) === symbol; - }); + return eachSymbolReferenceInFile(definition, checker, sourceFile, function () { return true; }) || false; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; + function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { + var symbol = checker.getSymbolAtLocation(definition); + if (!symbol) + return undefined; + for (var _i = 0, _a = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _i < _a.length; _i++) { + var token = _a[_i]; + if (!ts.isIdentifier(token) || token === definition || token.escapedText !== definition.escapedText) + continue; + var referenceSymbol = checker.getSymbolAtLocation(token); // See GH#19955 for why the type annotation is necessary + if (referenceSymbol === symbol + || checker.getShorthandAssignmentValueSymbol(token.parent) === symbol + || ts.isExportSpecifier(token.parent) && getLocalSymbolForExportSpecifier(token, referenceSymbol, token.parent, checker) === symbol) { + var res = cb(token); + if (res) + return res; + } + } + } + Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile; function getPossibleSymbolReferenceNodes(sourceFile, symbolName, container) { if (container === void 0) { container = sourceFile; } return getPossibleSymbolReferencePositions(sourceFile, symbolName, container).map(function (pos) { return ts.getTouchingPropertyName(sourceFile, pos, /*includeJsDocComment*/ true); }); @@ -91210,7 +91684,8 @@ var ts; if (!(referenceLocation === propertyName && state.options.isForRename)) { var exportKind = referenceLocation.originalKeywordKind === 79 /* DefaultKeyword */ ? 1 /* Default */ : 0 /* Named */; var exportInfo = FindAllReferences.getExportInfo(referenceSymbol, exportKind, state.checker); - ts.Debug.assert(!!exportInfo); + if (!exportInfo) + return ts.Debug.fail(); searchForImportsOfExport(referenceLocation, referenceSymbol, exportInfo, state); } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. @@ -91327,12 +91802,12 @@ var ts; for (var _i = 0, _a = classSymbol.members.get("__constructor" /* Constructor */).declarations; _i < _a.length; _i++) { var decl = _a[_i]; var ctrKeyword = ts.findChildOfKind(decl, 123 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 154 /* Constructor */ && !!ctrKeyword); + ts.Debug.assert(decl.kind === 155 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 153 /* MethodDeclaration */) { + if (decl && decl.kind === 154 /* MethodDeclaration */) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 99 /* ThisKeyword */, function (thisKeyword) { @@ -91346,14 +91821,13 @@ var ts; } /** Find references to `super` in the constructor of an extending class. */ function findSuperConstructorAccesses(cls, addNode) { - var symbol = cls.symbol; - var ctr = symbol.members.get("__constructor" /* Constructor */); + var ctr = cls.symbol.members.get("__constructor" /* Constructor */); if (!ctr) { return; } for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 154 /* Constructor */); + ts.Debug.assert(decl.kind === 155 /* Constructor */); var body = decl.body; if (body) { forEachDescendantOfKind(body, 97 /* SuperKeyword */, function (node) { @@ -91367,13 +91841,13 @@ var ts; function addImplementationReferences(refNode, addReference, state) { // Check if we found a function/propertyAssignment/method with an implementation or initializer if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - addReference(refNode.parent); + addReference(refNode); return; } if (refNode.kind !== 71 /* Identifier */) { return; } - if (refNode.parent.kind === 270 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 271 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -91393,7 +91867,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 212 /* Block */) { + if (body.kind === 213 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -91421,13 +91895,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 192 /* ArrowFunction */: - case 191 /* FunctionExpression */: - case 183 /* ObjectLiteralExpression */: - case 204 /* ClassExpression */: - case 182 /* ArrayLiteralExpression */: + case 193 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 184 /* ObjectLiteralExpression */: + case 205 /* ClassExpression */: + case 183 /* ArrayLiteralExpression */: return true; default: return false; @@ -91480,13 +91954,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -91511,34 +91985,34 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // falls through - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 192 /* 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 === 273 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 274 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -91546,19 +92020,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 204 /* ClassExpression */: - case 234 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 235 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 273 /* SourceFile */: - return container.kind === 273 /* SourceFile */ && !ts.isExternalModule(container); + case 274 /* SourceFile */: + return container.kind === 274 /* SourceFile */ && !ts.isExternalModule(container); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -91643,37 +92117,11 @@ var ts; return cbSymbol(sym, rootSymbol) // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */) && allowBaseTypes(rootSymbol) - ? getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base); }) + ? ts.getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base); }) : undefined); }); } } - /** - * Find symbol of the given property-name and add the symbol to the given result array - * @param symbol a symbol to start searching for the given propertyName - * @param propertyName a name of property to search for - * @param result an array of symbol of found property symbols - * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. - * The value of previousIterationSymbol is undefined when the function is first called. - */ - function getPropertySymbolsFromBaseTypes(symbol, propertyName, checker, cb) { - var seen = ts.createMap(); - return recur(symbol); - function recur(symbol) { - // Use `addToSeen` to ensure we don't infinitely recurse in this situation: - // interface C extends C { - // /*findRef*/propName: string; - // } - if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) - return; - return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { - var type = checker.getTypeAtLocation(typeReference); - var propertySymbol = type && type.symbol && checker.getPropertyOfType(type, propertyName); - // Visit the typeReference as well to see if it directly or indirectly uses that property - return propertySymbol && (ts.firstDefined(checker.getRootSymbols(propertySymbol), cb) || recur(type.symbol)); - }); }); - } - } function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { var checker = state.checker; return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, function (sym, rootSymbol, baseSymbol) { return search.includes(baseSymbol || rootSymbol || sym) @@ -91690,7 +92138,7 @@ var ts; var name = ts.getNameFromPropertyName(node.name); var symbol = contextualType && name && contextualType.getProperty(name); return symbol ? [symbol] : - contextualType && contextualType.isUnion() ? ts.mapDefined(contextualType.types, function (t) { return t.getProperty(name); }) : ts.emptyArray; + contextualType && contextualType.isUnion() ? ts.mapDefined(contextualType.types, function (t) { return t.getProperty(name); }) : ts.emptyArray; // TODO: GH#18217 } /** * Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations @@ -91712,8 +92160,8 @@ var ts; // To achieve that we will keep iterating until the result stabilizes. // Remember the last meaning lastIterationMeaning = meaning; - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var declaration = declarations_10[_i]; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; var declarationMeaning = ts.getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -91774,6 +92222,184 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, preferences) { + var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); + var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + var oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName); + var newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName); + return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { + updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); + updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences); + }); + } + ts.getEditsForFileRename = getEditsForFileRename; + function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName) { + var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); + return function (path) { + var canonicalPath = getCanonicalFileName(path); + if (canonicalPath === canonicalOldPath) + return newFileOrDirPath; + var suffix = ts.tryRemoveDirectoryPrefix(canonicalPath, canonicalOldPath); + return suffix === undefined ? undefined : newFileOrDirPath + "/" + suffix; + }; + } + function updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { + var configFile = program.getCompilerOptions().configFile; + if (!configFile) + return; + var configDir = ts.getDirectoryPath(configFile.fileName); + var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(configFile); + if (!jsonObjectLiteral) + return; + forEachProperty(jsonObjectLiteral, function (property, propertyName) { + switch (propertyName) { + case "files": + case "include": + case "exclude": { + var foundExactMatch = updatePaths(property); + if (!foundExactMatch && propertyName === "include" && ts.isArrayLiteralExpression(property.initializer)) { + var includes = ts.mapDefined(property.initializer.elements, function (e) { return ts.isStringLiteral(e) ? e.text : undefined; }); + var matchers = ts.getFileMatcherPatterns(configDir, /*excludes*/ [], includes, useCaseSensitiveFileNames, currentDirectory); + // If there isn't some include for this, add a new one. + if (!ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { + changeTracker.insertNodeAfter(configFile, ts.last(property.initializer.elements), ts.createStringLiteral(relativePath(newFileOrDirPath))); + } + } + break; + } + case "compilerOptions": + forEachProperty(property.initializer, function (property, propertyName) { + var option = ts.getOptionFromName(propertyName); + if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) { + updatePaths(property); + } + else if (propertyName === "paths") { + forEachProperty(property.initializer, function (pathsProperty) { + if (!ts.isArrayLiteralExpression(pathsProperty.initializer)) + return; + for (var _i = 0, _a = pathsProperty.initializer.elements; _i < _a.length; _i++) { + var e = _a[_i]; + tryUpdateString(e); + } + }); + } + }); + break; + } + }); + function updatePaths(property) { + // Type annotation needed due to #7294 + var elements = ts.isArrayLiteralExpression(property.initializer) ? property.initializer.elements : [property.initializer]; + var foundExactMatch = false; + for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) { + var element = elements_5[_i]; + foundExactMatch = tryUpdateString(element) || foundExactMatch; + } + return foundExactMatch; + } + function tryUpdateString(element) { + if (!ts.isStringLiteral(element)) + return false; + var elementFileName = combinePathsSafe(configDir, element.text); + var updated = oldToNew(elementFileName); + if (updated !== undefined) { + changeTracker.replaceRangeWithText(configFile, createStringRange(element, configFile), relativePath(updated)); + return true; + } + return false; + } + function relativePath(path) { + return ts.getRelativePathFromDirectory(configDir, path, /*ignoreCase*/ !useCaseSensitiveFileNames); + } + } + function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences) { + var _loop_14 = function (sourceFile) { + var newImportFromPath = oldToNew(sourceFile.fileName) || sourceFile.fileName; + var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); + var oldFromNew = newToOld(sourceFile.fileName); + var oldImportFromPath = oldFromNew || sourceFile.fileName; + var oldImportFromDirectory = ts.getDirectoryPath(oldImportFromPath); + updateImportsWorker(sourceFile, changeTracker, function (referenceText) { + if (!ts.pathIsRelative(referenceText)) + return undefined; + var oldAbsolute = combinePathsSafe(oldImportFromDirectory, referenceText); + var newAbsolute = oldToNew(oldAbsolute); + return newAbsolute === undefined ? undefined : ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(newImportFromDirectory, newAbsolute, getCanonicalFileName)); + }, function (importLiteral) { + 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. + // TODO:GH#18217 + ? getSourceFileToImportFromResolved(ts.resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host), oldToNew, program) + : getSourceFileToImport(importLiteral, sourceFile, program, host, oldToNew); + return toImport === undefined ? undefined : ts.moduleSpecifiers.getModuleSpecifier(program, sourceFile, newImportFromPath, toImport, host, preferences); + }); + }; + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + _loop_14(sourceFile); + } + } + function combineNormal(pathA, pathB) { + return ts.normalizePath(ts.combinePaths(pathA, pathB)); + } + function combinePathsSafe(pathA, pathB) { + return ts.ensurePathIsNonModuleName(combineNormal(pathA, pathB)); + } + function getSourceFileToImport(importLiteral, importingSourceFile, program, host, oldToNew) { + var symbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); + if (symbol) { + if (symbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + return undefined; // No need to update if it's an ambient module + var oldFileName = ts.find(symbol.declarations, ts.isSourceFile).fileName; + return oldToNew(oldFileName) || oldFileName; + } + else { + var resolved = host.resolveModuleNames + ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName) + : program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName); + return getSourceFileToImportFromResolved(resolved, oldToNew, program); + } + } + function getSourceFileToImportFromResolved(resolved, oldToNew, program) { + return resolved && ((resolved.resolvedModule && getIfInProgram(resolved.resolvedModule.resolvedFileName)) || ts.firstDefined(resolved.failedLookupLocations, getIfInProgram)); + function getIfInProgram(oldLocation) { + var newLocation = oldToNew(oldLocation); + return program.getSourceFile(oldLocation) || newLocation !== undefined && program.getSourceFile(newLocation) + ? newLocation || oldLocation + : undefined; + } + } + function updateImportsWorker(sourceFile, changeTracker, updateRef, updateImport) { + for (var _i = 0, _a = sourceFile.referencedFiles; _i < _a.length; _i++) { + var ref = _a[_i]; + var updated = updateRef(ref.fileName); + if (updated !== undefined && updated !== sourceFile.text.slice(ref.pos, ref.end)) + changeTracker.replaceRangeWithText(sourceFile, ref, updated); + } + for (var _b = 0, _c = sourceFile.imports; _b < _c.length; _b++) { + var importStringLiteral = _c[_b]; + var updated = updateImport(importStringLiteral); + if (updated !== undefined && updated !== importStringLiteral.text) + changeTracker.replaceRangeWithText(sourceFile, createStringRange(importStringLiteral, sourceFile), updated); + } + } + function createStringRange(node, sourceFile) { + return ts.createTextRange(node.getStart(sourceFile) + 1, node.end - 1); + } + function forEachProperty(objectLiteral, cb) { + if (!ts.isObjectLiteralExpression(objectLiteral)) + return; + for (var _i = 0, _a = objectLiteral.properties; _i < _a.length; _i++) { + var property = _a[_i]; + if (ts.isPropertyAssignment(property) && ts.isStringLiteral(property.name)) { + cb(property, property.name.text); + } + } + } +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var GoToDefinition; (function (GoToDefinition) { @@ -91786,10 +92412,11 @@ var ts; if (node === sourceFile) { return undefined; } + var parent = node.parent; // Labels if (ts.isJumpStatementTarget(node)) { var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 } var typeChecker = program.getTypeChecker(); var symbol = getSymbol(node, typeChecker); @@ -91805,7 +92432,7 @@ var ts; // If this is the original constructor definition, parent is the class. return typeChecker.getRootSymbols(symbol).some(function (s) { return calledDeclaration.symbol === s || calledDeclaration.symbol.parent === s; }) || // TODO: GH#23742 Following check shouldn't be necessary if 'require' is an alias - symbol.declarations.some(function (d) { return ts.isVariableDeclaration(d) && d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ false); }) + symbol.declarations.some(function (d) { return ts.isVariableDeclaration(d) && !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ false); }) ? [sigInfo] : [sigInfo].concat(getDefinitionFromSymbol(typeChecker, symbol, node)); } @@ -91814,7 +92441,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 270 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 271 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -91829,9 +92456,9 @@ var ts; // pr/*destination*/op1: number // } // bar(({pr/*goto*/op1})=>{}); - if (ts.isPropertyName(node) && ts.isBindingElement(node.parent) && ts.isObjectBindingPattern(node.parent.parent) && - (node === (node.parent.propertyName || node.parent.name))) { - var type = typeChecker.getTypeAtLocation(node.parent.parent); + if (ts.isPropertyName(node) && ts.isBindingElement(parent) && ts.isObjectBindingPattern(parent.parent) && + (node === (parent.propertyName || parent.name))) { + var type = typeChecker.getTypeAtLocation(parent.parent); if (type) { var propSymbols = ts.getPropertySymbolsFromType(type, node); if (propSymbols) { @@ -91866,7 +92493,7 @@ var ts; var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); - var file_17 = reference && program.getSourceFile(reference.resolvedFileName); + var file_17 = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217 return file_17 && { fileName: typeReferenceDirective.fileName, file: file_17 }; } return undefined; @@ -91883,7 +92510,7 @@ var ts; if (!type) { return undefined; } - if (type.isUnion() && !(type.flags & 16 /* Enum */)) { + if (type.isUnion() && !(type.flags & 32 /* Enum */)) { return ts.flatMap(type.types, function (t) { return t.symbol && getDefinitionFromSymbol(typeChecker, t.symbol, node); }); } return type.symbol && getDefinitionFromSymbol(typeChecker, type.symbol, node); @@ -91941,11 +92568,11 @@ var ts; return true; } switch (declaration.kind) { - case 244 /* ImportClause */: - case 242 /* ImportEqualsDeclaration */: + case 245 /* ImportClause */: + case 243 /* ImportEqualsDeclaration */: return true; - case 247 /* ImportSpecifier */: - return declaration.parent.kind === 246 /* NamedImports */; + case 248 /* ImportSpecifier */: + return declaration.parent.kind === 247 /* NamedImports */; default: return false; } @@ -92009,14 +92636,14 @@ var ts; kind: "script" /* scriptElement */, name: name, containerName: undefined, - containerKind: undefined + containerKind: undefined, }; } /** Returns a CallLikeExpression where `node` is the target being invoked. */ function getAncestorCallLikeExpression(node) { var target = climbPastManyPropertyAccesses(node); var callLike = target.parent; - return callLike && ts.isCallLikeExpression(callLike) && ts.getInvokedExpression(callLike) === target && callLike; + return callLike && ts.isCallLikeExpression(callLike) && ts.getInvokedExpression(callLike) === target ? callLike : undefined; } function climbPastManyPropertyAccesses(node) { return ts.isRightSideOfPropertyAccess(node) ? climbPastManyPropertyAccesses(node.parent) : node; @@ -92104,11 +92731,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 292 /* JSDocParameterTag */: - case 297 /* JSDocPropertyTag */: + case 293 /* JSDocParameterTag */: + case 298 /* JSDocPropertyTag */: return [declaration]; - case 291 /* JSDocCallbackTag */: - case 296 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -92129,16 +92756,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 289 /* JSDocAugmentsTag */: + case 290 /* JSDocAugmentsTag */: return withNode(tag.class); - case 295 /* JSDocTemplateTag */: + case 296 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 294 /* JSDocTypeTag */: + case 295 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: - case 297 /* JSDocPropertyTag */: - case 292 /* JSDocParameterTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 298 /* JSDocPropertyTag */: + case 293 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -92220,7 +92847,7 @@ var ts; if (!ts.isIdentifier(param.name)) return undefined; var name = param.name.text; - if (jsdoc.tags.some(function (t) { return t !== tag && ts.isJSDocParameterTag(t) && ts.isIdentifier(t.name) && t.name.escapedText === name; }) + if (jsdoc.tags.some(function (t) { return t !== tag && ts.isJSDocParameterTag(t) && ts.isIdentifier(t.name) && t.name.escapedText === name; }) // TODO: GH#18217 || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } @@ -92269,7 +92896,7 @@ var ts; return undefined; } var tokenAtPos = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); - var tokenStart = tokenAtPos.getStart(); + var tokenStart = tokenAtPos.getStart(sourceFile); if (!tokenAtPos || tokenStart < position) { return undefined; } @@ -92278,7 +92905,7 @@ var ts; return undefined; } var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters; - if (commentOwner.getStart() < position) { + if (commentOwner.getStart(sourceFile) < position) { return undefined; } if (!parameters || parameters.length === 0) { @@ -92290,18 +92917,6 @@ var ts; var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; // replace non-whitespace characters in prefix with spaces. var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); - var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); - var docParams = ""; - for (var i = 0; i < parameters.length; i++) { - var currentName = parameters[i].name; - var paramName = currentName.kind === 71 /* Identifier */ ? currentName.escapedText : "param" + i; - if (isJavaScriptFile) { - docParams += indentationStr + " * @param {any} " + paramName + newLine; - } - else { - docParams += indentationStr + " * @param " + paramName + newLine; - } - } // A doc comment consists of the following // * The opening comment line // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) @@ -92312,29 +92927,37 @@ var ts; var preamble = "/**" + newLine + indentationStr + " * "; var result = preamble + newLine + - docParams + + parameterDocComments(parameters, ts.hasJavaScriptFileExtension(sourceFile.fileName), indentationStr, newLine) + indentationStr + " */" + (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; + function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { + return parameters.map(function (_a, i) { + var name = _a.name, dotDotDotToken = _a.dotDotDotToken; + var paramName = name.kind === 71 /* Identifier */ ? name.text : "param" + i; + var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; + return indentationStr + " * @param " + type + paramName + newLine; + }).join(""); + } function getCommentOwnerInfo(tokenAtPos) { for (var commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: - case 152 /* MethodSignature */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: + case 153 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 150 /* PropertySignature */: - case 237 /* EnumDeclaration */: - case 272 /* EnumMember */: - case 236 /* TypeAliasDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 151 /* PropertySignature */: + case 238 /* EnumDeclaration */: + case 273 /* EnumMember */: + case 237 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 213 /* VariableStatement */: { + case 214 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -92342,14 +92965,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 273 /* SourceFile */: + case 274 /* SourceFile */: return undefined; - case 238 /* ModuleDeclaration */: + case 239 /* 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 === 238 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 199 /* BinaryExpression */: { + return commentOwner.parent.kind === 239 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 200 /* BinaryExpression */: { var be = commentOwner; if (ts.getSpecialPropertyAssignmentKind(be) === 0 /* None */) { return undefined; @@ -92369,16 +92992,16 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 190 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 191 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return rightHandSide.parameters; - case 204 /* ClassExpression */: { + case 205 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); - return ctr && ctr.parameters; + return ctr ? ctr.parameters : ts.emptyArray; } } return ts.emptyArray; @@ -92562,7 +93185,8 @@ var ts; } // Add the cached typing locations for inferred typings that are already installed packageNameToTypingLocation.forEach(function (typing, name) { - if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && isTypingUpToDate(typing, typesRegistry.get(name))) { + var registryEntry = typesRegistry.get(name); + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && registryEntry !== undefined && isTypingUpToDate(typing, registryEntry)) { inferredTypings.set(name, typing.typingLocation); } }); @@ -92589,7 +93213,7 @@ var ts; return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { - inferredTypings.set(typingName, undefined); + inferredTypings.set(typingName, undefined); // TODO: GH#18217 } } function addInferredTypings(typingNames, message) { @@ -92740,7 +93364,7 @@ var ts; case 0 /* Ok */: return ts.Debug.fail(); // Shouldn't have called this. default: - ts.Debug.assertNever(result); + throw ts.Debug.assertNever(result); } } JsTyping.renderPackageNameValidationFailure = renderPackageNameValidationFailure; @@ -92756,7 +93380,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_14 = function (sourceFile) { + var _loop_15 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */)) { return "continue"; @@ -92768,7 +93392,7 @@ var ts; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { var sourceFile = sourceFiles_7[_i]; - _loop_14(sourceFile); + _loop_15(sourceFile); } rawItems.sort(compareNavigateToItems); if (maxResultCount !== undefined) { @@ -92784,12 +93408,12 @@ var ts; if (!match) { return; // continue to next named declarations } - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_i]; if (!shouldKeepItem(declaration, checker)) continue; if (patternMatcher.patternContainsDots) { - var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); + var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); // TODO: GH#18217 if (fullMatch) { rawItems.push({ name: name, fileName: fileName, matchKind: fullMatch.kind, isCaseSensitive: fullMatch.isCaseSensitive, declaration: declaration }); } @@ -92802,9 +93426,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 244 /* ImportClause */: - case 247 /* ImportSpecifier */: - case 242 /* ImportEqualsDeclaration */: + case 245 /* ImportClause */: + case 248 /* ImportSpecifier */: + case 243 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -92818,7 +93442,7 @@ var ts; containers.unshift(ts.getTextOfIdentifierOrLiteral(name)); return true; } - else if (name && name.kind === 146 /* ComputedPropertyName */) { + else if (name && name.kind === 147 /* ComputedPropertyName */) { return tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ true); } else { @@ -92850,16 +93474,16 @@ 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.kind === 146 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { + if (name.kind === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } // Now, walk up our containers, adding all their names to the container array. - declaration = ts.getContainerNode(declaration); - while (declaration) { - if (!tryAddSingleDeclarationName(declaration, containers)) { + var container = ts.getContainerNode(declaration); + while (container) { + if (!tryAddSingleDeclarationName(container, containers)) { return undefined; } - declaration = ts.getContainerNode(declaration); + container = ts.getContainerNode(container); } return containers; } @@ -92882,7 +93506,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ + containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ // TODO: GH#18217 Just use `container ? ...` }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -93016,7 +93640,7 @@ var ts; return; } switch (node.kind) { - case 154 /* Constructor */: + case 155 /* 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); @@ -93028,21 +93652,21 @@ var ts; } } break; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 153 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 244 /* ImportClause */: + case 245 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -93054,7 +93678,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 245 /* NamespaceImport */) { + if (namedBindings.kind === 246 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -93065,8 +93689,8 @@ var ts; } } break; - case 181 /* BindingElement */: - case 231 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 232 /* VariableDeclaration */: var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -93087,12 +93711,12 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; - case 192 /* ArrowFunction */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -93102,9 +93726,9 @@ var ts; } endNode(); break; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -93112,18 +93736,18 @@ var ts; } endNode(); break; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 251 /* ExportSpecifier */: - case 242 /* ImportEqualsDeclaration */: - case 159 /* IndexSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 236 /* TypeAliasDeclaration */: + case 252 /* ExportSpecifier */: + case 243 /* ImportEqualsDeclaration */: + case 160 /* IndexSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 237 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 199 /* BinaryExpression */: { + case 200 /* BinaryExpression */: { var special = ts.getSpecialPropertyAssignmentKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -93202,12 +93826,12 @@ var ts; return false; } switch (a.kind) { - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -93216,7 +93840,8 @@ 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) { - return a.body.kind === b.body.kind && (a.body.kind !== 238 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + // TODO: GH#18217 + return a.body.kind === b.body.kind && (a.body.kind !== 239 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -93237,7 +93862,7 @@ var ts; children.sort(compareChildren); } function compareChildren(child1, child2) { - return ts.compareStringsCaseSensitiveUI(tryGetName(child1.node), tryGetName(child2.node)) + return ts.compareStringsCaseSensitiveUI(tryGetName(child1.node), tryGetName(child2.node)) // TODO: GH#18217 || ts.compareValues(navigationBarNodeKind(child1), navigationBarNodeKind(child2)); } /** @@ -93246,24 +93871,24 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 238 /* ModuleDeclaration */) { + if (node.kind === 239 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); if (declName) { - return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); + return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 204 /* ClassExpression */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 205 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 238 /* ModuleDeclaration */) { + if (node.kind === 239 /* ModuleDeclaration */) { return getModuleName(node); } var name = ts.getNameOfDeclaration(node); @@ -93274,16 +93899,16 @@ var ts; } } switch (node.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 192 /* ArrowFunction */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 193 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -93291,13 +93916,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return "constructor"; - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: return "new()"; - case 157 /* CallSignature */: + case 158 /* CallSignature */: return "()"; - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: return "[]"; default: return ""; @@ -93321,25 +93946,25 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 237 /* EnumDeclaration */: - case 235 /* InterfaceDeclaration */: - case 238 /* ModuleDeclaration */: - case 273 /* SourceFile */: - case 236 /* TypeAliasDeclaration */: - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 238 /* EnumDeclaration */: + case 236 /* InterfaceDeclaration */: + case 239 /* ModuleDeclaration */: + case 274 /* SourceFile */: + case 237 /* TypeAliasDeclaration */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: return true; - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 231 /* VariableDeclaration */: + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 232 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 192 /* ArrowFunction */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -93349,19 +93974,19 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 239 /* ModuleBlock */: - case 273 /* SourceFile */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: + case 240 /* ModuleBlock */: + case 274 /* SourceFile */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: return true; default: return hasSomeImportantChild(item); } } function hasSomeImportantChild(item) { - return ts.forEach(item.children, function (child) { + return ts.some(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 231 /* VariableDeclaration */ && childKind !== 181 /* BindingElement */; + return childKind !== 232 /* VariableDeclaration */ && childKind !== 182 /* BindingElement */; }); } } @@ -93417,7 +94042,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 238 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -93428,16 +94053,16 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 238 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 239 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 } function isComputedProperty(member) { - return !member.name || member.name.kind === 146 /* ComputedPropertyName */; + return !member.name || member.name.kind === 147 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 273 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 274 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 231 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 232 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -93447,16 +94072,16 @@ var ts; return ts.declarationNameToString(node.name); } // See if it is a var initializer. If so, use the var name. - else if (node.parent.kind === 231 /* VariableDeclaration */) { + else if (node.parent.kind === 232 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (node.parent.kind === 199 /* BinaryExpression */ && + else if (node.parent.kind === 200 /* BinaryExpression */ && node.parent.operatorToken.kind === 58 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name - else if (node.parent.kind === 269 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 270 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } // Default exports are named "default" @@ -93469,9 +94094,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 192 /* ArrowFunction */: - case 191 /* FunctionExpression */: - case 204 /* ClassExpression */: + case 193 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 205 /* ClassExpression */: return true; default: return false; @@ -93501,7 +94126,7 @@ var ts; organizeImportsWorker(topLevelExportDecls, coalesceExports); for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) { var ambientModule = _a[_i]; - var ambientModuleBody = getModuleBlock(ambientModule); + var ambientModuleBody = getModuleBlock(ambientModule); // TODO: GH#18217 var ambientModuleImportDecls = ambientModuleBody.statements.filter(ts.isImportDeclaration); organizeImportsWorker(ambientModuleImportDecls, coalesceAndOrganizeImports); var ambientModuleExportDecls = ambientModuleBody.statements.filter(ts.isExportDeclaration); @@ -93549,12 +94174,12 @@ var ts; OrganizeImports.organizeImports = organizeImports; function getModuleBlock(moduleDecl) { var body = moduleDecl.body; - return body && !ts.isIdentifier(body) && (ts.isModuleBlock(body) ? body : getModuleBlock(body)); + return body && !ts.isIdentifier(body) ? (ts.isModuleBlock(body) ? body : getModuleBlock(body)) : undefined; } function removeUnusedImports(oldImports, sourceFile, program) { var typeChecker = program.getTypeChecker(); var jsxNamespace = typeChecker.getJsxNamespace(); - var jsxContext = sourceFile.languageVariant === 1 /* JSX */ && program.getCompilerOptions().jsx; + var jsxElementsPresent = !!(sourceFile.transformFlags & 4 /* ContainsJsx */); var usedImports = []; for (var _i = 0, oldImports_1 = oldImports; _i < oldImports_1.length; _i++) { var importDecl = oldImports_1[_i]; @@ -93592,8 +94217,8 @@ var ts; } return usedImports; function isDeclarationUsed(identifier) { - // The JSX factory symbol is always used. - return jsxContext && (identifier.text === jsxNamespace) || ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile); + // The JSX factory symbol is always used if JSX elements are present - even if they are not allowed. + return jsxElementsPresent && (identifier.text === jsxNamespace) || ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile); } } function getExternalModuleName(specifier) { @@ -93619,16 +94244,16 @@ var ts; if (defaultImports.length === 1 && namespaceImports.length === 1 && namedImports.length === 0) { // Add the namespace import to the existing default ImportDeclaration. var defaultImport = defaultImports[0]; - coalescedImports.push(updateImportDeclarationAndClause(defaultImport, defaultImport.importClause.name, namespaceImports[0].importClause.namedBindings)); + coalescedImports.push(updateImportDeclarationAndClause(defaultImport, defaultImport.importClause.name, namespaceImports[0].importClause.namedBindings)); // TODO: GH#18217 return coalescedImports; } var sortedNamespaceImports = ts.stableSort(namespaceImports, function (i1, i2) { return compareIdentifiers(i1.importClause.namedBindings.name, i2.importClause.namedBindings.name); - }); + }); // TODO: GH#18217 for (var _i = 0, sortedNamespaceImports_1 = sortedNamespaceImports; _i < sortedNamespaceImports_1.length; _i++) { var namespaceImport = sortedNamespaceImports_1[_i]; // Drop the name, if any - coalescedImports.push(updateImportDeclarationAndClause(namespaceImport, /*name*/ undefined, namespaceImport.importClause.namedBindings)); + coalescedImports.push(updateImportDeclarationAndClause(namespaceImport, /*name*/ undefined, namespaceImport.importClause.namedBindings)); // TODO: GH#18217 } if (defaultImports.length === 0 && namedImports.length === 0) { return coalescedImports; @@ -93641,10 +94266,10 @@ var ts; else { for (var _b = 0, defaultImports_1 = defaultImports; _b < defaultImports_1.length; _b++) { var defaultImport = defaultImports_1[_b]; - newImportSpecifiers.push(ts.createImportSpecifier(ts.createIdentifier("default"), defaultImport.importClause.name)); + newImportSpecifiers.push(ts.createImportSpecifier(ts.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217 } } - newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); + newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217 var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers); var importDecl = defaultImports.length > 0 ? defaultImports[0] @@ -93655,7 +94280,7 @@ var ts; : ts.createNamedImports(ts.emptyArray) : namedImports.length === 0 ? ts.createNamedImports(sortedImportSpecifiers) - : ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); + : ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); // TODO: GH#18217 coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, newNamedImports)); return coalescedImports; /* @@ -93749,7 +94374,8 @@ var ts; } OrganizeImports.coalesceExports = coalesceExports; function updateImportDeclarationAndClause(importDeclaration, name, namedBindings) { - return ts.updateImportDeclaration(importDeclaration, importDeclaration.decorators, importDeclaration.modifiers, ts.updateImportClause(importDeclaration.importClause, name, namedBindings), importDeclaration.moduleSpecifier); + return ts.updateImportDeclaration(importDeclaration, importDeclaration.decorators, importDeclaration.modifiers, ts.updateImportClause(importDeclaration.importClause, name, namedBindings), // TODO: GH#18217 + importDeclaration.moduleSpecifier); } function sortSpecifiers(specifiers) { return ts.stableSort(specifiers, function (s1, s2) { @@ -93773,73 +94399,6 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; -(function (ts) { - function getEditsForFileRename(program, oldFilePath, newFilePath, host, formatContext) { - var pathUpdater = getPathUpdater(oldFilePath, newFilePath, host); - return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { - updateTsconfigFiles(program, changeTracker, oldFilePath, newFilePath); - for (var _i = 0, _a = getImportsToUpdate(program, oldFilePath, host); _i < _a.length; _i++) { - var _b = _a[_i], sourceFile = _b.sourceFile, toUpdate = _b.toUpdate; - var newPath = pathUpdater(isRef(toUpdate) ? toUpdate.fileName : toUpdate.text); - if (newPath !== undefined) { - var range = isRef(toUpdate) ? toUpdate : createStringRange(toUpdate, sourceFile); - changeTracker.replaceRangeWithText(sourceFile, range, isRef(toUpdate) ? newPath : ts.removeFileExtension(newPath)); - } - } - }); - } - ts.getEditsForFileRename = getEditsForFileRename; - function updateTsconfigFiles(program, changeTracker, oldFilePath, newFilePath) { - var configFile = program.getCompilerOptions().configFile; - var oldFile = ts.getTsConfigPropArrayElementValue(configFile, "files", oldFilePath); - if (oldFile) { - changeTracker.replaceRangeWithText(configFile, createStringRange(oldFile, configFile), newFilePath); - } - } - function isRef(toUpdate) { - return "fileName" in toUpdate; - } - function getImportsToUpdate(program, oldFilePath, host) { - var checker = program.getTypeChecker(); - var result = []; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { - var ref = _c[_b]; - if (!program.getSourceFileFromReference(sourceFile, ref) && ts.resolveTripleslashReference(ref.fileName, sourceFile.fileName) === oldFilePath) { - result.push({ sourceFile: sourceFile, toUpdate: ref }); - } - } - for (var _d = 0, _e = sourceFile.imports; _d < _e.length; _d++) { - var importStringLiteral = _e[_d]; - // If it resolved to something already, ignore. - if (checker.getSymbolAtLocation(importStringLiteral)) - continue; - var resolved = host.resolveModuleNames - ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importStringLiteral.text, sourceFile.fileName) - : program.getResolvedModuleWithFailedLookupLocationsFromCache(importStringLiteral.text, sourceFile.fileName); - if (resolved && ts.contains(resolved.failedLookupLocations, oldFilePath)) { - result.push({ sourceFile: sourceFile, toUpdate: importStringLiteral }); - } - } - } - return result; - } - function getPathUpdater(oldFilePath, newFilePath, host) { - // Get the relative path from old to new location, and append it on to the end of imports and normalize. - var rel = ts.getRelativePathFromFile(oldFilePath, newFilePath, ts.createGetCanonicalFileName(ts.hostUsesCaseSensitiveFileNames(host))); - return function (oldPath) { - if (!ts.pathIsRelative(oldPath)) - return; - return ts.ensurePathIsNonModuleName(ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(oldPath), rel))); - }; - } - function createStringRange(node, sourceFile) { - return ts.createTextRange(node.getStart(sourceFile) + 1, node.end - 1); - } -})(ts || (ts = {})); -/* @internal */ -var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { @@ -93964,24 +94523,24 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 212 /* Block */: + case 213 /* Block */: if (ts.isFunctionBlock(n)) { - return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 192 /* ArrowFunction */); + return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 193 /* ArrowFunction */); } // Check if the block is standalone, or 'attached' to some parent statement. // 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 217 /* DoStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 219 /* ForStatement */: - case 216 /* IfStatement */: - case 218 /* WhileStatement */: - case 225 /* WithStatement */: - case 268 /* CatchClause */: + case 218 /* DoStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 220 /* ForStatement */: + case 217 /* IfStatement */: + case 219 /* WhileStatement */: + case 226 /* WithStatement */: + case 269 /* CatchClause */: return spanForNode(n.parent); - case 229 /* TryStatement */: + case 230 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -93996,16 +94555,16 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return spanForNode(n.parent); - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 240 /* CaseBlock */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 241 /* CaseBlock */: return spanForNode(n); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 21 /* OpenBracketToken */); } function spanForObjectOrArrayLiteral(node, open) { @@ -94075,7 +94634,7 @@ var ts; // First, check that the last part of the dot separated pattern matches the name of the // candidate. If not, then there's no point in proceeding and doing the more // expensive work. - var candidateMatch = matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments), stringToWordSpans); + var candidateMatch = matchSegment(candidate, ts.last(dotSeparatedSegments), stringToWordSpans); if (!candidateMatch) { return undefined; } @@ -94316,13 +94875,13 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_15 = function (start) { + var _loop_16 = 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_4 = _loop_15(start); + var state_4 = _loop_16(start); if (typeof state_4 === "object") return state_4.value; } @@ -94595,7 +95154,7 @@ var ts; else { if (token === 71 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -94626,7 +95185,7 @@ var ts; } if (token === 18 /* CloseBraceToken */) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -94642,7 +95201,7 @@ var ts; token = nextToken(); if (token === 71 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -94672,7 +95231,7 @@ var ts; } if (token === 18 /* CloseBraceToken */) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -94684,7 +95243,7 @@ var ts; } else if (token === 39 /* AsteriskToken */) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -94808,7 +95367,7 @@ var ts; importedFiles.push(decl.ref); } } - return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: pragmaContext.hasNoDefaultLib, ambientExternalModules: undefined }; + return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: !!pragmaContext.hasNoDefaultLib, ambientExternalModules: undefined }; } else { // for global scripts ambient modules still can have augmentations - look for ambient modules with depth > 0 @@ -94827,7 +95386,7 @@ var ts; } } } - return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: pragmaContext.hasNoDefaultLib, ambientExternalModules: ambientModuleNames }; + return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: !!pragmaContext.hasNoDefaultLib, ambientExternalModules: ambientModuleNames }; } } ts.preProcessFile = preProcessFile; @@ -94856,36 +95415,30 @@ var ts; Rename.getRenameInfo = getRenameInfo; function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) + return; // Only allow a symbol to be renamed if it actually has at least one declaration. - if (symbol) { - var declarations = symbol.declarations; - if (declarations && declarations.length > 0) { - // Disallow rename for elements that are defined in the standard TypeScript library. - if (declarations.some(isDefinedInLibraryFile)) { - 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 === 79 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { - return undefined; - } - // Can't rename a module name. - if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) - return undefined; - var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteral(node) && node.parent.kind === 146 /* 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(symbol), node, sourceFile); - } + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) + return; + // Disallow rename for elements that are defined in the standard TypeScript library. + if (declarations.some(isDefinedInLibraryFile)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } - else if (ts.isStringLiteral(node)) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); - } - return getRenameInfoSuccess(node.text, node.text, "var" /* variableElement */, "" /* none */, node, sourceFile); + // Cannot rename `default` as in `import { default as foo } from "./someModule"; + if (ts.isIdentifier(node) && node.originalKeywordKind === 79 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + return undefined; } + // Can't rename a module name. + if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) + return undefined; + var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteral(node) && node.parent.kind === 147 /* 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(symbol), node, sourceFile); } function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { return { @@ -94899,6 +95452,7 @@ var ts; }; } function getRenameInfoError(diagnostic) { + // TODO: GH#18217 return { canRename: false, localizedErrorMessage: ts.getLocaleSpecificMessage(diagnostic), @@ -94944,7 +95498,12 @@ var ts; ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; ArgumentListKind[ArgumentListKind["JSXAttributesArguments"] = 3] = "JSXAttributesArguments"; - })(ArgumentListKind = SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); + })(ArgumentListKind || (ArgumentListKind = {})); + var InvocationKind; + (function (InvocationKind) { + InvocationKind[InvocationKind["Call"] = 0] = "Call"; + InvocationKind[InvocationKind["TypeArgs"] = 1] = "TypeArgs"; + })(InvocationKind || (InvocationKind = {})); function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); // Decide whether to show signature help @@ -94958,11 +95517,9 @@ var ts; return undefined; cancellationToken.throwIfCancellationRequested(); // Semantic filtering of signature help - var call = argumentInfo.invocation; - var candidates = []; - var resolvedSignature = typeChecker.getResolvedSignature(call, candidates, argumentInfo.argumentCount); + var candidateInfo = getCandidateInfo(argumentInfo, typeChecker); cancellationToken.throwIfCancellationRequested(); - if (!candidates.length) { + if (!candidateInfo) { // We didn't have any sig help items produced by the TS compiler. If this is a JS // file, then see if we can figure out anything better. if (ts.isSourceFileJavaScript(sourceFile)) { @@ -94970,54 +95527,76 @@ var ts; } return undefined; } - return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo, typeChecker); }); + return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker); }); } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; - function createJavaScriptSignatureHelpItems(argumentInfo, program, cancellationToken) { - if (argumentInfo.invocation.kind !== 186 /* CallExpression */) { - return undefined; + function getCandidateInfo(argumentInfo, checker) { + var invocation = argumentInfo.invocation; + if (invocation.kind === 0 /* Call */) { + var candidates = []; + var resolvedSignature = checker.getResolvedSignature(invocation.node, candidates, argumentInfo.argumentCount); // TODO: GH#18217 + return candidates.length === 0 ? undefined : { candidates: candidates, resolvedSignature: resolvedSignature }; } + else { + var type = checker.getTypeAtLocation(invocation.called); // TODO: GH#18217 + var signatures = ts.isNewExpression(invocation.called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); + var candidates = signatures.filter(function (candidate) { return !!candidate.typeParameters && candidate.typeParameters.length >= argumentInfo.argumentCount; }); + return candidates.length === 0 ? undefined : { candidates: candidates, resolvedSignature: ts.first(candidates) }; + } + } + function createJavaScriptSignatureHelpItems(argumentInfo, program, cancellationToken) { // See if we can find some symbol with the call expression name that has call signatures. - var callExpression = argumentInfo.invocation; - var expression = callExpression.expression; + var expression = getExpressionFromInvocation(argumentInfo.invocation); var name = ts.isIdentifier(expression) ? expression : ts.isPropertyAccessExpression(expression) ? expression.name : undefined; if (!name || !name.escapedText) { return undefined; } var typeChecker = program.getTypeChecker(); - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; + var _loop_17 = function (sourceFile) { var nameToDeclarations = sourceFile.getNamedDeclarations(); var declarations = nameToDeclarations.get(name.text); if (declarations) { - var _loop_16 = function (declaration) { + var _loop_18 = function (declaration) { var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); if (type) { var callSignatures_1 = type.getCallSignatures(); if (callSignatures_1 && callSignatures_1.length) { - return { value: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(callSignatures_1, callSignatures_1[0], argumentInfo, typeChecker); }) }; + return { value: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(callSignatures_1, callSignatures_1[0], argumentInfo, sourceFile, typeChecker); }) }; } } } }; - for (var _b = 0, declarations_12 = declarations; _b < declarations_12.length; _b++) { - var declaration = declarations_12[_b]; - var state_5 = _loop_16(declaration); - if (typeof state_5 === "object") - return state_5.value; + for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { + var declaration = declarations_13[_i]; + var state_6 = _loop_18(declaration); + if (typeof state_6 === "object") + return state_6; } } + }; + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + var state_5 = _loop_17(sourceFile); + if (typeof state_5 === "object") + return state_5.value; } } + function getArgumentInfoForCompletions(node, position, sourceFile) { + var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile); + return !info || info.kind === 0 /* TypeArguments */ || info.invocation.kind === 1 /* TypeArgs */ ? undefined + : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex }; + } + SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions; /** * Returns relevant information for the argument list and the current argument if we are * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (ts.isCallOrNewExpression(node.parent)) { - var invocation = node.parent; + var parent = node.parent; + if (ts.isCallOrNewExpression(parent)) { + var invocation = parent; var list = void 0; var argumentIndex = void 0; // There are 3 cases to handle: @@ -95037,7 +95616,7 @@ var ts; if (node.kind === 27 /* LessThanToken */ || node.kind === 19 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. - list = getChildListThatStartsWithOpenerToken(invocation, node, sourceFile); + list = getChildListThatStartsWithOpenerToken(parent, node, sourceFile); ts.Debug.assert(list !== undefined); argumentIndex = 0; } @@ -95053,60 +95632,66 @@ var ts; return undefined; argumentIndex = getArgumentIndex(list, node); } - var kind = invocation.typeArguments && invocation.typeArguments.pos === list.pos ? 0 /* TypeArguments */ : 1 /* CallArguments */; + var kind = parent.typeArguments && parent.typeArguments.pos === list.pos ? 0 /* TypeArguments */ : 1 /* CallArguments */; var argumentCount = getArgumentCount(list); if (argumentIndex !== 0) { ts.Debug.assertLessThan(argumentIndex, argumentCount); } var argumentsSpan = getApplicableSpanForArguments(list, sourceFile); - return { kind: kind, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; + return { kind: kind, invocation: { kind: 0 /* Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } - else if (node.kind === 13 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 188 /* TaggedTemplateExpression */) { + else if (ts.isNoSubstitutionTemplateLiteral(node) && ts.isTaggedTemplateExpression(parent)) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. - if (ts.isInsideTemplateLiteral(node, position)) { - return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0, sourceFile); + if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { + return getArgumentListInfoForTemplate(parent, /*argumentIndex*/ 0, sourceFile); } } - else if (node.kind === 14 /* TemplateHead */ && node.parent.parent.kind === 188 /* TaggedTemplateExpression */) { - var templateExpression = node.parent; + else if (ts.isTemplateHead(node) && parent.parent.kind === 189 /* TaggedTemplateExpression */) { + var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 201 /* TemplateExpression */); - var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; + ts.Debug.assert(templateExpression.kind === 202 /* TemplateExpression */); + var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 210 /* TemplateSpan */ && node.parent.parent.parent.kind === 188 /* TaggedTemplateExpression */) { - var templateSpan = node.parent; - var templateExpression = templateSpan.parent; - var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 201 /* TemplateExpression */); + else if (ts.isTemplateSpan(parent) && ts.isTaggedTemplateExpression(parent.parent.parent)) { + var templateSpan = parent; + var tagExpression = parent.parent.parent; // If we're just after a template tail, don't show signature help. - if (node.kind === 16 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (ts.isTemplateTail(node) && !ts.isInsideTemplateLiteral(node, position, sourceFile)) { return undefined; } - var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); - var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); + var spanIndex = templateSpan.parent.templateSpans.indexOf(templateSpan); + var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position, sourceFile); return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent && ts.isJsxOpeningLikeElement(node.parent)) { + else if (ts.isJsxOpeningLikeElement(parent)) { // Provide a signature help for JSX opening element or JSX self-closing element. // This is not guarantee that JSX tag-name is resolved into stateless function component. (that is done in "getSignatureHelpItems") // i.e // export function MainButton(props: ButtonProps, context: any): JSX.Element { ... } // 0 && ts.lastOrUndefined(listChildren).kind === 26 /* CommaToken */) { + if (listChildren.length > 0 && ts.last(listChildren).kind === 26 /* CommaToken */) { argumentCount++; } return argumentCount; } // spanIndex is either the index for a given template span. // This does not give appropriate results for a NoSubstitutionTemplateLiteral - function getArgumentIndexForTemplatePiece(spanIndex, node, position) { + function getArgumentIndexForTemplatePiece(spanIndex, node, position, sourceFile) { // Because the TemplateStringsArray is the first argument, we have to offset each substitution expression by 1. // There are three cases we can encounter: // 1. We are precisely in the template literal (argIndex = 0). @@ -95167,8 +95752,8 @@ var ts; // Case: 1 1 3 2 1 3 2 2 1 // tslint:enable no-double-space ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); - if (ts.isTemplateLiteralKind(node.kind)) { - if (ts.isInsideTemplateLiteral(node, position)) { + if (ts.isTemplateLiteralToken(node)) { + if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { return 0; } return spanIndex + 2; @@ -95183,7 +95768,7 @@ var ts; } return { kind: 2 /* TaggedTemplateArguments */, - invocation: tagExpression, + invocation: { kind: 0 /* Call */, node: tagExpression }, argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile), argumentIndex: argumentIndex, argumentCount: argumentCount @@ -95214,8 +95799,8 @@ 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 === 201 /* TemplateExpression */) { - var lastSpan = ts.lastOrUndefined(template.templateSpans); + if (template.kind === 202 /* TemplateExpression */) { + var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); } @@ -95223,39 +95808,40 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 273 /* SourceFile */; n = n.parent) { - if (ts.isFunctionBlock(n)) { - return undefined; - } + var _loop_19 = 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. - if (n.pos < n.parent.pos || n.end > n.parent.end) { - ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); - } + ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.showSyntaxKind(n) + ", parent: " + ts.Debug.showSyntaxKind(n.parent); }); var argumentInfo = getImmediatelyContainingArgumentInfo(n, position, sourceFile); if (argumentInfo) { - return argumentInfo; + return { value: argumentInfo }; } - // TODO: Handle generic call with incomplete syntax + }; + for (var n = node; !ts.isBlock(n) && !ts.isSourceFile(n); n = n.parent) { + var state_7 = _loop_19(n); + if (typeof state_7 === "object") + return state_7.value; } return undefined; } - SignatureHelp.getContainingArgumentInfo = getContainingArgumentInfo; function getChildListThatStartsWithOpenerToken(parent, openerToken, sourceFile) { var children = parent.getChildren(sourceFile); var indexOfOpenerToken = children.indexOf(openerToken); ts.Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1); return children[indexOfOpenerToken + 1]; } + function getExpressionFromInvocation(invocation) { + return invocation.kind === 0 /* Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; + } var signatureHelpNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 3112960 /* IgnoreErrors */; - function createSignatureHelpItems(candidates, resolvedSignature, argumentListInfo, typeChecker) { + function createSignatureHelpItems(candidates, resolvedSignature, argumentListInfo, sourceFile, typeChecker) { var argumentCount = argumentListInfo.argumentCount, applicableSpan = argumentListInfo.argumentsSpan, invocation = argumentListInfo.invocation, argumentIndex = argumentListInfo.argumentIndex; var isTypeParameterList = argumentListInfo.kind === 0 /* TypeArguments */; - var callTarget = ts.getInvokedExpression(invocation); - var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); + var enclosingDeclaration = invocation.kind === 0 /* Call */ ? invocation.node : invocation.called; + var callTargetSymbol = typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)); var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); var printer = ts.createPrinter({ removeComments: true }); - var items = ts.map(candidates, function (candidateSignature) { + var items = candidates.map(function (candidateSignature) { var signatureHelpParameters; var prefixDisplayParts = []; var suffixDisplayParts = []; @@ -95270,9 +95856,9 @@ var ts; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : ts.emptyArray; suffixDisplayParts.push(ts.punctuationPart(29 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { - var thisParameter = candidateSignature.thisParameter ? [typeChecker.symbolToParameterDeclaration(candidateSignature.thisParameter, invocation, signatureHelpNodeBuilderFlags)] : []; - var params = ts.createNodeArray(thisParameter.concat(ts.map(candidateSignature.parameters, function (param) { return typeChecker.symbolToParameterDeclaration(param, invocation, signatureHelpNodeBuilderFlags); }))); - printer.writeList(1296 /* CallExpressionArguments */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var thisParameter = candidateSignature.thisParameter ? [typeChecker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; + var params = ts.createNodeArray(thisParameter.concat(candidateSignature.parameters.map(function (param) { return typeChecker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); + printer.writeList(1296 /* CallExpressionArguments */, params, sourceFile, writer); }); ts.addRange(suffixDisplayParts, parameterParts); } @@ -95280,8 +95866,8 @@ var ts; isVariadic = candidateSignature.hasRestParameter; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { - var args = ts.createNodeArray(ts.map(candidateSignature.typeParameters, function (p) { return typeChecker.typeParameterToDeclaration(p, invocation); })); - printer.writeList(26896 /* TypeParameters */, args, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var args = ts.createNodeArray(candidateSignature.typeParameters.map(function (p) { return typeChecker.typeParameterToDeclaration(p, enclosingDeclaration); })); + printer.writeList(26896 /* TypeParameters */, args, sourceFile, writer); } }); ts.addRange(prefixDisplayParts, typeParameterParts); @@ -95294,10 +95880,10 @@ var ts; writer.writeSpace(" "); var predicate = typeChecker.getTypePredicateOfSignature(candidateSignature); if (predicate) { - typeChecker.writeTypePredicate(predicate, invocation, /*flags*/ undefined, writer); + typeChecker.writeTypePredicate(predicate, enclosingDeclaration, /*flags*/ undefined, writer); } else { - typeChecker.writeType(typeChecker.getReturnTypeOfSignature(candidateSignature), invocation, /*flags*/ undefined, writer); + typeChecker.writeType(typeChecker.getReturnTypeOfSignature(candidateSignature), enclosingDeclaration, /*flags*/ undefined, writer); } }); ts.addRange(suffixDisplayParts, returnTypeParts); @@ -95319,8 +95905,8 @@ var ts; return { items: items, applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; function createSignatureHelpParameterForParameter(parameter) { var displayParts = ts.mapToDisplayParts(function (writer) { - var param = typeChecker.symbolToParameterDeclaration(parameter, invocation, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var param = typeChecker.symbolToParameterDeclaration(parameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); + printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); }); return { name: parameter.name, @@ -95331,8 +95917,8 @@ var ts; } function createSignatureHelpParameterForTypeParameter(typeParameter) { var displayParts = ts.mapToDisplayParts(function (writer) { - var param = typeChecker.typeParameterToDeclaration(typeParameter, invocation); - printer.writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var param = typeChecker.typeParameterToDeclaration(typeParameter, enclosingDeclaration); + printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); }); return { name: typeParameter.symbol.name, @@ -95347,9 +95933,8 @@ var ts; /* @internal */ var ts; (function (ts) { - function computeSuggestionDiagnostics(sourceFile, program) { - program.getSemanticDiagnostics(sourceFile); - var checker = program.getDiagnosticsProducingTypeChecker(); + function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) { + program.getSemanticDiagnostics(sourceFile, cancellationToken); var diags = []; if (sourceFile.commonJsModuleIndicator && (ts.programContainsEs6Modules(program) || ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) && @@ -95357,40 +95942,10 @@ var ts; diags.push(ts.createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module)); } var isJsFile = ts.isSourceFileJavaScript(sourceFile); - function check(node) { - switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - if (isJsFile) { - var symbol = node.symbol; - if (symbol.members && (symbol.members.size > 0)) { - diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); - } - } - break; - } - if (!isJsFile && ts.codefix.parameterShouldGetTypeFromJSDoc(node)) { - diags.push(ts.createDiagnosticForNode(node.name || node, ts.Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types)); - } - node.forEachChild(check); - } check(sourceFile); - if (!isJsFile) { - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (ts.isVariableStatement(statement) && - statement.declarationList.flags & 2 /* Const */ && - statement.declarationList.declarations.length === 1) { - var init = statement.declarationList.declarations[0].initializer; - if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) { - diags.push(ts.createDiagnosticForNode(init, ts.Diagnostics.require_call_may_be_converted_to_an_import)); - } - } - } - } if (ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())) { - for (var _b = 0, _c = sourceFile.imports; _b < _c.length; _b++) { - var moduleSpecifier = _c[_b]; + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var moduleSpecifier = _a[_i]; var importNode = ts.importFromModuleSpecifier(moduleSpecifier); var name = importNameForConvertToDefaultImport(importNode); if (!name) @@ -95402,18 +95957,57 @@ var ts; } } } - return diags.concat(checker.getSuggestionDiagnostics(sourceFile)).sort(function (d1, d2) { return d1.start - d2.start; }); + ts.addRange(diags, sourceFile.bindSuggestionDiagnostics); + ts.addRange(diags, program.getSuggestionDiagnostics(sourceFile, cancellationToken)); + return diags.sort(function (d1, d2) { return d1.start - d2.start; }); + function check(node) { + if (isJsFile) { + switch (node.kind) { + case 192 /* FunctionExpression */: + var decl = ts.getDeclarationOfJSInitializer(node); + if (decl) { + var symbol_3 = decl.symbol; + if (symbol_3 && (symbol_3.exports && symbol_3.exports.size || symbol_3.members && symbol_3.members.size)) { + diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); + break; + } + } + // falls through if no diagnostic was created + case 234 /* FunctionDeclaration */: + var symbol = node.symbol; + if (symbol.members && (symbol.members.size > 0)) { + diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); + } + break; + } + } + else { + if (ts.isVariableStatement(node) && + node.parent === sourceFile && + node.declarationList.flags & 2 /* Const */ && + node.declarationList.declarations.length === 1) { + var init = node.declarationList.declarations[0].initializer; + if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) { + diags.push(ts.createDiagnosticForNode(init, ts.Diagnostics.require_call_may_be_converted_to_an_import)); + } + } + if (ts.codefix.parameterShouldGetTypeFromJSDoc(node)) { + diags.push(ts.createDiagnosticForNode(node.name || node, ts.Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types)); + } + } + node.forEachChild(check); + } } ts.computeSuggestionDiagnostics = computeSuggestionDiagnostics; // convertToEs6Module only works on top-level, so don't trigger it if commonjs code only appears in nested scopes. function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); - }); - case 215 /* ExpressionStatement */: { + }); // TODO: GH#18217 + case 216 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -95430,12 +96024,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings.kind === 245 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 246 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -95458,7 +96052,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 204 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -95546,11 +96140,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 256 /* JsxOpeningElement */: - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: return location.kind === 71 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -95576,7 +96170,7 @@ var ts; var tags; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - var hasAddedSymbolInfo; + var hasAddedSymbolInfo = false; var isThisExpression = location.kind === 99 /* ThisKeyword */ && ts.isExpression(location); var type; var printer; @@ -95590,7 +96184,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 184 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 185 /* 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)) { @@ -95610,8 +96204,8 @@ var ts; } if (callExpressionLike) { var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); - var useConstructSignatures = callExpressionLike.kind === 187 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); // TODO: GH#18217 + var useConstructSignatures = callExpressionLike.kind === 188 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -95666,7 +96260,7 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 154 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 155 /* 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 @@ -95674,21 +96268,21 @@ var ts; return declaration === (location.kind === 123 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 154 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 155 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { - signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); + signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 154 /* Constructor */) { + if (functionDeclaration_1.kind === 155 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 157 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 158 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -95698,7 +96292,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 204 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 205 /* 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 @@ -95742,7 +96336,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 238 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 239 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 130 /* NamespaceKeyword */ : 129 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -95763,23 +96357,24 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 147 /* TypeParameter */); - ts.Debug.assert(decl !== undefined); + var decl = ts.getDeclarationOfKind(symbol, 148 /* TypeParameter */); + if (decl === undefined) + return ts.Debug.fail(); var declaration = decl.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); - var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 158 /* ConstructSignature */) { + var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 + if (declaration.kind === 159 /* ConstructSignature */) { displayParts.push(ts.keywordPart(94 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 157 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 158 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 236 /* TypeAliasDeclaration */) { + else if (declaration.kind === 237 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -95796,7 +96391,7 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 272 /* EnumMember */) { + if (declaration.kind === 273 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -95826,17 +96421,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(130 /* NamespaceKeyword */)); break; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 58 /* EqualsToken */ : 79 /* DefaultKeyword */)); break; - case 251 /* ExportSpecifier */: + case 252 /* ExportSpecifier */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); break; default: @@ -95845,7 +96440,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 242 /* ImportEqualsDeclaration */) { + if (declaration.kind === 243 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -95923,10 +96518,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 === 273 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 274 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 199 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 200 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -96009,6 +96604,7 @@ var ts; } } function addSignatureDisplayParts(signature, allSignatures, flags) { + if (flags === void 0) { flags = 0 /* None */; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); @@ -96037,16 +96633,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 191 /* FunctionExpression */) { + if (declaration.kind === 192 /* FunctionExpression */) { return true; } - if (declaration.kind !== 231 /* VariableDeclaration */ && declaration.kind !== 233 /* FunctionDeclaration */) { + if (declaration.kind !== 232 /* VariableDeclaration */ && declaration.kind !== 234 /* 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 === 273 /* SourceFile */ || parent.kind === 239 /* ModuleBlock */) { + if (parent.kind === 274 /* SourceFile */ || parent.kind === 240 /* ModuleBlock */) { return false; } } @@ -96094,7 +96690,7 @@ var ts; options.noResolve = true; // if jsx is specified then treat file as .tsx var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); - var sourceFile = ts.createSourceFile(inputFileName, input, options.target); + var sourceFile = ts.createSourceFile(inputFileName, input, options.target); // TODO: GH#18217 if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; } @@ -96135,7 +96731,8 @@ var ts; } // Emit program.emit(/*targetSourceFile*/ undefined, /*writeFile*/ undefined, /*cancellationToken*/ undefined, /*emitOnlyDtsFiles*/ undefined, transpileOptions.transformers); - ts.Debug.assert(outputText !== undefined, "Output generation failed"); + if (outputText === undefined) + return ts.Debug.fail("Output generation failed"); return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; } ts.transpileModule = transpileModule; @@ -96158,7 +96755,7 @@ var ts; return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.cloneCompilerOptions(options); - var _loop_17 = function (opt) { + var _loop_20 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -96177,7 +96774,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_17(opt); + _loop_20(opt); } return options; } @@ -96314,7 +96911,7 @@ var ts; lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - wasNewLine = trailingTrivia && ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */; + wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* NewLineTrivia */; } else { scanner.scan(); @@ -96354,10 +96951,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 261 /* JsxAttribute */: - case 256 /* JsxOpeningElement */: - case 257 /* JsxClosingElement */: - case 255 /* JsxSelfClosingElement */: + case 262 /* JsxAttribute */: + case 257 /* JsxOpeningElement */: + case 258 /* JsxClosingElement */: + case 256 /* 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 === 71 /* Identifier */; } @@ -96534,7 +97131,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 144 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 145 /* LastToken */; token++) { allTokens.push(token); } function anyTokenExcept() { @@ -96546,9 +97143,9 @@ var ts; } var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(72 /* FirstKeyword */, 144 /* LastKeyword */); + var keywords = tokenRangeFromRange(72 /* FirstKeyword */, 145 /* LastKeyword */); var binaryOperators = tokenRangeFromRange(27 /* FirstBinaryOperator */, 70 /* LastBinaryOperator */); - var binaryKeywordOperators = [92 /* InKeyword */, 93 /* InstanceOfKeyword */, 144 /* OfKeyword */, 118 /* AsKeyword */, 127 /* IsKeyword */]; + var binaryKeywordOperators = [92 /* InKeyword */, 93 /* InstanceOfKeyword */, 145 /* OfKeyword */, 118 /* AsKeyword */, 127 /* IsKeyword */]; var unaryPrefixOperators = [43 /* PlusPlusToken */, 44 /* MinusMinusToken */, 52 /* TildeToken */, 51 /* ExclamationToken */]; var unaryPrefixExpressions = [ 8 /* NumericLiteral */, 71 /* Identifier */, 19 /* OpenParenToken */, 21 /* OpenBracketToken */, @@ -96669,11 +97266,11 @@ var ts; 136 /* SetKeyword */, 115 /* StaticKeyword */, 139 /* TypeKeyword */, - 142 /* FromKeyword */, + 143 /* FromKeyword */, 128 /* KeyOfKeyword */, 126 /* InferKeyword */, ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [85 /* ExtendsKeyword */, 108 /* ImplementsKeyword */, 142 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [85 /* ExtendsKeyword */, 108 /* ImplementsKeyword */, 143 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), // 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", 9 /* StringLiteral */, 17 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), // Lambda expressions @@ -96838,45 +97435,45 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 219 /* ForStatement */; + return context.contextNode.kind === 220 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 199 /* BinaryExpression */: - case 200 /* ConditionalExpression */: - case 170 /* ConditionalType */: - case 207 /* AsExpression */: - case 251 /* ExportSpecifier */: - case 247 /* ImportSpecifier */: - case 160 /* TypePredicate */: - case 168 /* UnionType */: - case 169 /* IntersectionType */: + case 200 /* BinaryExpression */: + case 201 /* ConditionalExpression */: + case 171 /* ConditionalType */: + case 208 /* AsExpression */: + case 252 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 161 /* TypePredicate */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 181 /* BindingElement */: + case 182 /* BindingElement */: // equals in type X = ... - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: // equal in p = 0; - case 148 /* Parameter */: - case 272 /* EnumMember */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 149 /* Parameter */: + case 273 /* EnumMember */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return context.currentTokenSpan.kind === 58 /* EqualsToken */ || context.nextTokenSpan.kind === 58 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return context.currentTokenSpan.kind === 92 /* InKeyword */ || context.nextTokenSpan.kind === 92 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 221 /* ForOfStatement */: - return context.currentTokenSpan.kind === 144 /* OfKeyword */ || context.nextTokenSpan.kind === 144 /* OfKeyword */; + case 222 /* ForOfStatement */: + return context.currentTokenSpan.kind === 145 /* OfKeyword */ || context.nextTokenSpan.kind === 145 /* OfKeyword */; } return false; } @@ -96888,22 +97485,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 151 /* PropertyDeclaration */ || - contextKind === 150 /* PropertySignature */ || - contextKind === 148 /* Parameter */ || - contextKind === 231 /* VariableDeclaration */ || + return contextKind === 152 /* PropertyDeclaration */ || + contextKind === 151 /* PropertySignature */ || + contextKind === 149 /* Parameter */ || + contextKind === 232 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 200 /* ConditionalExpression */ || - context.contextNode.kind === 170 /* ConditionalType */; + return context.contextNode.kind === 201 /* ConditionalExpression */ || + context.contextNode.kind === 171 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 179 /* ObjectBindingPattern */ || - context.contextNode.kind === 176 /* MappedType */ || + return context.contextNode.kind === 180 /* ObjectBindingPattern */ || + context.contextNode.kind === 177 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -96929,31 +97526,31 @@ var ts; return true; } switch (node.kind) { - case 212 /* Block */: - case 240 /* CaseBlock */: - case 183 /* ObjectLiteralExpression */: - case 239 /* ModuleBlock */: + case 213 /* Block */: + case 241 /* CaseBlock */: + case 184 /* ObjectLiteralExpression */: + case 240 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 157 /* CallSignature */: - case 191 /* FunctionExpression */: - case 154 /* Constructor */: - case 192 /* ArrowFunction */: + case 158 /* CallSignature */: + case 192 /* FunctionExpression */: + case 155 /* Constructor */: + case 193 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 235 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 236 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -96962,40 +97559,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 233 /* FunctionDeclaration */ || context.contextNode.kind === 191 /* FunctionExpression */; + return context.contextNode.kind === 234 /* FunctionDeclaration */ || context.contextNode.kind === 192 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 165 /* TypeLiteral */: - case 238 /* ModuleDeclaration */: - case 249 /* ExportDeclaration */: - case 250 /* NamedExports */: - case 243 /* ImportDeclaration */: - case 246 /* NamedImports */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 166 /* TypeLiteral */: + case 239 /* ModuleDeclaration */: + case 250 /* ExportDeclaration */: + case 251 /* NamedExports */: + case 244 /* ImportDeclaration */: + case 247 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 234 /* ClassDeclaration */: - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 268 /* CatchClause */: - case 239 /* ModuleBlock */: - case 226 /* SwitchStatement */: + case 235 /* ClassDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 269 /* CatchClause */: + case 240 /* ModuleBlock */: + case 227 /* SwitchStatement */: return true; - case 212 /* Block */: { + case 213 /* 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 !== 192 /* ArrowFunction */ && blockParent.kind !== 191 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 193 /* ArrowFunction */ && blockParent.kind !== 192 /* FunctionExpression */) { return true; } } @@ -97004,31 +97601,31 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 216 /* IfStatement */: - case 226 /* SwitchStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 218 /* WhileStatement */: - case 229 /* TryStatement */: - case 217 /* DoStatement */: - case 225 /* WithStatement */: + case 217 /* IfStatement */: + case 227 /* SwitchStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 219 /* WhileStatement */: + case 230 /* TryStatement */: + case 218 /* DoStatement */: + case 226 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 268 /* CatchClause */: + case 269 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 183 /* ObjectLiteralExpression */; + return context.contextNode.kind === 184 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 186 /* CallExpression */; + return context.contextNode.kind === 187 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 187 /* NewExpression */; + return context.contextNode.kind === 188 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -97040,35 +97637,35 @@ var ts; return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 192 /* ArrowFunction */; + return context.contextNode.kind === 193 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 178 /* ImportType */; + return context.contextNode.kind === 179 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 254 /* JsxElement */ && context.contextNode.kind !== 258 /* JsxFragment */; + return context.contextNode.kind !== 255 /* JsxElement */ && context.contextNode.kind !== 259 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 264 /* JsxExpression */ || context.contextNode.kind === 263 /* JsxSpreadAttribute */; + return context.contextNode.kind === 265 /* JsxExpression */ || context.contextNode.kind === 264 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 261 /* JsxAttribute */; + return context.nextTokenParent.kind === 262 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 261 /* JsxAttribute */; + return context.contextNode.kind === 262 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 255 /* JsxSelfClosingElement */; + return context.contextNode.kind === 256 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); } function isEndOfDecoratorContextOnSameLine(context) { return context.TokensAreOnSameLine() && - context.contextNode.decorators && + !!context.contextNode.decorators && nodeIsInDecoratorContext(context.currentTokenParent) && !nodeIsInDecoratorContext(context.nextTokenParent); } @@ -97076,45 +97673,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 149 /* Decorator */; + return node.kind === 150 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 232 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 233 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 238 /* ModuleDeclaration */; + return context.contextNode.kind === 239 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 165 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 166 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 158 /* ConstructSignature */; + return context.contextNode.kind === 159 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 27 /* LessThanToken */ && token.kind !== 29 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 161 /* TypeReference */: - case 189 /* TypeAssertionExpression */: - case 236 /* TypeAliasDeclaration */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 206 /* ExpressionWithTypeArguments */: + case 162 /* TypeReference */: + case 190 /* TypeAssertionExpression */: + case 237 /* TypeAliasDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 207 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -97125,16 +97722,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 189 /* TypeAssertionExpression */; + return context.contextNode.kind === 190 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 195 /* VoidExpression */; + return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 196 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 202 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 203 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 208 /* NonNullExpression */; + return context.contextNode.kind === 209 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -97185,12 +97782,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 144 /* LastKeyword */ && column <= 144 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 145 /* LastKeyword */ && column <= 145 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 144 /* LastToken */ + 1; + var mapRowLength = 145 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; @@ -97368,17 +97965,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 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 239 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 273 /* SourceFile */: - case 212 /* Block */: - case 239 /* ModuleBlock */: + return !!body && body.kind === 240 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 274 /* SourceFile */: + case 213 /* Block */: + case 240 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -97407,7 +98004,7 @@ var ts; } // pick only errors that fall in range var sorted = errors - .filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }) + .filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }) // TODO: GH#18217 .sort(function (e1, e2) { return e1.start - e2.start; }); if (!sorted.length) { return rangeHasNoErrors; @@ -97535,7 +98132,7 @@ var ts; if (!formattingScanner.isOnToken()) { var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { - processTrivia(leadingTrivia, enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); + processTrivia(leadingTrivia, enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); // TODO: GH#18217 trimTrailingWhitespacesForRemainingRange(); } } @@ -97601,19 +98198,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 234 /* ClassDeclaration */: return 75 /* ClassKeyword */; - case 235 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; - case 233 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; - case 237 /* EnumDeclaration */: return 237 /* EnumDeclaration */; - case 155 /* GetAccessor */: return 125 /* GetKeyword */; - case 156 /* SetAccessor */: return 136 /* SetKeyword */; - case 153 /* MethodDeclaration */: + case 235 /* ClassDeclaration */: return 75 /* ClassKeyword */; + case 236 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; + case 234 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; + case 238 /* EnumDeclaration */: return 238 /* EnumDeclaration */; + case 156 /* GetAccessor */: return 125 /* GetKeyword */; + case 157 /* SetAccessor */: return 136 /* SetKeyword */; + case 154 /* MethodDeclaration */: if (node.asteriskToken) { return 39 /* AsteriskToken */; } // falls through - case 151 /* PropertyDeclaration */: - case 148 /* Parameter */: + case 152 /* PropertyDeclaration */: + case 149 /* Parameter */: return ts.getNameOfDeclaration(node).kind; } } @@ -97658,15 +98255,15 @@ var ts; case 41 /* SlashToken */: case 29 /* GreaterThanToken */: switch (container.kind) { - case 256 /* JsxOpeningElement */: - case 257 /* JsxClosingElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 258 /* JsxClosingElement */: + case 256 /* JsxSelfClosingElement */: return false; } break; case 21 /* OpenBracketToken */: case 22 /* CloseBracketToken */: - if (container.kind !== 176 /* MappedType */) { + if (container.kind !== 177 /* MappedType */) { return false; } break; @@ -97758,7 +98355,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 149 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 150 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); if (child.kind === 10 /* JsxText */) { @@ -97766,7 +98363,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 182 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 183 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -97896,6 +98493,7 @@ var ts; } } } + // TODO: GH#18217 use an enum instead of `boolean | undefined` function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); var lineAction = 0 /* None */; @@ -98177,12 +98775,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 154 /* Constructor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 192 /* ArrowFunction */: + case 155 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 193 /* ArrowFunction */: if (node.typeParameters === list) { return 27 /* LessThanToken */; } @@ -98190,8 +98788,8 @@ var ts; return 19 /* OpenParenToken */; } break; - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: if (node.typeArguments === list) { return 27 /* LessThanToken */; } @@ -98199,7 +98797,7 @@ var ts; return 19 /* OpenParenToken */; } break; - case 161 /* TypeReference */: + case 162 /* TypeReference */: if (node.typeArguments === list) { return 27 /* LessThanToken */; } @@ -98316,7 +98914,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 199 /* BinaryExpression */) { + if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 200 /* 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 */) { @@ -98368,7 +98966,7 @@ var ts; // handle cases when codefix is about to be inserted before the close brace ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* CloseBrace */ ? options.indentSize : 0 : lineAtPosition !== currentStart.line ? options.indentSize : 0; - return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); + return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } // check if current node is a list item - if yes, take indentation from it var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); @@ -98377,7 +98975,7 @@ var ts; } actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + options.indentSize; + return actualIndentation + options.indentSize; // TODO: GH#18217 } previous = current; current = current.parent; @@ -98472,7 +99070,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 === 273 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 274 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -98520,7 +99118,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 216 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 217 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -98536,40 +99134,40 @@ var ts; if (node.parent) { var end = node.end; switch (node.parent.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), end); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return node.parent.properties; - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return node.parent.elements; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 154 /* Constructor */: - case 163 /* ConstructorType */: - case 158 /* ConstructSignature */: { + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 155 /* Constructor */: + case 164 /* ConstructorType */: + case 159 /* ConstructSignature */: { var start = node.getStart(sourceFile); return getListIfStartEndIsInListRange(node.parent.typeParameters, start, end) || getListIfStartEndIsInListRange(node.parent.parameters, start, end); } - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return getListIfStartEndIsInListRange(node.parent.typeParameters, node.getStart(sourceFile), end); - case 187 /* NewExpression */: - case 186 /* CallExpression */: { + case 188 /* NewExpression */: + case 187 /* CallExpression */: { var start = node.getStart(sourceFile); return getListIfStartEndIsInListRange(node.parent.typeArguments, start, end) || getListIfStartEndIsInListRange(node.parent.arguments, start, end); } - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), end); - case 246 /* NamedImports */: - case 250 /* NamedExports */: + case 247 /* NamedImports */: + case 251 /* NamedExports */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); } } @@ -98609,10 +99207,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: node = node.expression; break; default: @@ -98674,91 +99272,89 @@ var ts; return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; } SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; - function nodeContentIsAlwaysIndented(kind) { - switch (kind) { - case 215 /* ExpressionStatement */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 182 /* ArrayLiteralExpression */: - case 212 /* Block */: - case 239 /* ModuleBlock */: - case 183 /* ObjectLiteralExpression */: - case 165 /* TypeLiteral */: - case 176 /* MappedType */: - case 167 /* TupleType */: - case 240 /* CaseBlock */: - case 266 /* DefaultClause */: - case 265 /* CaseClause */: - case 190 /* ParenthesizedExpression */: - case 184 /* PropertyAccessExpression */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 213 /* VariableStatement */: - case 231 /* VariableDeclaration */: - case 248 /* ExportAssignment */: - case 224 /* ReturnStatement */: - case 200 /* ConditionalExpression */: - case 180 /* ArrayBindingPattern */: - case 179 /* ObjectBindingPattern */: - case 256 /* JsxOpeningElement */: - case 259 /* JsxOpeningFragment */: - case 255 /* JsxSelfClosingElement */: - case 264 /* JsxExpression */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 148 /* Parameter */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 172 /* ParenthesizedType */: - case 188 /* TaggedTemplateExpression */: - case 196 /* AwaitExpression */: - case 250 /* NamedExports */: - case 246 /* NamedImports */: - case 251 /* ExportSpecifier */: - case 247 /* ImportSpecifier */: - case 269 /* PropertyAssignment */: - case 151 /* PropertyDeclaration */: - return true; - } - return false; - } function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 231 /* VariableDeclaration */: - case 269 /* PropertyAssignment */: - case 183 /* ObjectLiteralExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 183 /* ObjectLiteralExpression */) { + case 216 /* ExpressionStatement */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 183 /* ArrayLiteralExpression */: + case 213 /* Block */: + case 240 /* ModuleBlock */: + case 184 /* ObjectLiteralExpression */: + case 166 /* TypeLiteral */: + case 177 /* MappedType */: + case 168 /* TupleType */: + case 241 /* CaseBlock */: + case 267 /* DefaultClause */: + case 266 /* CaseClause */: + case 191 /* ParenthesizedExpression */: + case 185 /* PropertyAccessExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 214 /* VariableStatement */: + case 249 /* ExportAssignment */: + case 225 /* ReturnStatement */: + case 201 /* ConditionalExpression */: + case 181 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningFragment */: + case 256 /* JsxSelfClosingElement */: + case 265 /* JsxExpression */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 149 /* Parameter */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 173 /* ParenthesizedType */: + case 189 /* TaggedTemplateExpression */: + case 197 /* AwaitExpression */: + case 251 /* NamedExports */: + case 247 /* NamedImports */: + case 252 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 152 /* PropertyDeclaration */: + return true; + case 232 /* VariableDeclaration */: + case 270 /* PropertyAssignment */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 184 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - break; - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 219 /* ForStatement */: - case 216 /* IfStatement */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 192 /* ArrowFunction */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - return childKind !== 212 /* Block */; - case 249 /* ExportDeclaration */: - return childKind !== 250 /* NamedExports */; - case 243 /* ImportDeclaration */: - return childKind !== 244 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 246 /* NamedImports */); - case 254 /* JsxElement */: - return childKind !== 257 /* JsxClosingElement */; - case 258 /* JsxFragment */: - return childKind !== 260 /* JsxClosingFragment */; + return true; + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 220 /* ForStatement */: + case 217 /* IfStatement */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 193 /* ArrowFunction */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + return childKind !== 213 /* Block */; + case 250 /* ExportDeclaration */: + return childKind !== 251 /* NamedExports */; + case 244 /* ImportDeclaration */: + return childKind !== 245 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 247 /* NamedImports */); + case 255 /* JsxElement */: + return childKind !== 258 /* JsxClosingElement */; + case 259 /* JsxFragment */: + return childKind !== 261 /* JsxClosingFragment */; + case 170 /* IntersectionType */: + case 169 /* UnionType */: + if (childKind === 166 /* TypeLiteral */) { + return false; + } + // falls through } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -98766,17 +99362,17 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 224 /* ReturnStatement */: - case 228 /* ThrowStatement */: { - if (parent.kind !== 212 /* Block */) { + case 225 /* ReturnStatement */: + case 229 /* ThrowStatement */: { + if (parent.kind !== 213 /* Block */) { return true; } var grandParent = parent.parent; // In a function, we may want to write inner functions after this. - return !(grandParent && grandParent.kind === 191 /* FunctionExpression */ || grandParent.kind === 233 /* FunctionDeclaration */); + return !(grandParent && grandParent.kind === 192 /* FunctionExpression */ || grandParent.kind === 234 /* FunctionDeclaration */); } - case 222 /* ContinueStatement */: - case 223 /* BreakStatement */: + case 223 /* ContinueStatement */: + case 224 /* BreakStatement */: return true; default: return false; @@ -98788,7 +99384,7 @@ var ts; */ function shouldIndentChildNode(settings, parent, child, sourceFile, isNextChild) { if (isNextChild === void 0) { isNextChild = false; } - return (nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(settings, parent, child, sourceFile, /*indentByDefault*/ false)) + return nodeWillIndentChild(settings, parent, child, sourceFile, /*indentByDefault*/ false) && !(isNextChild && child && isControlFlowEndingStatement(child.kind, parent)); } SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; @@ -98905,7 +99501,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 === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 183 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 184 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -98951,6 +99547,12 @@ var ts; this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); return this; }; + ChangeTracker.prototype.deleteNodeRangeExcludingEnd = function (sourceFile, startNode, afterEndNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); + var endPosition = afterEndNode === undefined ? sourceFile.text.length : getAdjustedStartPosition(sourceFile, afterEndNode, options, Position.FullStart); + this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + }; ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { var containingList = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); if (!containingList) { @@ -99064,7 +99666,7 @@ var ts; } } else { - endNode = node.kind !== 231 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 232 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -99168,7 +99770,7 @@ var ts; else if (ts.isStatement(node) || ts.isClassOrTypeElement(node)) { return { suffix: this.newLineCharacter }; } - else if (ts.isVariableDeclaration(node)) { + else if (ts.isVariableDeclaration(node) || ts.isStringLiteral(node)) { return { prefix: ", " }; } else if (ts.isPropertyAssignment(node)) { @@ -99181,7 +99783,7 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 192 /* ArrowFunction */) { + if (node.kind === 193 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 36 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 19 /* OpenParenToken */, sourceFile); if (lparen) { @@ -99195,14 +99797,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(20 /* CloseParenToken */)); } - if (node.body.kind !== 212 /* Block */) { + if (node.body.kind !== 213 /* Block */) { // `() => 0` => `function f() { return 0; }` this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(17 /* OpenBraceToken */), ts.createToken(96 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(25 /* SemicolonToken */), ts.createToken(18 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 191 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 192 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -99358,7 +99960,7 @@ var ts; var changes = changesToText.getTextChangesFromChanges(this.changes, this.newLineCharacter, this.formatContext, validate); for (var _i = 0, _a = this.newFiles; _i < _a.length; _i++) { var _b = _a[_i], oldFile = _b.oldFile, fileName = _b.fileName, statements = _b.statements; - changes.push(changesToText.newFileChanges(oldFile, fileName, statements, this.newLineCharacter)); + changes.push(changesToText.newFileChanges(oldFile, fileName, statements, this.newLineCharacter, this.formatContext)); } return changes; }; @@ -99383,14 +99985,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_18 = function (i) { + var _loop_21 = 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_18(i); + _loop_21(i); } var textChanges = normalized.map(function (c) { return ts.createTextChange(ts.createTextSpanFromRange(c.range), computeNewText(c, sourceFile, newLineCharacter, formatContext, validate)); @@ -99399,8 +100001,12 @@ var ts; }); } changesToText.getTextChangesFromChanges = getTextChangesFromChanges; - function newFileChanges(oldFile, fileName, statements, newLineCharacter) { - var text = statements.map(function (s) { return getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + function newFileChanges(oldFile, fileName, statements, newLineCharacter, formatContext) { + // TODO: this emits the file, parses it back, then formats it that -- may be a less roundabout way to do this + var nonFormattedText = statements.map(function (s) { return getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + var sourceFile = ts.createSourceFile(fileName, nonFormattedText, 6 /* ESNext */); + var changes = ts.formatting.formatDocument(sourceFile, formatContext); + var text = applyChanges(nonFormattedText, changes); return { fileName: fileName, textChanges: [ts.createTextChange(ts.createTextSpan(0, 0), text)], isNewFile: true }; } changesToText.newFileChanges = newFileChanges; @@ -99414,7 +100020,7 @@ var ts; var _a = change.options, options = _a === void 0 ? {} : _a, pos = change.range.pos; var format = function (n) { return getFormattedTextOfNode(n, sourceFile, pos, options, newLineCharacter, formatContext, validate); }; var text = change.kind === ChangeKind.ReplaceWithMultipleNodes - ? change.nodes.map(function (n) { return ts.removeSuffix(format(n), newLineCharacter); }).join(change.options.joiner || newLineCharacter) + ? change.nodes.map(function (n) { return ts.removeSuffix(format(n), newLineCharacter); }).join(change.options.joiner || newLineCharacter) // TODO: GH#18217 : format(change.node); // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, ""); @@ -99457,7 +100063,7 @@ var ts; return ts.skipTrivia(s, 0) === s.length; } function assignPositionsToNode(node) { - var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); + var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // TODO: GH#18217 // create proxy node for non synthesized nodes var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited); newNode.pos = getPos(node); @@ -99647,7 +100253,7 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 146 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 147 /* ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } })(textChanges = ts.textChanges || (ts.textChanges = {})); @@ -99718,8 +100324,8 @@ var ts; } codefix.codeFixAll = codeFixAll; function eachDiagnostic(_a, errorCodes, cb) { - var program = _a.program, sourceFile = _a.sourceFile; - for (var _i = 0, _b = program.getSemanticDiagnostics(sourceFile).concat(ts.computeSuggestionDiagnostics(sourceFile, program)); _i < _b.length; _i++) { + var program = _a.program, sourceFile = _a.sourceFile, cancellationToken = _a.cancellationToken; + for (var _i = 0, _b = program.getSemanticDiagnostics(sourceFile, cancellationToken).concat(ts.computeSuggestionDiagnostics(sourceFile, program, cancellationToken)); _i < _b.length; _i++) { var diag = _b[_i]; if (ts.contains(errorCodes, diag.code)) { cb(diag); @@ -99855,29 +100461,29 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 231 /* VariableDeclaration */ || - node.kind === 150 /* PropertySignature */ || - node.kind === 151 /* PropertyDeclaration */; + node.kind === 232 /* VariableDeclaration */ || + node.kind === 151 /* PropertySignature */ || + node.kind === 152 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 278 /* JSDocAllType */: - case 279 /* JSDocUnknownType */: + case 279 /* JSDocAllType */: + case 280 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 282 /* JSDocOptionalType */: + case 283 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 281 /* JSDocNonNullableType */: + case 282 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 280 /* JSDocNullableType */: + case 281 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return transformJSDocTypeReference(node); default: - var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); + var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 ts.setEmitFlags(visited, 1 /* SingleLine */); return visited; } @@ -99896,7 +100502,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 284 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; + var isRest = node.type.kind === 285 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(24 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -99972,16 +100578,16 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: precedingNode = ctorDeclaration; deleteNode(ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { - copyComments(precedingNode, newClassDeclaration, sourceFile); + copyComments(precedingNode, newClassDeclaration, sourceFile); // TODO: GH#18217 deleteNode(precedingNode); } else { @@ -100048,7 +100654,7 @@ var ts; return; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 215 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 216 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; deleteNode(nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -100056,7 +100662,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 191 /* FunctionExpression */: { + case 192 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 120 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, @@ -100064,12 +100670,12 @@ var ts; copyComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 192 /* ArrowFunction */: { + case 193 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 212 /* Block */) { + if (arrowFunctionBody.kind === 213 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -100097,13 +100703,13 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 191 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 192 /* FunctionExpression */) { return undefined; } if (node.name.kind !== 71 /* Identifier */) { return undefined; } - var memberElements = createClassElementsFromSymbol(initializer.symbol); + var memberElements = createClassElementsFromSymbol(node.symbol); if (initializer.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } @@ -100153,13 +100759,13 @@ var ts; codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module.code], getCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program; + var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { - var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, program.getCompilerOptions().target); + var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, program.getCompilerOptions().target, preferences); if (moduleExportsChangedToDefault) { for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var importingFile = _a[_i]; - fixImportOfModuleExports(importingFile, sourceFile, changes); + fixImportOfModuleExports(importingFile, sourceFile, changes, preferences); } } }); @@ -100167,7 +100773,7 @@ var ts; return [codefix.createCodeFixActionNoFixId("convertToEs6Module", changes, ts.Diagnostics.Convert_to_ES6_module)]; }, }); - function fixImportOfModuleExports(importingFile, exportingFile, changes) { + function fixImportOfModuleExports(importingFile, exportingFile, changes, preferences) { for (var _i = 0, _a = importingFile.imports; _i < _a.length; _i++) { var moduleSpecifier = _a[_i]; var imported = ts.getResolvedModule(importingFile, moduleSpecifier.text); @@ -100176,10 +100782,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 242 /* ImportEqualsDeclaration */: - changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier)); + case 243 /* ImportEqualsDeclaration */: + changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, preferences)); break; - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -100188,14 +100794,14 @@ var ts; } } /** @returns Whether we converted a `module.exports =` to a default export. */ - function convertFileToEs6Module(sourceFile, checker, changes, target) { + function convertFileToEs6Module(sourceFile, checker, changes, target, preferences) { var identifiers = { original: collectFreeIdentifiers(sourceFile), additional: ts.createMap() }; var exports = collectExportRenames(sourceFile, checker, identifiers); convertExportsAccesses(sourceFile, exports, changes); var moduleExportsChangedToDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - var moduleExportsChanged = convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports); + var moduleExportsChanged = convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, preferences); moduleExportsChangedToDefault = moduleExportsChangedToDefault || moduleExportsChanged; } return moduleExportsChangedToDefault; @@ -100230,22 +100836,22 @@ var ts; node.forEachChild(recur); }); } - function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports) { + function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, preferences) { switch (statement.kind) { - case 213 /* VariableStatement */: - convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target); + case 214 /* VariableStatement */: + convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, preferences); return false; - case 215 /* ExpressionStatement */: { + case 216 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 186 /* CallExpression */: { + case 187 /* 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])); + changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], preferences)); } return false; } - case 199 /* BinaryExpression */: { + case 200 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 58 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } @@ -100256,7 +100862,7 @@ var ts; return false; } } - function convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target) { + function convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, preferences) { var declarationList = statement.declarationList; var foundImport = false; var newNodes = ts.flatMap(declarationList.declarations, function (decl) { @@ -100269,11 +100875,11 @@ var ts; } else if (ts.isRequireCall(initializer, /*checkArgumentIsStringLiteralLike*/ true)) { foundImport = true; - return convertSingleImport(sourceFile, name, initializer.arguments[0], changes, checker, identifiers, target); + return convertSingleImport(sourceFile, name, initializer.arguments[0], changes, checker, identifiers, target, preferences); } else if (ts.isPropertyAccessExpression(initializer) && ts.isRequireCall(initializer.expression, /*checkArgumentIsStringLiteralLike*/ true)) { foundImport = true; - return convertPropertyAccessImport(name, initializer.name.text, initializer.expression.arguments[0], identifiers); + return convertPropertyAccessImport(name, initializer.name.text, initializer.expression.arguments[0], identifiers, preferences); } } // Move it out to its own variable statement. (This will not be used if `!foundImport`) @@ -100285,22 +100891,22 @@ var ts; } } /** Converts `const name = require("moduleSpecifier").propertyName` */ - function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers) { + function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, preferences) { switch (name.kind) { - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: { + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ - makeSingleImport(tmp, propertyName, moduleSpecifier), + makeSingleImport(tmp, propertyName, moduleSpecifier, preferences), makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } case 71 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; - return [makeSingleImport(name.text, propertyName, moduleSpecifier)]; + return [makeSingleImport(name.text, propertyName, moduleSpecifier, preferences)]; default: - ts.Debug.assertNever(name); + return ts.Debug.assertNever(name); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -100339,15 +100945,15 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 270 /* ShorthandPropertyAssignment */: - case 271 /* SpreadAssignment */: + case 271 /* ShorthandPropertyAssignment */: + case 272 /* SpreadAssignment */: return undefined; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(84 /* ExportKeyword */)], prop); default: ts.Debug.assertNever(prop); @@ -100413,7 +101019,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported) { var modifiers = [ts.createToken(84 /* ExportKeyword */)]; switch (exported.kind) { - case 191 /* FunctionExpression */: { + case 192 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -100421,10 +101027,10 @@ var ts; } } // falls through - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -100432,7 +101038,7 @@ var ts; } function exportConst() { // `exports.x = 0;` --> `export const x = 0;` - return makeConst(modifiers, ts.createIdentifier(name), exported); + return makeConst(modifiers, ts.createIdentifier(name), exported); // TODO: GH#18217 } } /** @@ -100440,41 +101046,41 @@ var ts; * Returns nodes that will replace the variable declaration for the commonjs import. * May also make use `changes` to remove qualifiers at the use sites of imports, to change `mod.x` to `x`. */ - function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target) { + function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, preferences) { switch (name.kind) { - case 179 /* ObjectBindingPattern */: { + case 180 /* 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 : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); + }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) if (importSpecifiers) { - return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier)]; + return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, preferences)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 180 /* ArrayBindingPattern */: { + case 181 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; */ var tmp = makeUniqueName(codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, target), identifiers); return [ - ts.makeImport(ts.createIdentifier(tmp), /*namedImports*/ undefined, moduleSpecifier), + ts.makeImport(ts.createIdentifier(tmp), /*namedImports*/ undefined, moduleSpecifier, preferences), makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } case 71 /* Identifier */: - return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers); + return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, preferences); default: - ts.Debug.assertNever(name); + return ts.Debug.assertNever(name); } } /** * Convert `import x = require("x").` * Also converts uses like `x.y()` to `y()` and uses a named import. */ - function convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers) { + function convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, preferences) { var nameSymbol = checker.getSymbolAtLocation(name); // Maps from module property name to name actually used. (The same if there isn't shadowing.) var namedBindingsNames = ts.createMap(); @@ -100509,7 +101115,7 @@ var ts; // If it was unused, ensure that we at least import *something*. needDefaultImport = true; } - return [ts.makeImport(needDefaultImport ? ts.getSynthesizedDeepClone(name) : undefined, namedBindings, moduleSpecifier)]; + return [ts.makeImport(needDefaultImport ? ts.getSynthesizedDeepClone(name) : undefined, namedBindings, moduleSpecifier, preferences)]; } // Identifiers helpers function makeUniqueName(name, identifiers) { @@ -100521,20 +101127,26 @@ var ts; } function collectFreeIdentifiers(file) { var map = ts.createMultiMap(); - file.forEachChild(function recur(node) { - if (ts.isIdentifier(node) && isFreeIdentifier(node)) { - map.add(node.text, node); - } - node.forEachChild(recur); - }); + forEachFreeIdentifier(file, function (id) { return map.add(id.text, id); }); return map; } + /** + * A free identifier is an identifier that can be accessed through name lookup as a local variable. + * In the expression `x.y`, `x` is a free identifier, but `y` is not. + */ + function forEachFreeIdentifier(node, cb) { + if (ts.isIdentifier(node) && isFreeIdentifier(node)) + cb(node); + node.forEachChild(function (child) { return forEachFreeIdentifier(child, cb); }); + } function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return parent.name !== node; - case 181 /* BindingElement */: + case 182 /* BindingElement */: + return parent.propertyName !== node; + case 248 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -100549,10 +101161,10 @@ var ts; return ts.createClassDeclaration(ts.getSynthesizedDeepClones(cls.decorators), // TODO: GH#19915 Don't think this is even legal. ts.concatenate(additionalModifiers, ts.getSynthesizedDeepClones(cls.modifiers)), name, ts.getSynthesizedDeepClones(cls.typeParameters), ts.getSynthesizedDeepClones(cls.heritageClauses), ts.getSynthesizedDeepClones(cls.members)); } - function makeSingleImport(localName, propertyName, moduleSpecifier) { + function makeSingleImport(localName, propertyName, moduleSpecifier, preferences) { return propertyName === "default" - ? ts.makeImport(ts.createIdentifier(localName), /*namedImports*/ undefined, moduleSpecifier) - : ts.makeImport(/*name*/ undefined, [makeImportSpecifier(propertyName, localName)], moduleSpecifier); + ? ts.makeImport(ts.createIdentifier(localName), /*namedImports*/ undefined, moduleSpecifier, preferences) + : ts.makeImport(/*name*/ undefined, [makeImportSpecifier(propertyName, localName)], moduleSpecifier, preferences); } function makeImportSpecifier(propertyName, name) { return ts.createImportSpecifier(propertyName !== undefined && propertyName !== name ? ts.createIdentifier(propertyName) : undefined, ts.createIdentifier(name)); @@ -100640,12 +101252,16 @@ var ts; function getClass(sourceFile, pos) { return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false))); } + function symbolPointsToNonPrivateMember(symbol) { + return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); + } function addMissingDeclarations(checker, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) { + var maybeHeritageClauseSymbol = getHeritageClauseSymbolTable(classDeclaration, checker); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. var implementedType = checker.getTypeAtLocation(implementedTypeNode); var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); - var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); }); + var nonPrivateAndNotExistedInHeritageClauseMembers = implementedTypeSymbols.filter(ts.and(symbolPointsToNonPrivateMember, function (symbol) { return !maybeHeritageClauseSymbol.has(symbol.escapedName); })); var classType = checker.getTypeAtLocation(classDeclaration); if (!classType.getNumberIndexType()) { createMissingIndexSignatureDeclaration(implementedType, 1 /* Number */); @@ -100653,7 +101269,7 @@ var ts; if (!classType.getStringIndexType()) { createMissingIndexSignatureDeclaration(implementedType, 0 /* String */); } - codefix.createMissingMemberNodes(classDeclaration, nonPrivateMembers, checker, preferences, function (member) { return changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member); }); + codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, checker, preferences, function (member) { return changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member); }); function createMissingIndexSignatureDeclaration(type, kind) { var indexInfoOfKind = checker.getIndexInfoOfType(type, kind); if (indexInfoOfKind) { @@ -100661,6 +101277,14 @@ var ts; } } } + function getHeritageClauseSymbolTable(classDeclaration, checker) { + var heritageClauseNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + if (!heritageClauseNode) + return ts.createSymbolTable(); + var heritageClauseType = checker.getTypeAtLocation(heritageClauseNode); + var heritageClauseTypeSymbols = checker.getPropertiesOfType(heritageClauseType); + return ts.createSymbolTable(heritageClauseTypeSymbols.filter(symbolPointsToNonPrivateMember)); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -100677,7 +101301,9 @@ var ts; ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code, ], - getCodeActions: getImportCodeActions, + getCodeActions: function (context) { return context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ? getActionsForUMDImport(context) + : getActionsForNonUMDImport(context); }, // TODO: GH#20315 fixIds: [], getAllCodeActions: ts.notImplemented, @@ -100696,7 +101322,6 @@ var ts; program: program, checker: checker, compilerOptions: program.getCompilerOptions(), - cachedImportDeclarations: [], getCanonicalFileName: ts.createGetCanonicalFileName(ts.hostUsesCaseSensitiveFileNames(context.host)), symbolName: symbolName, symbolToken: symbolToken, @@ -100742,9 +101367,17 @@ var ts; return result; } function getCodeActionsForImport_separateExistingAndNew(exportInfos, context, useExisting, addNew) { - var existingImports = ts.flatMap(exportInfos, function (info) { - return getImportDeclarations(info, context.checker, context.sourceFile, context.cachedImportDeclarations); - }); + var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, context.checker, context.sourceFile); }); + ts.append(useExisting, tryUseExistingNamespaceImport(existingImports, context, context.symbolToken, context.checker)); + var addToExisting = tryAddToExistingImport(existingImports, context); + if (addToExisting) { + useExisting.push(addToExisting); + } + else { // Don't bother providing an action to add a new import if we can add to an existing one. + getCodeActionsForAddImport(exportInfos, context, existingImports, addNew); + } + } + function tryUseExistingNamespaceImport(existingImports, context, symbolToken, checker) { // It is possible that multiple import statements with the same specifier exist in the file. // e.g. // @@ -100757,44 +101390,46 @@ var ts; // 1. change "member3" to "ns.member3" // 2. add "member3" to the second import statement's import list // and it is up to the user to decide which one fits best. - if (context.symbolToken && ts.isIdentifier(context.symbolToken)) { - for (var _i = 0, existingImports_1 = existingImports; _i < existingImports_1.length; _i++) { - var declaration = existingImports_1[_i].declaration; - var namespace_2 = getNamespaceImportName(declaration); - if (namespace_2) { - var moduleSymbol = context.checker.getAliasedSymbol(context.checker.getSymbolAtLocation(namespace_2)); - if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(context.symbolName))) { - useExisting.push(getCodeActionForUseExistingNamespaceImport(namespace_2.text, context, context.symbolToken)); - } + return !symbolToken || !ts.isIdentifier(symbolToken) ? undefined : ts.firstDefined(existingImports, function (_a) { + var declaration = _a.declaration; + var namespace = getNamespaceImportName(declaration); + if (namespace) { + var moduleSymbol = namespace && checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)); + if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(context.symbolName))) { + return getCodeActionForUseExistingNamespaceImport(namespace.text, context, symbolToken); } } - } - getCodeActionsForAddImport(exportInfos, context, existingImports, useExisting, addNew); + }); + } + function tryAddToExistingImport(existingImports, context) { + return ts.firstDefined(existingImports, function (_a) { + var declaration = _a.declaration, importKind = _a.importKind; + if (declaration.kind === 244 /* ImportDeclaration */ && declaration.importClause) { + var changes = tryUpdateExistingImport(context, declaration.importClause, importKind); + if (changes) { + var moduleSpecifierWithoutQuotes = ts.stripQuotes(declaration.moduleSpecifier.getText()); + return createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [context.symbolName, moduleSpecifierWithoutQuotes], changes); + } + } + }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 243 /* ImportDeclaration */) { + if (declaration.kind === 244 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 245 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 246 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; } } - // TODO(anhans): This doesn't seem important to cache... just use an iterator instead of creating a new array? - function getImportDeclarations(_a, checker, _b, cachedImportDeclarations) { + function getExistingImportDeclarations(_a, checker, _b) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind; var imports = _b.imports; - if (cachedImportDeclarations === void 0) { cachedImportDeclarations = []; } - var moduleSymbolId = ts.getUniqueSymbolId(moduleSymbol, checker); - var cached = cachedImportDeclarations[moduleSymbolId]; - if (!cached) { - cached = cachedImportDeclarations[moduleSymbolId] = ts.mapDefined(imports, function (moduleSpecifier) { - var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 243 /* ImportDeclaration */ || i.kind === 242 /* ImportEqualsDeclaration */) - && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; - }); - } - return cached; + return ts.mapDefined(imports, function (moduleSpecifier) { + var i = ts.importFromModuleSpecifier(moduleSpecifier); + return (i.kind === 244 /* ImportDeclaration */ || i.kind === 243 /* ImportEqualsDeclaration */) + && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; + }); } function getCodeActionForNewImport(context, _a) { var moduleSpecifier = _a.moduleSpecifier, importKind = _a.importKind; @@ -100819,7 +101454,7 @@ var ts; }); // if this file doesn't have any import statements, insert an import statement and then insert a new line // between the only import statement and user code. Otherwise just insert the statement because chances - // are there are already a new line seperating code and import statements. + // are there are already a new line separating code and import statements. return createCodeAction(ts.Diagnostics.Import_0_from_module_1, [symbolName, moduleSpecifierWithoutQuotes], changes); } function shouldUseSingleQuote(sourceFile, preferences) { @@ -100853,21 +101488,7 @@ var ts; // Sort to keep the shortest paths first, but keep [relativePath, importRelativeToBaseUrl] groups together return ts.flatten(choicesForEachExportingModule.sort(function (a, b) { return ts.first(a).moduleSpecifier.length - ts.first(b).moduleSpecifier.length; })); } - function getCodeActionsForAddImport(exportInfos, ctx, existingImports, useExisting, addNew) { - var fromExistingImport = ts.firstDefined(existingImports, function (_a) { - var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 243 /* ImportDeclaration */ && declaration.importClause) { - var changes = tryUpdateExistingImport(ctx, ts.isImportClause(declaration.importClause) && declaration.importClause || undefined, importKind); - if (changes) { - var moduleSpecifierWithoutQuotes = ts.stripQuotes(declaration.moduleSpecifier.getText()); - return createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [ctx.symbolName, moduleSpecifierWithoutQuotes], changes); - } - } - }); - if (fromExistingImport) { - useExisting.push(fromExistingImport); - return; - } + function getCodeActionsForAddImport(exportInfos, ctx, existingImports, addNew) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); var newImportInfos = existingDeclaration ? [existingDeclaration] @@ -100879,9 +101500,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 243 /* ImportDeclaration */ + var expression = declaration.kind === 244 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 253 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 254 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -100889,7 +101510,7 @@ var ts; function tryUpdateExistingImport(context, importClause, importKind) { var symbolName = context.symbolName, sourceFile = context.sourceFile; var name = importClause.name; - var namedBindings = (importClause.kind !== 242 /* ImportEqualsDeclaration */ && importClause).namedBindings; + var namedBindings = (importClause.kind !== 243 /* ImportEqualsDeclaration */ && importClause).namedBindings; // TODO: GH#18217 switch (importKind) { case 1 /* Default */: return name ? undefined : ChangeTracker.with(context, function (t) { @@ -100897,11 +101518,11 @@ var ts; }); case 0 /* Named */: { var newImportSpecifier_1 = ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(symbolName)); - if (namedBindings && namedBindings.kind === 246 /* NamedImports */ && namedBindings.elements.length !== 0) { + if (namedBindings && namedBindings.kind === 247 /* NamedImports */ && namedBindings.elements.length !== 0) { // There are already named imports; add another. return ChangeTracker.with(context, function (t) { return t.insertNodeInListAfter(sourceFile, namedBindings.elements[namedBindings.elements.length - 1], newImportSpecifier_1); }); } - if (!namedBindings || namedBindings.kind === 246 /* NamedImports */ && namedBindings.elements.length === 0) { + if (!namedBindings || namedBindings.kind === 247 /* NamedImports */ && namedBindings.elements.length === 0) { return ChangeTracker.with(context, function (t) { return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamedImports([newImportSpecifier_1]))); }); @@ -100935,11 +101556,6 @@ var ts; }); return createCodeAction(ts.Diagnostics.Change_0_to_1, [symbolName, namespacePrefix + "." + symbolName], changes); } - function getImportCodeActions(context) { - return context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code - ? getActionsForUMDImport(context) - : getActionsForNonUMDImport(context); - } function getActionsForUMDImport(context) { var token = ts.getTokenAtPosition(context.sourceFile, context.span.start, /*includeJsDocComment*/ false); var checker = context.program.getTypeChecker(); @@ -100952,7 +101568,7 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(parent); - if ((ts.isJsxOpeningLikeElement && parent.tagName === token) || parent.kind === 259 /* JsxOpeningFragment */) { + if ((ts.isJsxOpeningLikeElement && parent.tagName === token) || parent.kind === 260 /* JsxOpeningFragment */) { umdSymbol = checker.resolveName(checker.getJsxNamespace(parent), isNodeOpeningLikeElement ? parent.tagName : parent, 67216319 /* Value */, /*excludeGlobals*/ false); } } @@ -101001,7 +101617,14 @@ var ts; return undefined; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here ts.Debug.assert(symbolName !== "default"); - var currentTokenMeaning = ts.getMeaningFromLocation(symbolToken); + var addToExistingDeclaration = []; + var addNewDeclaration = []; + getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).forEach(function (exportInfos) { + getCodeActionsForImport_separateExistingAndNew(exportInfos, convertToImportCodeFixContext(context, symbolToken, symbolName), addToExistingDeclaration, addNewDeclaration); + }); + return addToExistingDeclaration.concat(addNewDeclaration); + } + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { // 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(); @@ -101026,7 +101649,7 @@ var ts; addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */); } function getEscapedNameForExportDefault(symbol) { - return ts.firstDefined(symbol.declarations, function (declaration) { + return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { if (ts.isExportAssignment(declaration)) { if (ts.isIdentifier(declaration.expression)) { return declaration.expression.escapedText; @@ -101034,19 +101657,12 @@ var ts; } else if (ts.isExportSpecifier(declaration)) { ts.Debug.assert(declaration.name.escapedText === "default" /* Default */); - if (declaration.propertyName) { - return declaration.propertyName.escapedText; - } + return declaration.propertyName && declaration.propertyName.escapedText; } }); } }); - var addToExistingDeclaration = []; - var addNewDeclaration = []; - originalSymbolToExportInfos.forEach(function (exportInfos) { - getCodeActionsForImport_separateExistingAndNew(exportInfos, convertToImportCodeFixContext(context, symbolToken, symbolName), addToExistingDeclaration, addNewDeclaration); - }); - return addToExistingDeclaration.concat(addNewDeclaration); + return originalSymbolToExportInfos; } function checkSymbolHasMeaning(_a, meaning) { var declarations = _a.declarations; @@ -101068,7 +101684,7 @@ var ts; for (var _b = 0, allSourceFiles_1 = allSourceFiles; _b < allSourceFiles_1.length; _b++) { var sourceFile = allSourceFiles_1[_b]; if (ts.isExternalOrCommonJsModule(sourceFile)) { - cb(sourceFile.symbol, sourceFile); + cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile); } } } @@ -101285,7 +101901,7 @@ var ts; } function addMissingMemberInJs(changeTracker, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 204 /* ClassExpression */) { + if (classDeclaration.kind === 205 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -101311,10 +101927,10 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 199 /* BinaryExpression */) { + if (token.parent.parent.kind === 200 /* 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))); + var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); // TODO: GH#18217 typeNode = checker.typeToTypeNode(widenedType, classDeclaration); } return typeNode || ts.createKeywordTypeNode(119 /* AnyKeyword */); @@ -101370,7 +101986,13 @@ var ts; } function addMethodDeclaration(changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(callExpression, token.text, inJs, makeStatic, preferences); - changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); + var containingMethodDeclaration = ts.getAncestor(callExpression, 154 /* MethodDeclaration */); + if (containingMethodDeclaration && containingMethodDeclaration.parent === classDeclaration) { + changeTracker.insertNodeAfter(classDeclarationSourceFile, containingMethodDeclaration, methodDeclaration); + } + else { + changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); + } } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -101409,7 +102031,7 @@ var ts; var packageName = ts.getPackageName(moduleName).packageName; return diagCode === errorCodeCannotFindModule ? (ts.JsTyping.nodeCoreModules.has(packageName) ? "@types/node" : undefined) - : (host.isKnownTypesPackageName(packageName) ? ts.getTypesPackageName(packageName) : undefined); + : (host.isKnownTypesPackageName(packageName) ? ts.getTypesPackageName(packageName) : undefined); // TODO: GH#18217 } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -101628,7 +102250,9 @@ var ts; }, fixIds: [fixId], getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - doChange(changes, context.sourceFile, getInfo(diag.file, diag.start, diag.code)); + var info = getInfo(diag.file, diag.start, diag.code); + if (info) + doChange(changes, context.sourceFile, info); }); }, }); function getInfo(sourceFile, pos, diagCode) { @@ -101659,23 +102283,30 @@ var ts; ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code, ts.Diagnostics.All_imports_in_import_declaration_are_unused.code, ts.Diagnostics.All_destructured_elements_are_unused.code, + ts.Diagnostics.All_variables_are_unused.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var errorCode = context.errorCode, sourceFile = context.sourceFile; - var importDecl = tryGetFullImport(sourceFile, context.span.start); + var errorCode = context.errorCode, sourceFile = context.sourceFile, program = context.program; + var checker = program.getTypeChecker(); + var startToken = ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); + var importDecl = tryGetFullImport(startToken); if (importDecl) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.deleteNode(sourceFile, importDecl); }); return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Remove_import_from_0, ts.showModuleSpecifier(importDecl)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } - var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, context.span.start, /*deleted*/ undefined); }); + var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, startToken, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); if (delDestructure.length) { return [codefix.createCodeFixAction(fixName, delDestructure, ts.Diagnostics.Remove_destructuring, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } + var delVar = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullVariableStatement(t, sourceFile, startToken, /*deleted*/ undefined); }); + if (delVar.length) { + return [codefix.createCodeFixAction(fixName, delVar, ts.Diagnostics.Remove_variable_statement, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; + } var token = getToken(sourceFile, ts.textSpanEnd(context.span)); var result = []; - var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, /*deleted*/ undefined); }); + var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); if (deletion.length) { result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, token.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)); } @@ -101688,9 +102319,11 @@ var ts; fixIds: [fixIdPrefix, fixIdDelete], getAllCodeActions: function (context) { // Track a set of deleted nodes that may be ancestors of other marked for deletion -- only delete the ancestors. - var deleted = new NodeSet(); + var deleted = new ts.NodeSet(); + var sourceFile = context.sourceFile, program = context.program; + var checker = program.getTypeChecker(); return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var sourceFile = context.sourceFile; + var startToken = ts.getTokenAtPosition(sourceFile, diag.start, /*includeJsDocComment*/ false); var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file); switch (context.fixId) { case fixIdPrefix: @@ -101702,14 +102335,13 @@ var ts; // Ignore if this range was already deleted. if (deleted.some(function (d) { return ts.rangeContainsPosition(d, diag.start); })) break; - var importDecl = tryGetFullImport(diag.file, diag.start); + var importDecl = tryGetFullImport(startToken); if (importDecl) { changes.deleteNode(sourceFile, importDecl); } - else { - if (!tryDeleteFullDestructure(changes, sourceFile, diag.start, deleted)) { - tryDeleteDeclaration(changes, sourceFile, token, deleted); - } + else if (!tryDeleteFullDestructure(changes, sourceFile, startToken, deleted, checker, /*isFixAll*/ true) && + !tryDeleteFullVariableStatement(changes, sourceFile, startToken, deleted)) { + tryDeleteDeclaration(changes, sourceFile, token, deleted, checker, /*isFixAll*/ true); } break; default: @@ -101719,25 +102351,25 @@ var ts; }, }); // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. - function tryGetFullImport(sourceFile, pos) { - var startToken = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + function tryGetFullImport(startToken) { return startToken.kind === 91 /* ImportKeyword */ ? ts.tryCast(startToken.parent, ts.isImportDeclaration) : undefined; } - function tryDeleteFullDestructure(changes, sourceFile, pos, deletedAncestors) { - var startToken = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + function tryDeleteFullDestructure(changes, sourceFile, startToken, deletedAncestors, checker, isFixAll) { if (startToken.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(startToken.parent)) return false; - var decl = startToken.parent.parent; + var decl = ts.cast(startToken.parent, ts.isObjectBindingPattern).parent; switch (decl.kind) { - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors); break; - case 148 /* Parameter */: + case 149 /* Parameter */: + if (!mayDeleteParameter(decl, checker, isFixAll)) + break; if (deletedAncestors) deletedAncestors.add(decl); changes.deleteNodeInList(sourceFile, decl); break; - case 181 /* BindingElement */: + case 182 /* BindingElement */: if (deletedAncestors) deletedAncestors.add(decl); changes.deleteNode(sourceFile, decl); @@ -101747,6 +102379,16 @@ var ts; } return true; } + function tryDeleteFullVariableStatement(changes, sourceFile, startToken, deletedAncestors) { + var declarationList = ts.tryCast(startToken.parent, ts.isVariableDeclarationList); + if (declarationList && declarationList.getChildren(sourceFile)[0] === startToken) { + if (deletedAncestors) + deletedAncestors.add(declarationList); + changes.deleteNode(sourceFile, declarationList.parent.kind === 214 /* VariableStatement */ ? declarationList.parent : declarationList); + return true; + } + return false; + } function getToken(sourceFile, pos) { var token = ts.findPrecedingToken(pos, sourceFile, /*startNode*/ undefined, /*includeJsDoc*/ true); // this handles var ["computed"] = 12; @@ -101760,26 +102402,26 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 148 /* Parameter */: + case 149 /* Parameter */: return true; - case 231 /* VariableDeclaration */: { + case 232 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 221 /* ForOfStatement */: - case 220 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 221 /* ForInStatement */: return true; } } } return false; } - function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors) { + function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { switch (token.kind) { case 71 /* Identifier */: - tryDeleteIdentifier(changes, sourceFile, token, deletedAncestors); + tryDeleteIdentifier(changes, sourceFile, token, deletedAncestors, checker, isFixAll); break; - case 151 /* PropertyDeclaration */: - case 245 /* NamespaceImport */: + case 152 /* PropertyDeclaration */: + case 246 /* NamespaceImport */: if (deletedAncestors) deletedAncestors.add(token.parent); changes.deleteNode(sourceFile, token.parent); @@ -101800,13 +102442,13 @@ var ts; changes.deleteNode(sourceFile, token.parent.parent); } } - function tryDeleteIdentifier(changes, sourceFile, identifier, deletedAncestors) { + function tryDeleteIdentifier(changes, sourceFile, identifier, deletedAncestors, checker, isFixAll) { var parent = identifier.parent; switch (parent.kind) { - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors); break; - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: var typeParameters = ts.getEffectiveTypeParameterDeclarations(parent.parent); if (typeParameters.length === 1) { var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end; @@ -101820,18 +102462,17 @@ var ts; changes.deleteNodeInList(sourceFile, parent); } break; - case 148 /* Parameter */: - var oldFunction = parent.parent; - if (ts.isSetAccessor(oldFunction)) { - // Setter must have a parameter + case 149 /* Parameter */: + if (!mayDeleteParameter(parent, checker, isFixAll)) break; - } + var oldFunction = parent.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) { // Lambdas with exactly one parameter are special because, after removal, there // must be an empty parameter list (i.e. `()`) and this won't necessarily be the // case if the parameter is simply removed (e.g. in `x => 1`). var newFunction = ts.updateArrowFunction(oldFunction, oldFunction.modifiers, oldFunction.typeParameters, - /*parameters*/ undefined, oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); + /*parameters*/ undefined, // TODO: GH#18217 + oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); // Drop leading and trailing trivia of the new function because we're only going // to replace the span (vs the full span) of the old function - the old leading // and trailing trivia will remain. @@ -101842,13 +102483,13 @@ var ts; changes.deleteNodeInList(sourceFile, parent); } break; - case 181 /* BindingElement */: { + case 182 /* BindingElement */: { var pattern = parent.parent; switch (pattern.kind) { - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: changes.deleteNode(sourceFile, parent); // Don't delete ',' break; - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: changes.deleteNodeInList(sourceFile, parent); break; default: @@ -101857,11 +102498,11 @@ var ts; break; } // handle case where 'import a = A;' - case 242 /* ImportEqualsDeclaration */: - var importEquals = ts.getAncestor(identifier, 242 /* ImportEqualsDeclaration */); + case 243 /* ImportEqualsDeclaration */: + var importEquals = ts.getAncestor(identifier, 243 /* ImportEqualsDeclaration */); changes.deleteNode(sourceFile, importEquals); break; - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: var namedImports = parent.parent; if (namedImports.elements.length === 1) { tryDeleteNamedImportBinding(changes, sourceFile, namedImports); @@ -101871,10 +102512,10 @@ var ts; changes.deleteNodeInList(sourceFile, parent); } break; - case 244 /* ImportClause */: // this covers both 'import |d|' and 'import |d,| *' + case 245 /* ImportClause */: // this covers both 'import |d|' and 'import |d,| *' var importClause = parent; if (!importClause.namedBindings) { // |import d from './file'| - changes.deleteNode(sourceFile, ts.getAncestor(importClause, 243 /* ImportDeclaration */)); + changes.deleteNode(sourceFile, ts.getAncestor(importClause, 244 /* ImportDeclaration */)); } else { // import |d,| * as ns from './file' @@ -101890,7 +102531,7 @@ var ts; } } break; - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: tryDeleteNamedImportBinding(changes, sourceFile, parent); break; default: @@ -101912,14 +102553,14 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(namedBindings, 243 /* ImportDeclaration */); + var importDecl = ts.getAncestor(namedBindings, 244 /* ImportDeclaration */); changes.deleteNode(sourceFile, importDecl); } } // token.parent is a variableDeclaration function tryDeleteVariableDeclaration(changes, sourceFile, varDecl, deletedAncestors) { switch (varDecl.parent.parent.kind) { - case 219 /* ForStatement */: { + case 220 /* ForStatement */: { var forStatement = varDecl.parent.parent; var forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { @@ -101934,16 +102575,16 @@ var ts; } break; } - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: var forOfStatement = varDecl.parent.parent; - ts.Debug.assert(forOfStatement.initializer.kind === 232 /* VariableDeclarationList */); + ts.Debug.assert(forOfStatement.initializer.kind === 233 /* VariableDeclarationList */); var forOfInitializer = forOfStatement.initializer; if (deletedAncestors) deletedAncestors.add(forOfInitializer.declarations[0]); changes.replaceNode(sourceFile, forOfInitializer.declarations[0], ts.createObjectLiteral()); break; - case 220 /* ForInStatement */: - case 229 /* TryStatement */: + case 221 /* ForInStatement */: + case 230 /* TryStatement */: break; default: var variableStatement = varDecl.parent.parent; @@ -101959,18 +102600,34 @@ var ts; } } } - var NodeSet = /** @class */ (function () { - function NodeSet() { - this.map = ts.createMap(); + function mayDeleteParameter(p, checker, isFixAll) { + var parent = p.parent; + switch (parent.kind) { + case 154 /* MethodDeclaration */: + // Don't remove a parameter if this overrides something + var symbol = checker.getSymbolAtLocation(parent.name); + if (ts.isMemberSymbolInBaseType(symbol, checker)) + return false; + // falls through + case 155 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: { + // Can't remove a non-last parameter. Can remove a parameter in code-fix-all if future parameters are also unused. + var parameters = parent.parameters; + var index = parameters.indexOf(p); + ts.Debug.assert(index !== -1); + return isFixAll + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 71 /* Identifier */ && !p.symbol.isReferenced; }) + : index === parameters.length - 1; + } + case 157 /* SetAccessor */: + // Setter must have a parameter + return false; + default: + return ts.Debug.failBadSyntaxKind(parent); } - NodeSet.prototype.add = function (node) { - this.map.set(String(ts.getNodeId(node)), node); - }; - NodeSet.prototype.some = function (pred) { - return ts.forEachEntry(this.map, pred) || false; - }; - return NodeSet; - }()); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -101995,7 +102652,7 @@ var ts; ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; switch (container.kind) { - case 216 /* IfStatement */: + case 217 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { changes.deleteNodeRange(sourceFile, ts.first(statement.parent.statements), ts.last(statement.parent.statements)); @@ -102006,8 +102663,8 @@ var ts; break; } // falls through - case 218 /* WhileStatement */: - case 219 /* ForStatement */: + case 219 /* WhileStatement */: + case 220 /* ForStatement */: changes.deleteNode(sourceFile, container); break; default: @@ -102027,13 +102684,15 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: return true; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return ts.getModuleInstanceState(s) !== 1 /* Instantiated */; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); + default: + return false; } } function sliceAfter(arr, value) { @@ -102094,10 +102753,10 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 280 /* JSDocNullableType */) { + if (typeNode.kind === 281 /* 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, 4096 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 8192 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -102114,13 +102773,13 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 280 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 4096 /* Undefined */) : type; + var fixedType = typeNode.kind === 281 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } }); function doChange(changes, sourceFile, oldTypeNode, newType, checker) { - changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(newType, /*enclosingDeclaration*/ oldTypeNode)); + changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(newType, /*enclosingDeclaration*/ oldTypeNode)); // TODO: GH#18217 } function getInfo(sourceFile, pos, checker) { var decl = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false), isTypeContainer); @@ -102131,22 +102790,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 207 /* AsExpression */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 233 /* FunctionDeclaration */: - case 155 /* GetAccessor */: - case 159 /* IndexSignature */: - case 176 /* MappedType */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 148 /* Parameter */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 156 /* SetAccessor */: - case 236 /* TypeAliasDeclaration */: - case 189 /* TypeAssertionExpression */: - case 231 /* VariableDeclaration */: + case 208 /* AsExpression */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 234 /* FunctionDeclaration */: + case 156 /* GetAccessor */: + case 160 /* IndexSignature */: + case 177 /* MappedType */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 149 /* Parameter */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 157 /* SetAccessor */: + case 237 /* TypeAliasDeclaration */: + case 190 /* TypeAssertionExpression */: + case 232 /* VariableDeclaration */: return true; default: return false; @@ -102200,20 +102859,20 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 89 /* FunctionKeyword */, sourceFile); break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 19 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: return; } - return { + return insertBefore && { insertBefore: insertBefore, returnType: getReturnType(containingFunction) }; @@ -102316,17 +102975,17 @@ var ts; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); switch (declaration.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 150 /* PropertySignature */: - case 151 /* PropertyDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 151 /* PropertySignature */: + case 152 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration); out(ts.createProperty( /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 152 /* MethodSignature */: - case 153 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 154 /* 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 @@ -102366,7 +103025,7 @@ var ts; } } function signatureToMethodDeclaration(checker, signature, enclosingDeclaration, modifiers, name, optional, body) { - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 153 /* MethodDeclaration */, enclosingDeclaration, 256 /* SuppressAnyReturnType */); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 154 /* MethodDeclaration */, enclosingDeclaration, 256 /* SuppressAnyReturnType */); if (!signatureDeclaration) { return undefined; } @@ -102508,7 +103167,7 @@ var ts; function getDiagnostic(errorCode, token) { switch (errorCode) { case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: - return ts.isSetAccessor(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; + return ts.isSetAccessor(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217 case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: return ts.Diagnostics.Infer_parameter_types_from_usage; default: @@ -102583,11 +103242,11 @@ var ts; } function isApplicableFunctionForInference(declaration) { switch (declaration.kind) { - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: return true; - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return !!declaration.name; } return false; @@ -102626,6 +103285,7 @@ var ts; var notAccessible = function () { typeIsAccessible = false; }; var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { trackSymbol: function (symbol, declaration, meaning) { + // TODO: GH#18217 typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; }, reportInaccessibleThisError: notAccessible, @@ -102645,11 +103305,11 @@ var ts; } function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { switch (containingFunction.kind) { - case 154 /* Constructor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - var isConstructor = containingFunction.kind === 154 /* Constructor */; + case 155 /* Constructor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + var isConstructor = containingFunction.kind === 155 /* Constructor */; var searchToken = isConstructor ? ts.findChildOfKind(containingFunction, 123 /* ConstructorKeyword */, sourceFile) : containingFunction.name; @@ -102683,7 +103343,7 @@ var ts; cancellationToken.throwIfCancellationRequested(); inferTypeFromContext(reference, checker, usageContext); } - var isConstructor = declaration.kind === 154 /* Constructor */; + var isConstructor = declaration.kind === 155 /* Constructor */; var callContexts = isConstructor ? usageContext.constructContexts : usageContext.callContexts; return callContexts && declaration.parameters.map(function (parameter, parameterIndex) { var types = []; @@ -102715,21 +103375,21 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: usageContext.isNumber = true; break; - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); break; - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); break; - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpressionContext(node.parent, checker, usageContext); } @@ -102737,13 +103397,13 @@ var ts; inferTypeFromContextualType(node, checker, usageContext); } break; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); break; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); break; - case 231 /* VariableDeclaration */: { + case 232 /* 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. @@ -102813,7 +103473,7 @@ var ts; case 29 /* GreaterThanToken */: case 31 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 272 /* EnumLike */) { + if (operandType.flags & 544 /* EnumLike */) { addCandidateType(usageContext, operandType); } else { @@ -102823,13 +103483,13 @@ var ts; case 59 /* PlusEqualsToken */: case 37 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 272 /* EnumLike */) { + if (otherOperandType.flags & 544 /* EnumLike */) { addCandidateType(usageContext, otherOperandType); } - else if (otherOperandType.flags & 84 /* NumberLike */) { + else if (otherOperandType.flags & 168 /* NumberLike */) { usageContext.isNumber = true; } - else if (otherOperandType.flags & 34 /* StringLike */) { + else if (otherOperandType.flags & 68 /* StringLike */) { usageContext.isString = true; } else { @@ -102852,7 +103512,7 @@ var ts; // LogicalOperator case 54 /* BarBarToken */: if (node === parent.left && - (node.parent.parent.kind === 231 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 232 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); @@ -102880,7 +103540,7 @@ var ts; } } inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 186 /* CallExpression */) { + if (parent.kind === 187 /* CallExpression */) { (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); } else { @@ -102905,7 +103565,7 @@ var ts; var indexType = checker.getTypeAtLocation(parent); var indexUsageContext = {}; inferTypeFromContext(parent, checker, indexUsageContext); - if (indexType.flags & 84 /* NumberLike */) { + if (indexType.flags & 168 /* NumberLike */) { usageContext.numberIndexContext = indexUsageContext; } else { @@ -102927,7 +103587,7 @@ var ts; return checker.getWidenedType(checker.getUnionType(usageContext.candidateTypes.map(function (t) { return checker.getBaseTypeOfLiteralType(t); }), 2 /* Subtype */)); } else if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); + var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 var types = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); return checker.createPromiseType(types.length ? checker.getUnionType(types, 2 /* Subtype */) : checker.getAnyType()); } @@ -102960,12 +103620,12 @@ var ts; } } if (usageContext.numberIndexContext) { - numberIndexInfo = checker.createIndexInfo(getTypeFromUsageContext(usageContext.numberIndexContext, checker), /*isReadonly*/ false); + numberIndexInfo = checker.createIndexInfo(getTypeFromUsageContext(usageContext.numberIndexContext, checker), /*isReadonly*/ false); // TODO: GH#18217 } if (usageContext.stringIndexContext) { stringIndexInfo = checker.createIndexInfo(getTypeFromUsageContext(usageContext.stringIndexContext, checker), /*isReadonly*/ false); } - return checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + return checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); // TODO: GH#18217 } else { return undefined; @@ -103000,15 +103660,16 @@ var ts; parameters.push(symbol); } var returnType = getTypeFromUsageContext(callContext.returnType, checker) || checker.getVoidType(); + // TODO: GH#18217 return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); } function addCandidateType(context, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 16384 /* Never */)) { + if (type && !(type.flags & 1 /* Any */) && !(type.flags & 32768 /* Never */)) { (context.candidateTypes || (context.candidateTypes = [])).push(type); } } function hasCallContext(usageContext) { - return usageContext && usageContext.callContexts; + return !!usageContext && !!usageContext.callContexts; } })(InferFromReference || (InferFromReference = {})); })(codefix = ts.codefix || (ts.codefix = {})); @@ -103041,7 +103702,7 @@ var ts; var opts = context.program.getCompilerOptions(); var variations = []; // import Bluebird from "bluebird"; - variations.push(createAction(context, sourceFile, node, ts.makeImport(namespace.name, /*namedImports*/ undefined, node.moduleSpecifier))); + variations.push(createAction(context, sourceFile, node, ts.makeImport(namespace.name, /*namedImports*/ undefined, node.moduleSpecifier, context.preferences))); if (ts.getEmitModuleKind(opts) === ts.ModuleKind.CommonJS) { // import Bluebird = require("bluebird"); variations.push(createAction(context, sourceFile, node, ts.createImportEqualsDeclaration( @@ -103063,18 +103724,18 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 186 /* CallExpression */ : 187 /* NewExpression */; + var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 187 /* CallExpression */ : 188 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } var expr = node.expression; - var type = context.program.getTypeChecker().getTypeAtLocation(expr); + var type = context.program.getTypeChecker().getTypeAtLocation(expr); // TODO: GH#18217 if (!(type.symbol && type.symbol.originatingImport)) { return []; } var fixes = []; - var relatedImport = type.symbol.originatingImport; + var relatedImport = type.symbol.originatingImport; // TODO: GH#18217 if (!ts.isImportCall(relatedImport)) { ts.addRange(fixes, getCodeFixesForImportDeclaration(context, relatedImport)); } @@ -103151,8 +103812,9 @@ var ts; } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { var undefinedTypeNode = ts.createKeywordTypeNode(140 /* UndefinedKeyword */); - var types = ts.isUnionTypeNode(propertyDeclaration.type) ? propertyDeclaration.type.types.concat(undefinedTypeNode) : [propertyDeclaration.type, undefinedTypeNode]; - changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration.type, ts.createUnionTypeNode(types)); + var type = propertyDeclaration.type; // TODO: GH#18217 + var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; + changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.createUnionTypeNode(types)); } function getActionForAddMissingInitializer(context, propertyDeclaration) { var checker = context.program.getTypeChecker(); @@ -103167,16 +103829,16 @@ var ts; changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getInitializer(checker, propertyDeclaration) { - return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); + return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 2 /* String */) { + if (type.flags & 4 /* String */) { return ts.createLiteral(""); } - else if (type.flags & 4 /* Number */) { + else if (type.flags & 8 /* Number */) { return ts.createNumericLiteral("0"); } - else if (type.flags & 8 /* Boolean */) { + else if (type.flags & 16 /* Boolean */) { return ts.createFalse(); } else if (type.isLiteral()) { @@ -103204,78 +103866,99 @@ var ts; (function (ts) { var moduleSpecifiers; (function (moduleSpecifiers) { + // Note: fromSourceFile is just for usesJsExtensionOnImports + function getModuleSpecifier(program, fromSourceFile, fromSourceFileName, toFileName, host, preferences) { + var info = getInfo(program.getCompilerOptions(), fromSourceFile, fromSourceFileName, host); + var compilerOptions = program.getCompilerOptions(); + return getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || + ts.first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); + } + moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; // For each symlink/original for a module, returns a list of ways to import that file. function getModuleSpecifiers(moduleSymbol, program, importingSourceFile, host, preferences) { + var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); + if (ambient) + return [[ambient]]; var compilerOptions = program.getCompilerOptions(); - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); - var addJsExtension = usesJsExtensionOnImports(importingSourceFile); - var getCanonicalFileName = ts.hostGetCanonicalFileName(host); - var sourceDirectory = ts.getDirectoryPath(importingSourceFile.fileName); - return getAllModulePaths(program, moduleSymbol.valueDeclaration.getSourceFile()).map(function (moduleFileName) { - var global = tryGetModuleNameFromAmbientModule(moduleSymbol) - || tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) - || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) - || rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); - if (global) { - return [global]; - } - var relativePath = removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); - if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { - return [relativePath]; - } - var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName); - if (!relativeToBaseUrl) { - return [relativePath]; - } - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, moduleResolutionKind, addJsExtension); - if (paths) { - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - if (fromPaths) { - return [fromPaths]; - } - } - if (preferences.importModuleSpecifierPreference === "non-relative") { - return [importRelativeToBaseUrl]; - } - if (preferences.importModuleSpecifierPreference !== undefined) - ts.Debug.assertNever(preferences.importModuleSpecifierPreference); - if (isPathRelativeToParent(relativeToBaseUrl)) { - return [relativePath]; - } - /* - Prefer a relative import over a baseUrl import if it doesn't traverse up to baseUrl. - - Suppose we have: - baseUrl = /base - sourceDirectory = /base/a/b - moduleFileName = /base/foo/bar - Then: - relativePath = ../../foo/bar - getRelativePathNParents(relativePath) = 2 - pathFromSourceToBaseUrl = ../../ - getRelativePathNParents(pathFromSourceToBaseUrl) = 2 - 2 < 2 = false - In this case we should prefer using the baseUrl path "/a/b" instead of the relative path "../../foo/bar". - - Suppose we have: - baseUrl = /base - sourceDirectory = /base/foo/a - moduleFileName = /base/foo/bar - Then: - relativePath = ../a - getRelativePathNParents(relativePath) = 1 - pathFromSourceToBaseUrl = ../../ - getRelativePathNParents(pathFromSourceToBaseUrl) = 2 - 1 < 2 = true - In this case we should prefer using the relative path "../a" instead of the baseUrl path "foo/a". - */ - var pathFromSourceToBaseUrl = ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, baseUrl, getCanonicalFileName)); - var relativeFirst = getRelativePathNParents(relativePath) < getRelativePathNParents(pathFromSourceToBaseUrl); - return relativeFirst ? [relativePath, importRelativeToBaseUrl] : [importRelativeToBaseUrl, relativePath]; + var info = getInfo(compilerOptions, importingSourceFile, importingSourceFile.fileName, host); + var modulePaths = getAllModulePaths(program, moduleSymbol.valueDeclaration.getSourceFile()); + var global = ts.mapDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }); + return global.length ? global.map(function (g) { return [g]; }) : modulePaths.map(function (moduleFileName) { + return getLocalModuleSpecifiers(moduleFileName, info, compilerOptions, preferences); }); } moduleSpecifiers.getModuleSpecifiers = getModuleSpecifiers; + // importingSourceFileName is separate because getEditsForFileRename may need to specify an updated path + function getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host) { + var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); + var addJsExtension = usesJsExtensionOnImports(importingSourceFile); + var getCanonicalFileName = ts.hostGetCanonicalFileName(host); + var sourceDirectory = ts.getDirectoryPath(importingSourceFileName); + return { moduleResolutionKind: moduleResolutionKind, addJsExtension: addJsExtension, getCanonicalFileName: getCanonicalFileName, sourceDirectory: sourceDirectory }; + } + function getGlobalModuleSpecifier(moduleFileName, _a, host, compilerOptions) { + var addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; + return tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) + || compilerOptions.rootDirs && tryGetModuleNameFromRootDirs(compilerOptions.rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); + } + function getLocalModuleSpecifiers(moduleFileName, _a, compilerOptions, preferences) { + var moduleResolutionKind = _a.moduleResolutionKind, addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var relativePath = removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); + if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { + return [relativePath]; + } + var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName); + if (!relativeToBaseUrl) { + return [relativePath]; + } + var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, moduleResolutionKind, addJsExtension); + if (paths) { + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); + if (fromPaths) { + return [fromPaths]; + } + } + if (preferences.importModuleSpecifierPreference === "non-relative") { + return [importRelativeToBaseUrl]; + } + if (preferences.importModuleSpecifierPreference !== undefined) + ts.Debug.assertNever(preferences.importModuleSpecifierPreference); + if (isPathRelativeToParent(relativeToBaseUrl)) { + return [relativePath]; + } + /* + Prefer a relative import over a baseUrl import if it doesn't traverse up to baseUrl. + + Suppose we have: + baseUrl = /base + sourceDirectory = /base/a/b + moduleFileName = /base/foo/bar + Then: + relativePath = ../../foo/bar + getRelativePathNParents(relativePath) = 2 + pathFromSourceToBaseUrl = ../../ + getRelativePathNParents(pathFromSourceToBaseUrl) = 2 + 2 < 2 = false + In this case we should prefer using the baseUrl path "/a/b" instead of the relative path "../../foo/bar". + + Suppose we have: + baseUrl = /base + sourceDirectory = /base/foo/a + moduleFileName = /base/foo/bar + Then: + relativePath = ../a + getRelativePathNParents(relativePath) = 1 + pathFromSourceToBaseUrl = ../../ + getRelativePathNParents(pathFromSourceToBaseUrl) = 2 + 1 < 2 = true + In this case we should prefer using the relative path "../a" instead of the baseUrl path "foo/a". + */ + var pathFromSourceToBaseUrl = ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, baseUrl, getCanonicalFileName)); + var relativeFirst = getRelativePathNParents(relativePath) < getRelativePathNParents(pathFromSourceToBaseUrl); + return relativeFirst ? [relativePath, importRelativeToBaseUrl] : [importRelativeToBaseUrl, relativePath]; + } function usesJsExtensionOnImports(_a) { var imports = _a.imports; return ts.firstDefined(imports, function (_a) { @@ -103369,14 +104052,16 @@ var ts; // If the module could be imported by a directory name, use that directory's name var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path - moduleSpecifier = getNodeResolvablePath(moduleSpecifier); + // if node_modules folder is in this folder or any of its parent folders, no need to keep it. + if (!ts.startsWith(sourceDirectory, moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex))) + return undefined; // If the module was found in @types, get the actual Node package name - return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier); + return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); function getDirectoryOrExtensionlessFileName(path) { // If the file is the main module, it can be imported by the package name var packageRootPath = path.substring(0, parts.packageRootIndex); var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - if (host.fileExists(packageJsonPath)) { + if (host.fileExists(packageJsonPath)) { // TODO: GH#18217 var packageJsonContent = JSON.parse(host.readFile(packageJsonPath)); if (packageJsonContent) { var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main; @@ -103396,16 +104081,6 @@ var ts; } return fullModulePathWithoutExtension; } - function getNodeResolvablePath(path) { - var basePath = path.substring(0, parts.topLevelNodeModulesIndex); - if (sourceDirectory.indexOf(basePath) === 0) { - // if node_modules folder is in this folder or any of its parent folders, no need to keep it. - return path.substring(parts.topLevelPackageNameIndex + 1); - } - else { - return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, path, getCanonicalFileName)); - } - } } function getNodeModulePathParts(fullPath) { // If fullPath can't be valid module file within node_modules, returns undefined. @@ -103461,7 +104136,7 @@ var ts; } function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) { return ts.firstDefined(rootDirs, function (rootDir) { - var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName); + var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName); // TODO: GH#18217 return isPathRelativeToParent(relativePath) ? undefined : relativePath; }); } @@ -103527,14 +104202,14 @@ var ts; var info = getInfo(sourceFile, start); if (!info) return undefined; - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info, context.preferences); }); return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_default_import, fixId, ts.Diagnostics.Convert_all_to_default_imports)]; }, fixIds: [fixId], getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { var info = getInfo(diag.file, diag.start); if (info) - doChange(changes, diag.file, info); + doChange(changes, diag.file, info, context.preferences); }); }, }); function getInfo(sourceFile, pos) { @@ -103550,8 +104225,8 @@ var ts; return { importNode: importNode, name: name, moduleSpecifier: importNode.moduleSpecifier }; } } - function doChange(changes, sourceFile, info) { - changes.replaceNode(sourceFile, info.importNode, ts.makeImport(info.name, /*namedImports*/ undefined, info.moduleSpecifier)); + function doChange(changes, sourceFile, info, preferences) { + changes.replaceNode(sourceFile, info.importNode, ts.makeImport(info.name, /*namedImports*/ undefined, info.moduleSpecifier, preferences)); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -103579,7 +104254,7 @@ var ts; function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); ts.Debug.assert(token.kind === 91 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 178 /* ImportType */); + ts.Debug.assert(token.parent.kind === 179 /* ImportType */); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -103590,6 +104265,187 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixIdAddMissingTypeof = "fixConvertToMappedObjectType"; + var fixId = fixIdAddMissingTypeof; + var errorCodes = [ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span; + var info = getInfo(sourceFile, span.start); + if (!info) + return undefined; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info); }); + var name = ts.idText(info.container.name); + return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Convert_0_to_mapped_object_type, name], fixId, [ts.Diagnostics.Convert_0_to_mapped_object_type, name])]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var info = getInfo(diag.file, diag.start); + if (info) + doChange(changes, diag.file, info); + }); } + }); + function getInfo(sourceFile, pos) { + var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var indexSignature = ts.cast(token.parent.parent, ts.isIndexSignatureDeclaration); + if (ts.isClassDeclaration(indexSignature.parent)) + return undefined; + var container = ts.isInterfaceDeclaration(indexSignature.parent) ? indexSignature.parent : ts.cast(indexSignature.parent.parent, ts.isTypeAliasDeclaration); + return { indexSignature: indexSignature, container: container }; + } + function createTypeAliasFromInterface(declaration, type) { + return ts.createTypeAliasDeclaration(declaration.decorators, declaration.modifiers, declaration.name, declaration.typeParameters, type); + } + function doChange(changes, sourceFile, _a) { + var indexSignature = _a.indexSignature, container = _a.container; + var members = ts.isInterfaceDeclaration(container) ? container.members : container.type.members; + var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); + var parameter = ts.first(indexSignature.parameters); + var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(132 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ + mappedIntersectionType + ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); + changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var refactor; + (function (refactor) { + var generateGetAccessorAndSetAccessor; + (function (generateGetAccessorAndSetAccessor) { + var refactorName = "Convert import"; + var actionNameNamespaceToNamed = "Convert namespace import to named imports"; + var actionNameNamedToNamespace = "Convert named imports to namespace import"; + refactor.registerRefactor(refactorName, { + getAvailableActions: function (context) { + var i = getImportToConvert(context); + if (!i) + return undefined; + var description = i.kind === 246 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 246 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; + }, + getEditsForAction: function (context, actionName) { + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + } + }); + // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`. + function getImportToConvert(context) { + var file = context.file; + var span = ts.getRefactorContextSpan(context); + var token = ts.getTokenAtPosition(file, span.start, /*includeJsDocComment*/ false); + var importDecl = ts.getParentNodeInSpan(token, file, span); + if (!importDecl || !ts.isImportDeclaration(importDecl)) + return undefined; + var importClause = importDecl.importClause; + return importClause && importClause.namedBindings; + } + function doChange(sourceFile, program, changes, toConvert) { + var checker = program.getTypeChecker(); + if (toConvert.kind === 246 /* NamespaceImport */) { + doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); + } + else { + doChangeNamedToNamespace(sourceFile, checker, changes, toConvert); + } + } + function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { + var usedAsNamespaceOrDefault = false; + var nodesToReplace = []; + var conflictingNames = ts.createMap(); + ts.FindAllReferences.Core.eachSymbolReferenceInFile(toConvert.name, checker, sourceFile, function (id) { + if (!ts.isPropertyAccessExpression(id.parent)) { + usedAsNamespaceOrDefault = true; + } + else { + var parent = ts.cast(id.parent, ts.isPropertyAccessExpression); + var exportName = parent.name.text; + if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { + conflictingNames.set(exportName, true); + } + ts.Debug.assert(parent.expression === id); + nodesToReplace.push(parent); + } + }); + // We may need to change `mod.x` to `_x` to avoid a name conflict. + var exportNameToImportName = ts.createMap(); + for (var _i = 0, nodesToReplace_1 = nodesToReplace; _i < nodesToReplace_1.length; _i++) { + var propertyAccess = nodesToReplace_1[_i]; + var exportName = propertyAccess.name.text; + var importName = exportNameToImportName.get(exportName); + if (importName === undefined) { + exportNameToImportName.set(exportName, importName = conflictingNames.has(exportName) ? ts.getUniqueName(exportName, sourceFile) : exportName); + } + changes.replaceNode(sourceFile, propertyAccess, ts.createIdentifier(importName)); + } + var importSpecifiers = []; + exportNameToImportName.forEach(function (name, propertyName) { + importSpecifiers.push(ts.createImportSpecifier(name === propertyName ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name))); + }); + var importDecl = toConvert.parent.parent; + if (usedAsNamespaceOrDefault && !allowSyntheticDefaultImports) { + // Need to leave the namespace import alone + changes.insertNodeAfter(sourceFile, importDecl, updateImport(importDecl, /*defaultImportName*/ undefined, importSpecifiers)); + } + else { + changes.replaceNode(sourceFile, importDecl, updateImport(importDecl, usedAsNamespaceOrDefault ? ts.createIdentifier(toConvert.name.text) : undefined, importSpecifiers)); + } + } + function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) { + var importDecl = toConvert.parent.parent; + var moduleSpecifier = importDecl.moduleSpecifier; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 6 /* ESNext */) : "module"; + var namespaceNameConflicts = toConvert.elements.some(function (element) { + return ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { + return !!checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + }) || false; + }); + var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; + var neededNamedImports = []; + var _loop_22 = function (element) { + var propertyName = (element.propertyName || element.name).text; + ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { + var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); + if (ts.isShorthandPropertyAssignment(id.parent)) { + changes.replaceNode(sourceFile, id.parent, ts.createPropertyAssignment(id.text, access)); + } + else if (ts.isExportSpecifier(id.parent) && !id.parent.propertyName) { + if (!neededNamedImports.some(function (n) { return n.name === element.name; })) { + neededNamedImports.push(ts.createImportSpecifier(element.propertyName && ts.createIdentifier(element.propertyName.text), ts.createIdentifier(element.name.text))); + } + } + else { + changes.replaceNode(sourceFile, id, access); + } + }); + }; + for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { + var element = _a[_i]; + _loop_22(element); + } + changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); + if (neededNamedImports.length) { + changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, neededNamedImports)); + } + } + function updateImport(old, defaultImportName, elements) { + return ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImportName, elements && elements.length ? ts.createNamedImports(elements) : undefined), old.moduleSpecifier); + } + })(generateGetAccessorAndSetAccessor = refactor.generateGetAccessorAndSetAccessor || (refactor.generateGetAccessorAndSetAccessor = {})); + })(refactor = ts.refactor || (ts.refactor = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -103672,7 +104528,7 @@ var ts; /* Exported for tests */ function getEditsForAction(context, actionName) { var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context)); - var targetRange = rangeToExtract.targetRange; + var targetRange = rangeToExtract.targetRange; // TODO:GH#18217 var parsedFunctionIndexMatch = /^function_scope_(\d+)$/.exec(actionName); if (parsedFunctionIndexMatch) { var index = +parsedFunctionIndexMatch[1]; @@ -103743,9 +104599,9 @@ var ts; } // 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 start = getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); + var start = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); // Do the same for the ending position - var end = getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); + var end = ts.getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); 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. @@ -103764,7 +104620,8 @@ var ts; return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } var statements = []; - for (var _i = 0, _a = start.parent.statements; _i < _a.length; _i++) { + var start2 = start; // TODO: GH#18217 Need to alias `start` to get this to compile. See https://github.com/Microsoft/TypeScript/issues/19955#issuecomment-344118248 + for (var _i = 0, _a = start2.parent.statements; _i < _a.length; _i++) { var statement = _a[_i]; if (statement === start || statements.length) { var errors_1 = checkNode(statement); @@ -103797,7 +104654,7 @@ var ts; if (errors) { return { errors: errors }; } - return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; + return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217 /** * Attempt to refine the extraction node (generally, by shrinking it) to produce better results. * @param node The unrefined extraction node. @@ -103839,20 +104696,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 151 /* PropertyDeclaration */) { + if (current.kind === 152 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 148 /* Parameter */) { + else if (current.kind === 149 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 154 /* Constructor */) { + if (ctorOrMethod.kind === 155 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 153 /* MethodDeclaration */) { + else if (current.kind === 154 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -103895,8 +104752,11 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 231 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 232 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(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`! + // Also TODO: GH#19956 (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; } @@ -103904,15 +104764,15 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; case 97 /* 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 === 186 /* CallExpression */) { + if (node.parent.kind === 187 /* CallExpression */) { // Super constructor call - var containingClass_1 = ts.getContainingClass(node); + var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractSuper)); return true; @@ -103923,10 +104783,10 @@ var ts; } break; } - if (!node || ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { + if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -103938,20 +104798,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 216 /* IfStatement */: + case 217 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 229 /* TryStatement */: + case 230 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 212 /* Block */: - if (node.parent && node.parent.kind === 229 /* TryStatement */ && node.parent.finallyBlock === node) { + case 213 /* Block */: + if (node.parent && node.parent.kind === 230 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 265 /* CaseClause */: + case 266 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -103963,11 +104823,11 @@ var ts; break; } switch (node.kind) { - case 173 /* ThisType */: + case 174 /* ThisType */: case 99 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); @@ -103975,8 +104835,8 @@ var ts; seenLabels.pop(); break; } - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: { var label = node.label; if (label) { @@ -103986,20 +104846,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 223 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 224 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -104053,7 +104913,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 === 148 /* Parameter */) { + if (current.kind === 149 /* 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; } @@ -104064,7 +104924,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 273 /* SourceFile */) { + if (current.kind === 274 /* SourceFile */) { return scopes; } } @@ -104073,7 +104933,7 @@ var ts; function getFunctionExtractionAtIndex(targetRange, context, requestedChangesIndex) { var _a = getPossibleExtractionsWorker(targetRange, context), scopes = _a.scopes, _b = _a.readsAndWrites, target = _b.target, usagesPerScope = _b.usagesPerScope, functionErrorsPerScope = _b.functionErrorsPerScope, exposedVariableDeclarations = _b.exposedVariableDeclarations; ts.Debug.assert(!functionErrorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?"); - context.cancellationToken.throwIfCancellationRequested(); + context.cancellationToken.throwIfCancellationRequested(); // TODO: GH#18217 return extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], exposedVariableDeclarations, targetRange, context); } function getConstantExtractionAtIndex(targetRange, context, requestedChangesIndex) { @@ -104154,32 +105014,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 154 /* Constructor */: + case 155 /* Constructor */: return "constructor"; - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return "arrow function"; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return "method '" + scope.name.getText(); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 234 /* ClassDeclaration */ + return scope.kind === 235 /* 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 === 239 /* ModuleBlock */ + return scope.kind === 240 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -104197,7 +105057,7 @@ var ts; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted function var file = scope.getSourceFile(); - var functionNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newMethod" : "newFunction", file.text); + var functionNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newMethod" : "newFunction", file); var isJS = ts.isInJavaScriptFile(scope); var functionName = ts.createIdentifier(functionNameText); var returnType; @@ -104238,7 +105098,7 @@ var ts; // to avoid problems when there are literal types present if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); - returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); + returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); // TODO: GH#18217 } var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; ts.suppressLeadingAndTrailingTrivia(body); @@ -104306,7 +105166,8 @@ var ts; /*propertyName*/ undefined, /*name*/ ts.getSynthesizedDeepClone(variableDeclaration.name))); // Being returned through an object literal will have widened the type. - var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NoTruncation */); + var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), // TODO: GH#18217 + scope, 1 /* NoTruncation */); typeElements.push(ts.createPropertySignature( /*modifiers*/ undefined, /*name*/ variableDeclaration.symbol.name, @@ -104413,11 +105274,11 @@ var ts; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable var file = scope.getSourceFile(); - var localNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file.text); + var localNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file); var isJS = ts.isInJavaScriptFile(scope); var variableType = isJS || !checker.isContextSensitive(node) ? undefined - : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); + : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); @@ -104433,7 +105294,7 @@ var ts; /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); var localReference = ts.createPropertyAccess(rangeFacts & RangeFacts.InStaticRegion - ? ts.createIdentifier(scope.name.getText()) + ? ts.createIdentifier(scope.name.getText()) // TODO: GH#18217 : ts.createThis(), ts.createIdentifier(localNameText)); // Declare var maxInsertionPos = node.pos; @@ -104457,7 +105318,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 215 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 216 /* 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.createVariableStatement( @@ -104476,7 +105337,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 215 /* ExpressionStatement */) { + if (node.parent.kind === 216 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.deleteNode(context.file, node.parent, ts.textChanges.useNonAdjustedPositions); } @@ -104527,7 +105388,7 @@ var ts; function getCalledExpression(scope, range, functionNameText) { var functionReference = ts.createIdentifier(functionNameText); if (ts.isClassLike(scope)) { - var lhs = range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.text) : ts.createThis(); + var lhs = range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.text) : ts.createThis(); // TODO: GH#18217 return ts.createPropertyAccess(lhs, functionReference); } else { @@ -104563,7 +105424,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 224 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 225 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -104599,7 +105460,7 @@ var ts; } function getStatementsOrClassElements(scope) { if (ts.isFunctionLikeDeclaration(scope)) { - var body = scope.body; + var body = scope.body; // TODO: GH#18217 if (ts.isBlock(body)) { return body.statements; } @@ -104644,7 +105505,8 @@ var ts; } prevMember = member; } - ts.Debug.assert(prevMember !== undefined); // If the loop didn't return, then it did set prevMember. + if (prevMember === undefined) + return ts.Debug.fail(); // If the loop didn't return, then it did set prevMember. return prevMember; } function getNodeToInsertConstantBefore(node, scope) { @@ -104671,18 +105533,15 @@ var ts; return curr.parent.parent; } // There must be at least one statement since we started in one. - ts.Debug.assert(prevStatement !== undefined); - return prevStatement; - } - if (curr === scope) { - ts.Debug.fail("Didn't encounter a block-like before encountering scope"); - break; + return ts.Debug.assertDefined(prevStatement); } + ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } } function getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes) { var variableAssignments = ts.map(exposedVariableDeclarations, function (v) { return ts.createShorthandPropertyAssignment(v.symbol.name); }); var writeAssignments = ts.map(writes, function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + // TODO: GH#18217 `variableAssignments` not possibly undefined! return variableAssignments === undefined ? writeAssignments : writeAssignments === undefined @@ -104735,7 +105594,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (2048 /* Void */ | 16384 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (4096 /* Void */ | 32768 /* Never */)) { // TODO: GH#18217 expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -104743,7 +105602,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 233 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 234 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -104768,7 +105627,7 @@ var ts; // will use the contextual type of an expression as the return type of the extracted // method (and will therefore "use" all the types involved). if (inGenericContext && !isReadonlyArray(targetRange.range)) { - var contextualType = checker.getContextualType(targetRange.range); + var contextualType = checker.getContextualType(targetRange.range); // TODO: GH#18217 recordTypeParameterUsages(contextualType); } if (allTypeParameterUsages.size > 0) { @@ -104806,7 +105665,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_19 = function (i) { + var _loop_23 = 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 @@ -104846,7 +105705,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_19(i); + _loop_23(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -104868,7 +105727,7 @@ var ts; function collectUsages(node, valueUsage) { if (valueUsage === void 0) { valueUsage = 1 /* Read */; } if (inGenericContext) { - var type = checker.getTypeAtLocation(node); + var type = checker.getTypeAtLocation(node); // TODO: GH#18217 recordTypeParameterUsages(type); } if (ts.isDeclaration(node) && node.symbol) { @@ -105049,20 +105908,6 @@ var ts; : ts.createPropertyAccess(prefix, symbol.name); } } - function getParentNodeInSpan(node, file, span) { - if (!node) - return undefined; - while (node.parent) { - if (ts.isSourceFile(node.parent) || !spanContainsNode(span, node.parent, file)) { - return node; - } - node = node.parent; - } - } - function spanContainsNode(span, node, file) { - return ts.textSpanContainsPosition(span, node.getStart(file)) && - node.getEnd() <= ts.textSpanEnd(span); - } /** * Computes whether or not a node represents an expression in a position where it could * be extracted. @@ -105071,31 +105916,32 @@ var ts; * in the sense of something that you could extract on */ function isExtractableExpression(node) { - switch (node.parent.kind) { - case 272 /* EnumMember */: + var parent = node.parent; + switch (parent.kind) { + case 273 /* EnumMember */: return false; } switch (node.kind) { case 9 /* StringLiteral */: - return node.parent.kind !== 243 /* ImportDeclaration */ && - node.parent.kind !== 247 /* ImportSpecifier */; - case 203 /* SpreadElement */: - case 179 /* ObjectBindingPattern */: - case 181 /* BindingElement */: + return parent.kind !== 244 /* ImportDeclaration */ && + parent.kind !== 248 /* ImportSpecifier */; + case 204 /* SpreadElement */: + case 180 /* ObjectBindingPattern */: + case 182 /* BindingElement */: return false; case 71 /* Identifier */: - return node.parent.kind !== 181 /* BindingElement */ && - node.parent.kind !== 247 /* ImportSpecifier */ && - node.parent.kind !== 251 /* ExportSpecifier */; + return parent.kind !== 182 /* BindingElement */ && + parent.kind !== 248 /* ImportSpecifier */ && + parent.kind !== 252 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 212 /* Block */: - case 273 /* SourceFile */: - case 239 /* ModuleBlock */: - case 265 /* CaseClause */: + case 213 /* Block */: + case 274 /* SourceFile */: + case 240 /* ModuleBlock */: + case 266 /* CaseClause */: return true; default: return false; @@ -105172,7 +106018,7 @@ var ts; var renameLocation = renameLocationOffset + ts.getRenameLocation(edits, renameFilename, nameNeedRename.text, /*preferLastLocation*/ ts.isParameter(declaration)); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; } - function isConvertableName(name) { + function isConvertibleName(name) { return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { @@ -105182,7 +106028,7 @@ var ts; return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); } function createAccessorAccessExpression(fieldName, isStatic, container) { - var leftHead = isStatic ? container.name : ts.createThis(); + var leftHead = isStatic ? container.name : ts.createThis(); // TODO: GH#18217 return ts.isIdentifier(fieldName) ? ts.createPropertyAccess(leftHead, fieldName) : ts.createElementAccess(leftHead, ts.createLiteral(fieldName)); } function getModifiers(isJS, isStatic, accessModifier) { @@ -105198,18 +106044,18 @@ var ts; var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; - if (!declaration || !ts.rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition) - || !isConvertableName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) + if (!declaration || !ts.rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition) // TODO: GH#18217 + || !isConvertibleName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) return undefined; var name = declaration.name.text; var startWithUnderscore = startsWithUnderscore(name); - var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file.text), declaration.name); - var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file.text) : name, declaration.name); + var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file), declaration.name); + var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file) : name, declaration.name); return { isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 148 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 149 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name, declaration: declaration, fieldName: fieldName, @@ -105220,7 +106066,8 @@ var ts; function generateGetAccessor(fieldName, accessorName, type, modifiers, isStatic, container) { return ts.createGetAccessor( /*decorators*/ undefined, modifiers, accessorName, - /*parameters*/ undefined, type, ts.createBlock([ + /*parameters*/ undefined, // TODO: GH#18217 + type, ts.createBlock([ ts.createReturn(createAccessorAccessExpression(fieldName, isStatic, container)) ], /*multiLine*/ true)); } @@ -105264,7 +106111,9 @@ var ts; if (!constructor.body) return; var file = context.file, program = context.program, cancellationToken = context.cancellationToken; - var referenceEntries = ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(originalName.parent.pos, originalName, program, [file], cancellationToken), function (entry) { return ((entry.type === "node" && ts.rangeContainsRange(constructor, entry.node) && ts.isIdentifier(entry.node) && ts.isWriteAccess(entry.node)) ? entry.node : undefined); }); + var referenceEntries = ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(originalName.parent.pos, originalName, program, [file], cancellationToken), function (entry) { + return (entry.type === "node" && ts.rangeContainsRange(constructor, entry.node) && ts.isIdentifier(entry.node) && ts.isWriteAccess(entry.node)) ? entry.node : undefined; + }); ts.forEach(referenceEntries, function (entry) { var parent = entry.parent; var accessorName = ts.createIdentifier(fieldName.text); @@ -105287,7 +106136,7 @@ var ts; var refactorName = "Move to a new file"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { - if (!context.preferences.allowTextChangesInNewFiles || getFirstAndLastStatementToMove(context) === undefined) + if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined) return undefined; var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Move_to_a_new_file); return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; @@ -105295,27 +106144,34 @@ var ts; getEditsForAction: function (context, actionName) { ts.Debug.assert(actionName === refactorName); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); - function getFirstAndLastStatementToMove(context) { + function getRangeToMove(context) { var file = context.file; var range = ts.createTextRangeFromSpan(ts.getRefactorContextSpan(context)); var statements = file.statements; var startNodeIndex = ts.findIndex(statements, function (s) { return s.end > range.pos; }); if (startNodeIndex === -1) return undefined; + var startStatement = statements[startNodeIndex]; + if (ts.isNamedDeclaration(startStatement) && startStatement.name && ts.rangeContainsRange(startStatement.name, range)) { + return { toMove: [statements[startNodeIndex]], afterLast: statements[startNodeIndex + 1] }; + } // Can't only partially include the start node or be partially into the next node - if (range.pos > statements[startNodeIndex].getStart(file)) + if (range.pos > startStatement.getStart(file)) return undefined; var afterEndNodeIndex = ts.findIndex(statements, function (s) { return s.end > range.end; }, startNodeIndex); // Can't be partially into the next node if (afterEndNodeIndex !== -1 && (afterEndNodeIndex === 0 || statements[afterEndNodeIndex].getStart(file) < range.end)) return undefined; - return { first: startNodeIndex, afterLast: afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex }; + return { + toMove: statements.slice(startNodeIndex, afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex), + afterLast: afterEndNodeIndex === -1 ? undefined : statements[afterEndNodeIndex], + }; } - function doChange(oldFile, program, toMove, changes, host) { + function doChange(oldFile, program, toMove, changes, host, preferences) { var checker = program.getTypeChecker(); var usage = getUsageInfo(oldFile, toMove.all, checker); var currentDirectory = ts.getDirectoryPath(oldFile.fileName); @@ -105323,31 +106179,32 @@ var ts; var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host); var newFileNameWithExtension = newModuleName + extension; // If previous file was global, this is easy. - changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatements(oldFile, usage, changes, toMove, program, newModuleName)); + changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences)); addNewFileToTsconfig(program, changes, oldFile.fileName, newFileNameWithExtension, ts.hostGetCanonicalFileName(host)); } // Filters imports out of the range of statements to move. Imports will be copied to the new file anyway, and may still be needed in the old file. function getStatementsToMove(context) { - var statements = context.file.statements; - var _a = getFirstAndLastStatementToMove(context), first = _a.first, afterLast = _a.afterLast; + var rangeToMove = getRangeToMove(context); + if (rangeToMove === undefined) + return undefined; var all = []; var ranges = []; - var rangeToMove = statements.slice(first, afterLast); - ts.getRangesWhere(rangeToMove, function (s) { return !isPureImport(s); }, function (start, afterEnd) { - for (var i = start; i < afterEnd; i++) - all.push(rangeToMove[i]); - ranges.push({ first: rangeToMove[start], last: rangeToMove[afterEnd - 1] }); + var toMove = rangeToMove.toMove, afterLast = rangeToMove.afterLast; + ts.getRangesWhere(toMove, function (s) { return !isPureImport(s); }, function (start, afterEndIndex) { + for (var i = start; i < afterEndIndex; i++) + all.push(toMove[i]); + ranges.push({ first: toMove[start], afterLast: afterLast }); }); - return { all: all, ranges: ranges }; + return all.length === 0 ? undefined : { all: all, ranges: ranges }; } function isPureImport(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return true; - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 213 /* VariableStatement */: - return node.declarationList.declarations.every(function (d) { return d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); + case 214 /* VariableStatement */: + return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; } @@ -105366,26 +106223,26 @@ var ts; changes.insertNodeInListAfter(cfg, ts.last(filesProp.initializer.elements), ts.createLiteral(newFilePath), filesProp.initializer.elements); } } - function getNewStatements(oldFile, usage, changes, toMove, program, newModuleName) { + function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences) { var checker = program.getTypeChecker(); if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) { deleteMovedStatements(oldFile, toMove.ranges, changes); return toMove.all; } var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator; - var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax); + var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax, preferences); if (importsFromNewFile) { changes.insertNodeBefore(oldFile, oldFile.statements[0], importsFromNewFile, /*blankLineBetween*/ true); } deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); deleteMovedStatements(oldFile, toMove.ranges, changes); updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName); - return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); + return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, preferences).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); } function deleteMovedStatements(sourceFile, moved, changes) { for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) { - var _a = moved_1[_i], first_1 = _a.first, last_3 = _a.last; - changes.deleteNodeRange(sourceFile, first_1, last_3); + var _a = moved_1[_i], first_1 = _a.first, afterLast = _a.afterLast; + changes.deleteNodeRangeExcludingEnd(sourceFile, first_1, afterLast); } } function deleteUnusedOldImports(oldFile, toMove, changes, toDelete, checker) { @@ -105398,15 +106255,17 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_20 = function (sourceFile) { + var _loop_24 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_21 = function (statement) { + var _loop_25 = function (statement) { forEachImportInStatement(statement, function (importNode) { + if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) + return; var shouldMove = function (name) { var symbol = ts.isBindingElement(name.parent) ? ts.getPropertySymbolFromBindingElement(checker, name.parent) - : ts.skipAlias(checker.getSymbolAtLocation(name), checker); + : ts.skipAlias(checker.getSymbolAtLocation(name), checker); // TODO: GH#18217 return !!symbol && movedSymbols.has(symbol); }; deleteUnusedImports(sourceFile, importNode, changes, shouldMove); // These will be changed to imports from the new file @@ -105414,21 +106273,73 @@ var ts; var newImportDeclaration = filterImport(importNode, ts.createLiteral(newModuleSpecifier), shouldMove); if (newImportDeclaration) changes.insertNodeAfter(sourceFile, statement, newImportDeclaration); + var ns = getNamespaceLikeImport(importNode); + if (ns) + updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, ns, importNode); }); }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_21(statement); + _loop_25(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_20(sourceFile); + _loop_24(sourceFile); + } + } + function getNamespaceLikeImport(node) { + switch (node.kind) { + case 244 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 246 /* NamespaceImport */ ? + node.importClause.namedBindings.name : undefined; + case 243 /* ImportEqualsDeclaration */: + return node.name; + case 232 /* VariableDeclaration */: + return ts.tryCast(node.name, ts.isIdentifier); + default: + return ts.Debug.assertNever(node); + } + } + function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { + var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 6 /* ESNext */); + var needUniqueName = false; + var toChange = []; + ts.FindAllReferences.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, function (ref) { + if (!ts.isPropertyAccessExpression(ref.parent)) + return; + needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* All */, /*excludeGlobals*/ true); + if (movedSymbols.has(checker.getSymbolAtLocation(ref.parent.name))) { + toChange.push(ref); + } + }); + if (toChange.length) { + var newNamespaceName = needUniqueName ? ts.getUniqueName(preferredNewNamespaceName, sourceFile) : preferredNewNamespaceName; + for (var _i = 0, toChange_1 = toChange; _i < toChange_1.length; _i++) { + var ref = toChange_1[_i]; + changes.replaceNode(sourceFile, ref, ts.createIdentifier(newNamespaceName)); + } + changes.insertNodeAfter(sourceFile, oldImportNode, updateNamespaceLikeImportNode(oldImportNode, newModuleName, newModuleSpecifier)); + } + } + function updateNamespaceLikeImportNode(node, newNamespaceName, newModuleSpecifier) { + var newNamespaceId = ts.createIdentifier(newNamespaceName); + var newModuleString = ts.createLiteral(newModuleSpecifier); + switch (node.kind) { + case 244 /* ImportDeclaration */: + return ts.createImportDeclaration( + /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); + case 243 /* ImportEqualsDeclaration */: + return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); + case 232 /* VariableDeclaration */: + return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); + default: + return ts.Debug.assertNever(node); } } function moduleSpecifierFromImport(i) { - return (i.kind === 243 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 242 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 244 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 243 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -105450,24 +106361,24 @@ var ts; } } } - function createOldFileImportsFromNewFile(newFileNeedExport, newFileNameWithExtension, useEs6Imports) { + function createOldFileImportsFromNewFile(newFileNeedExport, newFileNameWithExtension, useEs6Imports, preferences) { var defaultImport; var imports = []; newFileNeedExport.forEach(function (symbol) { if (symbol.escapedName === "default" /* Default */) { - defaultImport = ts.createIdentifier(ts.symbolNameNoDefault(symbol)); + defaultImport = ts.createIdentifier(ts.symbolNameNoDefault(symbol)); // TODO: GH#18217 } else { imports.push(symbol.name); } }); - return makeImportOrRequire(defaultImport, imports, newFileNameWithExtension, useEs6Imports); + return makeImportOrRequire(defaultImport, imports, newFileNameWithExtension, useEs6Imports, preferences); } - function makeImportOrRequire(defaultImport, imports, path, useEs6Imports) { + function makeImportOrRequire(defaultImport, imports, path, useEs6Imports, preferences) { path = ts.ensurePathIsNonModuleName(path); if (useEs6Imports) { var specifiers = imports.map(function (i) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(i)); }); - return ts.makeImportIfNecessary(defaultImport, specifiers, path); + return ts.makeImportIfNecessary(defaultImport, specifiers, path, preferences); } else { ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. @@ -105498,15 +106409,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.deleteNode(sourceFile, importDecl); } break; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -105519,7 +106430,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 245 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 246 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.deleteNode(sourceFile, importDecl); } @@ -105531,7 +106442,7 @@ var ts; if (namedBindingsUnused) { changes.deleteNode(sourceFile, namedBindings); } - else if (namedBindings.kind === 246 /* NamedImports */) { + else if (namedBindings.kind === 247 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -105549,9 +106460,9 @@ var ts; changes.deleteNode(sourceFile, name); } break; - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: break; - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.deleteNode(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -105566,7 +106477,7 @@ var ts; break; } } - function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax) { + function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, preferences) { var copiedOldImports = []; for (var _i = 0, _a = oldFile.statements; _i < _a.length; _i++) { var oldStatement = _a[_i]; @@ -105598,7 +106509,7 @@ var ts; } } }); - ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEs6ModuleSyntax)); + ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEs6ModuleSyntax, preferences)); return copiedOldImports; } function makeUniqueModuleName(moduleName, extension, inDirectory, host) { @@ -105606,7 +106517,7 @@ var ts; for (var i = 1;; i++) { var name = ts.combinePaths(inDirectory, newModuleName + extension); if (!host.fileExists(name)) - return newModuleName; + return newModuleName; // TODO: GH#18217 newModuleName = moduleName + "." + i; } } @@ -105633,7 +106544,7 @@ var ts; if (isInImport(decl)) { oldImportsNeededByNewFile.add(symbol); } - else if (isTopLevelDeclaration(decl) && !movedSymbols.has(symbol)) { + else if (isTopLevelDeclaration(decl) && sourceFileOfTopLevelDeclaration(decl) === oldFile && !movedSymbols.has(symbol)) { newFileImportsFromOldFile.add(symbol); } } @@ -105656,13 +106567,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 242 /* ImportEqualsDeclaration */: - case 247 /* ImportSpecifier */: - case 244 /* ImportClause */: + case 243 /* ImportEqualsDeclaration */: + case 248 /* ImportSpecifier */: + case 245 /* ImportClause */: return true; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -105674,7 +106585,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 243 /* ImportDeclaration */: { + case 244 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -105684,9 +106595,9 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 231 /* VariableDeclaration */: { + case 232 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -105695,7 +106606,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 245 /* NamespaceImport */) { + if (namedBindings.kind === 246 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -105707,9 +106618,9 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return keep(name) ? name : undefined; - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: return name; - case 179 /* ObjectBindingPattern */: { + case 180 /* 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.createObjectBindingPattern(newElements) : undefined; @@ -105755,7 +106666,10 @@ var ts; return SymbolSet; }()); function isTopLevelDeclaration(node) { - return isNonVariableTopLevelDeclaration(node) || ts.isVariableDeclaration(node) && ts.isSourceFile(node.parent.parent.parent); + return isNonVariableTopLevelDeclaration(node) && ts.isSourceFile(node.parent) || ts.isVariableDeclaration(node) && ts.isSourceFile(node.parent.parent.parent); + } + function sourceFileOfTopLevelDeclaration(node) { + return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { ts.Debug.assert(ts.isSourceFile(node.parent)); @@ -105763,13 +106677,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 235 /* InterfaceDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 243 /* ImportEqualsDeclaration */: return true; default: return false; @@ -105777,17 +106691,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 235 /* InterfaceDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 243 /* ImportEqualsDeclaration */: return cb(statement); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return ts.forEach(statement.declarationList.declarations, cb); - case 215 /* ExpressionStatement */: { + case 216 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getSpecialPropertyAssignmentKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -105796,7 +106710,7 @@ var ts; } } function nameOfTopLevelDeclaration(d) { - return d.kind === 215 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); + return d.kind === 216 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); } function getTopLevelDeclarationStatement(d) { return ts.isVariableDeclaration(d) ? d.parent.parent : d; @@ -105828,23 +106742,23 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.createModifier(84 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d); @@ -105855,21 +106769,21 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - return [decl.name.text]; - case 213 /* VariableStatement */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + return [decl.name.text]; // TODO: GH#18217 + case 214 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 235 /* InterfaceDeclaration */: - case 242 /* ImportEqualsDeclaration */: - return undefined; - case 215 /* ExpressionStatement */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 243 /* ImportEqualsDeclaration */: + return ts.emptyArray; + case 216 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - ts.Debug.assertNever(decl); + return ts.Debug.assertNever(decl); } } /** Creates `exports.x = x;` */ @@ -106089,7 +107003,7 @@ var ts; var value = 0; for (; moreDigits; state.decodingIndex++) { if (createErrorIfCondition(state.decodingIndex >= state.encodedText.length, "Error in decoding base64VLQFormatDecode, past the mapping string")) { - return; + return undefined; // TODO: GH#18217 } // 6 digit number var currentByte = base64FormatDecode(state.encodedText.charAt(state.decodingIndex)); @@ -106139,7 +107053,7 @@ var ts; this.pos = pos; this.end = end; this.flags = 0 /* None */; - this.transformFlags = undefined; + this.transformFlags = undefined; // TODO: GH#18217 this.parent = undefined; this.kind = kind; } @@ -106201,8 +107115,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 277 /* FirstJSDocNode */ || kid.kind > 297 /* LastJSDocNode */; }); - return child.kind < 145 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 278 /* FirstJSDocNode */ || kid.kind > 298 /* LastJSDocNode */; }); + return child.kind < 146 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -106213,7 +107127,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 145 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 146 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -106271,7 +107185,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(298 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(299 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -106325,7 +107239,7 @@ var ts; return 0; }; TokenOrIdentifierObject.prototype.getChildAt = function () { - return undefined; + return undefined; // TODO: GH#18217 }; TokenOrIdentifierObject.prototype.getChildren = function () { return ts.emptyArray; @@ -106449,25 +107363,25 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 131072 /* Union */); + return !!(this.flags & 262144 /* Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 262144 /* Intersection */); + return !!(this.flags & 524288 /* Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 393216 /* UnionOrIntersection */); + return !!(this.flags & 786432 /* UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 224 /* Literal */); + return !!(this.flags & 448 /* Literal */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 32 /* StringLiteral */); + return !!(this.flags & 64 /* StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 64 /* NumberLiteral */); + return !!(this.flags & 128 /* NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 32768 /* TypeParameter */); + return !!(this.flags & 65536 /* TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); @@ -106517,9 +107431,9 @@ var ts; return ts.emptyArray; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); if (doc.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { - var declaration = declarations_13[_i]; - var inheritedDocs = findInheritedJSDocComments(declaration, declaration.symbol.name, checker); + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; + var inheritedDocs = findInheritedJSDocComments(declaration, declaration.symbol.name, checker); // TODO: GH#18217 // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc); @@ -106604,10 +107518,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -106627,31 +107541,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 237 /* EnumDeclaration */: - case 238 /* ModuleDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 251 /* ExportSpecifier */: - case 247 /* ImportSpecifier */: - case 244 /* ImportClause */: - case 245 /* NamespaceImport */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 165 /* TypeLiteral */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 238 /* EnumDeclaration */: + case 239 /* ModuleDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 252 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 245 /* ImportClause */: + case 246 /* NamespaceImport */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 166 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 148 /* Parameter */: + case 149 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 231 /* VariableDeclaration */: - case 181 /* BindingElement */: { + case 232 /* VariableDeclaration */: + case 182 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -106662,19 +107576,19 @@ var ts; } } // falls through - case 272 /* EnumMember */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 273 /* EnumMember */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: addDeclaration(node); break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -106686,7 +107600,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 245 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -106695,7 +107609,7 @@ var ts; } } break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -106823,7 +107737,7 @@ var ts; }; HostCache.prototype.getOrCreateEntryByPath = function (fileName, path) { var info = this.getEntryByPath(path) || this.createEntry(fileName, path); - return ts.isString(info) ? undefined : info; + return ts.isString(info) ? undefined : info; // TODO: GH#18217 }; HostCache.prototype.getRootFileNames = function () { var names = []; @@ -106841,11 +107755,11 @@ var ts; }; HostCache.prototype.getVersion = function (path) { var file = this.getHostFileInformation(path); - return file && file.version; + return (file && file.version); // TODO: GH#18217 }; HostCache.prototype.getScriptSnapshot = function (path) { var file = this.getHostFileInformation(path); - return file && file.scriptSnapshot; + return (file && file.scriptSnapshot); // TODO: GH#18217 }; return HostCache; }()); @@ -106948,7 +107862,7 @@ var ts; this.cancellationToken = cancellationToken; } CancellationTokenObject.prototype.isCancellationRequested = function () { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + return !!this.cancellationToken && this.cancellationToken.isCancellationRequested(); }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { @@ -106998,7 +107912,7 @@ var ts; if (!host.fileExists || !host.readFile || !host.fileExists(path)) return; // And failing that, check the disk - var text = host.readFile(path); + var text = host.readFile(path); // TODO: GH#18217 var file = { text: text, lineMap: undefined, @@ -107056,7 +107970,7 @@ var ts; var typeRootsVersion = host.getTypeRootsVersion ? host.getTypeRootsVersion() : 0; if (lastTypesRootVersion !== typeRootsVersion) { log("TypeRoots version has changed; provide new program"); - program = undefined; + program = undefined; // TODO: GH#18217 lastTypesRootVersion = typeRootsVersion; } // Get a fresh cache of the host information @@ -107064,7 +107978,7 @@ var ts; var rootFileNames = hostCache.getRootFileNames(); var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; // If the program is already up-to-date, we can reuse it - if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (path) { return hostCache.getVersion(path); }, fileExists, hasInvalidatedResolution, host.hasChangedAutomaticTypeDirectiveNames)) { + if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (path) { return hostCache.getVersion(path); }, fileExists, hasInvalidatedResolution, !!host.hasChangedAutomaticTypeDirectiveNames)) { return; } // IMPORTANT - It is critical from this moment onward that we do not check @@ -107141,7 +108055,7 @@ var ts; var entry = hostCache.getEntryByPath(path); return entry ? !ts.isString(entry) : - (host.fileExists && host.fileExists(fileName)); + (!!host.fileExists && host.fileExists(fileName)); } // Release any files we have acquired in the old program but are // not part of the new program. @@ -107201,6 +108115,7 @@ var ts; return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } } + // TODO: GH#18217 frequently asserted as defined function getProgram() { if (syntaxOnly) { ts.Debug.assert(program === undefined); @@ -107210,14 +108125,14 @@ var ts; return program; } function cleanupSemanticCache() { - program = undefined; + program = undefined; // TODO: GH#18217 } function dispose() { if (program) { ts.forEach(program.getSourceFiles(), function (f) { return documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions()); }); - program = undefined; + program = undefined; // TODO: GH#18217 } host = undefined; } @@ -107245,7 +108160,7 @@ var ts; } function getSuggestionDiagnostics(fileName) { synchronizeHostData(); - return ts.computeSuggestionDiagnostics(getValidSourceFile(fileName), program); + return ts.computeSuggestionDiagnostics(getValidSourceFile(fileName), program, cancellationToken); } function getCompilerOptionsDiagnostics() { synchronizeHostData(); @@ -107261,7 +108176,8 @@ var ts; function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { if (preferences === void 0) { preferences = ts.defaultPreferences; } synchronizeHostData(); - return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, formattingOptions && ts.formatting.getFormatContext(formattingOptions), getCanonicalFileName, preferences, cancellationToken); + return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions)), // TODO: GH#18217 + getCanonicalFileName, preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); @@ -107286,10 +108202,10 @@ var ts; return undefined; } // falls through - case 184 /* PropertyAccessExpression */: - case 145 /* QualifiedName */: + case 185 /* PropertyAccessExpression */: + case 146 /* QualifiedName */: case 99 /* ThisKeyword */: - case 173 /* ThisType */: + case 174 /* ThisType */: case 97 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type_4 = typeChecker.getTypeAtLocation(node); @@ -107330,7 +108246,7 @@ var ts; } function toLineColumnOffset(fileName, position) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var file = program.getSourceFile(path) || sourcemappedFileCache.get(path); + var file = program.getSourceFile(path) || sourcemappedFileCache.get(path); // TODO: GH#18217 return file.getLineAndCharacterOfPosition(position); } // Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M]) @@ -107397,7 +108313,7 @@ var ts; var location = possibleMapLocations_1[_i]; var mapPath = ts.toPath(location, ts.getDirectoryPath(fileName), getCanonicalFileName); if (host.fileExists(mapPath)) { - return convertDocumentToSourceMapper(file, host.readFile(mapPath), mapPath); + return convertDocumentToSourceMapper(file, host.readFile(mapPath), mapPath); // TODO: GH#18217 } } return file.sourceMapper = ts.sourcemaps.identitySourceMapper; @@ -107509,18 +108425,9 @@ var ts; function getReferences(fileName, position, options) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. - var sourceFiles = []; - if (options && options.isForRename) { - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - if (!program.isSourceFileDefaultLibrary(sourceFile)) { - sourceFiles.push(sourceFile); - } - } - } - else { - sourceFiles = program.getSourceFiles().slice(); - } + var sourceFiles = options && options.isForRename + ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) + : program.getSourceFiles(); return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); } function findReferences(fileName, position) { @@ -107529,11 +108436,13 @@ var ts; } /// NavigateTo function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { + if (excludeDtsFiles === void 0) { excludeDtsFiles = false; } synchronizeHostData(); var sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); } function getEmitOutput(fileName, emitOnlyDtsFiles) { + if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); @@ -107552,31 +108461,28 @@ var ts; function getNonBoundSourceFile(fileName) { return syntaxTreeCache.getCurrentSourceFile(fileName); } - function getSourceFile(fileName) { - return getNonBoundSourceFile(fileName); - } function getNameOrDottedNameSpan(fileName, startPos, _endPos) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); // Get node at the location var node = ts.getTouchingPropertyName(sourceFile, startPos, /*includeJsDocComment*/ false); if (node === sourceFile) { - return; + return undefined; } switch (node.kind) { - case 184 /* PropertyAccessExpression */: - case 145 /* QualifiedName */: + case 185 /* PropertyAccessExpression */: + case 146 /* QualifiedName */: case 9 /* StringLiteral */: case 86 /* FalseKeyword */: case 101 /* TrueKeyword */: case 95 /* NullKeyword */: case 97 /* SuperKeyword */: case 99 /* ThisKeyword */: - case 173 /* ThisType */: + case 174 /* ThisType */: case 71 /* Identifier */: break; // Cant create the text span default: - return; + return undefined; } var nodeForStartPos = node; while (true) { @@ -107588,7 +108494,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 === 238 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 239 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -107725,8 +108631,9 @@ var ts; var formatContext = ts.formatting.getFormatContext(formatOptions); return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); } - function getEditsForFileRename(oldFilePath, newFilePath, formatOptions) { - return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions)); + function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { + if (preferences === void 0) { preferences = ts.defaultPreferences; } + return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions), preferences); } function applyCodeActionCommand(fileName, actionOrUndefined) { var action = typeof fileName === "string" ? actionOrUndefined : fileName; @@ -107739,7 +108646,7 @@ var ts; ? host.installPackage({ fileName: ts.toPath(action.file, currentDirectory, getCanonicalFileName), packageName: action.packageName }) : Promise.reject("Host does not implement `installPackage`"); default: - ts.Debug.fail(); + return ts.Debug.fail(); // TODO: Debug.assertNever(action); will only work if there is more than one type. } } @@ -107775,6 +108682,17 @@ var ts; } return true; } + function getJsxClosingTagAtPosition(fileName, position) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var token = ts.findPrecedingToken(position, sourceFile); + if (!token) + return undefined; + var element = token.kind === 29 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + : ts.isJsxText(token) ? token.parent : undefined; + if (element && !ts.tagNamesAreEquivalent(element.openingElement.tagName, element.closingElement.tagName)) { + return { newText: "" }; + } + } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); @@ -107830,7 +108748,8 @@ var ts; descriptor = descriptors[i]; } } - ts.Debug.assert(descriptor !== undefined); + if (descriptor === undefined) + return ts.Debug.fail(); // We don't want to match something like 'TODOBY', so we make sure a non // letter/digit follows the match. if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { @@ -107973,6 +108892,7 @@ var ts; getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, + getJsxClosingTagAtPosition: getJsxClosingTagAtPosition, getSpanOfEnclosingComment: getSpanOfEnclosingComment, getCodeFixesAtPosition: getCodeFixesAtPosition, getCombinedCodeFix: getCombinedCodeFix, @@ -107981,7 +108901,6 @@ var ts; getEditsForFileRename: getEditsForFileRename, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, - getSourceFile: getSourceFile, getProgram: getProgram, getApplicableRefactors: getApplicableRefactors, getEditsForRefactor: getEditsForRefactor, @@ -107995,7 +108914,7 @@ var ts; if (!sourceFile.nameTable) { initializeNameTable(sourceFile); } - return sourceFile.nameTable; + return sourceFile.nameTable; // TODO: GH#18217 } ts.getNameTable = getNameTable; function initializeNameTable(sourceFile) { @@ -108022,7 +108941,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 253 /* ExternalModuleReference */ || + node.parent.kind === 254 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -108034,13 +108953,13 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 146 /* ComputedPropertyName */) { + if (node.parent.kind === 147 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through case 71 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 183 /* ObjectLiteralExpression */ || node.parent.parent.kind === 262 /* JsxAttributes */) && + (node.parent.parent.kind === 184 /* ObjectLiteralExpression */ || node.parent.parent.kind === 263 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -108049,8 +108968,8 @@ var ts; /* @internal */ function getPropertySymbolsFromContextualType(typeChecker, node) { var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - return getPropertySymbolsFromType(contextualType, node.name); + var contextualType = typeChecker.getContextualType(objectLiteral); // TODO: GH#18217 + return getPropertySymbolsFromType(contextualType, node.name); // TODO: GH#18217 } ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; /* @internal */ @@ -108059,7 +108978,7 @@ var ts; if (name && type) { var result_7 = []; var symbol = type.getProperty(name); - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { ts.forEach(type.types, function (t) { var symbol = t.getProperty(name); if (symbol) { @@ -108079,7 +108998,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 185 /* ElementAccessExpression */ && + node.parent.kind === 186 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -108118,11 +109037,12 @@ var ts; // let y = 10; // token at position will return let keyword on second line as the token but we would like to use // token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line - tokenAtLocation = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); + var preceding = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); // It's a blank line - if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) { + if (!preceding || sourceFile.getLineAndCharacterOfPosition(preceding.getEnd()).line !== lineOfPosition) { return undefined; } + tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations if (tokenAtLocation.flags & 4194304 /* Ambient */) { @@ -108156,115 +109076,116 @@ var ts; } function spanInNode(node) { if (node) { + var parent = node.parent; switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 231 /* VariableDeclaration */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 232 /* VariableDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return spanInVariableDeclaration(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return spanInParameterDeclaration(node); - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 154 /* Constructor */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 155 /* Constructor */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 212 /* Block */: + case 213 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return spanInBlock(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return spanInBlock(node.block); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 217 /* DoStatement */: + case 218 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 230 /* DebuggerStatement */: + case 231 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 216 /* IfStatement */: + case 217 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return spanInForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 229 /* TryStatement */: + case 230 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: - case 272 /* EnumMember */: - case 181 /* BindingElement */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 273 /* EnumMember */: + case 182 /* BindingElement */: // span on complete node return textSpan(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 149 /* Decorator */: - return spanInNodeArray(node.parent.decorators); - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 150 /* Decorator */: + return spanInNodeArray(parent.decorators); + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: return undefined; // Tokens: case 25 /* SemicolonToken */: @@ -108294,7 +109215,7 @@ var ts; case 74 /* CatchKeyword */: case 87 /* FinallyKeyword */: return spanInNextNode(node); - case 144 /* OfKeyword */: + case 145 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -108307,13 +109228,13 @@ var ts; // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern if ((node.kind === 71 /* Identifier */ || - node.kind === 203 /* SpreadElement */ || - node.kind === 269 /* PropertyAssignment */ || - node.kind === 270 /* ShorthandPropertyAssignment */) && - ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + node.kind === 204 /* SpreadElement */ || + node.kind === 270 /* PropertyAssignment */ || + node.kind === 271 /* ShorthandPropertyAssignment */) && + ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 199 /* BinaryExpression */) { + if (node.kind === 200 /* 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 @@ -108334,23 +109255,23 @@ var ts; } } if (ts.isExpressionNode(node)) { - switch (node.parent.kind) { - case 217 /* DoStatement */: + switch (parent.kind) { + case 218 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 149 /* Decorator */: + case 150 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 219 /* ForStatement */: - case 221 /* ForOfStatement */: + case 220 /* ForStatement */: + case 222 /* ForOfStatement */: return textSpan(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (node.parent.operatorToken.kind === 26 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -108359,21 +109280,21 @@ var ts; } } switch (node.parent.kind) { - case 269 /* PropertyAssignment */: + case 270 /* 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 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: { + case 232 /* VariableDeclaration */: + case 149 /* 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)) { @@ -108381,7 +109302,7 @@ var ts; } break; } - case 199 /* BinaryExpression */: { + case 200 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -108411,9 +109332,10 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 220 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 221 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } + var parent = variableDeclaration.parent; // If this is a destructuring pattern, set breakpoint in binding pattern if (ts.isBindingPattern(variableDeclaration.name)) { return spanInBindingPattern(variableDeclaration.name); @@ -108422,7 +109344,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 221 /* ForOfStatement */) { + parent.parent.kind === 222 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -108463,7 +109385,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 234 /* ClassDeclaration */ && functionDeclaration.kind !== 154 /* Constructor */); + (functionDeclaration.parent.kind === 235 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -108486,26 +109408,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // falls through // Set on parent if on same line otherwise on first statement - case 218 /* WhileStatement */: - case 216 /* IfStatement */: - case 220 /* ForInStatement */: + case 219 /* WhileStatement */: + case 217 /* IfStatement */: + case 221 /* 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 219 /* ForStatement */: - case 221 /* ForOfStatement */: + case 220 /* ForStatement */: + case 222 /* 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 === 232 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 233 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -108530,21 +109452,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 205 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 181 /* BindingElement */) { + if (bindingPattern.parent.kind === 182 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 180 /* ArrayBindingPattern */ && node.kind !== 179 /* ObjectBindingPattern */); - var elements = node.kind === 182 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 205 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 181 /* ArrayBindingPattern */ && node.kind !== 180 /* ObjectBindingPattern */); + var elements = node.kind === 183 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -108552,18 +109474,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 === 199 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 200 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -108571,25 +109493,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 239 /* ModuleBlock */: + case 240 /* 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 237 /* EnumDeclaration */: - case 234 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 235 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 212 /* Block */: + case 213 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 268 /* CatchClause */: + case 269 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -108597,7 +109519,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 179 /* ObjectBindingPattern */: + case 180 /* 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); @@ -108613,7 +109535,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 180 /* ArrayBindingPattern */: + case 181 /* 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); @@ -108628,12 +109550,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 217 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 186 /* CallExpression */ || - node.parent.kind === 187 /* NewExpression */) { + if (node.parent.kind === 218 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 187 /* CallExpression */ || + node.parent.kind === 188 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 190 /* ParenthesizedExpression */) { + if (node.parent.kind === 191 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -108642,21 +109564,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 154 /* Constructor */: - case 218 /* WhileStatement */: - case 217 /* DoStatement */: - case 219 /* ForStatement */: - case 221 /* ForOfStatement */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 190 /* ParenthesizedExpression */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 155 /* Constructor */: + case 219 /* WhileStatement */: + case 218 /* DoStatement */: + case 220 /* ForStatement */: + case 222 /* ForOfStatement */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 191 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -108666,20 +109588,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 269 /* PropertyAssignment */ || - node.parent.kind === 148 /* Parameter */) { + node.parent.kind === 270 /* PropertyAssignment */ || + node.parent.kind === 149 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 189 /* TypeAssertionExpression */) { + if (node.parent.kind === 190 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 217 /* DoStatement */) { + if (node.parent.kind === 218 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -108687,7 +109609,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 221 /* ForOfStatement */) { + if (node.parent.kind === 222 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -108709,7 +109631,7 @@ var ts; */ function transform(source, transformers, compilerOptions) { var diagnostics = []; - compilerOptions = ts.fixupCompilerOptions(compilerOptions, diagnostics); + compilerOptions = ts.fixupCompilerOptions(compilerOptions, diagnostics); // TODO: GH#18217 var nodes = ts.isArray(source) ? source : [source]; var result = ts.transformNodes(/*resolver*/ undefined, /*emitHost*/ undefined, compilerOptions, nodes, transformers, /*allowDtsFiles*/ true); result.diagnostics = ts.concatenate(result.diagnostics, diagnostics); @@ -108758,16 +109680,16 @@ var ts; var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); if (encoded === null) { - return null; + return null; // TODO: GH#18217 } - var decoded = JSON.parse(encoded); + var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; ScriptSnapshotShimAdapter.prototype.dispose = function () { // if scriptSnapshotShim is a COM object then property check becomes method call with no arguments // 'in' does not have this effect if ("dispose" in this.scriptSnapshotShim) { - this.scriptSnapshotShim.dispose(); + this.scriptSnapshotShim.dispose(); // TODO: GH#18217 Can we just use `if (this.scriptSnapshotShim.dispose)`? } }; return ScriptSnapshotShimAdapter; @@ -108782,10 +109704,10 @@ var ts; // 'in' does not have this effect. if ("getModuleResolutionsForFile" in this.shimHost) { this.resolveModuleNames = function (moduleNames, containingFile) { - var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); // TODO: GH#18217 return ts.map(moduleNames, function (name) { var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; // TODO: GH#18217 }); }; } @@ -108794,8 +109716,8 @@ var ts; } if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); - return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); + var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); // TODO: GH#18217 + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); // TODO: GH#18217 }; } } @@ -108815,7 +109737,7 @@ var ts; LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { if (!this.shimHost.getProjectVersion) { // shimmed host does not support getProjectVersion - return undefined; + return undefined; // TODO: GH#18217 } return this.shimHost.getProjectVersion(); }; @@ -108848,7 +109770,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { if ("getScriptKind" in this.shimHost) { - return this.shimHost.getScriptKind(fileName); + return this.shimHost.getScriptKind(fileName); // TODO: GH#18217 } else { return 0 /* Unknown */; @@ -108884,7 +109806,7 @@ var ts; return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); }; LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); // TODO: GH#18217 return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); }; LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { @@ -108905,11 +109827,11 @@ var ts; this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; } if ("realpath" in this.shimHost) { - this.realpath = function (path) { return _this.shimHost.realpath(path); }; + this.realpath = function (path) { return _this.shimHost.realpath(path); }; // TODO: GH#18217 } } CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); // TODO: GH#18217 return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); }; CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { @@ -108981,7 +109903,8 @@ var ts; start: diagnostic.start, length: diagnostic.length, category: ts.diagnosticCategoryName(diagnostic), - code: diagnostic.code + code: diagnostic.code, + reportsUnnecessary: diagnostic.reportsUnnecessary, }; } var LanguageServiceShimObject = /** @class */ (function (_super) { @@ -109287,10 +110210,12 @@ var ts; } ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { var _this = this; + if (syntacticClassifierAbsent === void 0) { syntacticClassifierAbsent = false; } return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); }; /// COLORIZATION ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { + if (classifyKeywordsInGenerics === void 0) { classifyKeywordsInGenerics = false; } var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); var result = ""; for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { @@ -109648,7 +110573,7 @@ var ts; } server.makeInferredProjectName = makeInferredProjectName; function createSortedArray() { - return []; + return []; // TODO: GH#19873 } server.createSortedArray = createSortedArray; })(server = ts.server || (ts.server = {})); @@ -109661,7 +110586,7 @@ var ts; function ThrottledOperations(host, logger) { this.host = host; this.pendingTimeouts = ts.createMap(); - this.logger = logger.hasLevel(server.LogLevel.verbose) && logger; + this.logger = logger.hasLevel(server.LogLevel.verbose) ? logger : undefined; } /** * Wait `number` milliseconds and then invoke `cb`. If, while waiting, schedule @@ -109707,10 +110632,10 @@ var ts; GcTimer.run = function (self) { self.timerId = undefined; var log = self.logger.hasLevel(server.LogLevel.requestTime); - var before = log && self.host.getMemoryUsage(); - self.host.gc(); + var before = log && self.host.getMemoryUsage(); // TODO: GH#18217 + self.host.gc(); // TODO: GH#18217 if (log) { - var after_1 = self.host.getMemoryUsage(); + var after_1 = self.host.getMemoryUsage(); // TODO: GH#18217 self.logger.perftrc("GC::before " + before + ", after " + after_1); } }; @@ -109776,6 +110701,7 @@ var ts; // NOTE: If updating this, be sure to also update `allCommandNames` in `harness/unittests/session.ts`. var CommandTypes; (function (CommandTypes) { + CommandTypes["JsxClosingTag"] = "jsxClosingTag"; CommandTypes["Brace"] = "brace"; /* @internal */ CommandTypes["BraceFull"] = "brace-full"; @@ -110160,7 +111086,7 @@ var ts; this.realpath = project.toPath(realpath); // If it is different from this.path, add to the map if (this.realpath !== this.path) { - project.projectService.realpathToScriptInfos.add(this.realpath, this); + project.projectService.realpathToScriptInfos.add(this.realpath, this); // TODO: GH#18217 } } } @@ -110358,7 +111284,7 @@ var ts; enqueueInstallTypingsRequest: ts.noop, attach: ts.noop, onProjectClosed: ts.noop, - globalTypingsCacheLocation: undefined + globalTypingsCacheLocation: undefined // TODO: GH#18217 }; function setIsEqualTo(arr1, arr2) { if (arr1 === arr2) { @@ -110369,15 +111295,15 @@ var ts; } var set = ts.createMap(); var unique = 0; - for (var _i = 0, arr1_1 = arr1; _i < arr1_1.length; _i++) { - var v = arr1_1[_i]; + for (var _i = 0, _a = arr1; _i < _a.length; _i++) { + var v = _a[_i]; if (set.get(v) !== true) { set.set(v, true); unique++; } } - for (var _a = 0, arr2_1 = arr2; _a < arr2_1.length; _a++) { - var v = arr2_1[_a]; + for (var _b = 0, _c = arr2; _b < _c.length; _b++) { + var v = _c[_b]; var isSet = set.get(v); if (isSet === undefined) { return false; @@ -110612,7 +111538,7 @@ var ts; Project.resolveModule = function (moduleName, initialDir, host, log) { var resolvedPath = ts.normalizeSlashes(host.resolvePath(ts.combinePaths(initialDir, "node_modules"))); log("Loading " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")"); - var result = host.require(resolvedPath, moduleName); + var result = host.require(resolvedPath, moduleName); // TODO: GH#18217 if (result.error) { var err = result.error.stack || result.error.message || JSON.stringify(result.error); log("Failed to load module '" + moduleName + "': " + err); @@ -110679,11 +111605,11 @@ var ts; }; Project.prototype.getScriptKind = function (fileName) { var info = this.getOrCreateScriptInfoAndAttachToProject(fileName); - return info && info.scriptKind; + return (info && info.scriptKind); // TODO: GH#18217 }; Project.prototype.getScriptVersion = function (filename) { var info = this.getOrCreateScriptInfoAndAttachToProject(filename); - return info && info.getLatestVersion(); + return (info && info.getLatestVersion()); // TODO: GH#18217 }; Project.prototype.getScriptSnapshot = function (filename) { var scriptInfo = this.getOrCreateScriptInfoAndAttachToProject(filename); @@ -110726,14 +111652,14 @@ var ts; return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile); }; Project.prototype.directoryExists = function (path) { - return this.directoryStructureHost.directoryExists(path); + return this.directoryStructureHost.directoryExists(path); // TODO: GH#18217 }; Project.prototype.getDirectories = function (path) { - return this.directoryStructureHost.getDirectories(path); + return this.directoryStructureHost.getDirectories(path); // TODO: GH#18217 }; /*@internal*/ Project.prototype.getCachedDirectoryStructureHost = function () { - return undefined; + return undefined; // TODO: GH#18217 }; /*@internal*/ Project.prototype.toPath = function (fileName) { @@ -110801,7 +111727,9 @@ var ts; } this.updateGraph(); this.builderState = ts.BuilderState.create(this.program, this.projectService.toCanonicalFileName, this.builderState); - return ts.mapDefined(ts.BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, function (data) { return _this.projectService.host.createHash(data); }), function (sourceFile) { return _this.shouldEmitFile(_this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined; }); + return ts.mapDefined(ts.BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, function (data) { return _this.projectService.host.createHash(data); }), // TODO: GH#18217 + function (// TODO: GH#18217 + sourceFile) { return _this.shouldEmitFile(_this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined; }); }; /** * Returns true if emit was conducted @@ -110945,9 +111873,7 @@ var ts; } return ts.map(this.program.getSourceFiles(), function (sourceFile) { var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.path); - if (!scriptInfo) { - ts.Debug.fail("scriptInfo for a file '" + sourceFile.fileName + "' Path: '" + sourceFile.path + "' is missing."); - } + ts.Debug.assert(!!scriptInfo, "getScriptInfo", function () { return "scriptInfo for a file '" + sourceFile.fileName + "' Path: '" + sourceFile.path + "' is missing."; }); return scriptInfo; }); }; @@ -111018,6 +111944,7 @@ var ts; if (info && (info.isScriptOpen() || !requireOpen)) { return this.containsScriptInfo(info); } + return false; }; Project.prototype.isRoot = function (info) { return this.rootFilesMap && this.rootFilesMap.get(info.path) === info; @@ -111170,7 +112097,7 @@ var ts; var start = ts.timestamp(); this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution(); this.resolutionCache.startCachingPerDirectoryResolution(); - this.program = this.languageService.getProgram(); + this.program = this.languageService.getProgram(); // TODO: GH#18217 this.dirty = false; this.resolutionCache.finishCachingPerDirectoryResolution(); ts.Debug.assert(oldProgram === undefined || this.program !== undefined); @@ -111343,7 +112270,7 @@ var ts; // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ var searchPaths = [ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations); if (this.projectService.globalPlugins) { - var _loop_22 = function (globalPluginName) { + var _loop_26 = function (globalPluginName) { // Skip empty names from odd commandline parses if (!globalPluginName) return "continue"; @@ -111358,7 +112285,7 @@ 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_22(globalPluginName); + _loop_26(globalPluginName); } } }; @@ -111424,6 +112351,7 @@ var ts; /*@internal*/ function InferredProject(projectService, documentRegistry, compilerOptions, projectRootPath, currentDirectory) { var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, + // TODO: GH#18217 /*files*/ undefined, /*lastFileExceededProgramSize*/ undefined, compilerOptions, /*compileOnSaveEnabled*/ false, projectService.host, currentDirectory) || this; @@ -111661,9 +112589,9 @@ var ts; /*@internal*/ ConfiguredProject.prototype.updateErrorOnNoInputFiles = function (hasFileNames) { if (hasFileNames) { - ts.filterMutate(this.projectErrors, function (error) { return !ts.isErrorNoInputFiles(error); }); + ts.filterMutate(this.projectErrors, function (error) { return !ts.isErrorNoInputFiles(error); }); // TODO: GH#18217 } - else if (!this.configFileSpecs.filesSpecs && !ts.some(this.projectErrors, ts.isErrorNoInputFiles)) { + else if (!this.configFileSpecs.filesSpecs && !ts.some(this.projectErrors, ts.isErrorNoInputFiles)) { // TODO: GH#18217 this.projectErrors.push(ts.getErrorForNoInputFiles(this.configFileSpecs, this.getConfigFilePath())); } }; @@ -111835,14 +112763,14 @@ var ts; }); } } - return result; + return result; // TODO: GH#18217 }, hasMixedContent: function (fileName, extraFileExtensions) { return ts.some(extraFileExtensions, function (ext) { return ext.isMixedContent && ts.fileExtensionIs(fileName, ext.extension); }); }, }; var externalFilePropertyReader = { getFileName: function (x) { return x.fileName; }, getScriptKind: function (x) { return tryConvertScriptKindName(x.scriptKind); }, - hasMixedContent: function (x) { return x.hasMixedContent; }, + hasMixedContent: function (x) { return !!x.hasMixedContent; }, }; function findProjectByName(projectName, projects) { for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { @@ -111948,10 +112876,11 @@ var ts; if (this.host.realpath) { this.realpathToScriptInfos = ts.createMultiMap(); } - this.currentDirectory = this.host.getCurrentDirectory(); + this.currentDirectory = server.toNormalizedPath(this.host.getCurrentDirectory()); this.toCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); - this.globalCacheLocationDirectoryPath = this.typingsInstaller.globalTypingsCacheLocation && - ts.ensureTrailingDirectorySeparator(this.toPath(this.typingsInstaller.globalTypingsCacheLocation)); + this.globalCacheLocationDirectoryPath = this.typingsInstaller.globalTypingsCacheLocation + ? ts.ensureTrailingDirectorySeparator(this.toPath(this.typingsInstaller.globalTypingsCacheLocation)) + : undefined; this.throttledOperations = new server.ThrottledOperations(this.host, this.logger); if (this.typesMapLocation) { this.loadTypesMap(); @@ -111967,7 +112896,7 @@ var ts; hostInfo: "Unknown host", extraFileExtensions: [] }; - this.documentRegistry = ts.createDocumentRegistry(this.host.useCaseSensitiveFileNames, this.currentDirectory); + this.documentRegistry = ts.createDocumentRegistryInternal(this.host.useCaseSensitiveFileNames, this.currentDirectory, this); var watchLogLevel = this.logger.hasLevel(server.LogLevel.verbose) ? ts.WatchLogLevel.Verbose : this.logger.loggingEnabled() ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None; var log = watchLogLevel !== ts.WatchLogLevel.None ? (function (s) { return _this.logger.info(s); }) : ts.noop; @@ -111984,6 +112913,16 @@ var ts; ProjectService.prototype.getNormalizedAbsolutePath = function (fileName) { return ts.getNormalizedAbsolutePath(fileName, this.host.getCurrentDirectory()); }; + /*@internal*/ + ProjectService.prototype.setDocument = function (key, path, sourceFile) { + var info = ts.Debug.assertDefined(this.getScriptInfoForPath(path)); + info.cacheSourceFile = { key: key, sourceFile: sourceFile }; + }; + /*@internal*/ + ProjectService.prototype.getDocument = function (key, path) { + var info = this.getScriptInfoForPath(path); + return info && info.cacheSourceFile && info.cacheSourceFile.key === key ? info.cacheSourceFile.sourceFile : undefined; + }; /* @internal */ ProjectService.prototype.ensureInferredProjectsUpToDate_TestOnly = function () { this.ensureProjectStructuresUptoDate(); @@ -112005,7 +112944,7 @@ var ts; }; ProjectService.prototype.loadTypesMap = function () { try { - var fileContent = this.host.readFile(this.typesMapLocation); + var fileContent = this.host.readFile(this.typesMapLocation); // TODO: GH#18217 if (fileContent === undefined) { this.logger.info("Provided types map file \"" + this.typesMapLocation + "\" doesn't exist"); return; @@ -112160,7 +113099,7 @@ var ts; } return scriptInfo.getDefaultProject(); } - return scriptInfo && !scriptInfo.isOrphan() && scriptInfo.getDefaultProject(); + return scriptInfo && !scriptInfo.isOrphan() ? scriptInfo.getDefaultProject() : undefined; }; ProjectService.prototype.getScriptInfoEnsuringProjectsUptoDate = function (uncheckedFileName) { this.ensureProjectStructuresUptoDate(); @@ -112325,7 +113264,7 @@ var ts; } project.updateGraph(); if (!this.useSingleInferredProject && !project.projectRootPath) { - var _loop_23 = function (inferredProject) { + var _loop_27 = function (inferredProject) { if (inferredProject === project || inferredProject.isOrphan()) { return "continue"; } @@ -112346,7 +113285,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_23(inferredProject); + _loop_27(inferredProject); } } return project; @@ -112421,7 +113360,7 @@ var ts; this.filenameToScriptInfo.delete(info.path); var realpath = info.getRealpathIfDifferent(); if (realpath) { - this.realpathToScriptInfos.remove(realpath, info); + this.realpathToScriptInfos.remove(realpath, info); // TODO: GH#18217 } }; ProjectService.prototype.configFileExists = function (configFileName, canonicalConfigFilePath, info) { @@ -112717,7 +113656,7 @@ var ts; }; ProjectService.prototype.convertConfigFileContentToProjectOptions = function (configFilename, cachedDirectoryStructureHost) { configFilename = ts.normalizePath(configFilename); - var configFileContent = this.host.readFile(configFilename); + var configFileContent = this.host.readFile(configFilename); // TODO: GH#18217 var result = ts.parseJsonText(configFilename, configFileContent); if (!result.endOfFileToken) { result.endOfFileToken = { kind: 1 /* EndOfFileToken */ }; @@ -112776,7 +113715,7 @@ var ts; var propertyReader = _a.propertyReader, hasTypeScriptFileExtension = _a.hasTypeScriptFileExtension, host = _a.host; return fileNames.map(function (f) { return propertyReader.getFileName(f); }) .filter(function (name) { return hasTypeScriptFileExtension(name); }) - .map(function (name) { return ({ name: name, size: host.getFileSize(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); } @@ -112819,7 +113758,7 @@ var ts; if (!(project instanceof server.ConfiguredProject)) { return "other"; } - var configFilePath = project instanceof server.ConfiguredProject && project.getConfigFilePath(); + var configFilePath = project instanceof server.ConfiguredProject ? project.getConfigFilePath() : undefined; // TODO: GH#18217 return server.getBaseConfigFileName(configFilePath) || "other"; } function convertTypeAcquisition(_a) { @@ -112839,20 +113778,21 @@ var ts; }; ProjectService.prototype.createConfiguredProject = function (configFileName) { var _this = this; - var cachedDirectoryStructureHost = ts.createCachedDirectoryStructureHost(this.host, this.host.getCurrentDirectory(), this.host.useCaseSensitiveFileNames); + var cachedDirectoryStructureHost = ts.createCachedDirectoryStructureHost(this.host, this.host.getCurrentDirectory(), this.host.useCaseSensitiveFileNames); // TODO: GH#18217 var _a = this.convertConfigFileContentToProjectOptions(configFileName, cachedDirectoryStructureHost), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors, configFileSpecs = _a.configFileSpecs; this.logger.info("Opened configuration file " + configFileName); - var lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(configFileName, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); - var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, lastFileExceededProgramSize, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave, cachedDirectoryStructureHost, projectOptions.projectReferences); + var lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(configFileName, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); // TODO: GH#18217 + var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, // TODO: GH#18217 + lastFileExceededProgramSize, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave, cachedDirectoryStructureHost, projectOptions.projectReferences); project.configFileSpecs = configFileSpecs; // TODO: We probably should also watch the configFiles that are extended project.configFileWatcher = this.watchFactory.watchFile(this.host, configFileName, function (_fileName, eventKind) { return _this.onConfigChangedForConfiguredProject(project, eventKind); }, ts.PollingInterval.High, "Config file for the program" /* ConfigFilePath */, project); if (!lastFileExceededProgramSize) { - project.watchWildcards(projectOptions.wildcardDirectories); + project.watchWildcards(projectOptions.wildcardDirectories); // TODO: GH#18217 } project.setProjectErrors(configFileErrors); var filesToAdd = projectOptions.files.concat(project.getExternalFiles()); - this.addFilesToNonInferredProjectAndUpdateGraph(project, filesToAdd, fileNamePropertyReader, projectOptions.typeAcquisition); + this.addFilesToNonInferredProjectAndUpdateGraph(project, filesToAdd, fileNamePropertyReader, projectOptions.typeAcquisition); // TODO: GH#18217 this.configuredProjects.set(project.canonicalConfigFilePath, project); this.setConfigFileExistenceByNewConfiguredProject(project); this.sendProjectTelemetry(configFileName, project, projectOptions); @@ -112881,7 +113821,7 @@ var ts; else { var scriptKind = propertyReader.getScriptKind(f, this.hostConfiguration.extraFileExtensions); var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); - scriptInfo = this.getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(normalizedPath, project.currentDirectory, scriptKind, hasMixedContent, project.directoryStructureHost); + scriptInfo = this.getOrCreateScriptInfoNotOpenedByClientForNormalizedPath(normalizedPath, project.currentDirectory, scriptKind, hasMixedContent, project.directoryStructureHost); // TODO: GH#18217 path = scriptInfo.path; // If this script info is not already a root add it if (!project.isRoot(scriptInfo)) { @@ -112927,7 +113867,7 @@ var ts; */ /*@internal*/ ProjectService.prototype.reloadFileNamesOfConfiguredProject = function (project) { - var configFileSpecs = project.configFileSpecs; + var configFileSpecs = project.configFileSpecs; // TODO: GH#18217 var configFileName = project.getConfigFilePath(); var fileNamesResult = ts.getFileNamesFromConfigSpecs(configFileSpecs, ts.getDirectoryPath(configFileName), project.getCompilationSettings(), project.getCachedDirectoryStructureHost(), this.hostConfiguration.extraFileExtensions); project.updateErrorOnNoInputFiles(fileNamesResult.fileNames.length !== 0); @@ -112951,16 +113891,16 @@ var ts; project.configFileSpecs = configFileSpecs; project.setProjectErrors(configFileErrors); project.updateReferences(projectOptions.projectReferences); - var lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(project.canonicalConfigFilePath, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); + var lastFileExceededProgramSize = this.getFilenameForExceededTotalSizeLimitForNonTsFiles(project.canonicalConfigFilePath, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); // TODO: GH#18217 if (lastFileExceededProgramSize) { project.disableLanguageService(lastFileExceededProgramSize); project.stopWatchingWildCards(); } else { project.enableLanguageService(); - project.watchWildcards(projectOptions.wildcardDirectories); + project.watchWildcards(projectOptions.wildcardDirectories); // TODO: GH#18217 } - this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typeAcquisition, projectOptions.compileOnSave); + this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typeAcquisition, projectOptions.compileOnSave); // TODO: GH#18217 this.sendConfigFileDiagEvent(project, configFileName); }; ProjectService.prototype.sendConfigFileDiagEvent = function (project, triggerFile) { @@ -113074,7 +114014,7 @@ var ts; return projects; function combineProjects(toAddInfo) { if (toAddInfo !== info) { - var _loop_24 = function (project) { + var _loop_28 = function (project) { // Add the projects only if they can use symLink targets and not already in the list if (project.languageServiceEnabled && !project.isOrphan() && @@ -113091,7 +114031,7 @@ var ts; }; for (var _i = 0, _a = toAddInfo.containingProjects; _i < _a.length; _i++) { var project = _a[_i]; - _loop_24(project); + _loop_28(project); } } } @@ -113139,7 +114079,7 @@ var ts; if (!openedByClient && !isDynamic && !(hostToQueryFileExistsOn || this.host).fileExists(fileName)) { return; } - info = new server.ScriptInfo(this.host, fileName, scriptKind, hasMixedContent, path); + info = new server.ScriptInfo(this.host, fileName, scriptKind, !!hasMixedContent, path); // TODO: GH#18217 this.filenameToScriptInfo.set(info.path, info); if (!openedByClient) { this.watchClosedScriptInfo(info); @@ -113244,7 +114184,7 @@ var ts; if (!shouldReloadProjectFor(openFileValue)) { return; } - var info = _this.getScriptInfoForPath(path); + var info = _this.getScriptInfoForPath(path); // TODO: GH#18217 ts.Debug.assert(info.isScriptOpen()); // This tries to search for a tsconfig.json for the given file. If we found it, // we first detect if there is already a configured project created for it: if so, @@ -113342,7 +114282,7 @@ var ts; var _this = this; var configFileName; var configFileErrors; - var info = this.getOrCreateScriptInfoOpenedByClientForNormalizedPath(fileName, projectRootPath ? this.getNormalizedAbsolutePath(projectRootPath) : this.currentDirectory, fileContent, scriptKind, hasMixedContent); + var info = this.getOrCreateScriptInfoOpenedByClientForNormalizedPath(fileName, projectRootPath ? this.getNormalizedAbsolutePath(projectRootPath) : this.currentDirectory, fileContent, scriptKind, hasMixedContent); // TODO: GH#18217 this.openFiles.set(info.path, projectRootPath); var project = this.findExternalProjectContainingOpenScriptInfo(info); if (!project && !this.syntaxOnly) { // Checking syntaxOnly is an optimization @@ -113430,13 +114370,13 @@ var ts; this.printProjects(); }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_25 = function (proj) { - var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); + var _loop_29 = function (proj) { + var knownProject = ts.find(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName(); }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_25(proj); + _loop_29(proj); } }; /* @internal */ @@ -113455,7 +114395,7 @@ var ts; var scriptInfo = this.getScriptInfo(file_21.fileName); ts.Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen(), "Script should not exist and not be open already"); var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file_21.fileName); - this.openClientFileWithNormalizedPath(normalizedPath, file_21.content, tryConvertScriptKindName(file_21.scriptKind), file_21.hasMixedContent); + this.openClientFileWithNormalizedPath(normalizedPath, file_21.content, tryConvertScriptKindName(file_21.scriptKind), file_21.hasMixedContent); // TODO: GH#18217 } } if (changedFiles) { @@ -113535,7 +114475,8 @@ var ts; }; ProjectService.prototype.applySafeList = function (proj) { var _this = this; - var rootFiles = proj.rootFiles, typeAcquisition = proj.typeAcquisition; + var rootFiles = proj.rootFiles; + var typeAcquisition = proj.typeAcquisition; ts.Debug.assert(!!typeAcquisition, "proj.typeAcquisition should be set by now"); // If type acquisition has been explicitly disabled, do not exclude anything from the project if (typeAcquisition.enable === false) { @@ -113545,7 +114486,7 @@ var ts; var excludeRules = []; var normalizedNames = rootFiles.map(function (f) { return ts.normalizeSlashes(f.fileName); }); var excludedFiles = []; - var _loop_26 = function (name) { + var _loop_30 = function (name) { var rule_2 = this_2.safelist[name]; for (var _i = 0, normalizedNames_1 = normalizedNames; _i < normalizedNames_1.length; _i++) { var root = normalizedNames_1[_i]; @@ -113563,7 +114504,7 @@ var ts; } } if (rule_2.exclude) { - var _loop_28 = function (exclude) { + var _loop_32 = function (exclude) { var processedRule = root.replace(rule_2.match, function () { var groups = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -113590,7 +114531,7 @@ var ts; }; for (var _c = 0, _d = rule_2.exclude; _c < _d.length; _c++) { var exclude = _d[_c]; - _loop_28(exclude); + _loop_32(exclude); } } else { @@ -113606,11 +114547,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_26(name); + _loop_30(name); } var excludeRegexes = excludeRules.map(function (e) { return new RegExp(e, "i"); }); var filesToKeep = []; - var _loop_27 = function (i) { + var _loop_31 = function (i) { if (excludeRegexes.some(function (re) { return re.test(normalizedNames[i]); })) { excludedFiles.push(normalizedNames[i]); } @@ -113648,7 +114589,7 @@ var ts; }; var this_3 = this; for (var i = 0; i < proj.rootFiles.length; i++) { - _loop_27(i); + _loop_31(i); } proj.rootFiles = filesToKeep; return excludedFiles; @@ -113763,7 +114704,7 @@ var ts; } }; ProjectService.prototype.hasDeferredExtension = function () { - for (var _i = 0, _a = this.hostConfiguration.extraFileExtensions; _i < _a.length; _i++) { + for (var _i = 0, _a = this.hostConfiguration.extraFileExtensions; _i < _a.length; _i++) { // TODO: GH#18217 var extension = _a[_i]; if (extension.scriptKind === 7 /* Deferred */) { return true; @@ -113832,7 +114773,7 @@ var ts; } } function formatDiag(fileName, project, diag) { - var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); + var scriptInfo = project.getScriptInfoForNormalizedPath(fileName); // TODO: GH#18217 return { start: scriptInfo.positionToLineOffset(diag.start), end: scriptInfo.positionToLineOffset(diag.start + diag.length), @@ -113847,8 +114788,8 @@ var ts; return { line: lineAndCharacter.line + 1, offset: lineAndCharacter.character + 1 }; } function formatConfigFileDiag(diag, includeFileName) { - var start = diag.file && convertToLocation(ts.getLineAndCharacterOfPosition(diag.file, diag.start)); - var end = diag.file && convertToLocation(ts.getLineAndCharacterOfPosition(diag.file, diag.start + diag.length)); + var start = (diag.file && convertToLocation(ts.getLineAndCharacterOfPosition(diag.file, diag.start))); // TODO: GH#18217 + var end = (diag.file && convertToLocation(ts.getLineAndCharacterOfPosition(diag.file, diag.start + diag.length))); // TODO: GH#18217 var text = ts.flattenDiagnosticMessageText(diag.messageText, "\n"); var code = diag.code, source = diag.source; var category = ts.diagnosticCategoryName(diag); @@ -114025,7 +114966,7 @@ var ts; }, _a[server.CommandNames.ApplyChangedToOpenFiles] = function (request) { _this.changeSeq++; - _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); + _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); // TODO: GH#18217 // TODO: report errors return _this.requiredResponse(/*response*/ true); }, @@ -114070,7 +115011,8 @@ var ts; return _this.requiredResponse(_this.getRenameInfo(request.arguments)); }, _a[server.CommandNames.Open] = function (request) { - _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName), request.arguments.projectRootPath ? server.toNormalizedPath(request.arguments.projectRootPath) : undefined); + _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName), // TODO: GH#18217 + request.arguments.projectRootPath ? server.toNormalizedPath(request.arguments.projectRootPath) : undefined); return _this.notRequired(); }, _a[server.CommandNames.Quickinfo] = function (request) { @@ -114239,6 +115181,9 @@ var ts; _this.projectService.reloadProjects(); return _this.notRequired(); }, + _a[server.CommandNames.JsxClosingTag] = function (request) { + return _this.requiredResponse(_this.getJsxClosingTag(request.arguments)); + }, _a[server.CommandNames.GetCodeFixes] = function (request) { return _this.requiredResponse(_this.getCodeFixes(request.arguments, /*simplifiedResult*/ true)); }, @@ -114287,6 +115232,7 @@ var ts; this.logger = opts.logger; this.canUseEvents = opts.canUseEvents; this.suppressDiagnosticEvents = opts.suppressDiagnosticEvents; + this.noGetErrOnBackgroundUpdate = opts.noGetErrOnBackgroundUpdate; var throttleWaitMilliseconds = opts.throttleWaitMilliseconds; this.eventHandler = this.canUseEvents ? opts.eventHandler || (function (event) { return _this.defaultEventHandler(event); }) @@ -114358,7 +115304,7 @@ var ts; var _this = this; this.projectService.logger.info("got projects updated in background, updating diagnostics for " + openFiles); if (openFiles.length) { - if (!this.suppressDiagnosticEvents) { + if (!this.suppressDiagnosticEvents && !this.noGetErrOnBackgroundUpdate) { var checkList_1 = this.createCheckList(openFiles); // For now only queue error checking for open files. We can change this to include non open files as well this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, checkList_1, 100, /*requireOpen*/ true); }); @@ -114394,7 +115340,7 @@ var ts; // For backwards-compatibility only. /** @deprecated */ Session.prototype.output = function (info, cmdName, reqSeq, errorMsg) { - this.doOutput(info, cmdName, reqSeq, /*success*/ !errorMsg, errorMsg); + this.doOutput(info, cmdName, reqSeq, /*success*/ !errorMsg, errorMsg); // TODO: GH#18217 }; Session.prototype.doOutput = function (info, cmdName, reqSeq, success, message) { var res = { @@ -114505,20 +115451,20 @@ var ts; return project.getLanguageService().getEncodedSemanticClassifications(file, args); }; Session.prototype.getProject = function (projectFileName) { - return projectFileName && this.projectService.findProject(projectFileName); + return projectFileName === undefined ? undefined : this.projectService.findProject(projectFileName); }; Session.prototype.getConfigFileAndProject = function (args) { var project = this.getProject(args.projectFileName); var file = server.toNormalizedPath(args.file); return { - configFile: project && project.hasConfigFile(file) && file, + configFile: project && project.hasConfigFile(file) ? file : undefined, project: project }; }; Session.prototype.getConfigFileDiagnostics = function (configFile, project, includeLinePosition) { var projectErrors = project.getAllProjectErrors(); var optionsErrors = project.getLanguageService().getCompilerOptionsDiagnostics(); - var diagnosticsForConfigFile = ts.filter(ts.concatenate(projectErrors, optionsErrors), function (diagnostic) { return diagnostic.file && diagnostic.file.fileName === configFile; }); + var diagnosticsForConfigFile = ts.filter(ts.concatenate(projectErrors, optionsErrors), function (diagnostic) { return !!diagnostic.file && diagnostic.file.fileName === configFile; }); return includeLinePosition ? this.convertToDiagnosticsWithLinePositionFromDiagnosticFile(diagnosticsForConfigFile) : ts.map(diagnosticsForConfigFile, function (diagnostic) { return formatConfigFileDiag(diagnostic, /*includeFileName*/ false); }); @@ -114531,8 +115477,8 @@ var ts; length: d.length, category: ts.diagnosticCategoryName(d), code: d.code, - startLocation: d.file && convertToLocation(ts.getLineAndCharacterOfPosition(d.file, d.start)), - endLocation: d.file && convertToLocation(ts.getLineAndCharacterOfPosition(d.file, d.start + d.length)) + startLocation: (d.file && convertToLocation(ts.getLineAndCharacterOfPosition(d.file, d.start))), + endLocation: (d.file && convertToLocation(ts.getLineAndCharacterOfPosition(d.file, d.start + d.length))) // TODO: GH#18217 }); }); }; Session.prototype.getCompilerOptionsDiagnostics = function (args) { @@ -114588,7 +115534,7 @@ var ts; if (!definitionAndBoundSpan || !definitionAndBoundSpan.definitions) { return { definitions: server.emptyArray, - textSpan: undefined + textSpan: undefined // TODO: GH#18217 }; } if (simplifiedResult) { @@ -114619,7 +115565,7 @@ var ts; }; Session.prototype.toFileSpan = function (fileName, textSpan, project) { var ls = project.getLanguageService(); - var start = ls.toLineColumnOffset(fileName, textSpan.start); + var start = ls.toLineColumnOffset(fileName, textSpan.start); // TODO: GH#18217 var end = ls.toLineColumnOffset(fileName, ts.textSpanEnd(textSpan)); return { file: fileName, @@ -114681,14 +115627,14 @@ var ts; // all the config file errors are reported as part of semantic check so nothing to report here return server.emptyArray; } - return this.getDiagnosticsWorker(args, /*isSemantic*/ false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, args.includeLinePosition); + return this.getDiagnosticsWorker(args, /*isSemantic*/ false, function (project, file) { return project.getLanguageService().getSyntacticDiagnostics(file); }, !!args.includeLinePosition); }; Session.prototype.getSemanticDiagnosticsSync = function (args) { var _a = this.getConfigFileAndProject(args), configFile = _a.configFile, project = _a.project; if (configFile) { - return this.getConfigFileDiagnostics(configFile, project, args.includeLinePosition); + return this.getConfigFileDiagnostics(configFile, project, !!args.includeLinePosition); // TODO: GH#18217 } - return this.getDiagnosticsWorker(args, /*isSemantic*/ true, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, args.includeLinePosition); + return this.getDiagnosticsWorker(args, /*isSemantic*/ true, function (project, file) { return project.getLanguageService().getSemanticDiagnostics(file); }, !!args.includeLinePosition); }; Session.prototype.getSuggestionDiagnosticsSync = function (args) { var configFile = this.getConfigFileAndProject(args).configFile; @@ -114697,7 +115643,13 @@ var ts; return server.emptyArray; } // isSemantic because we don't want to info diagnostics in declaration files for JS-only users - return this.getDiagnosticsWorker(args, /*isSemantic*/ true, function (project, file) { return project.getLanguageService().getSuggestionDiagnostics(file); }, args.includeLinePosition); + return this.getDiagnosticsWorker(args, /*isSemantic*/ true, function (project, file) { return project.getLanguageService().getSuggestionDiagnostics(file); }, !!args.includeLinePosition); + }; + Session.prototype.getJsxClosingTag = function (args) { + var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; + var position = this.getPositionInFile(args, file); + var tag = project.getLanguageService().getJsxClosingTagAtPosition(file, position); + return tag === undefined ? undefined : { newText: tag.newText, caretOffset: 0 }; }; Session.prototype.getDocumentHighlights = function (args, simplifiedResult) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; @@ -114767,7 +115719,7 @@ var ts; if ((!projects || !projects.length) && !symLinkedProjects) { return server.Errors.ThrowNoProject(); } - return symLinkedProjects ? { projects: projects, symLinkedProjects: symLinkedProjects } : projects; + return symLinkedProjects ? { projects: projects, symLinkedProjects: symLinkedProjects } : projects; // TODO: GH#18217 }; Session.prototype.getDefaultProject = function (args) { if (args.projectFileName) { @@ -114874,13 +115826,10 @@ var ts; var position = this.getPosition(args, scriptInfo); if (simplifiedResult) { var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position); - if (!nameInfo) { - return undefined; - } - var displayString = ts.displayPartsToString(nameInfo.displayParts); - var nameSpan = nameInfo.textSpan; - var nameColStart = scriptInfo.positionToLineOffset(nameSpan.start).offset; - var nameText = scriptInfo.getSnapshot().getText(nameSpan.start, ts.textSpanEnd(nameSpan)); + var displayString = nameInfo ? ts.displayPartsToString(nameInfo.displayParts) : ""; + var nameSpan = nameInfo && nameInfo.textSpan; + var nameColStart = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0; + var nameText = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, ts.textSpanEnd(nameSpan)) : ""; var refs = combineProjectOutput(file, function (path) { return _this.projectService.getScriptInfoForPath(path).fileName; }, projects, function (project, file) { var references = project.getLanguageService().getReferencesAtPosition(file, position); if (!references) { @@ -114953,7 +115902,7 @@ var ts; }; Session.prototype.getFileAndProjectWorker = function (uncheckedFileName, projectFileName) { var file = server.toNormalizedPath(uncheckedFileName); - var project = this.getProject(projectFileName) || this.projectService.getDefaultProjectForFile(file, /*ensureProject*/ true); + var project = this.getProject(projectFileName) || this.projectService.getDefaultProjectForFile(file, /*ensureProject*/ true); // TODO: GH#18217 return { file: file, project: project }; }; Session.prototype.getOutliningSpans = function (args, simplifiedResult) { @@ -115051,7 +116000,7 @@ var ts; Session.prototype.getFormattingEditsForRangeFull = function (args) { var _a = this.getFileAndLanguageServiceForSyntacticOperation(args), file = _a.file, languageService = _a.languageService; var options = args.options ? server.convertFormatOptions(args.options) : this.getFormatOptions(file); - return languageService.getFormattingEditsForRange(file, args.position, args.endPosition, options); + return languageService.getFormattingEditsForRange(file, args.position, args.endPosition, options); // TODO: GH#18217 }; Session.prototype.getFormattingEditsForDocumentFull = function (args) { var _a = this.getFileAndLanguageServiceForSyntacticOperation(args), file = _a.file, languageService = _a.languageService; @@ -115061,7 +116010,7 @@ var ts; Session.prototype.getFormattingEditsAfterKeystrokeFull = function (args) { var _a = this.getFileAndLanguageServiceForSyntacticOperation(args), file = _a.file, languageService = _a.languageService; var options = args.options ? server.convertFormatOptions(args.options) : this.getFormatOptions(file); - return languageService.getFormattingEditsAfterKeystroke(file, args.position, args.key, options); + return languageService.getFormattingEditsAfterKeystroke(file, args.position, args.key, options); // TODO: GH#18217 }; Session.prototype.getFormattingEditsAfterKeystroke = function (args) { var _a = this.getFileAndLanguageServiceForSyntacticOperation(args), file = _a.file, languageService = _a.languageService; @@ -115086,7 +116035,7 @@ var ts; hasIndent++; } else if (lineText.charAt(i) === "\t") { - hasIndent += formatOptions.tabSize; + hasIndent += formatOptions.tabSize; // TODO: GH#18217 } else { break; @@ -115232,13 +116181,13 @@ var ts; this.changeSeq++; this.projectService.applyChangesToFile(scriptInfo, [{ span: { start: start, length: end - start }, - newText: args.insertString + newText: args.insertString // TODO: GH#18217 }]); } }; Session.prototype.reload = function (args, reqSeq) { var file = server.toNormalizedPath(args.file); - var tempFileName = args.tmpfile && server.toNormalizedPath(args.tmpfile); + var tempFileName = args.tmpfile === undefined ? undefined : server.toNormalizedPath(args.tmpfile); var info = this.projectService.getScriptInfoForNormalizedPath(file); if (info) { this.changeSeq++; @@ -115396,7 +116345,7 @@ var ts; var _a = this.getStartAndEndPosition(args, scriptInfo), startPosition = _a.startPosition, endPosition = _a.endPosition; textRange = { pos: startPosition, end: endPosition }; } - return { position: position, textRange: textRange }; + return { position: position, textRange: textRange }; // TODO: GH#18217 function getPosition(loc) { return loc.position !== undefined ? loc.position : scriptInfo.lineOffsetToPosition(loc.line, loc.offset); } @@ -115444,12 +116393,12 @@ var ts; }; Session.prototype.getEditsForFileRename = function (args, simplifiedResult) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var changes = project.getLanguageService().getEditsForFileRename(args.oldFilePath, args.newFilePath, this.getFormatOptions(file)); + var changes = project.getLanguageService().getEditsForFileRename(args.oldFilePath, args.newFilePath, this.getFormatOptions(file), this.getPreferences(file)); return simplifiedResult ? this.mapTextChangesToCodeEdits(project, changes) : changes; }; Session.prototype.getCodeFixes = function (args, simplifiedResult) { var _this = this; - if (args.errorCodes.length === 0) { + if (args.errorCodes.length === 0) { // TODO: GH#18217 return undefined; } var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; @@ -115557,7 +116506,7 @@ var ts; return; } // No need to analyze lib.d.ts - var fileNamesInProject = fileNames.filter(function (value) { return !ts.stringContains(value, "lib.d.ts"); }); + var fileNamesInProject = fileNames.filter(function (value) { return !ts.stringContains(value, "lib.d.ts"); }); // TODO: GH#18217 if (fileNamesInProject.length === 0) { return; } @@ -115574,7 +116523,7 @@ var ts; highPriorityFiles.push(fileNameInProject); } else { - var info = this.projectService.getScriptInfo(fileNameInProject); + var info = this.projectService.getScriptInfo(fileNameInProject); // TODO: GH#18217 if (!info.isScriptOpen()) { if (ts.fileExtensionIs(fileNameInProject, ".d.ts" /* Dts */)) { veryLowPriorityFiles.push(fileNameInProject); @@ -115618,7 +116567,7 @@ var ts; }; Session.prototype.resetCurrentRequest = function (requestId) { ts.Debug.assert(this.currentRequestId === requestId); - this.currentRequestId = undefined; + this.currentRequestId = undefined; // TODO: GH#18217 this.cancellationToken.resetRequest(requestId); }; Session.prototype.executeWithRequestId = function (requestId, f) { @@ -116000,7 +116949,7 @@ var ts; if (oldVersion >= this.minVersion) { var textChangeRanges = []; for (var i = oldVersion + 1; i <= newVersion; i++) { - var snap = this.versions[this.versionToIndex(i)]; + var snap = this.versions[this.versionToIndex(i)]; // TODO: GH#18217 for (var _i = 0, _a = snap.changesSincePreviousVersion; _i < _a.length; _i++) { var textChange = _a[_i]; textChangeRanges.push(textChange.getTextChangeRange()); @@ -116136,6 +117085,7 @@ var ts; this.load(LineIndex.linesFromText(newText).lines); return this; } + return undefined; // TODO: GH#18217 } else { var checkText = void 0; @@ -116164,7 +117114,7 @@ var ts; var _a = this.positionToColumnAndLineText(e), zeroBasedColumn = _a.zeroBasedColumn, lineText = _a.lineText; if (zeroBasedColumn === 0) { // move range end just past line that will merge with previous line - deleteLength += lineText.length; + deleteLength += lineText.length; // TODO: GH#18217 // store text by appending to end of insertedText newText = newText ? newText + lineText : lineText; } diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index b449fc853c6..51bd949ae4d 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -204,169 +204,170 @@ declare namespace ts { TypeKeyword = 139, UndefinedKeyword = 140, UniqueKeyword = 141, - FromKeyword = 142, - GlobalKeyword = 143, - OfKeyword = 144, - QualifiedName = 145, - ComputedPropertyName = 146, - TypeParameter = 147, - Parameter = 148, - Decorator = 149, - PropertySignature = 150, - PropertyDeclaration = 151, - MethodSignature = 152, - MethodDeclaration = 153, - Constructor = 154, - GetAccessor = 155, - SetAccessor = 156, - CallSignature = 157, - ConstructSignature = 158, - IndexSignature = 159, - TypePredicate = 160, - TypeReference = 161, - FunctionType = 162, - ConstructorType = 163, - TypeQuery = 164, - TypeLiteral = 165, - ArrayType = 166, - TupleType = 167, - UnionType = 168, - IntersectionType = 169, - ConditionalType = 170, - InferType = 171, - ParenthesizedType = 172, - ThisType = 173, - TypeOperator = 174, - IndexedAccessType = 175, - MappedType = 176, - LiteralType = 177, - ImportType = 178, - ObjectBindingPattern = 179, - ArrayBindingPattern = 180, - BindingElement = 181, - ArrayLiteralExpression = 182, - ObjectLiteralExpression = 183, - PropertyAccessExpression = 184, - ElementAccessExpression = 185, - CallExpression = 186, - NewExpression = 187, - TaggedTemplateExpression = 188, - TypeAssertionExpression = 189, - ParenthesizedExpression = 190, - FunctionExpression = 191, - ArrowFunction = 192, - DeleteExpression = 193, - TypeOfExpression = 194, - VoidExpression = 195, - AwaitExpression = 196, - PrefixUnaryExpression = 197, - PostfixUnaryExpression = 198, - BinaryExpression = 199, - ConditionalExpression = 200, - TemplateExpression = 201, - YieldExpression = 202, - SpreadElement = 203, - ClassExpression = 204, - OmittedExpression = 205, - ExpressionWithTypeArguments = 206, - AsExpression = 207, - NonNullExpression = 208, - MetaProperty = 209, - TemplateSpan = 210, - SemicolonClassElement = 211, - Block = 212, - VariableStatement = 213, - EmptyStatement = 214, - ExpressionStatement = 215, - IfStatement = 216, - DoStatement = 217, - WhileStatement = 218, - ForStatement = 219, - ForInStatement = 220, - ForOfStatement = 221, - ContinueStatement = 222, - BreakStatement = 223, - ReturnStatement = 224, - WithStatement = 225, - SwitchStatement = 226, - LabeledStatement = 227, - ThrowStatement = 228, - TryStatement = 229, - DebuggerStatement = 230, - VariableDeclaration = 231, - VariableDeclarationList = 232, - FunctionDeclaration = 233, - ClassDeclaration = 234, - InterfaceDeclaration = 235, - TypeAliasDeclaration = 236, - EnumDeclaration = 237, - ModuleDeclaration = 238, - ModuleBlock = 239, - CaseBlock = 240, - NamespaceExportDeclaration = 241, - ImportEqualsDeclaration = 242, - ImportDeclaration = 243, - ImportClause = 244, - NamespaceImport = 245, - NamedImports = 246, - ImportSpecifier = 247, - ExportAssignment = 248, - ExportDeclaration = 249, - NamedExports = 250, - ExportSpecifier = 251, - MissingDeclaration = 252, - ExternalModuleReference = 253, - JsxElement = 254, - JsxSelfClosingElement = 255, - JsxOpeningElement = 256, - JsxClosingElement = 257, - JsxFragment = 258, - JsxOpeningFragment = 259, - JsxClosingFragment = 260, - JsxAttribute = 261, - JsxAttributes = 262, - JsxSpreadAttribute = 263, - JsxExpression = 264, - CaseClause = 265, - DefaultClause = 266, - HeritageClause = 267, - CatchClause = 268, - PropertyAssignment = 269, - ShorthandPropertyAssignment = 270, - SpreadAssignment = 271, - EnumMember = 272, - SourceFile = 273, - Bundle = 274, - UnparsedSource = 275, - InputFiles = 276, - JSDocTypeExpression = 277, - JSDocAllType = 278, - JSDocUnknownType = 279, - JSDocNullableType = 280, - JSDocNonNullableType = 281, - JSDocOptionalType = 282, - JSDocFunctionType = 283, - JSDocVariadicType = 284, - JSDocComment = 285, - JSDocTypeLiteral = 286, - JSDocSignature = 287, - JSDocTag = 288, - JSDocAugmentsTag = 289, - JSDocClassTag = 290, - JSDocCallbackTag = 291, - JSDocParameterTag = 292, - JSDocReturnTag = 293, - JSDocTypeTag = 294, - JSDocTemplateTag = 295, - JSDocTypedefTag = 296, - JSDocPropertyTag = 297, - SyntaxList = 298, - NotEmittedStatement = 299, - PartiallyEmittedExpression = 300, - CommaListExpression = 301, - MergeDeclarationMarker = 302, - EndOfDeclarationMarker = 303, - Count = 304, + UnknownKeyword = 142, + FromKeyword = 143, + GlobalKeyword = 144, + OfKeyword = 145, + QualifiedName = 146, + ComputedPropertyName = 147, + TypeParameter = 148, + Parameter = 149, + Decorator = 150, + PropertySignature = 151, + PropertyDeclaration = 152, + MethodSignature = 153, + MethodDeclaration = 154, + Constructor = 155, + GetAccessor = 156, + SetAccessor = 157, + CallSignature = 158, + ConstructSignature = 159, + IndexSignature = 160, + TypePredicate = 161, + TypeReference = 162, + FunctionType = 163, + ConstructorType = 164, + TypeQuery = 165, + TypeLiteral = 166, + ArrayType = 167, + TupleType = 168, + UnionType = 169, + IntersectionType = 170, + ConditionalType = 171, + InferType = 172, + ParenthesizedType = 173, + ThisType = 174, + TypeOperator = 175, + IndexedAccessType = 176, + MappedType = 177, + LiteralType = 178, + ImportType = 179, + ObjectBindingPattern = 180, + ArrayBindingPattern = 181, + BindingElement = 182, + ArrayLiteralExpression = 183, + ObjectLiteralExpression = 184, + PropertyAccessExpression = 185, + ElementAccessExpression = 186, + CallExpression = 187, + NewExpression = 188, + TaggedTemplateExpression = 189, + TypeAssertionExpression = 190, + ParenthesizedExpression = 191, + FunctionExpression = 192, + ArrowFunction = 193, + DeleteExpression = 194, + TypeOfExpression = 195, + VoidExpression = 196, + AwaitExpression = 197, + PrefixUnaryExpression = 198, + PostfixUnaryExpression = 199, + BinaryExpression = 200, + ConditionalExpression = 201, + TemplateExpression = 202, + YieldExpression = 203, + SpreadElement = 204, + ClassExpression = 205, + OmittedExpression = 206, + ExpressionWithTypeArguments = 207, + AsExpression = 208, + NonNullExpression = 209, + MetaProperty = 210, + TemplateSpan = 211, + SemicolonClassElement = 212, + Block = 213, + VariableStatement = 214, + EmptyStatement = 215, + ExpressionStatement = 216, + IfStatement = 217, + DoStatement = 218, + WhileStatement = 219, + ForStatement = 220, + ForInStatement = 221, + ForOfStatement = 222, + ContinueStatement = 223, + BreakStatement = 224, + ReturnStatement = 225, + WithStatement = 226, + SwitchStatement = 227, + LabeledStatement = 228, + ThrowStatement = 229, + TryStatement = 230, + DebuggerStatement = 231, + VariableDeclaration = 232, + VariableDeclarationList = 233, + FunctionDeclaration = 234, + ClassDeclaration = 235, + InterfaceDeclaration = 236, + TypeAliasDeclaration = 237, + EnumDeclaration = 238, + ModuleDeclaration = 239, + ModuleBlock = 240, + CaseBlock = 241, + NamespaceExportDeclaration = 242, + ImportEqualsDeclaration = 243, + ImportDeclaration = 244, + ImportClause = 245, + NamespaceImport = 246, + NamedImports = 247, + ImportSpecifier = 248, + ExportAssignment = 249, + ExportDeclaration = 250, + NamedExports = 251, + ExportSpecifier = 252, + MissingDeclaration = 253, + ExternalModuleReference = 254, + JsxElement = 255, + JsxSelfClosingElement = 256, + JsxOpeningElement = 257, + JsxClosingElement = 258, + JsxFragment = 259, + JsxOpeningFragment = 260, + JsxClosingFragment = 261, + JsxAttribute = 262, + JsxAttributes = 263, + JsxSpreadAttribute = 264, + JsxExpression = 265, + CaseClause = 266, + DefaultClause = 267, + HeritageClause = 268, + CatchClause = 269, + PropertyAssignment = 270, + ShorthandPropertyAssignment = 271, + SpreadAssignment = 272, + EnumMember = 273, + SourceFile = 274, + Bundle = 275, + UnparsedSource = 276, + InputFiles = 277, + JSDocTypeExpression = 278, + JSDocAllType = 279, + JSDocUnknownType = 280, + JSDocNullableType = 281, + JSDocNonNullableType = 282, + JSDocOptionalType = 283, + JSDocFunctionType = 284, + JSDocVariadicType = 285, + JSDocComment = 286, + JSDocTypeLiteral = 287, + JSDocSignature = 288, + JSDocTag = 289, + JSDocAugmentsTag = 290, + JSDocClassTag = 291, + JSDocCallbackTag = 292, + JSDocParameterTag = 293, + JSDocReturnTag = 294, + JSDocTypeTag = 295, + JSDocTemplateTag = 296, + JSDocTypedefTag = 297, + JSDocPropertyTag = 298, + SyntaxList = 299, + NotEmittedStatement = 300, + PartiallyEmittedExpression = 301, + CommaListExpression = 302, + MergeDeclarationMarker = 303, + EndOfDeclarationMarker = 304, + Count = 305, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -374,15 +375,15 @@ declare namespace ts { FirstReservedWord = 72, LastReservedWord = 107, FirstKeyword = 72, - LastKeyword = 144, + LastKeyword = 145, FirstFutureReservedWord = 108, LastFutureReservedWord = 116, - FirstTypeNode = 160, - LastTypeNode = 178, + FirstTypeNode = 161, + LastTypeNode = 179, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, - LastToken = 144, + LastToken = 145, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -391,11 +392,11 @@ declare namespace ts { LastTemplateToken = 16, FirstBinaryOperator = 27, LastBinaryOperator = 70, - FirstNode = 145, - FirstJSDocNode = 277, - LastJSDocNode = 297, - FirstJSDocTagNode = 288, - LastJSDocTagNode = 297 + FirstNode = 146, + FirstJSDocNode = 278, + LastJSDocNode = 298, + FirstJSDocTagNode = 289, + LastJSDocTagNode = 298 } enum NodeFlags { None = 0, @@ -460,7 +461,7 @@ declare namespace ts { flags: NodeFlags; decorators?: NodeArray; modifiers?: ModifiersArray; - parent?: Node; + parent: Node; } interface JSDocContainer { } @@ -525,12 +526,12 @@ declare namespace ts { } interface Decorator extends Node { kind: SyntaxKind.Decorator; - parent?: NamedDeclaration; + parent: NamedDeclaration; expression: LeftHandSideExpression; } interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; - parent?: DeclarationWithTypeParameters | InferTypeNode; + parent: DeclarationWithTypeParameters | InferTypeNode; name: Identifier; constraint?: TypeNode; default?: TypeNode; @@ -541,7 +542,7 @@ declare namespace ts { name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; - type: TypeNode | undefined; + type?: TypeNode; } type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { @@ -553,7 +554,7 @@ declare namespace ts { type BindingName = Identifier | BindingPattern; interface VariableDeclaration extends NamedDeclaration { kind: SyntaxKind.VariableDeclaration; - parent?: VariableDeclarationList | CatchClause; + parent: VariableDeclarationList | CatchClause; name: BindingName; exclamationToken?: ExclamationToken; type?: TypeNode; @@ -561,12 +562,12 @@ declare namespace ts { } interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; - parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement; + parent: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; - parent?: SignatureDeclaration; + parent: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; name: BindingName; questionToken?: QuestionToken; @@ -575,7 +576,7 @@ declare namespace ts { } interface BindingElement extends NamedDeclaration { kind: SyntaxKind.BindingElement; - parent?: BindingPattern; + parent: BindingPattern; propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; name: BindingName; @@ -628,12 +629,12 @@ declare namespace ts { } interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; - parent?: VariableDeclaration | ParameterDeclaration | BindingElement; + parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; - parent?: VariableDeclaration | ParameterDeclaration | BindingElement; + parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; @@ -662,47 +663,47 @@ declare namespace ts { } interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; - parent?: ObjectTypeDeclaration; + parent: ObjectTypeDeclaration; name: PropertyName; } interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; - parent?: ClassLikeDeclaration | ObjectLiteralExpression; + parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; - parent?: ClassLikeDeclaration; + parent: ClassLikeDeclaration; body?: FunctionBody; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; - parent?: ClassLikeDeclaration; + parent: ClassLikeDeclaration; } interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; - parent?: ClassLikeDeclaration | ObjectLiteralExpression; + parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; - parent?: ClassLikeDeclaration | ObjectLiteralExpression; + parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; - parent?: ObjectTypeDeclaration; + parent: ObjectTypeDeclaration; } interface TypeNode extends Node { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; @@ -730,7 +731,7 @@ declare namespace ts { } interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; - parent?: SignatureDeclaration; + parent: SignatureDeclaration; parameterName: Identifier | ThisTypeNode; type: TypeNode; } @@ -959,15 +960,15 @@ declare namespace ts { } interface TemplateHead extends LiteralLikeNode { kind: SyntaxKind.TemplateHead; - parent?: TemplateExpression; + parent: TemplateExpression; } interface TemplateMiddle extends LiteralLikeNode { kind: SyntaxKind.TemplateMiddle; - parent?: TemplateSpan; + parent: TemplateSpan; } interface TemplateTail extends LiteralLikeNode { kind: SyntaxKind.TemplateTail; - parent?: TemplateSpan; + parent: TemplateSpan; } type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; interface TemplateExpression extends PrimaryExpression { @@ -977,7 +978,7 @@ declare namespace ts { } interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; - parent?: TemplateExpression; + parent: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } @@ -991,7 +992,7 @@ declare namespace ts { } interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; - parent?: ArrayLiteralExpression | CallExpression | NewExpression; + parent: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; } /** @@ -1044,7 +1045,7 @@ declare namespace ts { } interface ExpressionWithTypeArguments extends NodeWithTypeArguments { kind: SyntaxKind.ExpressionWithTypeArguments; - parent?: HeritageClause; + parent: HeritageClause; expression: LeftHandSideExpression; } interface NewExpression extends PrimaryExpression, Declaration { @@ -1090,11 +1091,11 @@ declare namespace ts { type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; interface JsxAttributes extends ObjectLiteralExpressionBase { - parent?: JsxOpeningLikeElement; + parent: JsxOpeningLikeElement; } interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; - parent?: JsxElement; + parent: JsxElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; @@ -1113,38 +1114,38 @@ declare namespace ts { } interface JsxOpeningFragment extends Expression { kind: SyntaxKind.JsxOpeningFragment; - parent?: JsxFragment; + parent: JsxFragment; } interface JsxClosingFragment extends Expression { kind: SyntaxKind.JsxClosingFragment; - parent?: JsxFragment; + parent: JsxFragment; } interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; - parent?: JsxAttributes; + parent: JsxAttributes; name: Identifier; initializer?: StringLiteral | JsxExpression; } interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; - parent?: JsxAttributes; + parent: JsxAttributes; expression: Expression; } interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; - parent?: JsxElement; + parent: JsxElement; tagName: JsxTagNameExpression; } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; - parent?: JsxElement | JsxAttributeLike; + parent: JsxElement | JsxAttributeLike; dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { kind: SyntaxKind.JsxText; containsOnlyWhiteSpaces: boolean; - parent?: JsxElement; + parent: JsxElement; } type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; interface Statement extends Node { @@ -1245,18 +1246,18 @@ declare namespace ts { } interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; - parent?: SwitchStatement; + parent: SwitchStatement; clauses: NodeArray; } interface CaseClause extends Node { kind: SyntaxKind.CaseClause; - parent?: CaseBlock; + parent: CaseBlock; expression: Expression; statements: NodeArray; } interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; - parent?: CaseBlock; + parent: CaseBlock; statements: NodeArray; } type CaseOrDefaultClause = CaseClause | DefaultClause; @@ -1267,7 +1268,7 @@ declare namespace ts { } interface ThrowStatement extends Statement { kind: SyntaxKind.ThrowStatement; - expression: Expression; + expression?: Expression; } interface TryStatement extends Statement { kind: SyntaxKind.TryStatement; @@ -1277,7 +1278,7 @@ declare namespace ts { } interface CatchClause extends Node { kind: SyntaxKind.CatchClause; - parent?: TryStatement; + parent: TryStatement; variableDeclaration?: VariableDeclaration; block: Block; } @@ -1317,7 +1318,7 @@ declare namespace ts { } interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; - parent?: InterfaceDeclaration | ClassLikeDeclaration; + parent: InterfaceDeclaration | ClassLikeDeclaration; token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; types: NodeArray; } @@ -1329,7 +1330,7 @@ declare namespace ts { } interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; - parent?: EnumDeclaration; + parent: EnumDeclaration; name: PropertyName; initializer?: Expression; } @@ -1342,7 +1343,7 @@ declare namespace ts { type ModuleBody = NamespaceBody | JSDocNamespaceBody; interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; - parent?: ModuleBody | SourceFile; + parent: ModuleBody | SourceFile; name: ModuleName; body?: ModuleBody | JSDocNamespaceDeclaration; } @@ -1354,11 +1355,11 @@ declare namespace ts { type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: JSDocNamespaceBody; + body?: JSDocNamespaceBody; } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; - parent?: ModuleDeclaration; + parent: ModuleDeclaration; statements: NodeArray; } type ModuleReference = EntityName | ExternalModuleReference; @@ -1369,18 +1370,18 @@ declare namespace ts { */ interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; - parent?: SourceFile | ModuleBlock; + parent: SourceFile | ModuleBlock; name: Identifier; moduleReference: ModuleReference; } interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; - parent?: ImportEqualsDeclaration; - expression?: Expression; + parent: ImportEqualsDeclaration; + expression: Expression; } interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; - parent?: SourceFile | ModuleBlock; + parent: SourceFile | ModuleBlock; importClause?: ImportClause; /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier: Expression; @@ -1388,13 +1389,13 @@ declare namespace ts { type NamedImportBindings = NamespaceImport | NamedImports; interface ImportClause extends NamedDeclaration { kind: SyntaxKind.ImportClause; - parent?: ImportDeclaration; + parent: ImportDeclaration; name?: Identifier; namedBindings?: NamedImportBindings; } interface NamespaceImport extends NamedDeclaration { kind: SyntaxKind.NamespaceImport; - parent?: ImportClause; + parent: ImportClause; name: Identifier; } interface NamespaceExportDeclaration extends DeclarationStatement { @@ -1403,7 +1404,7 @@ declare namespace ts { } interface ExportDeclaration extends DeclarationStatement { kind: SyntaxKind.ExportDeclaration; - parent?: SourceFile | ModuleBlock; + parent: SourceFile | ModuleBlock; /** Will not be assigned in the case of `export * from "foo";` */ exportClause?: NamedExports; /** If this is not a StringLiteral it will be a grammar error. */ @@ -1411,24 +1412,24 @@ declare namespace ts { } interface NamedImports extends Node { kind: SyntaxKind.NamedImports; - parent?: ImportClause; + parent: ImportClause; elements: NodeArray; } interface NamedExports extends Node { kind: SyntaxKind.NamedExports; - parent?: ExportDeclaration; + parent: ExportDeclaration; elements: NodeArray; } type NamedImportsOrExports = NamedImports | NamedExports; interface ImportSpecifier extends NamedDeclaration { kind: SyntaxKind.ImportSpecifier; - parent?: NamedImports; + parent: NamedImports; propertyName?: Identifier; name: Identifier; } interface ExportSpecifier extends NamedDeclaration { kind: SyntaxKind.ExportSpecifier; - parent?: NamedExports; + parent: NamedExports; propertyName?: Identifier; name: Identifier; } @@ -1439,7 +1440,7 @@ declare namespace ts { */ interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; - parent?: SourceFile; + parent: SourceFile; isExportEquals?: boolean; expression: Expression; } @@ -1494,15 +1495,15 @@ declare namespace ts { type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; interface JSDoc extends Node { kind: SyntaxKind.JSDocComment; - parent?: HasJSDoc; - tags: NodeArray | undefined; - comment: string | undefined; + parent: HasJSDoc; + tags?: NodeArray; + comment?: string; } interface JSDocTag extends Node { parent: JSDoc | JSDocTypeLiteral; atToken: AtToken; tagName: Identifier; - comment: string | undefined; + comment?: string; } interface JSDocUnknownTag extends JSDocTag { kind: SyntaxKind.JSDocTag; @@ -1526,11 +1527,11 @@ declare namespace ts { } interface JSDocReturnTag extends JSDocTag { kind: SyntaxKind.JSDocReturnTag; - typeExpression: JSDocTypeExpression; + typeExpression?: JSDocTypeExpression; } interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; - typeExpression: JSDocTypeExpression; + typeExpression?: JSDocTypeExpression; } interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { parent: JSDoc; @@ -1608,7 +1609,7 @@ declare namespace ts { container?: FunctionExpression | ArrowFunction | MethodDeclaration; } interface FlowLabel extends FlowNodeBase { - antecedents: FlowNode[]; + antecedents: FlowNode[] | undefined; } interface FlowAssignment extends FlowNodeBase { node: Expression | VariableDeclaration | BindingElement; @@ -1635,7 +1636,7 @@ declare namespace ts { } interface AmdDependency { path: string; - name: string; + name?: string; } interface SourceFile extends Declaration { kind: SyntaxKind.SourceFile; @@ -1644,7 +1645,7 @@ declare namespace ts { fileName: string; text: string; amdDependencies: ReadonlyArray; - moduleName: string; + moduleName?: string; referencedFiles: ReadonlyArray; typeReferenceDirectives: ReadonlyArray; languageVariant: LanguageVariant; @@ -1704,7 +1705,7 @@ declare namespace ts { fileExists(path: string): boolean; readFile(path: string): string | undefined; } - type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray) => void; + type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles?: ReadonlyArray) => void; class OperationCanceledException { } interface CancellationToken { @@ -1734,9 +1735,10 @@ declare namespace ts { emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + /** The first time this is called, it will return global diagnostics (no location). */ getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; getConfigFileParsingDiagnostics(): ReadonlyArray; /** * Gets a type checker that can be used to semantically analyze source files in the program. @@ -1793,7 +1795,7 @@ declare namespace ts { emitSkipped: boolean; /** Contains declaration emit diagnostics */ diagnostics: ReadonlyArray; - emittedFiles: string[]; + emittedFiles?: string[]; } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; @@ -1810,7 +1812,7 @@ declare namespace ts { getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; /** Note that the resulting nodes cannot be checked. */ - typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode; + typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): (SignatureDeclaration & { typeArguments?: NodeArray; @@ -1846,7 +1848,7 @@ declare namespace ts { */ getExportSymbolOfSymbol(symbol: Symbol): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined; - getTypeAtLocation(node: Node): Type; + getTypeAtLocation(node: Node): Type | undefined; getTypeFromTypeNode(node: TypeNode): Type; signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; @@ -1863,9 +1865,10 @@ declare namespace ts { getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. + * returns undefined if the node is not valid. * @param argumentCount Apparent number of arguments, passed in case of a possibly incomplete call. This should come from an ArgumentListInfo. See `signatureHelp.ts`. */ - getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature; + getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined; getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined; isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined; isUndefinedSymbol(symbol: Symbol): boolean; @@ -2069,8 +2072,8 @@ declare namespace ts { interface Symbol { flags: SymbolFlags; escapedName: __String; - declarations?: Declaration[]; - valueDeclaration?: Declaration; + declarations: Declaration[]; + valueDeclaration: Declaration; members?: SymbolTable; exports?: SymbolTable; globalExports?: SymbolTable; @@ -2126,61 +2129,62 @@ declare namespace ts { type SymbolTable = UnderscoreEscapedMap; enum TypeFlags { Any = 1, - String = 2, - Number = 4, - Boolean = 8, - Enum = 16, - StringLiteral = 32, - NumberLiteral = 64, - BooleanLiteral = 128, - EnumLiteral = 256, - ESSymbol = 512, - UniqueESSymbol = 1024, - Void = 2048, - Undefined = 4096, - Null = 8192, - Never = 16384, - TypeParameter = 32768, - Object = 65536, - Union = 131072, - Intersection = 262144, - Index = 524288, - IndexedAccess = 1048576, - Conditional = 2097152, - Substitution = 4194304, - NonPrimitive = 134217728, - Literal = 224, - Unit = 13536, - StringOrNumberLiteral = 96, - PossiblyFalsy = 14574, - StringLike = 34, - NumberLike = 84, - BooleanLike = 136, - EnumLike = 272, - ESSymbolLike = 1536, - VoidLike = 6144, - UnionOrIntersection = 393216, - StructuredType = 458752, - TypeVariable = 1081344, - InstantiableNonPrimitive = 7372800, - InstantiablePrimitive = 524288, - Instantiable = 7897088, - StructuredOrInstantiable = 8355840, - Narrowable = 142575359, - NotUnionOrUnit = 134283777 + Unknown = 2, + String = 4, + Number = 8, + Boolean = 16, + Enum = 32, + StringLiteral = 64, + NumberLiteral = 128, + BooleanLiteral = 256, + EnumLiteral = 512, + ESSymbol = 1024, + UniqueESSymbol = 2048, + Void = 4096, + Undefined = 8192, + Null = 16384, + Never = 32768, + TypeParameter = 65536, + Object = 131072, + Union = 262144, + Intersection = 524288, + Index = 1048576, + IndexedAccess = 2097152, + Conditional = 4194304, + Substitution = 8388608, + NonPrimitive = 16777216, + Literal = 448, + Unit = 27072, + StringOrNumberLiteral = 192, + PossiblyFalsy = 29148, + StringLike = 68, + NumberLike = 168, + BooleanLike = 272, + EnumLike = 544, + ESSymbolLike = 3072, + VoidLike = 12288, + UnionOrIntersection = 786432, + StructuredType = 917504, + TypeVariable = 2162688, + InstantiableNonPrimitive = 14745600, + InstantiablePrimitive = 1048576, + Instantiable = 15794176, + StructuredOrInstantiable = 16711680, + Narrowable = 33492479, + NotUnionOrUnit = 16909315 } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { flags: TypeFlags; - symbol?: Symbol; + symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; aliasTypeArguments?: Type[]; } interface LiteralType extends Type { value: string | number; - freshType?: LiteralType; - regularType?: LiteralType; + freshType: LiteralType; + regularType: LiteralType; } interface UniqueESSymbolType extends Type { symbol: Symbol; @@ -2215,18 +2219,18 @@ declare namespace ts { } /** Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). */ interface InterfaceType extends ObjectType { - typeParameters: TypeParameter[]; - outerTypeParameters: TypeParameter[]; - localTypeParameters: TypeParameter[]; - thisType: TypeParameter; + typeParameters: TypeParameter[] | undefined; + outerTypeParameters: TypeParameter[] | undefined; + localTypeParameters: TypeParameter[] | undefined; + thisType: TypeParameter | undefined; } type BaseType = ObjectType | IntersectionType; interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; - declaredStringIndexInfo: IndexInfo; - declaredNumberIndexInfo: IndexInfo; + declaredStringIndexInfo?: IndexInfo; + declaredNumberIndexInfo?: IndexInfo; } /** * Type references (ObjectFlags.Reference). When a class or interface has type parameters or @@ -2277,11 +2281,11 @@ declare namespace ts { trueType: Type; falseType: Type; isDistributive: boolean; - inferTypeParameters: TypeParameter[]; + inferTypeParameters?: TypeParameter[]; outerTypeParameters?: TypeParameter[]; instantiations?: Map; - aliasSymbol: Symbol; - aliasTypeArguments: Type[]; + aliasSymbol?: Symbol; + aliasTypeArguments?: Type[]; } interface ConditionalType extends InstantiableType { root: ConditionalRoot; @@ -2359,6 +2363,11 @@ declare namespace ts { code: number; source?: string; } + interface DiagnosticWithLocation extends Diagnostic { + file: SourceFile; + start: number; + length: number; + } enum DiagnosticCategory { Warning = 0, Error = 1, @@ -2624,7 +2633,7 @@ declare namespace ts { packageId?: PackageId; } interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { - readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective; + readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; readonly failedLookupLocations: ReadonlyArray; } interface CompilerHost extends ModuleResolutionHost { @@ -2644,8 +2653,8 @@ declare namespace ts { /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): (ResolvedTypeReferenceDirective | undefined)[]; - getEnvironmentVariable?(name: string): string; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; } interface SourceMapRange extends TextRange { @@ -2657,6 +2666,7 @@ declare namespace ts { skipTrivia?: (pos: number) => number; } enum EmitFlags { + None = 0, SingleLine = 1, AdviseOnEmitNode = 2, NoSubstitution = 4, @@ -2710,7 +2720,7 @@ declare namespace ts { /** Resumes a suspended lexical environment, usually before visiting a function body. */ resumeLexicalEnvironment(): void; /** Ends a lexical environment, returning any declarations. */ - endLexicalEnvironment(): Statement[]; + endLexicalEnvironment(): Statement[] | undefined; /** Hoists a function declaration to the containing scope. */ hoistFunctionDeclaration(node: FunctionDeclaration): void; /** Hoists a variable declaration to the containing scope. */ @@ -2754,7 +2764,7 @@ declare namespace ts { /** Gets the transformed source files. */ transformed: T[]; /** Gets diagnostics for the transformation. */ - diagnostics?: Diagnostic[]; + diagnostics?: DiagnosticWithLocation[]; /** * Gets a substitute for a node, if one is available; otherwise, returns the original node. * @@ -2841,7 +2851,7 @@ declare namespace ts { * }); * ``` */ - onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + onEmitNode?(hint: EmitHint, node: Node | undefined, emitCallback: (hint: EmitHint, node: Node | undefined) => void): void; /** * 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, @@ -2954,13 +2964,13 @@ declare namespace ts { } } declare namespace ts { - const versionMajorMinor = "2.9"; + const versionMajorMinor = "3.0"; /** The version of the TypeScript compiler release */ const version: string; } declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): Diagnostic[]; + function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): T[]; } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; @@ -3014,7 +3024,7 @@ declare namespace ts { interface FileWatcher { close(): void; } - function getNodeMajorVersion(): number; + function getNodeMajorVersion(): number | undefined; let sys: System; } declare namespace ts { @@ -3041,8 +3051,8 @@ declare namespace ts { scanJSDocToken(): JsDocSyntaxKind; scan(): SyntaxKind; getText(): string; - setText(text: string, start?: number, length?: number): void; - setOnError(onError: ErrorCallback): void; + setText(text: string | undefined, start?: number, length?: number): void; + setOnError(onError: ErrorCallback | undefined): void; setScriptTarget(scriptTarget: ScriptTarget): void; setLanguageVariant(variant: LanguageVariant): void; setTextPos(textPos: number): void; @@ -3062,15 +3072,15 @@ declare namespace ts { function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; - function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; - function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; + function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined; + function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined; function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; /** Optionally, get the shebang */ function getShebang(text: string): string | undefined; - function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; - function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; - function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; + function isIdentifierStart(ch: number, languageVersion: ScriptTarget | undefined): boolean; + function isIdentifierPart(ch: number, languageVersion: ScriptTarget | undefined): boolean; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, textInitial?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3079,12 +3089,12 @@ declare namespace ts { function textSpanContainsPosition(span: TextSpan, position: number): boolean; function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean; function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean; - function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan; + function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan | undefined; function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean; function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean; function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; - function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan; + function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan | undefined; function createTextSpan(start: number, length: number): TextSpan; function createTextSpanFromBounds(start: number, end: number): TextSpan; function textChangeRangeNewSpan(range: TextChangeRange): TextSpan; @@ -3100,7 +3110,7 @@ declare namespace ts { * Vn. */ function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; - function getTypeParameterOwner(d: Declaration): Declaration; + function getTypeParameterOwner(d: Declaration): Declaration | undefined; type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration; name: Identifier; @@ -3122,6 +3132,8 @@ declare namespace ts { }, errors?: Push): void; function getOriginalNode(node: Node): Node; function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; + function getOriginalNode(node: Node | undefined): Node | undefined; + function getOriginalNode(node: Node | undefined, nodeTest: (node: Node | undefined) => node is T): T | undefined; /** * Gets a value indicating whether a node originated in the parse tree. * @@ -3142,7 +3154,7 @@ declare namespace ts { * @param nodeTest A callback used to ensure the correct type of parse tree node is returned. * @returns The original parse tree node if found; otherwise, undefined. */ - function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; + function getParseTreeNode(node: Node | undefined, nodeTest?: (node: Node) => node is T): T | undefined; /** * Remove extra underscore from escaped identifier text content. * @@ -3160,7 +3172,7 @@ declare namespace ts { */ function unescapeIdentifier(id: string): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined; - function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; + function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName; /** * Gets the JSDoc parameter tags for the node if present. * @@ -3389,8 +3401,10 @@ declare namespace ts { */ function isToken(n: Node): boolean; function isLiteralExpression(node: Node): node is LiteralExpression; + type TemplateLiteralToken = NoSubstitutionTemplateLiteral | TemplateHead | TemplateMiddle | TemplateTail; + function isTemplateLiteralToken(node: Node): node is TemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail; - function isStringTextContainingNode(node: Node): boolean; + function isStringTextContainingNode(node: Node): node is StringLiteral | TemplateLiteralToken; function isModifier(node: Node): node is Modifier; function isEntityName(node: Node): node is EntityName; function isPropertyName(node: Node): node is PropertyName; @@ -3442,7 +3456,7 @@ declare namespace ts { */ function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; - function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName; + function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; /** * Parse json text into SyntaxTree and return node and parse errors if any * @param fileName @@ -3488,7 +3502,7 @@ declare namespace ts { getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; } interface PerModuleNameCache { - get(directory: string): ResolvedModuleWithFailedLookupLocations; + get(directory: string): ResolvedModuleWithFailedLookupLocations | undefined; set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; @@ -3570,7 +3584,7 @@ declare namespace ts { function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; function createTypeQueryNode(exprName: EntityName): TypeQueryNode; function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; - function createTypeLiteralNode(members: ReadonlyArray): TypeLiteralNode; + function createTypeLiteralNode(members: ReadonlyArray | undefined): TypeLiteralNode; function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; @@ -3609,23 +3623,23 @@ declare namespace ts { function updateArrayLiteral(node: ArrayLiteralExpression, elements: ReadonlyArray): ArrayLiteralExpression; function createObjectLiteral(properties?: ReadonlyArray, multiLine?: boolean): ObjectLiteralExpression; function updateObjectLiteral(node: ObjectLiteralExpression, properties: ReadonlyArray): ObjectLiteralExpression; - function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; + function createPropertyAccess(expression: Expression, name: string | Identifier | undefined): PropertyAccessExpression; function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; + function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): CallExpression; function updateCall(node: CallExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; function createNew(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; function updateNew(node: NewExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray, template: TemplateLiteral): TaggedTemplateExpression; + function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; + function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; @@ -3655,15 +3669,15 @@ declare namespace ts { function createTemplateTail(text: string): TemplateTail; function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral; function createYield(expression?: Expression): YieldExpression; - function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; + function createYield(asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray, members: ReadonlyArray): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray, members: ReadonlyArray): ClassExpression; + function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; function createOmittedExpression(): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: ReadonlyArray, expression: Expression): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray, expression: Expression): ExpressionWithTypeArguments; + function createExpressionWithTypeArguments(typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; function createAsExpression(expression: Expression, type: TypeNode): AsExpression; function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; function createNonNullExpression(expression: Expression): NonNullExpression; @@ -3690,8 +3704,8 @@ declare namespace ts { function updateFor(node: ForStatement, initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement): ForStatement; function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; - function createForOf(awaitModifier: AwaitKeywordToken, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; - function updateForOf(node: ForOfStatement, awaitModifier: AwaitKeywordToken, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function createForOf(awaitModifier: AwaitKeywordToken | undefined, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function updateForOf(node: ForOfStatement, awaitModifier: AwaitKeywordToken | undefined, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; function createContinue(label?: string | Identifier): ContinueStatement; function updateContinue(node: ContinueStatement, label: Identifier | undefined): ContinueStatement; function createBreak(label?: string | Identifier): BreakStatement; @@ -3715,8 +3729,8 @@ declare namespace ts { function updateVariableDeclarationList(node: VariableDeclarationList, declarations: ReadonlyArray): VariableDeclarationList; function createFunctionDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; function updateFunctionDeclaration(node: FunctionDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray, members: ReadonlyArray): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray, members: ReadonlyArray): ClassDeclaration; + function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; function createInterfaceDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; function createTypeAliasDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; @@ -3734,7 +3748,7 @@ declare namespace ts { function createImportEqualsDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; function createImportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression | undefined): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; function createImportClause(name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function updateImportClause(node: ImportClause, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; @@ -3743,7 +3757,7 @@ declare namespace ts { function updateNamedImports(node: NamedImports, elements: ReadonlyArray): NamedImports; function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean, expression: Expression): ExportAssignment; + function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; function updateExportAssignment(node: ExportAssignment, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, expression: Expression): ExportAssignment; function createExportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; function updateExportDeclaration(node: ExportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; @@ -3873,16 +3887,16 @@ declare namespace ts { */ function setCommentRange(node: T, range: TextRange): T; function getSyntheticLeadingComments(node: Node): SynthesizedComment[] | undefined; - function setSyntheticLeadingComments(node: T, comments: SynthesizedComment[]): T; + function setSyntheticLeadingComments(node: T, comments: SynthesizedComment[] | undefined): T; function addSyntheticLeadingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T; function getSyntheticTrailingComments(node: Node): SynthesizedComment[] | undefined; - function setSyntheticTrailingComments(node: T, comments: SynthesizedComment[]): T; + function setSyntheticTrailingComments(node: T, comments: SynthesizedComment[] | undefined): T; function addSyntheticTrailingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T; function moveSyntheticComments(node: T, original: Node): T; /** * Gets the constant value to emit for an expression. */ - function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): string | number; + function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): string | number | undefined; /** * Sets the constant value to emit for an expression. */ @@ -3918,7 +3932,7 @@ declare namespace ts { * @param test A callback to execute to verify the Node is valid. * @param lift An optional callback to execute to lift a NodeArray into a valid Node. */ - function visitNode(node: T, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T; + function visitNode(node: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T; /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. * @@ -3927,7 +3941,7 @@ declare namespace ts { * @param test A callback to execute to verify the Node is valid. * @param lift An optional callback to execute to lift a NodeArray into a valid Node. */ - function visitNode(node: T | undefined, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T | undefined; + function visitNode(node: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T | undefined; /** * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. * @@ -3937,7 +3951,7 @@ declare namespace ts { * @param start An optional value indicating the starting offset at which to start visiting. * @param count An optional value indicating the maximum number of nodes to visit. */ - function visitNodes(nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; + function visitNodes(nodes: NodeArray | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; /** * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. * @@ -3957,7 +3971,7 @@ declare namespace ts { * Starts a new lexical environment and visits a parameter list, suspending the lexical * environment upon completion. */ - function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): NodeArray; + function visitParameterList(nodes: NodeArray | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): NodeArray; /** * Resumes a suspended lexical environment and visits a function body, ending the lexical * environment and merging hoisted declarations upon completion. @@ -4006,8 +4020,19 @@ declare namespace ts { function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; + function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain | undefined, newLine: string): string; function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): ReadonlyArray; + /** + * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' + * that represent a compilation unit. + * + * Creating a program proceeds from a set of root files, expanding the set of inputs by following imports and + * triple-slash-reference-path directives transitively. '@types' and triple-slash-reference-types are also pulled in. + * + * @param createProgramOptions - The options for creating a program. + * @returns A 'Program' object. + */ + function createProgram(createProgramOptions: CreateProgramOptions): Program; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4022,7 +4047,6 @@ declare namespace ts { * @param configFileParsingDiagnostics - error during config file parsing * @returns A 'Program' object. */ - function createProgram(createProgramOptions: CreateProgramOptions): Program; function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; } declare namespace ts { @@ -4148,18 +4172,18 @@ declare namespace ts { * Create the builder to manage semantic diagnostics and cache them */ function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; - function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; /** * Create the builder that can handle the changes in program and iterate through changed files * to emit the those files and manage semantic diagnostics cache as well */ function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; - function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; /** * Creates a builder thats just abstraction over program and can be used with watch */ function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; - function createAbstractBuilder(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; + function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; } declare namespace ts { type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void; @@ -4201,11 +4225,11 @@ declare namespace ts { /** If provided would be used to write log about compilation */ trace?(s: string): void; /** If provided is used to get the environment variable */ - getEnvironmentVariable?(name: string): string; + getEnvironmentVariable?(name: string): string | undefined; /** If provided, used to resolve the module names, otherwise typescript's default module resolution */ resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; /** Used to watch changes in source files, missing files needed to update the program or config file */ watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; /** Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added */ @@ -4355,8 +4379,8 @@ declare namespace ts { getLeadingTriviaWidth(sourceFile?: SourceFile): number; getFullText(sourceFile?: SourceFile): string; getText(sourceFile?: SourceFile): string; - getFirstToken(sourceFile?: SourceFile): Node; - getLastToken(sourceFile?: SourceFile): Node; + getFirstToken(sourceFile?: SourceFile): Node | undefined; + getLastToken(sourceFile?: SourceFile): Node | undefined; forEachChild(cbNode: (node: Node) => T | undefined, cbNodeArray?: (nodes: NodeArray) => T | undefined): T | undefined; } interface Identifier { @@ -4444,7 +4468,7 @@ declare namespace ts { referencedFiles: FileReference[]; typeReferenceDirectives: FileReference[]; importedFiles: FileReference[]; - ambientExternalModules: string[]; + ambientExternalModules?: string[]; isLibFile: boolean; } interface HostCancellationToken { @@ -4477,7 +4501,7 @@ declare namespace ts { fileExists?(path: string): boolean; getTypeRootsVersion?(): number; resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; - getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations; + getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getDirectories?(directoryName: string): string[]; /** @@ -4497,9 +4521,10 @@ declare namespace ts { } interface LanguageService { cleanupSemanticCache(): void; - getSyntacticDiagnostics(fileName: string): Diagnostic[]; + getSyntacticDiagnostics(fileName: string): DiagnosticWithLocation[]; + /** The first time this is called, it will return global diagnostics (no location). */ getSemanticDiagnostics(fileName: string): Diagnostic[]; - getSuggestionDiagnostics(fileName: string): Diagnostic[]; + getSuggestionDiagnostics(fileName: string): DiagnosticWithLocation[]; getCompilerOptionsDiagnostics(): Diagnostic[]; /** * @deprecated Use getEncodedSyntacticClassifications instead. @@ -4511,24 +4536,24 @@ declare namespace ts { getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; - getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): CompletionInfo; - getCompletionEntryDetails(fileName: string, position: number, name: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails; - getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol; - getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; - getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan; - getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan; - getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems; + getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): CompletionInfo | undefined; + getCompletionEntryDetails(fileName: string, position: number, name: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails | undefined; + getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol | undefined; + getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined; + getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined; + getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; + getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; - getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; - getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan; - getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; - getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[]; - getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; - findReferences(fileName: string, position: number): ReferencedSymbol[]; - getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; + getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; + getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; + getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] | undefined; + getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; + findReferences(fileName: string, position: number): ReferencedSymbol[] | undefined; + getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; /** @deprecated */ - getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -4539,9 +4564,14 @@ 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; + getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion | undefined; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan; + /** + * 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. + * Editors should call this after `>` is typed. + */ + getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined; + getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; @@ -4557,11 +4587,14 @@ declare namespace ts { getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined): 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): ReadonlyArray; - getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings): ReadonlyArray; + getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; - getProgram(): Program; + getProgram(): Program | undefined; dispose(): void; } + interface JsxClosingTagInfo { + readonly newText: string; + } interface CombinedCodeFixScope { type: "file"; fileName: string; @@ -4662,7 +4695,7 @@ declare namespace ts { } interface CombinedCodeActions { changes: ReadonlyArray; - commands: ReadonlyArray | undefined; + commands?: ReadonlyArray; } type CodeActionCommand = InstallPackageAction; interface InstallPackageAction { @@ -4712,8 +4745,8 @@ declare namespace ts { */ interface RefactorEditInfo { edits: FileTextChanges[]; - renameFilename: string | undefined; - renameLocation: number | undefined; + renameFilename?: string; + renameLocation?: number; commands?: CodeActionCommand[]; } interface TextInsertion { @@ -4834,7 +4867,7 @@ declare namespace ts { containerName: string; } interface DefinitionInfoAndBoundSpan { - definitions: ReadonlyArray; + definitions?: ReadonlyArray; textSpan: TextSpan; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { @@ -4880,13 +4913,13 @@ declare namespace ts { kind: ScriptElementKind; kindModifiers: string; textSpan: TextSpan; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - tags: JSDocTagInfo[]; + displayParts?: SymbolDisplayPart[]; + documentation?: SymbolDisplayPart[]; + tags?: JSDocTagInfo[]; } interface RenameInfo { canRename: boolean; - localizedErrorMessage: string; + localizedErrorMessage?: string; displayName: string; fullDisplayName: string; kind: ScriptElementKind; @@ -4938,7 +4971,7 @@ declare namespace ts { interface CompletionEntry { name: string; kind: ScriptElementKind; - kindModifiers: string; + kindModifiers?: string; sortText: string; insertText?: string; /** @@ -4956,8 +4989,8 @@ declare namespace ts { kind: ScriptElementKind; kindModifiers: string; displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - tags: JSDocTagInfo[]; + documentation?: SymbolDisplayPart[]; + tags?: JSDocTagInfo[]; codeActions?: CodeAction[]; source?: SymbolDisplayPart[]; } @@ -5270,12 +5303,12 @@ declare namespace ts { /** The version of the language service API */ const servicesVersion = "0.8"; function toEditorSettings(options: EditorOptions | EditorSettings): EditorSettings; - function displayPartsToString(displayParts: SymbolDisplayPart[]): string; + function displayPartsToString(displayParts: SymbolDisplayPart[] | undefined): string; function getDefaultCompilerOptions(): CompilerOptions; function getSupportedCodeFixes(): string[]; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile; let disableIncrementalParsing: boolean; - function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange | undefined, aggressiveChecks?: boolean): SourceFile; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry, syntaxOnly?: boolean): LanguageService; /** * Get the path of the default library files (lib.d.ts) as distributed with the typescript diff --git a/lib/typescript.js b/lib/typescript.js index 5a20323ef59..84491873e2b 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -202,190 +202,191 @@ var ts; SyntaxKind[SyntaxKind["TypeKeyword"] = 139] = "TypeKeyword"; SyntaxKind[SyntaxKind["UndefinedKeyword"] = 140] = "UndefinedKeyword"; SyntaxKind[SyntaxKind["UniqueKeyword"] = 141] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 142] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 143] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 144] = "OfKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 142] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 143] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 144] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 145] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 145] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 146] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 146] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 147] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 147] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 148] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 149] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 148] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 149] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 150] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 150] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 151] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 152] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 153] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 154] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 155] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 156] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 157] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 158] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 159] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 151] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 152] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 153] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 154] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 155] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 156] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 157] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 158] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 159] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 160] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 160] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 161] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 162] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 163] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 164] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 165] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 166] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 167] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 168] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 169] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 170] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 171] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 172] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 173] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 174] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 175] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 176] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 177] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 178] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 161] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 162] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 163] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 164] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 165] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 166] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 167] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 168] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 169] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 170] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 171] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 172] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 173] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 174] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 175] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 176] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 177] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 178] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 179] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 179] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 180] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 181] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 180] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 181] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 182] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 182] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 183] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 184] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 185] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 186] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 187] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 188] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 189] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 190] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 191] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 192] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 193] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 194] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 195] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 196] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 197] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 198] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 199] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 200] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 201] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 202] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 203] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 204] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 205] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 206] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 207] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 208] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 209] = "MetaProperty"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 183] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 184] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 185] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 186] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 187] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 188] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 189] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 190] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 191] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 192] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 193] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 194] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 195] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 196] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 197] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 198] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 199] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 200] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 201] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 202] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 203] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 204] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 205] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 206] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 207] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 208] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 209] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 210] = "MetaProperty"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 210] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 211] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 211] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 212] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 212] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 213] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 214] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 215] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 216] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 217] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 218] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 219] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 220] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 221] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 222] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 223] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 224] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 225] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 226] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 227] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 228] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 229] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 230] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 231] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 232] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 233] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 234] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 235] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 236] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 237] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 238] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 239] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 240] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 241] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 242] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 243] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 244] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 245] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 246] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 247] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 248] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 249] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 250] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 251] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 252] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 213] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 214] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 215] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 216] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 217] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 218] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 219] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 220] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 221] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 222] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 223] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 224] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 225] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 226] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 227] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 228] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 229] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 230] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 231] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 232] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 233] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 234] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 235] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 236] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 237] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 238] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 239] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 240] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 241] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 242] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 243] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 244] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 245] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 246] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 247] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 248] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 249] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 250] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 251] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 252] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 253] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 253] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 254] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 254] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 255] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 256] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 257] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 258] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 259] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 260] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 261] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 262] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 263] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 264] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 255] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 256] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 257] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 258] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 259] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 260] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 261] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 262] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 263] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 264] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 265] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 265] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 266] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 267] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 268] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 266] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 267] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 268] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 269] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 269] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 270] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 271] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 270] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 271] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 272] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 272] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 273] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 273] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 274] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 275] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 276] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 274] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 275] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 276] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 277] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 277] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 278] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 278] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 279] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 279] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 280] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 281] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 282] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 283] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 284] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 285] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 286] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 287] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 288] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 289] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 290] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 291] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 292] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 293] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 294] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 295] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 296] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 297] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 280] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 281] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 282] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 283] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 284] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 285] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 286] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 288] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 289] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 290] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 291] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 292] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 293] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 294] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 295] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 296] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 297] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 298] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 298] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 299] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 299] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 300] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 301] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 302] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 303] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 300] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 301] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 302] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 303] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 304] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 304] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 305] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; @@ -394,15 +395,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 144] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 145] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 160] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 178] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 179] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 144] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 145] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -411,13 +412,13 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 145] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 277] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 297] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 288] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 297] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 278] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 298] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 289] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 298] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 144] = "LastContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -857,89 +858,93 @@ var ts; var TypeFlags; (function (TypeFlags) { TypeFlags[TypeFlags["Any"] = 1] = "Any"; - TypeFlags[TypeFlags["String"] = 2] = "String"; - TypeFlags[TypeFlags["Number"] = 4] = "Number"; - TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; - TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; - TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; - TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; - TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; - TypeFlags[TypeFlags["UniqueESSymbol"] = 1024] = "UniqueESSymbol"; - TypeFlags[TypeFlags["Void"] = 2048] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 4096] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 8192] = "Null"; - TypeFlags[TypeFlags["Never"] = 16384] = "Never"; - TypeFlags[TypeFlags["TypeParameter"] = 32768] = "TypeParameter"; - TypeFlags[TypeFlags["Object"] = 65536] = "Object"; - TypeFlags[TypeFlags["Union"] = 131072] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 262144] = "Intersection"; - TypeFlags[TypeFlags["Index"] = 524288] = "Index"; - TypeFlags[TypeFlags["IndexedAccess"] = 1048576] = "IndexedAccess"; - TypeFlags[TypeFlags["Conditional"] = 2097152] = "Conditional"; - TypeFlags[TypeFlags["Substitution"] = 4194304] = "Substitution"; + TypeFlags[TypeFlags["Unknown"] = 2] = "Unknown"; + TypeFlags[TypeFlags["String"] = 4] = "String"; + TypeFlags[TypeFlags["Number"] = 8] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 16] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 32] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 64] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 128] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 256] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 512] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 1024] = "ESSymbol"; + TypeFlags[TypeFlags["UniqueESSymbol"] = 2048] = "UniqueESSymbol"; + TypeFlags[TypeFlags["Void"] = 4096] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 8192] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 16384] = "Null"; + TypeFlags[TypeFlags["Never"] = 32768] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 65536] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 131072] = "Object"; + TypeFlags[TypeFlags["Union"] = 262144] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 524288] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 1048576] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 2097152] = "IndexedAccess"; + TypeFlags[TypeFlags["Conditional"] = 4194304] = "Conditional"; + TypeFlags[TypeFlags["Substitution"] = 8388608] = "Substitution"; + TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; /* @internal */ - TypeFlags[TypeFlags["FreshLiteral"] = 8388608] = "FreshLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 33554432] = "FreshLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsWideningType"] = 16777216] = "ContainsWideningType"; + TypeFlags[TypeFlags["UnionOfUnitTypes"] = 67108864] = "UnionOfUnitTypes"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 33554432] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 134217728] = "ContainsWideningType"; /* @internal */ - TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 67108864] = "ContainsAnyFunctionType"; - TypeFlags[TypeFlags["NonPrimitive"] = 134217728] = "NonPrimitive"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 268435456] = "ContainsObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["UnionOfUnitTypes"] = 268435456] = "UnionOfUnitTypes"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 536870912] = "ContainsAnyFunctionType"; /* @internal */ - TypeFlags[TypeFlags["GenericMappedType"] = 536870912] = "GenericMappedType"; + TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; /* @internal */ - TypeFlags[TypeFlags["Nullable"] = 12288] = "Nullable"; - TypeFlags[TypeFlags["Literal"] = 224] = "Literal"; - TypeFlags[TypeFlags["Unit"] = 13536] = "Unit"; - TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["Nullable"] = 24576] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 448] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 27072] = "Unit"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 192] = "StringOrNumberLiteral"; /* @internal */ - TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 1120] = "StringOrNumberLiteralOrUnique"; + TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 2240] = "StringOrNumberLiteralOrUnique"; /* @internal */ - TypeFlags[TypeFlags["DefinitelyFalsy"] = 14560] = "DefinitelyFalsy"; - TypeFlags[TypeFlags["PossiblyFalsy"] = 14574] = "PossiblyFalsy"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 29120] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 29148] = "PossiblyFalsy"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 134249103] = "Intrinsic"; + TypeFlags[TypeFlags["Intrinsic"] = 16839967] = "Intrinsic"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 16382] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 84] = "NumberLike"; - TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; - TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; - TypeFlags[TypeFlags["ESSymbolLike"] = 1536] = "ESSymbolLike"; - TypeFlags[TypeFlags["VoidLike"] = 6144] = "VoidLike"; + TypeFlags[TypeFlags["Primitive"] = 32764] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 68] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 168] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 272] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 544] = "EnumLike"; + TypeFlags[TypeFlags["ESSymbolLike"] = 3072] = "ESSymbolLike"; + TypeFlags[TypeFlags["VoidLike"] = 12288] = "VoidLike"; /* @internal */ - TypeFlags[TypeFlags["DisjointDomains"] = 134233854] = "DisjointDomains"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 393216] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 458752] = "StructuredType"; - TypeFlags[TypeFlags["TypeVariable"] = 1081344] = "TypeVariable"; - TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 7372800] = "InstantiableNonPrimitive"; - TypeFlags[TypeFlags["InstantiablePrimitive"] = 524288] = "InstantiablePrimitive"; - TypeFlags[TypeFlags["Instantiable"] = 7897088] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 8355840] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["DisjointDomains"] = 16809468] = "DisjointDomains"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 786432] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 917504] = "StructuredType"; + TypeFlags[TypeFlags["TypeVariable"] = 2162688] = "TypeVariable"; + TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 14745600] = "InstantiableNonPrimitive"; + TypeFlags[TypeFlags["InstantiablePrimitive"] = 1048576] = "InstantiablePrimitive"; + TypeFlags[TypeFlags["Instantiable"] = 15794176] = "Instantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 16711680] = "StructuredOrInstantiable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 142575359] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 134283777] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["Narrowable"] = 33492479] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 16909315] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["NotUnit"] = 8374815] = "NotUnit"; + TypeFlags[TypeFlags["NotUnit"] = 16749629] = "NotUnit"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 50331648] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 402653184] = "RequiresWidening"; /* @internal */ - TypeFlags[TypeFlags["PropagatingFlags"] = 117440512] = "PropagatingFlags"; + TypeFlags[TypeFlags["PropagatingFlags"] = 939524096] = "PropagatingFlags"; // The following flags are used for different purposes during union and intersection type construction /* @internal */ - TypeFlags[TypeFlags["NonWideningType"] = 16777216] = "NonWideningType"; + TypeFlags[TypeFlags["NonWideningType"] = 134217728] = "NonWideningType"; /* @internal */ - TypeFlags[TypeFlags["Wildcard"] = 33554432] = "Wildcard"; + TypeFlags[TypeFlags["Wildcard"] = 268435456] = "Wildcard"; /* @internal */ - TypeFlags[TypeFlags["EmptyObject"] = 67108864] = "EmptyObject"; + TypeFlags[TypeFlags["EmptyObject"] = 536870912] = "EmptyObject"; /* @internal */ - TypeFlags[TypeFlags["ConstructionFlags"] = 117440512] = "ConstructionFlags"; + TypeFlags[TypeFlags["ConstructionFlags"] = 939524096] = "ConstructionFlags"; + // The following flag is used for different purposes by maybeTypeOfKind + /* @internal */ + TypeFlags[TypeFlags["GenericMappedType"] = 134217728] = "GenericMappedType"; })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); var ObjectFlags; (function (ObjectFlags) { @@ -1325,6 +1330,7 @@ var ts; })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); var EmitFlags; (function (EmitFlags) { + EmitFlags[EmitFlags["None"] = 0] = "None"; EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine"; EmitFlags[EmitFlags["AdviseOnEmitNode"] = 2] = "AdviseOnEmitNode"; EmitFlags[EmitFlags["NoSubstitution"] = 4] = "NoSubstitution"; @@ -1633,7 +1639,7 @@ var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "2.9"; + ts.versionMajorMinor = "3.0"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); @@ -1781,6 +1787,10 @@ var ts; return array ? array.length : 0; } ts.length = length; + function hasEntries(map) { + return !!map && !!map.size; + } + ts.hasEntries = hasEntries; /** * Iterates through 'array' by index and performs the callback on each element of array until the callback * returns a truthy value, then returns that value. @@ -1937,7 +1947,7 @@ var ts; return result; } } - Debug.fail(); + return Debug.fail(); } ts.findMap = findMap; function contains(array, value, equalityComparer) { @@ -2055,11 +2065,6 @@ var ts; return array; } ts.sameMap = sameMap; - /** - * Flattens an array containing a mix of array or non-array elements. - * - * @param array The array to flatten. - */ function flatten(array) { var result; if (array) { @@ -2079,12 +2084,6 @@ var ts; return result; } ts.flatten = flatten; - /** - * Maps an array. If the mapped value is an array, it is spread into the result. - * - * @param array The array to map. - * @param mapfn The callback used to map the result into one or more values. - */ function flatMap(array, mapfn) { var result; if (array) { @@ -2207,13 +2206,6 @@ var ts; }; } ts.singleIterator = singleIterator; - /** - * Maps contiguous spans of values with the same key. - * - * @param array The array to map. - * @param keyfn A callback used to select the key for an element. - * @param mapfn A callback used to map a contiguous chunk of values to a single value. - */ function spanMap(array, keyfn, mapfn) { var result; if (array) { @@ -2331,12 +2323,6 @@ var ts; } return result; } - /** - * Deduplicates an unsorted array. - * @param equalityComparer An optional `EqualityComparer` used to determine if two values are duplicates. - * @param comparer An optional `Comparer` used to sort entries before comparison, though the - * result will remain in the original order in `array`. - */ function deduplicate(array, equalityComparer, comparer) { return !array ? undefined : array.length === 0 ? [] : @@ -2345,9 +2331,6 @@ var ts; deduplicateEquality(array, equalityComparer); } ts.deduplicate = deduplicate; - /** - * Deduplicates an array that has already been sorted. - */ function deduplicateSorted(array, comparer) { if (!array) return undefined; @@ -2490,14 +2473,6 @@ var ts; return result; } ts.sum = sum; - /** - * Appends a value to an array, returning the array. - * - * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array - * is created if `value` was appended. - * @param value The value to append to the array. If `value` is `undefined`, nothing is - * appended. - */ function append(to, value) { if (value === undefined) return to; @@ -2514,16 +2489,6 @@ var ts; function toOffset(array, offset) { return offset < 0 ? array.length + offset : offset; } - /** - * Appends a range of value to an array, returning the array. - * - * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array - * is created if `value` was appended. - * @param from The values to append to the array. If `from` is `undefined`, nothing is - * appended. If an element of `from` is `undefined`, that element is not appended. - * @param start The offset in `from` at which to start copying values. - * @param end The offset in `from` at which to stop copying values (non-inclusive). - */ function addRange(to, from, start, end) { if (from === undefined || from.length === 0) return to; @@ -2539,23 +2504,6 @@ var ts; return to; } ts.addRange = addRange; - /** - * Appends a range of value to begin of an array, returning the array. - * - * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array - * is created if `value` was appended. - * @param from The values to append to the array. If `from` is `undefined`, nothing is - * appended. If an element of `from` is `undefined`, that element is not appended. - */ - function prependRange(to, from) { - if (from === undefined || from.length === 0) - return to; - if (to === undefined) - return from.slice(); - to.unshift.apply(to, from); - return to; - } - ts.prependRange = prependRange; /** * @return Whether the value was added. */ @@ -2853,7 +2801,7 @@ var ts; var arg = args_1[_a]; for (var p in arg) { if (hasProperty(arg, p)) { - t[p] = arg[p]; + t[p] = arg[p]; // TODO: GH#23368 } } } @@ -3012,10 +2960,10 @@ var ts; if (value !== undefined && test(value)) return value; if (value && typeof value.kind === "number") { - Debug.fail("Invalid cast. The supplied " + Debug.showSyntaxKind(value) + " did not pass the test '" + Debug.getFunctionName(test) + "'."); + return Debug.fail("Invalid cast. The supplied " + Debug.showSyntaxKind(value) + " did not pass the test '" + Debug.getFunctionName(test) + "'."); } else { - Debug.fail("Invalid cast. The supplied value did not pass the test '" + Debug.getFunctionName(test) + "'."); + return Debug.fail("Invalid cast. The supplied value did not pass the test '" + Debug.getFunctionName(test) + "'."); } } ts.cast = cast; @@ -3101,7 +3049,7 @@ var ts; } ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { - baseIndex = baseIndex || 0; + if (baseIndex === void 0) { baseIndex = 0; } return text.replace(/{(\d+)}/g, function (_match, index) { return Debug.assertDefined(args[+index + baseIndex]); }); } ts.formatStringFromArgs = formatStringFromArgs; @@ -3409,7 +3357,9 @@ var ts; return compareValues(a ? 1 : 0, b ? 1 : 0); } ts.compareBooleans = compareBooleans; - function compareMessageText(text1, text2) { + function compareMessageText(t1, t2) { + var text1 = t1; + var text2 = t2; while (text1 && text2) { // We still have both chains. var string1 = isString(text1) ? text1 : text1.messageText; @@ -3446,6 +3396,14 @@ var ts; return moduleResolution; } ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; + function unreachableCodeIsError(options) { + return options.allowUnreachableCode === false; + } + ts.unreachableCodeIsError = unreachableCodeIsError; + function unusedLabelIsError(options) { + return options.allowUnusedLabels === false; + } + ts.unusedLabelIsError = unusedLabelIsError; function getAreDeclarationMapsEnabled(options) { return !!(options.declaration && options.declarationMap); } @@ -3464,7 +3422,7 @@ var ts; } ts.getEmitDeclarations = getEmitDeclarations; function getStrictOptionValue(compilerOptions, flag) { - return compilerOptions[flag] === undefined ? compilerOptions.strict : compilerOptions[flag]; + return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; } ts.getStrictOptionValue = getStrictOptionValue; function hasZeroOrOneAsteriskCharacter(str) { @@ -3947,6 +3905,23 @@ var ts; return startsWith(str, prefix) ? str.substr(prefix.length) : str; } ts.removePrefix = removePrefix; + function tryRemovePrefix(str, prefix) { + return startsWith(str, prefix) ? str.substring(prefix.length) : undefined; + } + ts.tryRemovePrefix = tryRemovePrefix; + function tryRemoveDirectoryPrefix(path, dirPath) { + var a = tryRemovePrefix(path, dirPath); + if (a === undefined) + return undefined; + switch (a.charCodeAt(0)) { + case 47 /* slash */: + case 92 /* backslash */: + return a.slice(1); + default: + return undefined; + } + } + ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; function endsWith(str, suffix) { var expectedPos = str.length - suffix.length; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; @@ -3956,6 +3931,10 @@ var ts; return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str; } ts.removeSuffix = removeSuffix; + function tryRemoveSuffix(str, suffix) { + return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : undefined; + } + ts.tryRemoveSuffix = tryRemoveSuffix; function stringContains(str, substring) { return str.indexOf(substring) !== -1; } @@ -3989,7 +3968,7 @@ var ts; /** * Matches any single directory segment unless it is the last segment and a .min.js file * Breakdown: - * [^./] # matches everything up to the first . character (excluding directory seperators) + * [^./] # matches everything up to the first . character (excluding directory separators) * (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension */ singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*", @@ -4051,7 +4030,7 @@ var ts; var subpattern = ""; var hasWrittenComponent = false; var components = getNormalizedPathComponents(spec, basePath); - var lastComponent = lastOrUndefined(components); + var lastComponent = last(components); if (usage !== "exclude" && lastComponent === "**") { return undefined; } @@ -4115,6 +4094,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } + /** @param path directory of the tsconfig.json */ function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); @@ -4128,14 +4108,18 @@ var ts; }; } ts.getFileMatcherPatterns = getFileMatcherPatterns; + function getRegexFromPattern(pattern, useCaseSensitiveFileNames) { + return new RegExp(pattern, useCaseSensitiveFileNames ? "" : "i"); + } + ts.getRegexFromPattern = getRegexFromPattern; + /** @param path directory of the tsconfig.json */ function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); - var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); - var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); - var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return getRegexFromPattern(pattern, useCaseSensitiveFileNames); }); + var includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames); + var excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames); // Associate an array of results with each include regex. This keeps results in order of the "include" order. // If there are no "includes", then just put everything in results[0]. var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; @@ -4277,11 +4261,11 @@ var ts; return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */; } function hasJavaScriptFileExtension(fileName) { - return forEach(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + return some(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); } ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; function hasTypeScriptFileExtension(fileName) { - return forEach(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + return some(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); } ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) { @@ -4487,7 +4471,8 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { - assert(value !== undefined && value !== null, message); + if (value === undefined || value === null) + return fail(message); return value; } Debug.assertDefined = assertDefined; @@ -4671,10 +4656,7 @@ var ts; */ function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - if (ext !== undefined) { - return ext; - } - Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : Debug.fail("File " + path + " has unknown extension."); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -5118,6 +5100,7 @@ var ts; return parseInt(version.substring(1, dot)); } ts.getNodeMajorVersion = getNodeMajorVersion; + // TODO: this is used as if it's certainly defined in many places. ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does @@ -5299,6 +5282,7 @@ var ts; return watchDirectoryRecursively(directoryName, callback); } watchDirectory(directoryName, callback); + return undefined; // TODO: GH#18217 }; } function createNonPollingWatchFile() { @@ -5330,7 +5314,7 @@ var ts; var watcher = fsWatchDirectory(dirName, function (_eventName, relativeFileName) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" var fileName = !ts.isString(relativeFileName) - ? undefined + ? undefined // TODO: GH#18217 : ts.getNormalizedAbsolutePath(relativeFileName, dirName); // Some applications save a working file via rename operations var callbacks = fileWatcherCallbacks.get(toCanonicalName(fileName)); @@ -5579,6 +5563,7 @@ var ts; switch (entryKind) { case 0 /* File */: return stat.isFile(); case 1 /* Directory */: return stat.isDirectory(); + default: return false; } } catch (e) { @@ -5770,6 +5755,7 @@ var ts; The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), + Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), @@ -6221,6 +6207,7 @@ var ts; Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2568, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators_2568", "Type '{0}' is not an array type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: diag(2570, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await_2570", "Property '{0}' does not exist on type '{1}'. Did you forget to use 'await'?"), + Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."), JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -6274,7 +6261,7 @@ var ts; _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: diag(2692, ts.DiagnosticCategory.Error, "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible."), _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: diag(2693, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", "'{0}' only refers to a type, but is being used as a value here."), 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."), + 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."), 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."), @@ -6304,6 +6291,7 @@ var ts; Cannot_invoke_an_object_which_is_possibly_undefined: diag(2722, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_undefined_2722", "Cannot invoke an object which is possibly 'undefined'."), Cannot_invoke_an_object_which_is_possibly_null_or_undefined: diag(2723, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_null_or_undefined_2723", "Cannot invoke an object which is possibly 'null' or 'undefined'."), Module_0_has_no_exported_member_1_Did_you_mean_2: diag(2724, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_2_2724", "Module '{0}' has no exported member '{1}'. Did you mean '{2}'?"), + Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."), 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}'."), @@ -6602,6 +6590,7 @@ var ts; _0_is_declared_but_never_used: diag(6196, ts.DiagnosticCategory.Error, "_0_is_declared_but_never_used_6196", "'{0}' is declared but never used.", /*reportsUnnecessary*/ true), Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"), All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", /*reportsUnnecessary*/ true), + All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), 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"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -6629,7 +6618,7 @@ var ts; Function_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: diag(7024, ts.DiagnosticCategory.Error, "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", "Function 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."), Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: diag(7025, ts.DiagnosticCategory.Error, "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type."), JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: diag(7026, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists."), - Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected."), + Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected.", /*reportsUnnecessary*/ true), Unused_label: diag(7028, ts.DiagnosticCategory.Error, "Unused_label_7028", "Unused label.", /*reportsUnnecessary*/ true), Fallthrough_case_in_switch: diag(7029, ts.DiagnosticCategory.Error, "Fallthrough_case_in_switch_7029", "Fallthrough case in switch."), Not_all_code_paths_return_a_value: diag(7030, ts.DiagnosticCategory.Error, "Not_all_code_paths_return_a_value_7030", "Not all code paths return a value."), @@ -6710,6 +6699,7 @@ var ts; Implement_inherited_abstract_class: diag(90007, ts.DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"), Add_0_to_unresolved_variable: diag(90008, ts.DiagnosticCategory.Message, "Add_0_to_unresolved_variable_90008", "Add '{0}.' to unresolved variable"), Remove_destructuring: diag(90009, ts.DiagnosticCategory.Message, "Remove_destructuring_90009", "Remove destructuring"), + Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"), Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""), Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"), Add_0_to_existing_import_declaration_from_1: diag(90015, ts.DiagnosticCategory.Message, "Add_0_to_existing_import_declaration_from_1_90015", "Add '{0}' to existing import declaration from \"{1}\""), @@ -6779,6 +6769,9 @@ var ts; Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing 'typeof'"), Remove_unused_label: diag(95053, ts.DiagnosticCategory.Message, "Remove_unused_label_95053", "Remove unused label"), Remove_all_unused_labels: diag(95054, ts.DiagnosticCategory.Message, "Remove_all_unused_labels_95054", "Remove all unused labels"), + Convert_0_to_mapped_object_type: diag(95055, ts.DiagnosticCategory.Message, "Convert_0_to_mapped_object_type_95055", "Convert '{0}' to mapped object type"), + Convert_namespace_import_to_named_imports: diag(95056, ts.DiagnosticCategory.Message, "Convert_namespace_import_to_named_imports_95056", "Convert namespace import to named imports"), + Convert_named_imports_to_namespace_import: diag(95057, ts.DiagnosticCategory.Message, "Convert_named_imports_to_namespace_import_95057", "Convert named imports to namespace import"), }; })(ts || (ts = {})); var ts; @@ -6817,7 +6810,7 @@ var ts; "false": 86 /* FalseKeyword */, "finally": 87 /* FinallyKeyword */, "for": 88 /* ForKeyword */, - "from": 142 /* FromKeyword */, + "from": 143 /* FromKeyword */, "function": 89 /* FunctionKeyword */, "get": 125 /* GetKeyword */, "if": 90 /* IfKeyword */, @@ -6843,7 +6836,7 @@ var ts; "public": 114 /* PublicKeyword */, "readonly": 132 /* ReadonlyKeyword */, "require": 133 /* RequireKeyword */, - "global": 143 /* GlobalKeyword */, + "global": 144 /* GlobalKeyword */, "return": 96 /* ReturnKeyword */, "set": 136 /* SetKeyword */, "static": 115 /* StaticKeyword */, @@ -6859,6 +6852,7 @@ var ts; "typeof": 103 /* TypeOfKeyword */, "undefined": 140 /* UndefinedKeyword */, "unique": 141 /* UniqueKeyword */, + "unknown": 142 /* UnknownKeyword */, "var": 104 /* VarKeyword */, "void": 105 /* VoidKeyword */, "while": 106 /* WhileKeyword */, @@ -6866,7 +6860,7 @@ var ts; "yield": 116 /* YieldKeyword */, "async": 120 /* AsyncKeyword */, "await": 121 /* AwaitKeyword */, - "of": 144 /* OfKeyword */, + "of": 145 /* OfKeyword */, "{": 17 /* OpenBraceToken */, "}": 18 /* CloseBraceToken */, "(": 19 /* OpenParenToken */, @@ -7485,8 +7479,9 @@ var ts; } ts.isIdentifierText = isIdentifierText; // Creates a scanner over a (possibly unspecified) range of a piece of text. - function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + var text = textInitial; // Current position (end position of text of current token) var pos; // end of text @@ -7942,7 +7937,7 @@ var ts; var isPreviousTokenSeparator = false; while (true) { var ch = text.charCodeAt(pos); - // Numeric seperators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator + // Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator if (ch === 95 /* _ */) { tokenFlags |= 512 /* ContainsSeparator */; if (separatorAllowed) { @@ -8758,7 +8753,7 @@ var ts; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function packageIdIsEqual(a, b) { - return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; + return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; } function packageIdToString(_a) { var name = _a.name, subModuleName = _a.subModuleName, version = _a.version; @@ -8809,7 +8804,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 273 /* SourceFile */) { + while (node && node.kind !== 274 /* SourceFile */) { node = node.parent; } return node; @@ -8817,11 +8812,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 212 /* Block */: - case 240 /* CaseBlock */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 213 /* Block */: + case 241 /* CaseBlock */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: return true; } return false; @@ -8866,11 +8861,11 @@ var ts; } ts.getEndLinePosition = getEndLinePosition; /** - * Returns a value indicating whether a name is unique globally or within the current file + * Returns a value indicating whether a name is unique globally or within the current file. + * Note: This does not consider whether a name appears as a free identifier or not, so at the expression `x.y` this includes both `x` and `y`. */ - function isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) { - return !(hasGlobalName && hasGlobalName(name)) - && !currentSourceFile.identifiers.has(name); + function isFileLevelUniqueName(sourceFile, name, hasGlobalName) { + return !(hasGlobalName && hasGlobalName(name)) && !sourceFile.identifiers.has(name); } ts.isFileLevelUniqueName = isFileLevelUniqueName; // Returns true if this node is missing from the actual source code. A 'missing' node is different @@ -8896,6 +8891,27 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + /** + * Appends a range of value to begin of an array, returning the array. + * + * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array + * is created if `value` was appended. + * @param from The values to append to the array. If `from` is `undefined`, nothing is + * appended. If an element of `from` is `undefined`, that element is not appended. + */ + function prependStatements(to, from) { + if (from === undefined || from.length === 0) + return to; + if (to === undefined) + return from.slice(); + var prologue = to.length && isPrologueDirective(to[0]) && to.shift(); + to.unshift.apply(to, from); + if (prologue) { + to.unshift(prologue); + } + return to; + } + ts.prependStatements = prependStatements; /** * Determine if the given comment is a triple-slash * @@ -8938,7 +8954,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 298 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 299 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -8985,7 +9001,7 @@ var ts; */ function getEmitFlags(node) { var emitNode = node.emitNode; - return emitNode && emitNode.flags; + return emitNode && emitNode.flags || 0; } ts.getEmitFlags = getEmitFlags; function getLiteralText(node, sourceFile) { @@ -9019,7 +9035,7 @@ var ts; case 12 /* RegularExpressionLiteral */: return node.text; } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); } ts.getLiteralText = getLiteralText; function getTextOfConstantValue(value) { @@ -9052,7 +9068,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 231 /* VariableDeclaration */ && node.parent.kind === 268 /* CatchClause */; + return node.kind === 232 /* VariableDeclaration */ && node.parent.kind === 269 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9074,11 +9090,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 === 238 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 239 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 273 /* SourceFile */ || - node.kind === 238 /* ModuleDeclaration */ || + return node.kind === 274 /* SourceFile */ || + node.kind === 239 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -9095,9 +9111,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: return ts.isExternalModule(node.parent); - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9109,53 +9125,53 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 273 /* SourceFile */: - case 240 /* CaseBlock */: - case 268 /* CatchClause */: - case 238 /* ModuleDeclaration */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 274 /* SourceFile */: + case 241 /* CaseBlock */: + case 269 /* CatchClause */: + case 239 /* ModuleDeclaration */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return true; - case 212 /* Block */: + case 213 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block - return parentNode && !ts.isFunctionLike(parentNode); + return !ts.isFunctionLike(parentNode); } return false; } ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 152 /* MethodSignature */: - case 159 /* IndexSignature */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 283 /* JSDocFunctionType */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 295 /* JSDocTemplateTag */: - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 291 /* JSDocCallbackTag */: - case 296 /* JSDocTypedefTag */: - case 287 /* JSDocSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 153 /* MethodSignature */: + case 160 /* IndexSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 284 /* JSDocFunctionType */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 296 /* JSDocTemplateTag */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 292 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 288 /* JSDocSignature */: return true; default: ts.assertTypeIsNever(node); @@ -9165,8 +9181,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9175,15 +9191,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 213 /* VariableStatement */: - case 234 /* ClassDeclaration */: - case 233 /* FunctionDeclaration */: - case 238 /* ModuleDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 214 /* VariableStatement */: + case 235 /* ClassDeclaration */: + case 234 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: return true; default: return false; @@ -9218,8 +9234,8 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return escapeLeadingUnderscores(name.text); - case 146 /* ComputedPropertyName */: - return isStringOrNumericLiteral(name.expression) ? escapeLeadingUnderscores(name.expression.text) : undefined; + case 147 /* ComputedPropertyName */: + return isStringOrNumericLiteral(name.expression) ? escapeLeadingUnderscores(name.expression.text) : undefined; // TODO: GH#18217 Almost all uses of this assume the result to be defined! default: ts.Debug.assertNever(name); } @@ -9229,10 +9245,12 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); + default: + throw ts.Debug.assertNever(name); } } ts.entityNameToString = entityNameToString; @@ -9251,11 +9269,6 @@ var ts; return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3); } ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; - function createDiagnosticForNodeSpan(sourceFile, startNode, endNode, message, arg0, arg1, arg2, arg3) { - var start = ts.skipTrivia(sourceFile.text, startNode.pos); - return ts.createFileDiagnostic(sourceFile, start, endNode.end - start, message, arg0, arg1, arg2, arg3); - } - ts.createDiagnosticForNodeSpan = createDiagnosticForNodeSpan; function createDiagnosticForNodeFromMessageChain(node, messageChain) { var sourceFile = getSourceFileOfNode(node); var span = getErrorSpanForNode(sourceFile, node); @@ -9278,7 +9291,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 212 /* Block */) { + if (node.body && node.body.kind === 213 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9292,7 +9305,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 273 /* SourceFile */: + case 274 /* 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 @@ -9301,25 +9314,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 231 /* VariableDeclaration */: - case 181 /* BindingElement */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 272 /* EnumMember */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 236 /* TypeAliasDeclaration */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 232 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 273 /* EnumMember */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 237 /* TypeAliasDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: errorNode = node.name; break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -9352,7 +9365,7 @@ var ts; } ts.isJsonSourceFile = isJsonSourceFile; function isConstEnumDeclaration(node) { - return node.kind === 237 /* EnumDeclaration */ && isConst(node); + return node.kind === 238 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -9365,21 +9378,21 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 186 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 187 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 186 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 187 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 178 /* ImportType */ && - n.argument.kind === 177 /* LiteralType */ && + return n.kind === 179 /* ImportType */ && + n.argument.kind === 178 /* LiteralType */ && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 215 /* ExpressionStatement */ + return node.kind === 216 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9388,11 +9401,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 148 /* Parameter */ || - node.kind === 147 /* TypeParameter */ || - node.kind === 191 /* FunctionExpression */ || - node.kind === 192 /* ArrowFunction */ || - node.kind === 190 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 149 /* Parameter */ || + node.kind === 148 /* TypeParameter */ || + node.kind === 192 /* FunctionExpression */ || + node.kind === 193 /* ArrowFunction */ || + node.kind === 191 /* ParenthesizedExpression */) ? 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 '/**/' @@ -9408,11 +9421,12 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (160 /* FirstTypeNode */ <= node.kind && node.kind <= 178 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 179 /* LastTypeNode */) { return true; } switch (node.kind) { case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 134 /* NumberKeyword */: case 137 /* StringKeyword */: case 122 /* BooleanKeyword */: @@ -9421,32 +9435,32 @@ var ts; case 131 /* NeverKeyword */: return true; case 105 /* VoidKeyword */: - return node.parent.kind !== 195 /* VoidExpression */; - case 206 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 196 /* VoidExpression */; + case 207 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 147 /* TypeParameter */: - return node.parent.kind === 176 /* MappedType */ || node.parent.kind === 171 /* InferType */; + case 148 /* TypeParameter */: + return node.parent.kind === 177 /* MappedType */ || node.parent.kind === 172 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 71 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 145 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 185 /* 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 === 71 /* Identifier */ || node.kind === 145 /* QualifiedName */ || node.kind === 184 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 185 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 145 /* QualifiedName */: - case 184 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: + case 146 /* QualifiedName */: + case 185 /* PropertyAccessExpression */: + case 99 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 164 /* TypeQuery */) { + if (parent.kind === 165 /* TypeQuery */) { return false; } - if (parent.kind === 178 /* ImportType */) { + if (parent.kind === 179 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9455,41 +9469,42 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (160 /* FirstTypeNode */ <= parent.kind && parent.kind <= 178 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 179 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return node === parent.constraint; - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 148 /* Parameter */: - case 231 /* VariableDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 149 /* Parameter */: + case 232 /* VariableDeclaration */: return node === parent.type; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return node === parent.type; - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: return node === parent.type; - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: return node === parent.type; - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } + } } return false; } @@ -9510,23 +9525,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return visitor(node); - case 240 /* CaseBlock */: - case 212 /* Block */: - case 216 /* IfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 225 /* WithStatement */: - case 226 /* SwitchStatement */: - case 265 /* CaseClause */: - case 266 /* DefaultClause */: - case 227 /* LabeledStatement */: - case 229 /* TryStatement */: - case 268 /* CatchClause */: + case 241 /* CaseBlock */: + case 213 /* Block */: + case 217 /* IfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 226 /* WithStatement */: + case 227 /* SwitchStatement */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: + case 228 /* LabeledStatement */: + case 230 /* TryStatement */: + case 269 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9536,26 +9551,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 237 /* EnumDeclaration */: - case 235 /* InterfaceDeclaration */: - case 238 /* ModuleDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 238 /* EnumDeclaration */: + case 236 /* InterfaceDeclaration */: + case 239 /* ModuleDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 146 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 147 /* 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); @@ -9578,10 +9593,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 166 /* ArrayType */) { + if (node && node.kind === 167 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 161 /* TypeReference */) { + else if (node && node.kind === 162 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9591,12 +9606,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 235 /* InterfaceDeclaration */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 165 /* TypeLiteral */: + case 236 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 166 /* TypeLiteral */: return node.members; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return node.properties; } } @@ -9604,14 +9619,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 181 /* BindingElement */: - case 272 /* EnumMember */: - case 148 /* Parameter */: - case 269 /* PropertyAssignment */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 270 /* ShorthandPropertyAssignment */: - case 231 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 273 /* EnumMember */: + case 149 /* Parameter */: + case 270 /* PropertyAssignment */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 271 /* ShorthandPropertyAssignment */: + case 232 /* VariableDeclaration */: return true; } } @@ -9623,8 +9638,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 232 /* VariableDeclarationList */ - && node.parent.parent.kind === 213 /* VariableStatement */; + return node.parent.kind === 233 /* VariableDeclarationList */ + && node.parent.parent.kind === 214 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9635,13 +9650,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: return true; } return false; @@ -9652,7 +9667,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 227 /* LabeledStatement */) { + if (node.statement.kind !== 228 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9660,17 +9675,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 212 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 213 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 153 /* MethodDeclaration */ && node.parent.kind === 183 /* ObjectLiteralExpression */; + return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 184 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 153 /* MethodDeclaration */ && - (node.parent.kind === 183 /* ObjectLiteralExpression */ || - node.parent.kind === 204 /* ClassExpression */); + return node.kind === 154 /* MethodDeclaration */ && + (node.parent.kind === 184 /* ObjectLiteralExpression */ || + node.parent.kind === 205 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9682,31 +9697,35 @@ var ts; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { - return ts.filter(objectLiteral.properties, function (property) { - if (property.kind === 269 /* PropertyAssignment */) { + return objectLiteral.properties.filter(function (property) { + if (property.kind === 270 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); - return key === propName || (key2 && key2 === propName); + return key === propName || (!!key2 && key2 === propName); } + return false; }); } ts.getPropertyAssignment = getPropertyAssignment; function getTsConfigObjectLiteralExpression(tsConfigSourceFile) { if (tsConfigSourceFile && tsConfigSourceFile.statements.length) { var expression = tsConfigSourceFile.statements[0].expression; - return ts.isObjectLiteralExpression(expression) && expression; + return ts.tryCast(expression, ts.isObjectLiteralExpression); } } ts.getTsConfigObjectLiteralExpression = getTsConfigObjectLiteralExpression; function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) { - var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile); - return jsonObjectLiteral && - ts.firstDefined(getPropertyAssignment(jsonObjectLiteral, propKey), function (property) { - return ts.isArrayLiteralExpression(property.initializer) ? - ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) : - undefined; - }); + return ts.firstDefined(getTsConfigPropArray(tsConfigSourceFile, propKey), function (property) { + return ts.isArrayLiteralExpression(property.initializer) ? + ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) : + undefined; + }); } ts.getTsConfigPropArrayElementValue = getTsConfigPropArrayElementValue; + function getTsConfigPropArray(tsConfigSourceFile, propKey) { + var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile); + return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : ts.emptyArray; + } + ts.getTsConfigPropArray = getTsConfigPropArray; function getContainingFunction(node) { return ts.findAncestor(node.parent, ts.isFunctionLike); } @@ -9716,13 +9735,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { + ts.Debug.assert(node.kind !== 274 /* SourceFile */); while (true) { node = node.parent; if (!node) { - return undefined; + 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 146 /* ComputedPropertyName */: + case 147 /* 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 @@ -9737,9 +9757,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 149 /* Decorator */: + case 150 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 148 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 149 /* 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; @@ -9750,26 +9770,26 @@ var ts; node = node.parent; } break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 238 /* ModuleDeclaration */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 237 /* EnumDeclaration */: - case 273 /* SourceFile */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 239 /* ModuleDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 238 /* EnumDeclaration */: + case 274 /* SourceFile */: return node; } } @@ -9779,9 +9799,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 154 /* Constructor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 155 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: return container; } } @@ -9803,27 +9823,27 @@ var ts; return node; } switch (node.kind) { - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: node = node.parent; break; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return node; - case 149 /* Decorator */: + case 150 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 148 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 149 /* 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; @@ -9839,14 +9859,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 191 /* FunctionExpression */ || func.kind === 192 /* ArrowFunction */) { + if (func.kind === 192 /* FunctionExpression */ || func.kind === 193 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 190 /* ParenthesizedExpression */) { + while (parent.kind === 191 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 186 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 187 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -9857,7 +9877,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 184 /* PropertyAccessExpression */ || kind === 185 /* ElementAccessExpression */) + return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) && node.expression.kind === 97 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -9866,20 +9886,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 184 /* PropertyAccessExpression */ || kind === 185 /* ElementAccessExpression */) + return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) && node.expression.kind === 99 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return node.typeName; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 71 /* Identifier */: - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return node; } return undefined; @@ -9887,10 +9907,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return node.tag; - case 256 /* JsxOpeningElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9899,53 +9919,55 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: // classes are valid targets return true; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 234 /* ClassDeclaration */; - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 153 /* MethodDeclaration */: + return parent.kind === 235 /* ClassDeclaration */; + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 154 /* 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 === 234 /* ClassDeclaration */; - case 148 /* Parameter */: + && parent.kind === 235 /* ClassDeclaration */; + case 149 /* 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 === 154 /* Constructor */ - || parent.kind === 153 /* MethodDeclaration */ - || parent.kind === 156 /* SetAccessor */) - && grandparent.kind === 234 /* ClassDeclaration */; + && (parent.kind === 155 /* Constructor */ + || parent.kind === 154 /* MethodDeclaration */ + || parent.kind === 157 /* SetAccessor */) + && grandparent.kind === 235 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node, parent, grandparent) { return node.decorators !== undefined - && nodeCanBeDecorated(node, parent, grandparent); + && nodeCanBeDecorated(node, parent, grandparent); // TODO: GH#18217 } ts.nodeIsDecorated = nodeIsDecorated; function nodeOrChildIsDecorated(node, parent, grandparent) { - return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent); + return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent); // TODO: GH#18217 } ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 234 /* ClassDeclaration */: - return ts.forEach(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); - case 153 /* MethodDeclaration */: - case 156 /* SetAccessor */: - return ts.forEach(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); + case 235 /* ClassDeclaration */: + return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 + case 154 /* MethodDeclaration */: + case 157 /* SetAccessor */: + return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 + default: + return false; } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 256 /* JsxOpeningElement */ || - parent.kind === 255 /* JsxSelfClosingElement */ || - parent.kind === 257 /* JsxClosingElement */) { + if (parent.kind === 257 /* JsxOpeningElement */ || + parent.kind === 256 /* JsxSelfClosingElement */ || + parent.kind === 258 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -9958,45 +9980,45 @@ var ts; case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 12 /* RegularExpressionLiteral */: - case 182 /* ArrayLiteralExpression */: - case 183 /* ObjectLiteralExpression */: - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 188 /* TaggedTemplateExpression */: - case 207 /* AsExpression */: - case 189 /* TypeAssertionExpression */: - case 208 /* NonNullExpression */: - case 190 /* ParenthesizedExpression */: - case 191 /* FunctionExpression */: - case 204 /* ClassExpression */: - case 192 /* ArrowFunction */: - case 195 /* VoidExpression */: - case 193 /* DeleteExpression */: - case 194 /* TypeOfExpression */: - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: - case 199 /* BinaryExpression */: - case 200 /* ConditionalExpression */: - case 203 /* SpreadElement */: - case 201 /* TemplateExpression */: + case 183 /* ArrayLiteralExpression */: + case 184 /* ObjectLiteralExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 189 /* TaggedTemplateExpression */: + case 208 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 209 /* NonNullExpression */: + case 191 /* ParenthesizedExpression */: + case 192 /* FunctionExpression */: + case 205 /* ClassExpression */: + case 193 /* ArrowFunction */: + case 196 /* VoidExpression */: + case 194 /* DeleteExpression */: + case 195 /* TypeOfExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: + case 200 /* BinaryExpression */: + case 201 /* ConditionalExpression */: + case 204 /* SpreadElement */: + case 202 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: - case 205 /* OmittedExpression */: - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: - case 258 /* JsxFragment */: - case 202 /* YieldExpression */: - case 196 /* AwaitExpression */: - case 209 /* MetaProperty */: + case 206 /* OmittedExpression */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: + case 259 /* JsxFragment */: + case 203 /* YieldExpression */: + case 197 /* AwaitExpression */: + case 210 /* MetaProperty */: return true; - case 145 /* QualifiedName */: - while (node.parent.kind === 145 /* QualifiedName */) { + case 146 /* QualifiedName */: + while (node.parent.kind === 146 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 164 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node); case 71 /* Identifier */: - if (node.parent.kind === 164 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through @@ -10012,47 +10034,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 272 /* EnumMember */: - case 269 /* PropertyAssignment */: - case 181 /* BindingElement */: + case 232 /* VariableDeclaration */: + case 149 /* Parameter */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 273 /* EnumMember */: + case 270 /* PropertyAssignment */: + case 182 /* BindingElement */: return parent.initializer === node; - case 215 /* ExpressionStatement */: - case 216 /* IfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 224 /* ReturnStatement */: - case 225 /* WithStatement */: - case 226 /* SwitchStatement */: - case 265 /* CaseClause */: - case 228 /* ThrowStatement */: + case 216 /* ExpressionStatement */: + case 217 /* IfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 225 /* ReturnStatement */: + case 226 /* WithStatement */: + case 227 /* SwitchStatement */: + case 266 /* CaseClause */: + case 229 /* ThrowStatement */: return parent.expression === node; - case 219 /* ForStatement */: + case 220 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 232 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 233 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 232 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233 /* VariableDeclarationList */) || forInStatement.expression === node; - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: return node === parent.expression; - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return node === parent.expression; - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return node === parent.expression; - case 149 /* Decorator */: - case 264 /* JsxExpression */: - case 263 /* JsxSpreadAttribute */: - case 271 /* SpreadAssignment */: + case 150 /* Decorator */: + case 265 /* JsxExpression */: + case 264 /* JsxSpreadAttribute */: + case 272 /* SpreadAssignment */: return true; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -10060,7 +10082,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 242 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 253 /* ExternalModuleReference */; + return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10069,7 +10091,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 242 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 253 /* ExternalModuleReference */; + return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 254 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -10081,15 +10103,15 @@ var ts; } ts.isSourceFileNotJavaScript = isSourceFileNotJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 65536 /* JavaScriptFile */); + return !!node && !!(node.flags & 65536 /* JavaScriptFile */); } ts.isInJavaScriptFile = isInJavaScriptFile; function isInJsonFile(node) { - return node && !!(node.flags & 16777216 /* JsonFile */); + return !!node && !!(node.flags & 16777216 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return node && !!(node.flags & 2097152 /* JSDoc */); + return !!node && !!(node.flags & 2097152 /* JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -10101,7 +10123,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 186 /* CallExpression */) { + if (callExpression.kind !== 187 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -10123,30 +10145,49 @@ var ts; return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */; } ts.isStringDoubleQuoted = isStringDoubleQuoted; - /** - * Given the symbol of a declaration, find the symbol of its Javascript container-like initializer, - * if it has one. Otherwise just return the original symbol. - * - * Container-like initializer behave like namespaces, so the binder needs to add contained symbols - * to their exports. An example is a function with assignments to `this` inside. - */ - function getJSInitializerSymbol(symbol) { - if (!symbol || !symbol.valueDeclaration) { - return symbol; + function getDeclarationOfJSInitializer(node) { + if (!isInJavaScriptFile(node) || !node.parent) { + return undefined; } - var declaration = symbol.valueDeclaration; - var e = getDeclaredJavascriptInitializer(declaration) || getAssignedJavascriptInitializer(declaration); - return e && e.symbol ? e.symbol : symbol; - } - ts.getJSInitializerSymbol = getJSInitializerSymbol; - /** Get the declaration initializer, when the initializer is container-like (See getJavascriptInitializer) */ - function getDeclaredJavascriptInitializer(node) { - if (node && ts.isVariableDeclaration(node) && node.initializer) { - return getJavascriptInitializer(node.initializer, /*isPrototypeAssignment*/ false) || - ts.isIdentifier(node.name) && getDefaultedJavascriptInitializer(node.name, node.initializer, /*isPrototypeAssignment*/ false); + var name; + var decl; + if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) { + name = node.parent.name; + decl = node.parent; } + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.right === node) { + name = node.parent.left; + decl = name; + } + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 54 /* BarBarToken */) { + if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { + name = node.parent.parent.name; + decl = node.parent.parent; + } + else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.parent.right === node.parent) { + name = node.parent.parent.left; + decl = name; + } + if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { + return undefined; + } + } + if (!name || !getJavascriptInitializer(node, isPrototypeAccess(name))) { + return undefined; + } + return decl; } - ts.getDeclaredJavascriptInitializer = getDeclaredJavascriptInitializer; + ts.getDeclarationOfJSInitializer = getDeclarationOfJSInitializer; + /** Get the initializer, taking into account defaulted Javascript initializers */ + function getEffectiveInitializer(node) { + if (isInJavaScriptFile(node) && node.initializer && + ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 54 /* BarBarToken */ && + node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { + return node.initializer.right; + } + return node.initializer; + } + ts.getEffectiveInitializer = getEffectiveInitializer; /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getJavascriptInitializer). * We treat the right hand side of assignments with container-like initalizers as declarations. @@ -10172,11 +10213,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 191 /* FunctionExpression */ || e.kind === 192 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 192 /* FunctionExpression */ || e.kind === 193 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 191 /* FunctionExpression */ || - initializer.kind === 204 /* ClassExpression */ || - initializer.kind === 192 /* ArrowFunction */) { + if (initializer.kind === 192 /* FunctionExpression */ || + initializer.kind === 205 /* ClassExpression */ || + initializer.kind === 193 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10198,6 +10239,13 @@ var ts; return e; } } + function isDefaultedJavascriptInitializer(node) { + var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ ? node.parent.left : + undefined; + return name && getJavascriptInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); + } + ts.isDefaultedJavascriptInitializer = isDefaultedJavascriptInitializer; /** Given a Javascript initializer, return the outer name. That is, the lhs of the assignment or the declaration name. */ function getOuterNameOfJsInitializer(node) { if (ts.isBinaryExpression(node.parent)) { @@ -10307,7 +10355,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 215 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 216 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10317,14 +10365,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: return node.parent; - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: return node.parent.parent; - case 186 /* CallExpression */: + case 187 /* CallExpression */: return node.parent; - case 177 /* LiteralType */: + case 178 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10334,12 +10382,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: return node.moduleSpecifier; - case 242 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 253 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 178 /* ImportType */: + case 243 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 254 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 179 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10348,11 +10396,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return node; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10360,19 +10408,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 243 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 244 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 148 /* Parameter */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 270 /* ShorthandPropertyAssignment */: - case 269 /* PropertyAssignment */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 149 /* Parameter */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 271 /* ShorthandPropertyAssignment */: + case 270 /* PropertyAssignment */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10380,14 +10428,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 283 /* JSDocFunctionType */ && + return node.kind === 284 /* JSDocFunctionType */ && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 296 /* JSDocTypedefTag */ || node.kind === 291 /* JSDocCallbackTag */; + return node.kind === 297 /* JSDocTypedefTag */ || node.kind === 292 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10397,38 +10445,39 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 58 /* EqualsToken */ && - node.expression.right; + node.expression.operatorToken.kind === 58 /* EqualsToken */ + ? node.expression.right + : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && getSpecialPropertyAssignmentKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 54 /* BarBarToken */ && - node.expression.right.right; + node.expression.right.operatorToken.kind === 54 /* BarBarToken */ + ? node.expression.right.right + : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return node.initializer; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return node.initializer; } } function getSingleVariableOfVariableStatement(node) { - return ts.isVariableStatement(node) && - node.declarationList.declarations.length > 0 && - node.declarationList.declarations[0]; + return ts.isVariableStatement(node) ? ts.firstOrUndefined(node.declarationList.declarations) : undefined; } function getNestedModuleDeclaration(node) { - return node.kind === 238 /* ModuleDeclaration */ && + return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 238 /* ModuleDeclaration */ && - node.body; + node.body.kind === 239 /* ModuleDeclaration */ + ? node.body + : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; @@ -10438,7 +10487,7 @@ var ts; var parent = node.parent; if (!parent) return; - if (parent.kind === 269 /* PropertyAssignment */ || parent.kind === 151 /* PropertyDeclaration */ || getNestedModuleDeclaration(parent)) { + if (parent.kind === 270 /* PropertyAssignment */ || parent.kind === 152 /* PropertyDeclaration */ || getNestedModuleDeclaration(parent)) { getJSDocCommentsAndTagsWorker(parent); } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -10458,11 +10507,11 @@ var ts; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */ || ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */ || - node.kind === 184 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 215 /* ExpressionStatement */) { + node.kind === 185 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 216 /* ExpressionStatement */) { getJSDocCommentsAndTagsWorker(parent); } // Pull parameter comments from declaring function as well - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); } if (isVariableLike(node) && ts.hasInitializer(node) && node.initializer !== hostNode && ts.hasJSDocNodes(node.initializer)) { @@ -10517,12 +10566,12 @@ var ts; ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { var last = ts.lastOrUndefined(s.parameters); - return last && isRestParameter(last); + return !!last && isRestParameter(last); } 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 === 284 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 285 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10535,31 +10584,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 190 /* ParenthesizedExpression */: - case 182 /* ArrayLiteralExpression */: - case 203 /* SpreadElement */: - case 208 /* NonNullExpression */: + case 191 /* ParenthesizedExpression */: + case 183 /* ArrayLiteralExpression */: + case 204 /* SpreadElement */: + case 209 /* NonNullExpression */: node = parent; break; - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10586,22 +10635,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 212 /* Block */: - case 213 /* VariableStatement */: - case 225 /* WithStatement */: - case 216 /* IfStatement */: - case 226 /* SwitchStatement */: - case 240 /* CaseBlock */: - case 265 /* CaseClause */: - case 266 /* DefaultClause */: - case 227 /* LabeledStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 229 /* TryStatement */: - case 268 /* CatchClause */: + case 213 /* Block */: + case 214 /* VariableStatement */: + case 226 /* WithStatement */: + case 217 /* IfStatement */: + case 227 /* SwitchStatement */: + case 241 /* CaseBlock */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: + case 228 /* LabeledStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 230 /* TryStatement */: + case 269 /* CatchClause */: return true; } return false; @@ -10618,15 +10667,15 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 172 /* ParenthesizedType */); + return walkUp(node, 173 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 190 /* ParenthesizedExpression */); + return walkUp(node, 191 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 190 /* ParenthesizedExpression */) { + while (node.kind === 191 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -10634,11 +10683,11 @@ var ts; ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 184 /* PropertyAccessExpression */ && node.kind !== 185 /* ElementAccessExpression */) { + if (node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 193 /* DeleteExpression */; + return node && node.kind === 194 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10660,9 +10709,10 @@ var ts; switch (name.kind) { case 71 /* Identifier */: case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - if (ts.isDeclaration(name.parent)) { - return name.parent.name === name; + case 8 /* NumericLiteral */: { + var parent = name.parent; + if (ts.isDeclaration(parent)) { + return parent.name === name; } else if (ts.isQualifiedName(name.parent)) { var tag = name.parent.parent; @@ -10672,6 +10722,7 @@ var ts; var binExp = name.parent.parent; return ts.isBinaryExpression(binExp) && getSpecialPropertyAssignmentKind(binExp) !== 0 /* None */ && ts.getNameOfDeclaration(binExp) === name; } + } default: return false; } @@ -10679,7 +10730,7 @@ var ts; ts.isAnyDeclarationName = isAnyDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 146 /* ComputedPropertyName */ && + node.parent.kind === 147 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10687,32 +10738,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 272 /* EnumMember */: - case 269 /* PropertyAssignment */: - case 184 /* PropertyAccessExpression */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 273 /* EnumMember */: + case 270 /* PropertyAssignment */: + case 185 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 145 /* QualifiedName */) { + while (parent.kind === 146 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 164 /* TypeQuery */ || parent.kind === 161 /* TypeReference */; + return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; } return false; - case 181 /* BindingElement */: - case 247 /* ImportSpecifier */: + case 182 /* BindingElement */: + case 248 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 251 /* ExportSpecifier */: - case 261 /* JsxAttribute */: + case 252 /* ExportSpecifier */: + case 262 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10728,13 +10779,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 242 /* ImportEqualsDeclaration */ || - node.kind === 241 /* NamespaceExportDeclaration */ || - node.kind === 244 /* ImportClause */ && !!node.name || - node.kind === 245 /* NamespaceImport */ || - node.kind === 247 /* ImportSpecifier */ || - node.kind === 251 /* ExportSpecifier */ || - node.kind === 248 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 243 /* ImportEqualsDeclaration */ || + node.kind === 242 /* NamespaceExportDeclaration */ || + node.kind === 245 /* ImportClause */ && !!node.name || + node.kind === 246 /* NamespaceImport */ || + node.kind === 248 /* ImportSpecifier */ || + node.kind === 252 /* ExportSpecifier */ || + node.kind === 249 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -10795,11 +10846,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 72 /* FirstKeyword */ <= token && token <= 144 /* LastKeyword */; + return 72 /* FirstKeyword */ <= token && token <= 145 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 117 /* FirstContextualKeyword */ <= token && token <= 144 /* LastContextualKeyword */; + return 117 /* FirstContextualKeyword */ <= token && token <= 145 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -10829,14 +10880,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -10850,10 +10901,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -10876,11 +10927,11 @@ var ts; */ function hasDynamicName(declaration) { var name = ts.getNameOfDeclaration(declaration); - return name && isDynamicName(name); + return !!name && isDynamicName(name); } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 146 /* ComputedPropertyName */ && + return name.kind === 147 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -10901,7 +10952,7 @@ var ts; if (name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return escapeLeadingUnderscores(name.text); } - if (name.kind === 146 /* ComputedPropertyName */) { + if (name.kind === 147 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -10954,11 +11005,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 148 /* Parameter */; + return root.kind === 149 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 181 /* BindingElement */) { + while (node.kind === 182 /* BindingElement */) { node = node.parent.parent; } return node; @@ -10966,15 +11017,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 154 /* Constructor */ - || kind === 191 /* FunctionExpression */ - || kind === 233 /* FunctionDeclaration */ - || kind === 192 /* ArrowFunction */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */ - || kind === 238 /* ModuleDeclaration */ - || kind === 273 /* SourceFile */; + return kind === 155 /* Constructor */ + || kind === 192 /* FunctionExpression */ + || kind === 234 /* FunctionDeclaration */ + || kind === 193 /* ArrowFunction */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */ + || kind === 239 /* ModuleDeclaration */ + || kind === 274 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -10993,23 +11044,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 187 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 187 /* NewExpression */: + case 188 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 197 /* PrefixUnaryExpression */: - case 194 /* TypeOfExpression */: - case 195 /* VoidExpression */: - case 193 /* DeleteExpression */: - case 196 /* AwaitExpression */: - case 200 /* ConditionalExpression */: - case 202 /* YieldExpression */: + case 198 /* PrefixUnaryExpression */: + case 195 /* TypeOfExpression */: + case 196 /* VoidExpression */: + case 194 /* DeleteExpression */: + case 197 /* AwaitExpression */: + case 201 /* ConditionalExpression */: + case 203 /* YieldExpression */: return 1 /* Right */; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: switch (operator) { case 40 /* AsteriskAsteriskToken */: case 58 /* EqualsToken */: @@ -11033,15 +11084,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 187 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 199 /* BinaryExpression */) { + if (expression.kind === 200 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 197 /* PrefixUnaryExpression */ || expression.kind === 198 /* PostfixUnaryExpression */) { + else if (expression.kind === 198 /* PrefixUnaryExpression */ || expression.kind === 199 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11051,15 +11102,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: return 0; - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return 1; - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return 2; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return 4; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: switch (operatorKind) { case 26 /* CommaToken */: return 0; @@ -11080,21 +11131,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 197 /* PrefixUnaryExpression */: - case 194 /* TypeOfExpression */: - case 195 /* VoidExpression */: - case 193 /* DeleteExpression */: - case 196 /* AwaitExpression */: + case 198 /* PrefixUnaryExpression */: + case 195 /* TypeOfExpression */: + case 196 /* VoidExpression */: + case 194 /* DeleteExpression */: + case 197 /* AwaitExpression */: return 16; - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return 17; - case 186 /* CallExpression */: + case 187 /* CallExpression */: return 18; - case 187 /* NewExpression */: + case 188 /* NewExpression */: return hasArguments ? 19 : 18; - case 188 /* TaggedTemplateExpression */: - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: + case 189 /* TaggedTemplateExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: return 19; case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: @@ -11104,19 +11155,19 @@ var ts; case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 182 /* ArrayLiteralExpression */: - case 183 /* ObjectLiteralExpression */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 204 /* ClassExpression */: - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: - case 258 /* JsxFragment */: + case 183 /* ArrayLiteralExpression */: + case 184 /* ObjectLiteralExpression */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 205 /* ClassExpression */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: + case 259 /* JsxFragment */: case 12 /* RegularExpressionLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 201 /* TemplateExpression */: - case 190 /* ParenthesizedExpression */: - case 205 /* OmittedExpression */: + case 202 /* TemplateExpression */: + case 191 /* ParenthesizedExpression */: + case 206 /* OmittedExpression */: return 20; default: return -1; @@ -11169,7 +11220,7 @@ var ts; } ts.getBinaryOperatorPrecedence = getBinaryOperatorPrecedence; function createDiagnosticCollection() { - var nonFileDiagnostics = []; + var nonFileDiagnostics = []; // See GH#19873 var filesWithDiagnostics = []; var fileDiagnostics = ts.createMap(); var hasReadNonFileDiagnostics = false; @@ -11187,7 +11238,7 @@ var ts; if (diagnostic.file) { diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { - diagnostics = []; + diagnostics = []; // See GH#19873 fileDiagnostics.set(diagnostic.file.fileName, diagnostics); ts.insertSorted(filesWithDiagnostics, diagnostic.file.fileName, ts.compareStringsCaseSensitive); } @@ -11334,7 +11385,7 @@ var ts; var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + linePos = output.length - s.length + ts.last(lineStartsOfS); } } } @@ -11509,7 +11560,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 71 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 71 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { @@ -11517,16 +11568,17 @@ var ts; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { + // TODO: GH#18217 var firstAccessor; var secondAccessor; var getAccessor; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 155 /* GetAccessor */) { + if (accessor.kind === 156 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 156 /* SetAccessor */) { + else if (accessor.kind === 157 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11535,7 +11587,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 155 /* GetAccessor */ || member.kind === 156 /* SetAccessor */) + if ((member.kind === 156 /* GetAccessor */ || member.kind === 157 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -11546,10 +11598,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 155 /* GetAccessor */ && !getAccessor) { + if (member.kind === 156 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 156 /* SetAccessor */ && !setAccessor) { + if (member.kind === 157 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11596,25 +11648,20 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 285 /* JSDocComment */); - var templateTags = ts.flatMap(ts.filter(node.parent.tags, ts.isJSDocTemplateTag), function (tag) { return tag.typeParameters; }); - var templateTagNodes = templateTags; - templateTagNodes.pos = templateTagNodes.length > 0 ? ts.first(templateTagNodes).pos : node.pos; - templateTagNodes.end = templateTagNodes.length > 0 ? ts.last(templateTagNodes).end : node.end; - templateTagNodes.hasTrailingComma = false; - return templateTagNodes; + ts.Debug.assert(node.parent.kind === 286 /* JSDocComment */); + return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray); } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getJSDocTypeParameterDeclarations(node) { - // template tags are only available when a typedef isn't already using them - var tag = ts.find(ts.getJSDocTags(node), function (tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 285 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); - }); - return (tag && tag.typeParameters) || ts.emptyArray; + return ts.flatMap(ts.getJSDocTags(node), function (tag) { return isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined; }); } 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 === 286 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node * was parsed in a JavaScript file, gets the type annotation from JSDoc. @@ -11713,13 +11760,13 @@ var ts; // All comments look like they could have been part of the copyright header. Make // sure there is at least one blank line between it and the node. If not, it's not // a copyright header. - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.last(detachedComments).end); var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); if (nodeLine >= lastCommentLine + 2) { // Valid detachedComments emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); emitComments(text, lineMap, writer, detachedComments, /*leadingSeparator*/ false, /*trailingSeparator*/ true, newLine, writeComment); - currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.last(detachedComments).end }; } } } @@ -11888,7 +11935,7 @@ var ts; ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 206 /* ExpressionWithTypeArguments */ && + if (ts.isExpressionWithTypeArguments(node) && node.parent.token === 85 /* ExtendsKeyword */ && ts.isClassLike(node.parent.parent)) { return node.parent.parent; @@ -11906,8 +11953,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 183 /* ObjectLiteralExpression */ - || kind === 182 /* ArrayLiteralExpression */; + return kind === 184 /* ObjectLiteralExpression */ + || kind === 183 /* ArrayLiteralExpression */; } return false; } @@ -11917,7 +11964,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 206 /* ExpressionWithTypeArguments */ + return node.kind === 207 /* ExpressionWithTypeArguments */ && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 /* ImplementsKeyword */ @@ -11938,17 +11985,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 145 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 183 /* ObjectLiteralExpression */ && + return expression.kind === 184 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 182 /* ArrayLiteralExpression */ && + return expression.kind === 183 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12062,14 +12109,14 @@ var ts; return output; } function base64encode(host, input) { - if (host.base64encode) { + if (host && host.base64encode) { return host.base64encode(input); } return convertToBase64(input); } ts.base64encode = base64encode; function base64decode(host, input) { - if (host.base64decode) { + if (host && host.base64decode) { return host.base64decode(input); } var length = input.length; @@ -12289,8 +12336,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 237 /* EnumDeclaration */: - case 238 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 239 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12363,21 +12410,21 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 198 /* PostfixUnaryExpression */: - case 197 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0 /* Read */; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : 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 && parent.parent.kind === 215 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && parent.parent.kind === 216 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function compareDataObjects(dst, src) { @@ -12468,7 +12515,7 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 65536 /* Object */ ? type.objectFlags : 0; + return type.flags & 131072 /* Object */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { @@ -12739,9 +12786,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 147 /* TypeParameter */) { + if (d && d.kind === 148 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 235 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236 /* InterfaceDeclaration */) { return current; } } @@ -12749,7 +12796,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 154 /* Constructor */; + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 155 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12767,7 +12814,7 @@ var ts; } ts.isEmptyBindingElement = isEmptyBindingElement; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 181 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 182 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -12775,14 +12822,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 231 /* VariableDeclaration */) { + if (node.kind === 232 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 232 /* VariableDeclarationList */) { + if (node && node.kind === 233 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 213 /* VariableStatement */) { + if (node && node.kind === 214 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -12798,14 +12845,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 231 /* VariableDeclaration */) { + if (node.kind === 232 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 232 /* VariableDeclarationList */) { + if (node && node.kind === 233 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 213 /* VariableStatement */) { + if (node && node.kind === 214 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -12858,7 +12905,7 @@ var ts; // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) ts.localizedDiagnosticMessages = JSON.parse(fileContents); } - catch (e) { + catch (_a) { if (errors) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath)); } @@ -12942,17 +12989,17 @@ var ts; } // Covers remaining cases switch (hostNode.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return expr.name; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -12961,10 +13008,10 @@ var ts; return undefined; case 1 /* EndOfFileToken */: return undefined; - case 190 /* ParenthesizedExpression */: { + case 191 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 227 /* LabeledStatement */: { + case 228 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12987,28 +13034,29 @@ var ts; return !!node.name; // A 'name' property should always be a DeclarationName. } ts.isNamedDeclaration = isNamedDeclaration; + // TODO: GH#18217 This is often used as if it returns a defined result function getNameOfDeclaration(declaration) { if (!declaration) { return undefined; } switch (declaration.kind) { - case 204 /* ClassExpression */: - case 191 /* FunctionExpression */: + case 205 /* ClassExpression */: + case 192 /* FunctionExpression */: if (!declaration.name) { return getAssignedName(declaration); } break; case 71 /* Identifier */: return declaration; - case 297 /* JSDocPropertyTag */: - case 292 /* JSDocParameterTag */: { + case 298 /* JSDocPropertyTag */: + case 293 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 145 /* QualifiedName */) { + if (name.kind === 146 /* QualifiedName */) { return name.right; } break; } - case 199 /* BinaryExpression */: { + case 200 /* BinaryExpression */: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1 /* ExportsProperty */: @@ -13020,11 +13068,11 @@ var ts; return undefined; } } - case 291 /* JSDocCallbackTag */: + case 292 /* JSDocCallbackTag */: return declaration.name; - case 296 /* JSDocTypedefTag */: + case 297 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 248 /* ExportAssignment */: { + case 249 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -13214,637 +13262,637 @@ var ts; ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 145 /* QualifiedName */; + return node.kind === 146 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 146 /* ComputedPropertyName */; + return node.kind === 147 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 147 /* TypeParameter */; + return node.kind === 148 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 148 /* Parameter */; + return node.kind === 149 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 149 /* Decorator */; + return node.kind === 150 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 150 /* PropertySignature */; + return node.kind === 151 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 151 /* PropertyDeclaration */; + return node.kind === 152 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 152 /* MethodSignature */; + return node.kind === 153 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 153 /* MethodDeclaration */; + return node.kind === 154 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 154 /* Constructor */; + return node.kind === 155 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 155 /* GetAccessor */; + return node.kind === 156 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 156 /* SetAccessor */; + return node.kind === 157 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 157 /* CallSignature */; + return node.kind === 158 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 158 /* ConstructSignature */; + return node.kind === 159 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 159 /* IndexSignature */; + return node.kind === 160 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 156 /* SetAccessor */ || node.kind === 155 /* GetAccessor */; + return node.kind === 157 /* SetAccessor */ || node.kind === 156 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 160 /* TypePredicate */; + return node.kind === 161 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 161 /* TypeReference */; + return node.kind === 162 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 162 /* FunctionType */; + return node.kind === 163 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 163 /* ConstructorType */; + return node.kind === 164 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 164 /* TypeQuery */; + return node.kind === 165 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 165 /* TypeLiteral */; + return node.kind === 166 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 166 /* ArrayType */; + return node.kind === 167 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 167 /* TupleType */; + return node.kind === 168 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 168 /* UnionType */; + return node.kind === 169 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 169 /* IntersectionType */; + return node.kind === 170 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 170 /* ConditionalType */; + return node.kind === 171 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 171 /* InferType */; + return node.kind === 172 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 172 /* ParenthesizedType */; + return node.kind === 173 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 173 /* ThisType */; + return node.kind === 174 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 174 /* TypeOperator */; + return node.kind === 175 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 175 /* IndexedAccessType */; + return node.kind === 176 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 176 /* MappedType */; + return node.kind === 177 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 177 /* LiteralType */; + return node.kind === 178 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 178 /* ImportType */; + return node.kind === 179 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 179 /* ObjectBindingPattern */; + return node.kind === 180 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 180 /* ArrayBindingPattern */; + return node.kind === 181 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 181 /* BindingElement */; + return node.kind === 182 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 182 /* ArrayLiteralExpression */; + return node.kind === 183 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 183 /* ObjectLiteralExpression */; + return node.kind === 184 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 184 /* PropertyAccessExpression */; + return node.kind === 185 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 185 /* ElementAccessExpression */; + return node.kind === 186 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 186 /* CallExpression */; + return node.kind === 187 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 187 /* NewExpression */; + return node.kind === 188 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 188 /* TaggedTemplateExpression */; + return node.kind === 189 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 189 /* TypeAssertionExpression */; + return node.kind === 190 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 190 /* ParenthesizedExpression */; + return node.kind === 191 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 300 /* PartiallyEmittedExpression */) { + while (node.kind === 301 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 191 /* FunctionExpression */; + return node.kind === 192 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 192 /* ArrowFunction */; + return node.kind === 193 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 193 /* DeleteExpression */; + return node.kind === 194 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 194 /* TypeOfExpression */; + return node.kind === 195 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 195 /* VoidExpression */; + return node.kind === 196 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 196 /* AwaitExpression */; + return node.kind === 197 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 197 /* PrefixUnaryExpression */; + return node.kind === 198 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 198 /* PostfixUnaryExpression */; + return node.kind === 199 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 199 /* BinaryExpression */; + return node.kind === 200 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 200 /* ConditionalExpression */; + return node.kind === 201 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 201 /* TemplateExpression */; + return node.kind === 202 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 202 /* YieldExpression */; + return node.kind === 203 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 203 /* SpreadElement */; + return node.kind === 204 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 204 /* ClassExpression */; + return node.kind === 205 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 205 /* OmittedExpression */; + return node.kind === 206 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 206 /* ExpressionWithTypeArguments */; + return node.kind === 207 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 207 /* AsExpression */; + return node.kind === 208 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 208 /* NonNullExpression */; + return node.kind === 209 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 209 /* MetaProperty */; + return node.kind === 210 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 210 /* TemplateSpan */; + return node.kind === 211 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 211 /* SemicolonClassElement */; + return node.kind === 212 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 212 /* Block */; + return node.kind === 213 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 213 /* VariableStatement */; + return node.kind === 214 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 214 /* EmptyStatement */; + return node.kind === 215 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 215 /* ExpressionStatement */; + return node.kind === 216 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 216 /* IfStatement */; + return node.kind === 217 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 217 /* DoStatement */; + return node.kind === 218 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 218 /* WhileStatement */; + return node.kind === 219 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 219 /* ForStatement */; + return node.kind === 220 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 220 /* ForInStatement */; + return node.kind === 221 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 221 /* ForOfStatement */; + return node.kind === 222 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 222 /* ContinueStatement */; + return node.kind === 223 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 223 /* BreakStatement */; + return node.kind === 224 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 223 /* BreakStatement */ || node.kind === 222 /* ContinueStatement */; + return node.kind === 224 /* BreakStatement */ || node.kind === 223 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 224 /* ReturnStatement */; + return node.kind === 225 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 225 /* WithStatement */; + return node.kind === 226 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 226 /* SwitchStatement */; + return node.kind === 227 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 227 /* LabeledStatement */; + return node.kind === 228 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 228 /* ThrowStatement */; + return node.kind === 229 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 229 /* TryStatement */; + return node.kind === 230 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 230 /* DebuggerStatement */; + return node.kind === 231 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 231 /* VariableDeclaration */; + return node.kind === 232 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 232 /* VariableDeclarationList */; + return node.kind === 233 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 233 /* FunctionDeclaration */; + return node.kind === 234 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 234 /* ClassDeclaration */; + return node.kind === 235 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 235 /* InterfaceDeclaration */; + return node.kind === 236 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 236 /* TypeAliasDeclaration */; + return node.kind === 237 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 237 /* EnumDeclaration */; + return node.kind === 238 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 238 /* ModuleDeclaration */; + return node.kind === 239 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 239 /* ModuleBlock */; + return node.kind === 240 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 240 /* CaseBlock */; + return node.kind === 241 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 241 /* NamespaceExportDeclaration */; + return node.kind === 242 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 242 /* ImportEqualsDeclaration */; + return node.kind === 243 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 243 /* ImportDeclaration */; + return node.kind === 244 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 244 /* ImportClause */; + return node.kind === 245 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 245 /* NamespaceImport */; + return node.kind === 246 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 246 /* NamedImports */; + return node.kind === 247 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 247 /* ImportSpecifier */; + return node.kind === 248 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 248 /* ExportAssignment */; + return node.kind === 249 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 249 /* ExportDeclaration */; + return node.kind === 250 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 250 /* NamedExports */; + return node.kind === 251 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 251 /* ExportSpecifier */; + return node.kind === 252 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 252 /* MissingDeclaration */; + return node.kind === 253 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 253 /* ExternalModuleReference */; + return node.kind === 254 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 254 /* JsxElement */; + return node.kind === 255 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 255 /* JsxSelfClosingElement */; + return node.kind === 256 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 256 /* JsxOpeningElement */; + return node.kind === 257 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 257 /* JsxClosingElement */; + return node.kind === 258 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 258 /* JsxFragment */; + return node.kind === 259 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 259 /* JsxOpeningFragment */; + return node.kind === 260 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 260 /* JsxClosingFragment */; + return node.kind === 261 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 261 /* JsxAttribute */; + return node.kind === 262 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 262 /* JsxAttributes */; + return node.kind === 263 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 263 /* JsxSpreadAttribute */; + return node.kind === 264 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 264 /* JsxExpression */; + return node.kind === 265 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 265 /* CaseClause */; + return node.kind === 266 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 266 /* DefaultClause */; + return node.kind === 267 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 267 /* HeritageClause */; + return node.kind === 268 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 268 /* CatchClause */; + return node.kind === 269 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 269 /* PropertyAssignment */; + return node.kind === 270 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 270 /* ShorthandPropertyAssignment */; + return node.kind === 271 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 271 /* SpreadAssignment */; + return node.kind === 272 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 272 /* EnumMember */; + return node.kind === 273 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 273 /* SourceFile */; + return node.kind === 274 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 274 /* Bundle */; + return node.kind === 275 /* Bundle */; } ts.isBundle = isBundle; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 277 /* JSDocTypeExpression */; + return node.kind === 278 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 278 /* JSDocAllType */; + return node.kind === 279 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 279 /* JSDocUnknownType */; + return node.kind === 280 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 280 /* JSDocNullableType */; + return node.kind === 281 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 281 /* JSDocNonNullableType */; + return node.kind === 282 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 282 /* JSDocOptionalType */; + return node.kind === 283 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 283 /* JSDocFunctionType */; + return node.kind === 284 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 284 /* JSDocVariadicType */; + return node.kind === 285 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 285 /* JSDocComment */; + return node.kind === 286 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 289 /* JSDocAugmentsTag */; + return node.kind === 290 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 290 /* JSDocClassTag */; + return node.kind === 291 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocParameterTag(node) { - return node.kind === 292 /* JSDocParameterTag */; + return node.kind === 293 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 293 /* JSDocReturnTag */; + return node.kind === 294 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 294 /* JSDocTypeTag */; + return node.kind === 295 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 295 /* JSDocTemplateTag */; + return node.kind === 296 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 296 /* JSDocTypedefTag */; + return node.kind === 297 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 297 /* JSDocPropertyTag */; + return node.kind === 298 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 297 /* JSDocPropertyTag */ || node.kind === 292 /* JSDocParameterTag */; + return node.kind === 298 /* JSDocPropertyTag */ || node.kind === 293 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 286 /* JSDocTypeLiteral */; + return node.kind === 287 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 291 /* JSDocCallbackTag */; + return node.kind === 292 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 287 /* JSDocSignature */; + return node.kind === 288 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -13855,7 +13903,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 298 /* SyntaxList */; + return n.kind === 299 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -13865,7 +13913,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 145 /* FirstNode */; + return kind >= 146 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13874,7 +13922,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 144 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 145 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -13899,6 +13947,10 @@ var ts; return 13 /* FirstTemplateToken */ <= kind && kind <= 16 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isTemplateLiteralToken(node) { + return isTemplateLiteralKind(node.kind); + } + ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; return kind === 15 /* TemplateMiddle */ @@ -13912,7 +13964,6 @@ var ts; // Identifiers /* @internal */ function isGeneratedIdentifier(node) { - // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */; } ts.isGeneratedIdentifier = isGeneratedIdentifier; @@ -13952,7 +14003,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 145 /* QualifiedName */ + return kind === 146 /* QualifiedName */ || kind === 71 /* Identifier */; } ts.isEntityName = isEntityName; @@ -13961,14 +14012,14 @@ var ts; return kind === 71 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 146 /* ComputedPropertyName */; + || kind === 147 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 179 /* ObjectBindingPattern */ - || kind === 180 /* ArrayBindingPattern */; + || kind === 180 /* ObjectBindingPattern */ + || kind === 181 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13983,13 +14034,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return true; default: return false; @@ -13998,14 +14049,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 287 /* JSDocSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 162 /* FunctionType */: - case 283 /* JSDocFunctionType */: - case 163 /* ConstructorType */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 288 /* JSDocSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 163 /* FunctionType */: + case 284 /* JSDocFunctionType */: + case 164 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14020,29 +14071,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 154 /* Constructor */ - || kind === 151 /* PropertyDeclaration */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */ - || kind === 159 /* IndexSignature */ - || kind === 211 /* SemicolonClassElement */; + return kind === 155 /* Constructor */ + || kind === 152 /* PropertyDeclaration */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */ + || kind === 160 /* IndexSignature */ + || kind === 212 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 234 /* ClassDeclaration */ || node.kind === 204 /* ClassExpression */); + return node && (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 155 /* GetAccessor */ || node.kind === 156 /* SetAccessor */); + return node && (node.kind === 156 /* GetAccessor */ || node.kind === 157 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return true; default: return false; @@ -14052,11 +14103,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 158 /* ConstructSignature */ - || kind === 157 /* CallSignature */ - || kind === 150 /* PropertySignature */ - || kind === 152 /* MethodSignature */ - || kind === 159 /* IndexSignature */; + return kind === 159 /* ConstructSignature */ + || kind === 158 /* CallSignature */ + || kind === 151 /* PropertySignature */ + || kind === 153 /* MethodSignature */ + || kind === 160 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14065,18 +14116,19 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 269 /* PropertyAssignment */ - || kind === 270 /* ShorthandPropertyAssignment */ - || kind === 271 /* SpreadAssignment */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */; + return kind === 270 /* PropertyAssignment */ + || kind === 271 /* ShorthandPropertyAssignment */ + || kind === 272 /* SpreadAssignment */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 160 /* FirstTypeNode */ && kind <= 178 /* LastTypeNode */) + return (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) || kind === 119 /* AnyKeyword */ + || kind === 142 /* UnknownKeyword */ || kind === 134 /* NumberKeyword */ || kind === 135 /* ObjectKeyword */ || kind === 122 /* BooleanKeyword */ @@ -14087,14 +14139,14 @@ var ts; || kind === 140 /* UndefinedKeyword */ || kind === 95 /* NullKeyword */ || kind === 131 /* NeverKeyword */ - || kind === 206 /* ExpressionWithTypeArguments */ - || kind === 278 /* JSDocAllType */ - || kind === 279 /* JSDocUnknownType */ - || kind === 280 /* JSDocNullableType */ - || kind === 281 /* JSDocNonNullableType */ - || kind === 282 /* JSDocOptionalType */ - || kind === 283 /* JSDocFunctionType */ - || kind === 284 /* JSDocVariadicType */; + || kind === 207 /* ExpressionWithTypeArguments */ + || kind === 279 /* JSDocAllType */ + || kind === 280 /* JSDocUnknownType */ + || kind === 281 /* JSDocNullableType */ + || kind === 282 /* JSDocNonNullableType */ + || kind === 283 /* JSDocOptionalType */ + || kind === 284 /* JSDocFunctionType */ + || kind === 285 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -14107,8 +14159,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 162 /* FunctionType */: - case 163 /* ConstructorType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: return true; } return false; @@ -14119,8 +14171,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 180 /* ArrayBindingPattern */ - || kind === 179 /* ObjectBindingPattern */; + return kind === 181 /* ArrayBindingPattern */ + || kind === 180 /* ObjectBindingPattern */; } return false; } @@ -14128,15 +14180,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 182 /* ArrayLiteralExpression */ - || kind === 183 /* ObjectLiteralExpression */; + return kind === 183 /* ArrayLiteralExpression */ + || kind === 184 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 181 /* BindingElement */ - || kind === 205 /* OmittedExpression */; + return kind === 182 /* BindingElement */ + || kind === 206 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14145,9 +14197,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: - case 181 /* BindingElement */: + case 232 /* VariableDeclaration */: + case 149 /* Parameter */: + case 182 /* BindingElement */: return true; } return false; @@ -14168,8 +14220,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 179 /* ObjectBindingPattern */: - case 183 /* ObjectLiteralExpression */: + case 180 /* ObjectBindingPattern */: + case 184 /* ObjectLiteralExpression */: return true; } return false; @@ -14181,8 +14233,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180 /* ArrayBindingPattern */: - case 182 /* ArrayLiteralExpression */: + case 181 /* ArrayBindingPattern */: + case 183 /* ArrayLiteralExpression */: return true; } return false; @@ -14191,26 +14243,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 184 /* PropertyAccessExpression */ - || kind === 145 /* QualifiedName */ - || kind === 178 /* ImportType */; + return kind === 185 /* PropertyAccessExpression */ + || kind === 146 /* QualifiedName */ + || kind === 179 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 184 /* PropertyAccessExpression */ - || kind === 145 /* QualifiedName */; + return kind === 185 /* PropertyAccessExpression */ + || kind === 146 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 256 /* JsxOpeningElement */: - case 255 /* JsxSelfClosingElement */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 188 /* TaggedTemplateExpression */: - case 149 /* Decorator */: + case 257 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 189 /* TaggedTemplateExpression */: + case 150 /* Decorator */: return true; default: return false; @@ -14218,12 +14270,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 186 /* CallExpression */ || node.kind === 187 /* NewExpression */; + return node.kind === 187 /* CallExpression */ || node.kind === 188 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 201 /* TemplateExpression */ + return kind === 202 /* TemplateExpression */ || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14234,32 +14286,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: - case 187 /* NewExpression */: - case 186 /* CallExpression */: - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: - case 258 /* JsxFragment */: - case 188 /* TaggedTemplateExpression */: - case 182 /* ArrayLiteralExpression */: - case 190 /* ParenthesizedExpression */: - case 183 /* ObjectLiteralExpression */: - case 204 /* ClassExpression */: - case 191 /* FunctionExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: + case 188 /* NewExpression */: + case 187 /* CallExpression */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: + case 259 /* JsxFragment */: + case 189 /* TaggedTemplateExpression */: + case 183 /* ArrayLiteralExpression */: + case 191 /* ParenthesizedExpression */: + case 184 /* ObjectLiteralExpression */: + case 205 /* ClassExpression */: + case 192 /* FunctionExpression */: case 71 /* Identifier */: case 12 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 99 /* ThisKeyword */: case 101 /* TrueKeyword */: case 97 /* SuperKeyword */: - case 208 /* NonNullExpression */: - case 209 /* MetaProperty */: + case 209 /* NonNullExpression */: + case 210 /* MetaProperty */: case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -14273,13 +14325,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: - case 193 /* DeleteExpression */: - case 194 /* TypeOfExpression */: - case 195 /* VoidExpression */: - case 196 /* AwaitExpression */: - case 189 /* TypeAssertionExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: + case 194 /* DeleteExpression */: + case 195 /* TypeOfExpression */: + case 196 /* VoidExpression */: + case 197 /* AwaitExpression */: + case 190 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -14288,9 +14340,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return true; - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; default: @@ -14309,15 +14361,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 200 /* ConditionalExpression */: - case 202 /* YieldExpression */: - case 192 /* ArrowFunction */: - case 199 /* BinaryExpression */: - case 203 /* SpreadElement */: - case 207 /* AsExpression */: - case 205 /* OmittedExpression */: - case 301 /* CommaListExpression */: - case 300 /* PartiallyEmittedExpression */: + case 201 /* ConditionalExpression */: + case 203 /* YieldExpression */: + case 193 /* ArrowFunction */: + case 200 /* BinaryExpression */: + case 204 /* SpreadElement */: + case 208 /* AsExpression */: + case 206 /* OmittedExpression */: + case 302 /* CommaListExpression */: + case 301 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14325,18 +14377,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 189 /* TypeAssertionExpression */ - || kind === 207 /* AsExpression */; + return kind === 190 /* TypeAssertionExpression */ + || kind === 208 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 300 /* PartiallyEmittedExpression */; + return node.kind === 301 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 299 /* NotEmittedStatement */; + return node.kind === 300 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14347,13 +14399,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: return true; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14361,7 +14413,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 220 /* ForInStatement */ || node.kind === 221 /* ForOfStatement */; + return node.kind === 221 /* ForInStatement */ || node.kind === 222 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14385,113 +14437,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 239 /* ModuleBlock */ - || kind === 238 /* ModuleDeclaration */ + return kind === 240 /* ModuleBlock */ + || kind === 239 /* ModuleDeclaration */ || kind === 71 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 239 /* ModuleBlock */ - || kind === 238 /* ModuleDeclaration */; + return kind === 240 /* ModuleBlock */ + || kind === 239 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 238 /* ModuleDeclaration */; + || kind === 239 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 246 /* NamedImports */ - || kind === 245 /* NamespaceImport */; + return kind === 247 /* NamedImports */ + || kind === 246 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 238 /* ModuleDeclaration */ || node.kind === 237 /* EnumDeclaration */; + return node.kind === 239 /* ModuleDeclaration */ || node.kind === 238 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 192 /* ArrowFunction */ - || kind === 181 /* BindingElement */ - || kind === 234 /* ClassDeclaration */ - || kind === 204 /* ClassExpression */ - || kind === 154 /* Constructor */ - || kind === 237 /* EnumDeclaration */ - || kind === 272 /* EnumMember */ - || kind === 251 /* ExportSpecifier */ - || kind === 233 /* FunctionDeclaration */ - || kind === 191 /* FunctionExpression */ - || kind === 155 /* GetAccessor */ - || kind === 244 /* ImportClause */ - || kind === 242 /* ImportEqualsDeclaration */ - || kind === 247 /* ImportSpecifier */ - || kind === 235 /* InterfaceDeclaration */ - || kind === 261 /* JsxAttribute */ - || kind === 153 /* MethodDeclaration */ - || kind === 152 /* MethodSignature */ - || kind === 238 /* ModuleDeclaration */ - || kind === 241 /* NamespaceExportDeclaration */ - || kind === 245 /* NamespaceImport */ - || kind === 148 /* Parameter */ - || kind === 269 /* PropertyAssignment */ - || kind === 151 /* PropertyDeclaration */ - || kind === 150 /* PropertySignature */ - || kind === 156 /* SetAccessor */ - || kind === 270 /* ShorthandPropertyAssignment */ - || kind === 236 /* TypeAliasDeclaration */ - || kind === 147 /* TypeParameter */ - || kind === 231 /* VariableDeclaration */ - || kind === 296 /* JSDocTypedefTag */ - || kind === 291 /* JSDocCallbackTag */ - || kind === 297 /* JSDocPropertyTag */; + return kind === 193 /* ArrowFunction */ + || kind === 182 /* BindingElement */ + || kind === 235 /* ClassDeclaration */ + || kind === 205 /* ClassExpression */ + || kind === 155 /* Constructor */ + || kind === 238 /* EnumDeclaration */ + || kind === 273 /* EnumMember */ + || kind === 252 /* ExportSpecifier */ + || kind === 234 /* FunctionDeclaration */ + || kind === 192 /* FunctionExpression */ + || kind === 156 /* GetAccessor */ + || kind === 245 /* ImportClause */ + || kind === 243 /* ImportEqualsDeclaration */ + || kind === 248 /* ImportSpecifier */ + || kind === 236 /* InterfaceDeclaration */ + || kind === 262 /* JsxAttribute */ + || kind === 154 /* MethodDeclaration */ + || kind === 153 /* MethodSignature */ + || kind === 239 /* ModuleDeclaration */ + || kind === 242 /* NamespaceExportDeclaration */ + || kind === 246 /* NamespaceImport */ + || kind === 149 /* Parameter */ + || kind === 270 /* PropertyAssignment */ + || kind === 152 /* PropertyDeclaration */ + || kind === 151 /* PropertySignature */ + || kind === 157 /* SetAccessor */ + || kind === 271 /* ShorthandPropertyAssignment */ + || kind === 237 /* TypeAliasDeclaration */ + || kind === 148 /* TypeParameter */ + || kind === 232 /* VariableDeclaration */ + || kind === 297 /* JSDocTypedefTag */ + || kind === 292 /* JSDocCallbackTag */ + || kind === 298 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 233 /* FunctionDeclaration */ - || kind === 252 /* MissingDeclaration */ - || kind === 234 /* ClassDeclaration */ - || kind === 235 /* InterfaceDeclaration */ - || kind === 236 /* TypeAliasDeclaration */ - || kind === 237 /* EnumDeclaration */ - || kind === 238 /* ModuleDeclaration */ - || kind === 243 /* ImportDeclaration */ - || kind === 242 /* ImportEqualsDeclaration */ - || kind === 249 /* ExportDeclaration */ - || kind === 248 /* ExportAssignment */ - || kind === 241 /* NamespaceExportDeclaration */; + return kind === 234 /* FunctionDeclaration */ + || kind === 253 /* MissingDeclaration */ + || kind === 235 /* ClassDeclaration */ + || kind === 236 /* InterfaceDeclaration */ + || kind === 237 /* TypeAliasDeclaration */ + || kind === 238 /* EnumDeclaration */ + || kind === 239 /* ModuleDeclaration */ + || kind === 244 /* ImportDeclaration */ + || kind === 243 /* ImportEqualsDeclaration */ + || kind === 250 /* ExportDeclaration */ + || kind === 249 /* ExportAssignment */ + || kind === 242 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 223 /* BreakStatement */ - || kind === 222 /* ContinueStatement */ - || kind === 230 /* DebuggerStatement */ - || kind === 217 /* DoStatement */ - || kind === 215 /* ExpressionStatement */ - || kind === 214 /* EmptyStatement */ - || kind === 220 /* ForInStatement */ - || kind === 221 /* ForOfStatement */ - || kind === 219 /* ForStatement */ - || kind === 216 /* IfStatement */ - || kind === 227 /* LabeledStatement */ - || kind === 224 /* ReturnStatement */ - || kind === 226 /* SwitchStatement */ - || kind === 228 /* ThrowStatement */ - || kind === 229 /* TryStatement */ - || kind === 213 /* VariableStatement */ - || kind === 218 /* WhileStatement */ - || kind === 225 /* WithStatement */ - || kind === 299 /* NotEmittedStatement */ - || kind === 303 /* EndOfDeclarationMarker */ - || kind === 302 /* MergeDeclarationMarker */; + return kind === 224 /* BreakStatement */ + || kind === 223 /* ContinueStatement */ + || kind === 231 /* DebuggerStatement */ + || kind === 218 /* DoStatement */ + || kind === 216 /* ExpressionStatement */ + || kind === 215 /* EmptyStatement */ + || kind === 221 /* ForInStatement */ + || kind === 222 /* ForOfStatement */ + || kind === 220 /* ForStatement */ + || kind === 217 /* IfStatement */ + || kind === 228 /* LabeledStatement */ + || kind === 225 /* ReturnStatement */ + || kind === 227 /* SwitchStatement */ + || kind === 229 /* ThrowStatement */ + || kind === 230 /* TryStatement */ + || kind === 214 /* VariableStatement */ + || kind === 219 /* WhileStatement */ + || kind === 226 /* WithStatement */ + || kind === 300 /* NotEmittedStatement */ + || kind === 304 /* EndOfDeclarationMarker */ + || kind === 303 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 147 /* TypeParameter */) { - return node.parent.kind !== 295 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); + if (node.kind === 148 /* TypeParameter */) { + return node.parent.kind !== 296 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -14518,10 +14570,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 212 /* Block */) + if (node.kind !== 213 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 229 /* TryStatement */ || node.parent.kind === 268 /* CatchClause */) { + if (node.parent.kind === 230 /* TryStatement */ || node.parent.kind === 269 /* CatchClause */) { return false; } } @@ -14531,8 +14583,8 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 253 /* ExternalModuleReference */ - || kind === 145 /* QualifiedName */ + return kind === 254 /* ExternalModuleReference */ + || kind === 146 /* QualifiedName */ || kind === 71 /* Identifier */; } ts.isModuleReference = isModuleReference; @@ -14542,76 +14594,78 @@ var ts; var kind = node.kind; return kind === 99 /* ThisKeyword */ || kind === 71 /* Identifier */ - || kind === 184 /* PropertyAccessExpression */; + || kind === 185 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 254 /* JsxElement */ - || kind === 264 /* JsxExpression */ - || kind === 255 /* JsxSelfClosingElement */ + return kind === 255 /* JsxElement */ + || kind === 265 /* JsxExpression */ + || kind === 256 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */ - || kind === 258 /* JsxFragment */; + || kind === 259 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 261 /* JsxAttribute */ - || kind === 263 /* JsxSpreadAttribute */; + return kind === 262 /* JsxAttribute */ + || kind === 264 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 264 /* JsxExpression */; + || kind === 265 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 256 /* JsxOpeningElement */ - || kind === 255 /* JsxSelfClosingElement */; + return kind === 257 /* JsxOpeningElement */ + || kind === 256 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 265 /* CaseClause */ - || kind === 266 /* DefaultClause */; + return kind === 266 /* CaseClause */ + || kind === 267 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 277 /* FirstJSDocNode */ && node.kind <= 297 /* LastJSDocNode */; + return node.kind >= 278 /* FirstJSDocNode */ && node.kind <= 298 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 285 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 286 /* JSDocComment */ || 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 >= 288 /* FirstJSDocTagNode */ && node.kind <= 297 /* LastJSDocTagNode */; + return node.kind >= 289 /* FirstJSDocTagNode */ && node.kind <= 298 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 156 /* SetAccessor */; + return node.kind === 157 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 155 /* GetAccessor */; + return node.kind === 156 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ /* @internal */ + // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times function hasJSDocNodes(node) { - return !!node.jsDoc && node.jsDoc.length > 0; + var jsDoc = node.jsDoc; + return !!jsDoc && jsDoc.length > 0; } ts.hasJSDocNodes = hasJSDocNodes; /** True if has type node attached to it. */ @@ -14624,36 +14678,36 @@ var ts; /* @internal */ function couldHaveType(node) { switch (node.kind) { - case 148 /* Parameter */: - case 150 /* PropertySignature */: - case 151 /* PropertyDeclaration */: - case 152 /* MethodSignature */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 160 /* TypePredicate */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 172 /* ParenthesizedType */: - case 174 /* TypeOperator */: - case 176 /* MappedType */: - case 189 /* TypeAssertionExpression */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 207 /* AsExpression */: - case 231 /* VariableDeclaration */: - case 233 /* FunctionDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 277 /* JSDocTypeExpression */: - case 280 /* JSDocNullableType */: - case 281 /* JSDocNonNullableType */: - case 282 /* JSDocOptionalType */: - case 283 /* JSDocFunctionType */: - case 284 /* JSDocVariadicType */: + case 149 /* Parameter */: + case 151 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 153 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 161 /* TypePredicate */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 173 /* ParenthesizedType */: + case 175 /* TypeOperator */: + case 177 /* MappedType */: + case 190 /* TypeAssertionExpression */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 208 /* AsExpression */: + case 232 /* VariableDeclaration */: + case 234 /* FunctionDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 278 /* JSDocTypeExpression */: + case 281 /* JSDocNullableType */: + case 282 /* JSDocNonNullableType */: + case 283 /* JSDocOptionalType */: + case 284 /* JSDocFunctionType */: + case 285 /* JSDocVariadicType */: return true; } return false; @@ -14673,13 +14727,13 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 261 /* JsxAttribute */: - case 263 /* JsxSpreadAttribute */: - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 262 /* JsxAttribute */: + case 264 /* JsxSpreadAttribute */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return true; default: return false; @@ -14688,7 +14742,7 @@ var ts; ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 161 /* TypeReference */ || node.kind === 206 /* ExpressionWithTypeArguments */; + return node.kind === 162 /* TypeReference */ || node.kind === 207 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14722,7 +14776,7 @@ var ts; ts.isStringLiteralLike = isStringLiteralLike; /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 246 /* NamedImports */ || node.kind === 250 /* NamedExports */; + return node.kind === 247 /* NamedImports */ || node.kind === 251 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; })(ts || (ts = {})); @@ -14745,7 +14799,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 273 /* SourceFile */) { + if (kind === 274 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71 /* Identifier */) { @@ -14797,28 +14851,28 @@ 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 <= 144 /* LastToken */) { + if (!node || node.kind <= 145 /* LastToken */) { return; } switch (node.kind) { - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 148 /* Parameter */: + case 149 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -14826,7 +14880,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -14834,51 +14888,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150 /* PropertySignature */: + case 151 /* 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 269 /* PropertyAssignment */: + case 270 /* 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 231 /* VariableDeclaration */: + case 232 /* 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 181 /* BindingElement */: + case 182 /* 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 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* 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 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -14889,304 +14943,304 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 165 /* TypeLiteral */: + case 166 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 167 /* TupleType */: + case 168 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 168 /* UnionType */: - case 169 /* IntersectionType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 171 /* InferType */: + case 172 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 178 /* ImportType */: + case 179 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 172 /* ParenthesizedType */: - case 174 /* TypeOperator */: + case 173 /* ParenthesizedType */: + case 175 /* TypeOperator */: return visitNode(cbNode, node.type); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 176 /* MappedType */: + case 177 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 177 /* LiteralType */: + case 178 /* LiteralType */: return visitNode(cbNode, node.literal); - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 194 /* TypeOfExpression */: + case 195 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 207 /* AsExpression */: + case 208 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return visitNode(cbNode, node.name); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 212 /* Block */: - case 239 /* ModuleBlock */: + case 213 /* Block */: + case 240 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 273 /* SourceFile */: + case 274 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222 /* ContinueStatement */: - case 223 /* BreakStatement */: + case 223 /* ContinueStatement */: + case 224 /* BreakStatement */: return visitNode(cbNode, node.label); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 265 /* CaseClause */: + case 266 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 149 /* Decorator */: + case 150 /* Decorator */: return visitNode(cbNode, node.expression); - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* 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 235 /* InterfaceDeclaration */: + case 236 /* 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 236 /* TypeAliasDeclaration */: + case 237 /* 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 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 272 /* EnumMember */: + case 273 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 246 /* NamedImports */: - case 250 /* NamedExports */: + case 247 /* NamedImports */: + case 251 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 252 /* MissingDeclaration */: + case 253 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 254 /* JsxElement */: + case 255 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 255 /* JsxSelfClosingElement */: - case 256 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 263 /* JsxSpreadAttribute */: + case 264 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 277 /* JSDocTypeExpression */: + case 278 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 281 /* JSDocNonNullableType */: + case 282 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 280 /* JSDocNullableType */: + case 281 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 282 /* JSDocOptionalType */: + case 283 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 285 /* JSDocComment */: + case 286 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 292 /* JSDocParameterTag */: - case 297 /* JSDocPropertyTag */: + case 293 /* JSDocParameterTag */: + case 298 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -15195,17 +15249,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 293 /* JSDocReturnTag */: + case 294 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 294 /* JSDocTypeTag */: + case 295 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 289 /* JSDocAugmentsTag */: + case 290 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 295 /* JSDocTemplateTag */: + case 296 /* JSDocTemplateTag */: return visitNodes(cbNode, cbNodes, node.typeParameters); - case 296 /* JSDocTypedefTag */: + case 297 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 277 /* JSDocTypeExpression */) { + node.typeExpression.kind === 278 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -15213,16 +15267,16 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 291 /* JSDocCallbackTag */: + case 292 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 287 /* JSDocSignature */: + case 288 /* JSDocSignature */: 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 286 /* JSDocTypeLiteral */: + case 287 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -15230,7 +15284,7 @@ var ts; } } return; - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -15278,6 +15332,7 @@ var ts; // becoming detached from any SourceFile). It is recommended that this SourceFile not // be used once 'update' is called on it. function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + if (aggressiveChecks === void 0) { aggressiveChecks = false; } var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. @@ -15403,6 +15458,7 @@ var ts; // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { + if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); if (scriptKind === 6 /* JSON */) { var result_1 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); @@ -15433,6 +15489,7 @@ var ts; initializeState(sourceText, languageVersion, syntaxCursor, 6 /* JSON */); // Set source file so that errors will be reported with this file name sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false); + sourceFile.flags = contextFlags; // Prime the scanner. nextToken(); var pos = getNodePos(); @@ -15441,7 +15498,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(215 /* ExpressionStatement */); + var statement = createNode(216 /* ExpressionStatement */); switch (token()) { case 21 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -15600,10 +15657,11 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(273 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(274 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; + sourceFile.bindSuggestionDiagnostics = undefined; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); sourceFile.languageVariant = getLanguageVariant(scriptKind); @@ -15987,7 +16045,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(146 /* ComputedPropertyName */); + var node = createNode(147 /* ComputedPropertyName */); parseExpected(21 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -16124,7 +16182,7 @@ var ts; case 14 /* JsxChildren */: return true; } - ts.Debug.fail("Non-exhaustive case in 'isListElement'."); + return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { ts.Debug.assert(token() === 17 /* OpenBraceToken */); @@ -16213,6 +16271,8 @@ var ts; return token() === 29 /* GreaterThanToken */ || token() === 41 /* SlashToken */; case 14 /* JsxChildren */: return token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + default: + return false; } } function isVariableDeclaratorListTerminator() { @@ -16399,14 +16459,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 154 /* Constructor */: - case 159 /* IndexSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 151 /* PropertyDeclaration */: - case 211 /* SemicolonClassElement */: + case 155 /* Constructor */: + case 160 /* IndexSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 212 /* SemicolonClassElement */: return true; - case 153 /* MethodDeclaration */: + case 154 /* 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. @@ -16421,8 +16481,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: return true; } } @@ -16431,58 +16491,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 213 /* VariableStatement */: - case 212 /* Block */: - case 216 /* IfStatement */: - case 215 /* ExpressionStatement */: - case 228 /* ThrowStatement */: - case 224 /* ReturnStatement */: - case 226 /* SwitchStatement */: - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 219 /* ForStatement */: - case 218 /* WhileStatement */: - case 225 /* WithStatement */: - case 214 /* EmptyStatement */: - case 229 /* TryStatement */: - case 227 /* LabeledStatement */: - case 217 /* DoStatement */: - case 230 /* DebuggerStatement */: - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 249 /* ExportDeclaration */: - case 248 /* ExportAssignment */: - case 238 /* ModuleDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 234 /* FunctionDeclaration */: + case 214 /* VariableStatement */: + case 213 /* Block */: + case 217 /* IfStatement */: + case 216 /* ExpressionStatement */: + case 229 /* ThrowStatement */: + case 225 /* ReturnStatement */: + case 227 /* SwitchStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 220 /* ForStatement */: + case 219 /* WhileStatement */: + case 226 /* WithStatement */: + case 215 /* EmptyStatement */: + case 230 /* TryStatement */: + case 228 /* LabeledStatement */: + case 218 /* DoStatement */: + case 231 /* DebuggerStatement */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 250 /* ExportDeclaration */: + case 249 /* ExportAssignment */: + case 239 /* ModuleDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 272 /* EnumMember */; + return node.kind === 273 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 158 /* ConstructSignature */: - case 152 /* MethodSignature */: - case 159 /* IndexSignature */: - case 150 /* PropertySignature */: - case 157 /* CallSignature */: + case 159 /* ConstructSignature */: + case 153 /* MethodSignature */: + case 160 /* IndexSignature */: + case 151 /* PropertySignature */: + case 158 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 231 /* VariableDeclaration */) { + if (node.kind !== 232 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -16503,7 +16563,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 148 /* Parameter */) { + if (node.kind !== 149 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -16544,6 +16604,7 @@ var ts; case 22 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; case 13 /* JsxAttributes */: return ts.Diagnostics.Identifier_expected; case 14 /* JsxChildren */: return ts.Diagnostics.Identifier_expected; + default: return undefined; // TODO: GH#18217 `default: Debug.assertNever(context);` } } // Parses a comma-delimited list of elements @@ -16632,7 +16693,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(145 /* QualifiedName */, entity.pos); + var node = createNode(146 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -16669,19 +16730,19 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(201 /* TemplateExpression */); + var template = createNode(202 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); var list = []; var listPos = getNodePos(); do { list.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(list).literal.kind === 15 /* TemplateMiddle */); + } while (ts.last(list).literal.kind === 15 /* TemplateMiddle */); template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { - var span = createNode(210 /* TemplateSpan */); + var span = createNode(211 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18 /* CloseBraceToken */) { @@ -16732,7 +16793,7 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(161 /* TypeReference */); + var node = createNode(162 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token() === 27 /* LessThanToken */) { node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */); @@ -16741,20 +16802,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(160 /* TypePredicate */, lhs.pos); + var node = createNode(161 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(173 /* ThisType */); + var node = createNode(174 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(278 /* JSDocAllType */); + var result = createNode(279 /* JSDocAllType */); if (postFixEquals) { - return createJSDocPostfixType(282 /* JSDocOptionalType */, result); + return createJSDocPostfixType(283 /* JSDocOptionalType */, result); } else { nextToken(); @@ -16762,7 +16823,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(281 /* JSDocNonNullableType */); + var result = createNode(282 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -16786,28 +16847,28 @@ var ts; token() === 29 /* GreaterThanToken */ || token() === 58 /* EqualsToken */ || token() === 49 /* BarToken */) { - var result = createNode(279 /* JSDocUnknownType */, pos); + var result = createNode(280 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(280 /* JSDocNullableType */, pos); + var result = createNode(281 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(283 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(284 /* JSDocFunctionType */); nextToken(); fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(161 /* TypeReference */); + var node = createNode(162 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(148 /* Parameter */); + var parameter = createNode(149 /* Parameter */); if (token() === 99 /* ThisKeyword */ || token() === 94 /* NewKeyword */) { parameter.name = parseIdentifierName(); parseExpected(56 /* ColonToken */); @@ -16819,23 +16880,23 @@ var ts; var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); var type = parseType(); if (dotdotdot) { - var variadic = createNode(284 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(285 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58 /* EqualsToken */) { - return createJSDocPostfixType(282 /* JSDocOptionalType */, type); + return createJSDocPostfixType(283 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(164 /* TypeQuery */); + var node = createNode(165 /* TypeQuery */); parseExpected(103 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(147 /* TypeParameter */); + var node = createNode(148 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(85 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -16880,7 +16941,7 @@ var ts; isStartOfType(/*inStartOfParameter*/ true); } function parseParameter() { - var node = createNodeWithJSDoc(148 /* Parameter */); + var node = createNodeWithJSDoc(149 /* Parameter */); if (token() === 99 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); @@ -16915,7 +16976,7 @@ var ts; if (!(flags & 32 /* JSDoc */)) { signature.typeParameters = parseTypeParameters(); } - signature.parameters = parseParameterList(flags); + signature.parameters = parseParameterList(flags); // TODO: GH#18217 if (shouldParseReturnType(returnToken, !!(flags & 4 /* Type */))) { signature.type = parseTypeOrTypePredicate(); return signature.type !== undefined; @@ -16983,7 +17044,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 158 /* ConstructSignature */) { + if (kind === 159 /* ConstructSignature */) { parseExpected(94 /* NewKeyword */); } fillSignature(56 /* ColonToken */, 4 /* Type */, node); @@ -17044,7 +17105,7 @@ var ts; return token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 22 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 159 /* IndexSignature */; + node.kind = 160 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -17054,13 +17115,13 @@ var ts; node.name = parsePropertyName(); node.questionToken = parseOptionalToken(55 /* QuestionToken */); if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - node.kind = 152 /* MethodSignature */; + node.kind = 153 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] fillSignature(56 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 150 /* PropertySignature */; + node.kind = 151 /* PropertySignature */; node.type = parseTypeAnnotation(); if (token() === 58 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt @@ -17077,7 +17138,7 @@ var ts; if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { return true; } - var idToken; + var idToken = false; // Eat up all modifiers, but hold on to the last one in case it is actually an identifier while (ts.isModifierKind(token())) { idToken = true; @@ -17106,10 +17167,10 @@ var ts; } function parseTypeMember() { if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - return parseSignatureMember(157 /* CallSignature */); + return parseSignatureMember(158 /* CallSignature */); } if (token() === 94 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(158 /* ConstructSignature */); + return parseSignatureMember(159 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -17135,7 +17196,7 @@ var ts; return false; } function parseTypeLiteral() { - var node = createNode(165 /* TypeLiteral */); + var node = createNode(166 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -17161,14 +17222,14 @@ var ts; return token() === 21 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 92 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(147 /* TypeParameter */); + var node = createNode(148 /* TypeParameter */); node.name = parseIdentifier(); parseExpected(92 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(176 /* MappedType */); + var node = createNode(177 /* MappedType */); parseExpected(17 /* OpenBraceToken */); if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -17191,23 +17252,23 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(167 /* TupleType */); + var node = createNode(168 /* TupleType */); node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(172 /* ParenthesizedType */); + var node = createNode(173 /* ParenthesizedType */); parseExpected(19 /* OpenParenToken */); node.type = parseType(); if (!node.type) { - return undefined; + return undefined; // TODO: GH#18217 } parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 163 /* ConstructorType */) { + if (kind === 164 /* ConstructorType */) { parseExpected(94 /* NewKeyword */); } if (!fillSignature(36 /* EqualsGreaterThanToken */, 4 /* Type */ | (sourceFile.languageVariant === 1 /* JSX */ ? 8 /* RequireCompleteParameterList */ : 0), node)) { @@ -17223,10 +17284,10 @@ var ts; return token() === 23 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(177 /* LiteralType */); + var node = createNode(178 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(197 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(198 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 38 /* MinusToken */; nextToken(); } @@ -17247,7 +17308,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(178 /* ImportType */); + var node = createNode(179 /* ImportType */); if (parseOptional(103 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -17267,6 +17328,7 @@ var ts; function parseNonArrayType() { switch (token()) { case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 137 /* StringKeyword */: case 134 /* NumberKeyword */: case 138 /* SymbolKeyword */: @@ -17323,6 +17385,7 @@ var ts; function isStartOfType(inStartOfParameter) { switch (token()) { case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 137 /* StringKeyword */: case 134 /* NumberKeyword */: case 122 /* BooleanKeyword */: @@ -17371,26 +17434,26 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51 /* ExclamationToken */: - type = createJSDocPostfixType(281 /* JSDocNonNullableType */, type); + type = createJSDocPostfixType(282 /* JSDocNonNullableType */, type); break; case 55 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createJSDocPostfixType(280 /* JSDocNullableType */, type); + type = createJSDocPostfixType(281 /* JSDocNullableType */, type); break; case 21 /* OpenBracketToken */: parseExpected(21 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(175 /* IndexedAccessType */, type.pos); + var node = createNode(176 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(166 /* ArrayType */, type.pos); + var node = createNode(167 /* ArrayType */, type.pos); node.elementType = type; parseExpected(22 /* CloseBracketToken */); type = finishNode(node); @@ -17409,16 +17472,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(174 /* TypeOperator */); + var node = createNode(175 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(171 /* InferType */); + var node = createNode(172 /* InferType */); parseExpected(126 /* InferKeyword */); - var typeParameter = createNode(147 /* TypeParameter */); + var typeParameter = createNode(148 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -17449,10 +17512,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(169 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(170 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(168 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(169 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); } function isStartOfFunctionType() { if (token() === 27 /* LessThanToken */) { @@ -17509,7 +17572,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(160 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(161 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -17532,14 +17595,14 @@ var ts; } function parseTypeWorker(noConditionalTypes) { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(162 /* FunctionType */); + return parseFunctionOrConstructorType(163 /* FunctionType */); // TODO: GH#18217 } if (token() === 94 /* NewKeyword */) { - return parseFunctionOrConstructorType(163 /* ConstructorType */); + return parseFunctionOrConstructorType(164 /* ConstructorType */); } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(170 /* ConditionalType */, type.pos); + var node = createNode(171 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -17732,7 +17795,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(202 /* YieldExpression */); + var node = createNode(203 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -17754,13 +17817,13 @@ var ts; ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(192 /* ArrowFunction */, asyncModifier.pos); + node = createNode(193 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(192 /* ArrowFunction */, identifier.pos); + node = createNode(193 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(148 /* Parameter */, identifier.pos); + var parameter = createNode(149 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); @@ -17956,7 +18019,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(192 /* ArrowFunction */); + var node = createNodeWithJSDoc(193 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -18024,7 +18087,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(200 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(201 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -18039,7 +18102,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 92 /* InKeyword */ || t === 144 /* OfKeyword */; + return t === 92 /* InKeyword */ || t === 145 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -18104,39 +18167,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(199 /* BinaryExpression */, left.pos); + var node = createNode(200 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(207 /* AsExpression */, left.pos); + var node = createNode(208 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(197 /* PrefixUnaryExpression */); + var node = createNode(198 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(193 /* DeleteExpression */); + var node = createNode(194 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(194 /* TypeOfExpression */); + var node = createNode(195 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(195 /* VoidExpression */); + var node = createNode(196 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18152,7 +18215,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(196 /* AwaitExpression */); + var node = createNode(197 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18196,7 +18259,7 @@ var ts; if (token() === 40 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 189 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 190 /* 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 { @@ -18293,7 +18356,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(197 /* PrefixUnaryExpression */); + var node = createNode(198 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -18306,7 +18369,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(198 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(199 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -18362,7 +18425,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(209 /* MetaProperty */, fullStart); + var node = createNode(210 /* MetaProperty */, fullStart); node.keywordToken = 91 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -18437,33 +18500,17 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(184 /* PropertyAccessExpression */, expression.pos); + var node = createNode(185 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(23 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } - function tagNamesAreEquivalent(lhs, rhs) { - if (lhs.kind !== rhs.kind) { - return false; - } - if (lhs.kind === 71 /* Identifier */) { - return lhs.escapedText === rhs.escapedText; - } - if (lhs.kind === 99 /* ThisKeyword */) { - return true; - } - // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only - // take forms of JsxTagNameExpression which includes an identifier, "this" expression, or another propertyAccessExpression - // it is safe to case the expression property as such. See parseJsxElementName for how we parse tag name in Jsx element - return lhs.name.escapedText === rhs.name.escapedText && - tagNamesAreEquivalent(lhs.expression, rhs.expression); - } function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 256 /* JsxOpeningElement */) { - var node = createNode(254 /* JsxElement */, opening.pos); + if (opening.kind === 257 /* JsxOpeningElement */) { + var node = createNode(255 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -18472,15 +18519,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 259 /* JsxOpeningFragment */) { - var node = createNode(258 /* JsxFragment */, opening.pos); + else if (opening.kind === 260 /* JsxOpeningFragment */) { + var node = createNode(259 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 255 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 256 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -18495,11 +18542,11 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(199 /* BinaryExpression */, result.pos); + var badNode = createNode(200 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(26 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); + badNode.operatorToken = createMissingNode(26 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); // TODO: GH#18217 badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -18553,7 +18600,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(262 /* JsxAttributes */); + var jsxAttributes = createNode(263 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -18562,7 +18609,7 @@ var ts; parseExpected(27 /* LessThanToken */); if (token() === 29 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(259 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(260 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -18574,7 +18621,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(256 /* JsxOpeningElement */, fullStart); + node = createNode(257 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -18586,7 +18633,7 @@ var ts; parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(255 /* JsxSelfClosingElement */, fullStart); + node = createNode(256 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -18603,7 +18650,7 @@ var ts; var expression = token() === 99 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(184 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18611,7 +18658,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(264 /* JsxExpression */); + var node = createNode(265 /* JsxExpression */); if (!parseExpected(17 /* OpenBraceToken */)) { return undefined; } @@ -18633,7 +18680,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(261 /* JsxAttribute */); + var node = createNode(262 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 58 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -18648,7 +18695,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(263 /* JsxSpreadAttribute */); + var node = createNode(264 /* JsxSpreadAttribute */); parseExpected(17 /* OpenBraceToken */); parseExpected(24 /* DotDotDotToken */); node.expression = parseExpression(); @@ -18656,7 +18703,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(257 /* JsxClosingElement */); + var node = createNode(258 /* JsxClosingElement */); parseExpected(28 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -18669,7 +18716,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(260 /* JsxClosingFragment */); + var node = createNode(261 /* JsxClosingFragment */); parseExpected(28 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -18684,7 +18731,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(189 /* TypeAssertionExpression */); + var node = createNode(190 /* TypeAssertionExpression */); parseExpected(27 /* LessThanToken */); node.type = parseType(); parseExpected(29 /* GreaterThanToken */); @@ -18695,7 +18742,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(184 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18703,14 +18750,14 @@ var ts; } if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(208 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(209 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(21 /* OpenBracketToken */)) { - var indexedAccess = createNode(185 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(186 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; if (token() === 22 /* CloseBracketToken */) { indexedAccess.argumentExpression = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -18737,7 +18784,7 @@ var ts; return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(188 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(189 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ @@ -18761,7 +18808,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(186 /* CallExpression */, expression.pos); + var callExpr = createNode(187 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -18769,7 +18816,7 @@ var ts; continue; } else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(186 /* CallExpression */, expression.pos); + var callExpr = createNode(187 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -18881,28 +18928,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(190 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(191 /* ParenthesizedExpression */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(203 /* SpreadElement */); + var node = createNode(204 /* SpreadElement */); parseExpected(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(205 /* OmittedExpression */) : + token() === 26 /* CommaToken */ ? createNode(206 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(182 /* ArrayLiteralExpression */); + var node = createNode(183 /* ArrayLiteralExpression */); parseExpected(21 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -18914,17 +18961,17 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 271 /* SpreadAssignment */; + node.kind = 272 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 155 /* GetAccessor */); + return parseAccessorDeclaration(node, 156 /* GetAccessor */); } if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* SetAccessor */); + return parseAccessorDeclaration(node, 157 /* SetAccessor */); } var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -18941,7 +18988,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */); if (isShorthandPropertyAssignment) { - node.kind = 270 /* ShorthandPropertyAssignment */; + node.kind = 271 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(58 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -18949,14 +18996,14 @@ var ts; } } else { - node.kind = 269 /* PropertyAssignment */; + node.kind = 270 /* PropertyAssignment */; parseExpected(56 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(183 /* ObjectLiteralExpression */); + var node = createNode(184 /* ObjectLiteralExpression */); parseExpected(17 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -18975,7 +19022,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(191 /* FunctionExpression */); + var node = createNodeWithJSDoc(192 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); @@ -19000,7 +19047,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94 /* NewKeyword */); if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(209 /* MetaProperty */, fullStart); + var node_2 = createNode(210 /* MetaProperty */, fullStart); node_2.keywordToken = 94 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -19017,7 +19064,7 @@ var ts; } break; } - var node = createNode(187 /* NewExpression */, fullStart); + var node = createNode(188 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19 /* OpenParenToken */) { @@ -19027,7 +19074,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(212 /* Block */); + var node = createNode(213 /* Block */); if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19060,12 +19107,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(214 /* EmptyStatement */); + var node = createNode(215 /* EmptyStatement */); parseExpected(25 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(216 /* IfStatement */); + var node = createNode(217 /* IfStatement */); parseExpected(90 /* IfKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19075,7 +19122,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(217 /* DoStatement */); + var node = createNode(218 /* DoStatement */); parseExpected(81 /* DoKeyword */); node.statement = parseStatement(); parseExpected(106 /* WhileKeyword */); @@ -19090,7 +19137,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(218 /* WhileStatement */); + var node = createNode(219 /* WhileStatement */); parseExpected(106 /* WhileKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19113,8 +19160,8 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(144 /* OfKeyword */) : parseOptional(144 /* OfKeyword */)) { - var forOfStatement = createNode(221 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { + var forOfStatement = createNode(222 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -19122,14 +19169,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(220 /* ForInStatement */, pos); + var forInStatement = createNode(221 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(219 /* ForStatement */, pos); + var forStatement = createNode(220 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(25 /* SemicolonToken */); if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { @@ -19147,7 +19194,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 223 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 224 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -19155,7 +19202,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(224 /* ReturnStatement */); + var node = createNode(225 /* ReturnStatement */); parseExpected(96 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -19164,7 +19211,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(225 /* WithStatement */); + var node = createNode(226 /* WithStatement */); parseExpected(107 /* WithKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19173,7 +19220,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(265 /* CaseClause */); + var node = createNode(266 /* CaseClause */); parseExpected(73 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(56 /* ColonToken */); @@ -19181,7 +19228,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(266 /* DefaultClause */); + var node = createNode(267 /* DefaultClause */); parseExpected(79 /* DefaultKeyword */); parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -19191,12 +19238,12 @@ var ts; return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(226 /* SwitchStatement */); + var node = createNode(227 /* SwitchStatement */); parseExpected(98 /* SwitchKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(240 /* CaseBlock */); + var caseBlock = createNode(241 /* CaseBlock */); parseExpected(17 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(18 /* CloseBraceToken */); @@ -19211,7 +19258,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(228 /* ThrowStatement */); + var node = createNode(229 /* ThrowStatement */); parseExpected(100 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -19219,7 +19266,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(229 /* TryStatement */); + var node = createNode(230 /* TryStatement */); parseExpected(102 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -19232,7 +19279,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(268 /* CatchClause */); + var result = createNode(269 /* CatchClause */); parseExpected(74 /* CatchKeyword */); if (parseOptional(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -19246,7 +19293,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(230 /* DebuggerStatement */); + var node = createNode(231 /* DebuggerStatement */); parseExpected(78 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -19258,12 +19305,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 227 /* LabeledStatement */; + node.kind = 228 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 215 /* ExpressionStatement */; + node.kind = 216 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -19335,7 +19382,7 @@ var ts; return false; } continue; - case 143 /* GlobalKeyword */: + case 144 /* GlobalKeyword */: nextToken(); return token() === 17 /* OpenBraceToken */ || token() === 71 /* Identifier */ || token() === 84 /* ExportKeyword */; case 91 /* ImportKeyword */: @@ -19399,7 +19446,7 @@ var ts; case 129 /* ModuleKeyword */: case 130 /* NamespaceKeyword */: case 139 /* TypeKeyword */: - case 143 /* GlobalKeyword */: + case 144 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 114 /* PublicKeyword */: @@ -19430,16 +19477,16 @@ var ts; case 17 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(231 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); case 110 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(231 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); } break; case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(233 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(234 /* FunctionDeclaration */)); case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(234 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(235 /* ClassDeclaration */)); case 90 /* IfKeyword */: return parseIfStatement(); case 81 /* DoKeyword */: @@ -19449,9 +19496,9 @@ var ts; case 88 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(222 /* ContinueStatement */); + return parseBreakOrContinueStatement(223 /* ContinueStatement */); case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(223 /* BreakStatement */); + return parseBreakOrContinueStatement(224 /* BreakStatement */); case 96 /* ReturnKeyword */: return parseReturnStatement(); case 107 /* WithKeyword */: @@ -19485,7 +19532,7 @@ var ts; case 117 /* AbstractKeyword */: case 115 /* StaticKeyword */: case 132 /* ReadonlyKeyword */: - case 143 /* GlobalKeyword */: + case 144 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -19527,7 +19574,7 @@ var ts; return parseTypeAliasDeclaration(node); case 83 /* EnumKeyword */: return parseEnumDeclaration(node); - case 143 /* GlobalKeyword */: + case 144 /* GlobalKeyword */: case 129 /* ModuleKeyword */: case 130 /* NamespaceKeyword */: return parseModuleDeclaration(node); @@ -19548,12 +19595,13 @@ var ts; if (node.decorators || node.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(252 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(253 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; return finishNode(missing); } + return undefined; // TODO: GH#18217 } } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { @@ -19570,16 +19618,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 26 /* CommaToken */) { - return createNode(205 /* OmittedExpression */); + return createNode(206 /* OmittedExpression */); } - var node = createNode(181 /* BindingElement */); + var node = createNode(182 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(181 /* BindingElement */); + var node = createNode(182 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -19595,14 +19643,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(179 /* ObjectBindingPattern */); + var node = createNode(180 /* ObjectBindingPattern */); parseExpected(17 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(180 /* ArrayBindingPattern */); + var node = createNode(181 /* ArrayBindingPattern */); parseExpected(21 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(22 /* CloseBracketToken */); @@ -19624,7 +19672,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(231 /* VariableDeclaration */); + var node = createNode(232 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 /* Identifier */ && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -19637,7 +19685,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(232 /* VariableDeclarationList */); + var node = createNode(233 /* VariableDeclarationList */); switch (token()) { case 104 /* VarKeyword */: break; @@ -19660,7 +19708,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 144 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 145 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -19675,13 +19723,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 213 /* VariableStatement */; + node.kind = 214 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 233 /* FunctionDeclaration */; + node.kind = 234 /* FunctionDeclaration */; parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -19692,14 +19740,14 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(node) { - node.kind = 154 /* Constructor */; + node.kind = 155 /* Constructor */; parseExpected(123 /* ConstructorKeyword */); fillSignature(56 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 153 /* MethodDeclaration */; + node.kind = 154 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; @@ -19708,7 +19756,7 @@ var ts; return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 151 /* PropertyDeclaration */; + node.kind = 152 /* PropertyDeclaration */; if (!node.questionToken && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } @@ -19813,7 +19861,7 @@ var ts; if (!parseOptional(57 /* AtToken */)) { break; } - var decorator = createNode(149 /* Decorator */, decoratorStart); + var decorator = createNode(150 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -19863,7 +19911,7 @@ var ts; } function parseClassElement() { if (token() === 25 /* SemicolonToken */) { - var result = createNode(211 /* SemicolonClassElement */); + var result = createNode(212 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -19871,10 +19919,10 @@ var ts; node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 155 /* GetAccessor */); + return parseAccessorDeclaration(node, 156 /* GetAccessor */); } if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* SetAccessor */); + return parseAccessorDeclaration(node, 157 /* SetAccessor */); } if (token() === 123 /* ConstructorKeyword */) { return parseConstructorDeclaration(node); @@ -19897,13 +19945,13 @@ var ts; return parsePropertyDeclaration(node); } // 'isClassMemberStart' should have hinted not to attempt parsing. - ts.Debug.fail("Should not have attempted to parse class member declaration."); + return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 204 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 205 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 234 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 235 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -19945,17 +19993,15 @@ var ts; } function parseHeritageClause() { var tok = token(); - if (tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */) { - var node = createNode(267 /* HeritageClause */); - node.token = tok; - nextToken(); - node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); - return finishNode(node); - } - return undefined; + ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(268 /* HeritageClause */); + node.token = tok; + nextToken(); + node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(206 /* ExpressionWithTypeArguments */); + var node = createNode(207 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -19972,7 +20018,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 235 /* InterfaceDeclaration */; + node.kind = 236 /* InterfaceDeclaration */; parseExpected(109 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -19981,7 +20027,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 236 /* TypeAliasDeclaration */; + node.kind = 237 /* TypeAliasDeclaration */; parseExpected(139 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -19995,13 +20041,13 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(272 /* EnumMember */); + var node = createNodeWithJSDoc(273 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 237 /* EnumDeclaration */; + node.kind = 238 /* EnumDeclaration */; parseExpected(83 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(17 /* OpenBraceToken */)) { @@ -20014,7 +20060,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(239 /* ModuleBlock */); + var node = createNode(240 /* ModuleBlock */); if (parseExpected(17 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(18 /* CloseBraceToken */); @@ -20025,7 +20071,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 238 /* ModuleDeclaration */; + node.kind = 239 /* ModuleDeclaration */; // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -20037,8 +20083,8 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 238 /* ModuleDeclaration */; - if (token() === 143 /* GlobalKeyword */) { + node.kind = 239 /* ModuleDeclaration */; + if (token() === 144 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -20057,7 +20103,7 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 143 /* GlobalKeyword */) { + if (token() === 144 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } @@ -20083,7 +20129,7 @@ var ts; return nextToken() === 41 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 241 /* NamespaceExportDeclaration */; + node.kind = 242 /* NamespaceExportDeclaration */; parseExpected(118 /* AsKeyword */); parseExpected(130 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -20096,12 +20142,12 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 26 /* CommaToken */ && token() !== 142 /* FromKeyword */) { + if (token() !== 26 /* CommaToken */ && token() !== 143 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 243 /* ImportDeclaration */; + node.kind = 244 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -20109,14 +20155,14 @@ var ts; token() === 39 /* AsteriskToken */ || // import * token() === 17 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(142 /* FromKeyword */); + parseExpected(143 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 242 /* ImportEqualsDeclaration */; + node.kind = 243 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(58 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -20130,7 +20176,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(244 /* ImportClause */, fullStart); + var importClause = createNode(245 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -20140,7 +20186,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(246 /* NamedImports */); + importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(247 /* NamedImports */); } return finishNode(importClause); } @@ -20150,7 +20196,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(253 /* ExternalModuleReference */); + var node = createNode(254 /* ExternalModuleReference */); parseExpected(133 /* RequireKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -20173,7 +20219,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(245 /* NamespaceImport */); + var namespaceImport = createNode(246 /* NamespaceImport */); parseExpected(39 /* AsteriskToken */); parseExpected(118 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -20188,14 +20234,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 246 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 247 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(251 /* ExportSpecifier */); + return parseImportOrExportSpecifier(252 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(247 /* ImportSpecifier */); + return parseImportOrExportSpecifier(248 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -20220,24 +20266,24 @@ var ts; else { node.name = identifierName; } - if (kind === 247 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 248 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 249 /* ExportDeclaration */; + node.kind = 250 /* ExportDeclaration */; if (parseOptional(39 /* AsteriskToken */)) { - parseExpected(142 /* FromKeyword */); + parseExpected(143 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(250 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(251 /* 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() === 142 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(142 /* FromKeyword */); + if (token() === 143 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(143 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -20245,7 +20291,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 248 /* ExportAssignment */; + node.kind = 249 /* ExportAssignment */; if (parseOptional(58 /* EqualsToken */)) { node.isExportEquals = true; } @@ -20265,10 +20311,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 242 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 253 /* ExternalModuleReference */ - || node.kind === 243 /* ImportDeclaration */ - || node.kind === 248 /* ExportAssignment */ - || node.kind === 249 /* ExportDeclaration */ + || node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */ + || node.kind === 244 /* ImportDeclaration */ + || node.kind === 249 /* ExportAssignment */ + || node.kind === 250 /* ExportDeclaration */ ? node : undefined; } @@ -20331,7 +20377,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(277 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -20384,8 +20430,8 @@ var ts; PropertyLikeParse[PropertyLikeParse["CallbackParameter"] = 4] = "CallbackParameter"; })(PropertyLikeParse || (PropertyLikeParse = {})); function parseJSDocCommentWorker(start, length) { + if (start === void 0) { start = 0; } var content = sourceText; - start = start || 0; var end = length === undefined ? content.length : start + length; length = end - start; ts.Debug.assert(start >= 0); @@ -20415,17 +20461,15 @@ var ts; comments.push(text); indent += text.length; } - var t = nextJSDocToken(); - while (t === 5 /* WhitespaceTrivia */) { - t = nextJSDocToken(); - } - if (t === 4 /* NewLineTrivia */) { + nextJSDocToken(); + while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) + ; + if (parseOptionalJsdoc(4 /* NewLineTrivia */)) { state = 0 /* BeginningOfLine */; indent = 0; - t = nextJSDocToken(); } loop: while (true) { - switch (t) { + switch (token()) { case 57 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingNewlines(comments); @@ -20485,7 +20529,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - t = nextJSDocToken(); + nextJSDocToken(); } removeLeadingNewlines(comments); removeTrailingNewlines(comments); @@ -20503,7 +20547,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(285 /* JSDocComment */, start); + var result = createNode(286 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -20650,7 +20694,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(288 /* JSDocTag */, atToken.pos); + var result = createNode(289 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -20694,7 +20738,7 @@ var ts; switch (node.kind) { case 135 /* ObjectKeyword */: return true; - case 166 /* ArrayType */: + case 167 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -20710,12 +20754,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(297 /* JSDocPropertyTag */, atToken.pos) : - createNode(292 /* JSDocParameterTag */, atToken.pos); + createNode(298 /* JSDocPropertyTag */, atToken.pos) : + createNode(293 /* JSDocParameterTag */, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); - var nestedTypeLiteral = parseNestedTypeLiteral(typeExpression, name, target); + var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; @@ -20731,20 +20775,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(277 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) { - if (child.kind === 292 /* JSDocParameterTag */ || child.kind === 297 /* JSDocPropertyTag */) { + if (child.kind === 293 /* JSDocParameterTag */ || child.kind === 298 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(286 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 166 /* ArrayType */) { + if (typeExpression.type.kind === 167 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -20753,27 +20797,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 293 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(293 /* JSDocReturnTag */, atToken.pos); + var result = createNode(294 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 295 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(294 /* JSDocTypeTag */, atToken.pos); + var result = createNode(295 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(289 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(290 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -20781,7 +20825,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(206 /* ExpressionWithTypeArguments */); + var node = createNode(207 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -20793,15 +20837,15 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(/*createIfMissing*/ true); while (parseOptional(23 /* DotToken */)) { - var prop = createNode(184 /* PropertyAccessExpression */, node.pos); + var prop = createNode(185 /* PropertyAccessExpression */, node.pos); prop.expression = node; - prop.name = parseJSDocIdentifierName(); + prop.name = parseJSDocIdentifierName(); // TODO: GH#18217 node = finishNode(prop); } return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(290 /* JSDocClassTag */, atToken.pos); + var tag = createNode(291 /* JSDocClassTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); @@ -20809,7 +20853,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(296 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(297 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -20825,9 +20869,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(286 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_3); } - if (child.kind === 294 /* JSDocTypeTag */) { + if (child.kind === 295 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -20840,7 +20884,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 166 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 167 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -20856,7 +20900,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(238 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(239 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -20870,7 +20914,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(291 /* JSDocCallbackTag */, atToken.pos); + var callbackTag = createNode(292 /* JSDocCallbackTag */, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -20879,16 +20923,15 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(287 /* JSDocSignature */, start); + var jsdocSignature = createNode(288 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (token() === 57 /* AtToken */) { - nextJSDocToken(); + if (parseOptionalJsdoc(57 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 293 /* JSDocReturnTag */) { + if (tag && tag.kind === 294 /* JSDocReturnTag */) { return tag; } } @@ -20933,9 +20976,9 @@ var ts; case 57 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 292 /* JSDocParameterTag */ && + if (child && child.kind === 293 /* JSDocParameterTag */ && target !== 4 /* CallbackParameter */ && - (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { + (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { // TODO: GH#18217 return false; } return child; @@ -20994,49 +21037,45 @@ var ts; return tag; } function parseTemplateTag(atToken, tagName) { - if (ts.some(tags, ts.isJSDocTemplateTag)) { - parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); + // the template tag looks like '@template {Constraint} T,U,V' + var constraint; + if (token() === 17 /* OpenBraceToken */) { + constraint = parseJSDocTypeExpression(); } - // Type parameter list looks like '@template T,U,V' var typeParameters = []; var typeParametersPos = getNodePos(); - while (true) { - var typeParameter = createNode(147 /* TypeParameter */); - var name = parseJSDocIdentifierNameWithOptionalBraces(); + do { skipWhitespace(); - if (!name) { - parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); + var typeParameter = createNode(148 /* TypeParameter */); + if (!ts.tokenIsIdentifierOrKeyword(token())) { + parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); return undefined; } - typeParameter.name = name; + typeParameter.name = parseJSDocIdentifierName(); + skipWhitespace(); finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 26 /* CommaToken */) { - nextJSDocToken(); - skipWhitespace(); - } - else { - break; - } + } while (parseOptionalJsdoc(26 /* CommaToken */)); + if (constraint) { + ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(295 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(296 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); finishNode(result); return result; } - function parseJSDocIdentifierNameWithOptionalBraces() { - var parsedBrace = parseOptional(17 /* OpenBraceToken */); - var res = parseJSDocIdentifierName(); - if (parsedBrace) { - parseExpected(18 /* CloseBraceToken */); - } - return res; - } function nextJSDocToken() { return currentToken = scanner.scanJSDocToken(); } + function parseOptionalJsdoc(t) { + if (token() === t) { + nextJSDocToken(); + return true; + } + return false; + } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(/*createIfMissing*/ true); if (parseOptional(21 /* OpenBracketToken */)) { @@ -21581,7 +21620,7 @@ var ts; context.pragmas = ts.createMap(); for (var _i = 0, pragmas_1 = pragmas; _i < pragmas_1.length; _i++) { var pragma = pragmas_1[_i]; - if (context.pragmas.has(pragma.name)) { + if (context.pragmas.has(pragma.name)) { // TODO: GH#18217 var currentValue = context.pragmas.get(pragma.name); if (currentValue instanceof Array) { currentValue.push(pragma.args); @@ -21610,6 +21649,7 @@ var ts; var referencedFiles_1 = context.referencedFiles; var typeReferenceDirectives_1 = context.typeReferenceDirectives; ts.forEach(ts.toArray(entryOrList), function (arg) { + // TODO: GH#18217 if (arg.arguments["no-default-lib"]) { context.hasNoDefaultLib = true; } @@ -21626,10 +21666,7 @@ var ts; break; } case "amd-dependency": { - context.amdDependencies = ts.map(ts.toArray(entryOrList), function (_a) { - var _b = _a.arguments, name = _b.name, path = _b.path; - return ({ name: name, path: path }); - }); + context.amdDependencies = ts.map(ts.toArray(entryOrList), function (x) { return ({ name: x.arguments.name, path: x.arguments.path }); }); // TODO: GH#18217 break; } case "amd-module": { @@ -21652,7 +21689,7 @@ var ts; case "ts-check": { // _last_ of either nocheck or check in a file is the "winner" ts.forEach(ts.toArray(entryOrList), function (entry) { - if (!context.checkJsDirective || entry.range.pos > context.checkJsDirective.pos) { + if (!context.checkJsDirective || entry.range.pos > context.checkJsDirective.pos) { // TODO: GH#18217 context.checkJsDirective = { enabled: key === "ts-check", end: entry.range.end, @@ -21763,6 +21800,24 @@ var ts; } return argMap; } + /** @internal */ + function tagNamesAreEquivalent(lhs, rhs) { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === 71 /* Identifier */) { + return lhs.escapedText === rhs.escapedText; + } + if (lhs.kind === 99 /* ThisKeyword */) { + return true; + } + // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only + // take forms of JsxTagNameExpression which includes an identifier, "this" expression, or another propertyAccessExpression + // it is safe to case the expression property as such. See parseJsxElementName for how we parse tag name in Jsx element + return lhs.name.escapedText === rhs.name.escapedText && + tagNamesAreEquivalent(lhs.expression, rhs.expression); + } + ts.tagNamesAreEquivalent = tagNamesAreEquivalent; })(ts || (ts = {})); /* @internal */ var ts; @@ -21781,24 +21836,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: if (ts.isConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 239 /* ModuleBlock */: { + case 240 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -21820,7 +21875,7 @@ var ts; }); return state_1; } - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return getModuleInstanceState(node); case 71 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -21970,7 +22025,7 @@ var ts; if (symbolFlags & 67216319 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 238 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 239 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -21979,7 +22034,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 === 248 /* ExportAssignment */) { + if (node.kind === 249 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -21988,7 +22043,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 146 /* ComputedPropertyName */) { + if (name.kind === 147 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression)) { @@ -22000,43 +22055,43 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 154 /* Constructor */: + case 155 /* Constructor */: return "__constructor" /* Constructor */; - case 162 /* FunctionType */: - case 157 /* CallSignature */: - case 287 /* JSDocSignature */: + case 163 /* FunctionType */: + case 158 /* CallSignature */: + case 288 /* JSDocSignature */: return "__call" /* Call */; - case 163 /* ConstructorType */: - case 158 /* ConstructSignature */: + case 164 /* ConstructorType */: + case 159 /* ConstructSignature */: return "__new" /* New */; - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: return "__index" /* Index */; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 273 /* SourceFile */: + case 274 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 148 /* Parameter */: + case 149 /* 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 === 283 /* 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 === 284 /* 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; } } function getDisplayName(node) { - return ts.isNamedDeclaration(node) ? ts.declarationNameToString(node.name) : ts.unescapeLeadingUnderscores(getDeclarationName(node)); + return ts.isNamedDeclaration(node) ? ts.declarationNameToString(node.name) : ts.unescapeLeadingUnderscores(getDeclarationName(node)); // TODO: GH#18217 } /** * Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names. @@ -22123,7 +22178,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 === 248 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 249 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -22148,7 +22203,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 251 /* ExportSpecifier */ || (node.kind === 242 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 252 /* ExportSpecifier */ || (node.kind === 243 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -22215,7 +22270,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 !== 192 /* ArrowFunction */) { + if (node.kind !== 193 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -22247,7 +22302,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 intialization checks. - currentReturnTarget = isIIFE || node.kind === 154 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 155 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -22260,13 +22315,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 154 /* Constructor */) { + if (node.kind === 155 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -22309,8 +22364,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 233 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 233 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -22342,77 +22397,77 @@ var ts; return; } switch (node.kind) { - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: bindWhileStatement(node); break; - case 217 /* DoStatement */: + case 218 /* DoStatement */: bindDoStatement(node); break; - case 219 /* ForStatement */: + case 220 /* ForStatement */: bindForStatement(node); break; - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 216 /* IfStatement */: + case 217 /* IfStatement */: bindIfStatement(node); break; - case 224 /* ReturnStatement */: - case 228 /* ThrowStatement */: + case 225 /* ReturnStatement */: + case 229 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 229 /* TryStatement */: + case 230 /* TryStatement */: bindTryStatement(node); break; - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: bindSwitchStatement(node); break; - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: bindCaseBlock(node); break; - case 265 /* CaseClause */: + case 266 /* CaseClause */: bindCaseClause(node); break; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: bindLabeledStatement(node); break; - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 186 /* CallExpression */: + case 187 /* CallExpression */: bindCallExpressionFlow(node); break; - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 273 /* SourceFile */: + case 274 /* SourceFile */: bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 212 /* Block */: - case 239 /* ModuleBlock */: + case 213 /* Block */: + case 240 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -22425,15 +22480,15 @@ var ts; switch (expr.kind) { case 71 /* Identifier */: case 99 /* ThisKeyword */: - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return hasNarrowableArgument(expr); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -22442,7 +22497,7 @@ var ts; return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || - expr.kind === 184 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 185 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -22453,7 +22508,7 @@ var ts; } } } - if (expr.expression.kind === 184 /* PropertyAccessExpression */ && + if (expr.expression.kind === 185 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -22486,9 +22541,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 58 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -22566,33 +22621,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 216 /* IfStatement */: - case 218 /* WhileStatement */: - case 217 /* DoStatement */: + case 217 /* IfStatement */: + case 219 /* WhileStatement */: + case 218 /* DoStatement */: return parent.expression === node; - case 219 /* ForStatement */: - case 200 /* ConditionalExpression */: + case 220 /* ForStatement */: + case 201 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 190 /* ParenthesizedExpression */) { + if (node.kind === 191 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 197 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 198 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 199 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || + return node.kind === 200 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 54 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 190 /* ParenthesizedExpression */ || - node.parent.kind === 197 /* PrefixUnaryExpression */ && + while (node.parent.kind === 191 /* ParenthesizedExpression */ || + node.parent.kind === 198 /* PrefixUnaryExpression */ && node.parent.operator === 51 /* ExclamationToken */) { node = node.parent; } @@ -22634,7 +22689,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 227 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 228 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -22668,13 +22723,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 221 /* ForOfStatement */) { + if (node.kind === 222 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 232 /* VariableDeclarationList */) { + if (node.initializer.kind !== 233 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -22696,7 +22751,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 224 /* ReturnStatement */) { + if (node.kind === 225 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -22716,7 +22771,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 223 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 224 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -22812,7 +22867,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 266 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267 /* 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). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -22836,6 +22891,7 @@ var ts; } var preCaseLabel = createBranchLabel(); addAntecedent(preCaseLabel, createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1)); + addAntecedent(preCaseLabel, createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1)); addAntecedent(preCaseLabel, fallthroughFlow); currentFlow = finishFlowLabel(preCaseLabel); var clause = clauses[i]; @@ -22877,16 +22933,16 @@ var ts; bind(node.statement); popActiveLabel(); if (!activeLabel.referenced && !options.allowUnusedLabels) { - file.bindDiagnostics.push(createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); + errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 217 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 218 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 199 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -22897,10 +22953,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 182 /* ArrayLiteralExpression */) { + else if (node.kind === 183 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 203 /* SpreadElement */) { + if (e.kind === 204 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -22908,16 +22964,16 @@ var ts; } } } - else if (node.kind === 183 /* ObjectLiteralExpression */) { + else if (node.kind === 184 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 269 /* PropertyAssignment */) { + if (p.kind === 270 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 270 /* ShorthandPropertyAssignment */) { + else if (p.kind === 271 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 271 /* SpreadAssignment */) { + else if (p.kind === 272 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -22973,7 +23029,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 185 /* ElementAccessExpression */) { + if (operator === 58 /* EqualsToken */ && node.left.kind === 186 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -22984,7 +23040,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 184 /* PropertyAccessExpression */) { + if (node.expression.kind === 185 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -23031,10 +23087,10 @@ 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 = node.expression; - while (expr.kind === 190 /* ParenthesizedExpression */) { + while (expr.kind === 191 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 191 /* FunctionExpression */ || expr.kind === 192 /* ArrowFunction */) { + if (expr.kind === 192 /* FunctionExpression */ || expr.kind === 193 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -23042,7 +23098,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 184 /* PropertyAccessExpression */) { + if (node.expression.kind === 185 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -23051,54 +23107,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 204 /* ClassExpression */: - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: - case 183 /* ObjectLiteralExpression */: - case 165 /* TypeLiteral */: - case 286 /* JSDocTypeLiteral */: - case 262 /* JsxAttributes */: + case 205 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 184 /* ObjectLiteralExpression */: + case 166 /* TypeLiteral */: + case 287 /* JSDocTypeLiteral */: + case 263 /* JsxAttributes */: return 1 /* IsContainer */; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 238 /* ModuleDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 176 /* MappedType */: + case 239 /* ModuleDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 177 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 273 /* SourceFile */: + case 274 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 154 /* Constructor */: - case 233 /* FunctionDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 157 /* CallSignature */: - case 287 /* JSDocSignature */: - case 283 /* JSDocFunctionType */: - case 162 /* FunctionType */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 163 /* ConstructorType */: + case 155 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 158 /* CallSignature */: + case 288 /* JSDocSignature */: + case 284 /* JSDocFunctionType */: + case 163 /* FunctionType */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 164 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 268 /* CatchClause */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 240 /* CaseBlock */: + case 269 /* CatchClause */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 241 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 212 /* Block */: + case 213 /* 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 @@ -23131,45 +23187,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 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 273 /* SourceFile */: + case 274 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 204 /* ClassExpression */: - case 234 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 235 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 165 /* TypeLiteral */: - case 286 /* JSDocTypeLiteral */: - case 183 /* ObjectLiteralExpression */: - case 235 /* InterfaceDeclaration */: - case 262 /* JsxAttributes */: + case 166 /* TypeLiteral */: + case 287 /* JSDocTypeLiteral */: + case 184 /* ObjectLiteralExpression */: + case 236 /* InterfaceDeclaration */: + case 263 /* 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 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 287 /* JSDocSignature */: - case 159 /* IndexSignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 283 /* JSDocFunctionType */: - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: - case 236 /* TypeAliasDeclaration */: - case 176 /* MappedType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 288 /* JSDocSignature */: + case 160 /* IndexSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 284 /* JSDocFunctionType */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 237 /* TypeAliasDeclaration */: + case 177 /* 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 @@ -23190,11 +23246,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 273 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 273 /* SourceFile */ || body.kind === 239 /* ModuleBlock */)) { + var body = node.kind === 274 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 274 /* SourceFile */ || body.kind === 240 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 249 /* ExportDeclaration */ || stat.kind === 248 /* ExportAssignment */) { + if (stat.kind === 250 /* ExportDeclaration */ || stat.kind === 249 /* ExportAssignment */) { return true; } } @@ -23261,7 +23317,7 @@ var ts; // We do that by making an anonymous type literal symbol, and then setting the function // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); + var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); // TODO: GH#18217 addDeclarationToSymbol(symbol, node, 131072 /* Signature */); var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); @@ -23278,7 +23334,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 271 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 272 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { continue; } var identifier = prop.name; @@ -23290,7 +23346,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 === 269 /* PropertyAssignment */ || prop.kind === 270 /* ShorthandPropertyAssignment */ || prop.kind === 153 /* MethodDeclaration */ + var currentKind = prop.kind === 270 /* PropertyAssignment */ || prop.kind === 271 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -23318,13 +23374,14 @@ var ts; symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); + return symbol; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -23465,8 +23522,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 273 /* SourceFile */ && - blockScopeContainer.kind !== 238 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 274 /* SourceFile */ && + blockScopeContainer.kind !== 239 /* 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. @@ -23507,6 +23564,16 @@ var ts; var span = ts.getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } + function errorOrSuggestionOnFirstToken(isError, node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + var diag = ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2); + if (isError) { + file.bindDiagnostics.push(diag); + } + else { + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + } + } function bind(node) { if (!node) { return; @@ -23538,7 +23605,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 > 144 /* LastToken */) { + if (node.kind > 145 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -23610,11 +23677,11 @@ var ts; } // falls through case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 270 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 271 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -23622,7 +23689,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -23650,137 +23717,137 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return checkStrictModeCatchClause(node); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return checkStrictModeWithStatement(node); - case 173 /* ThisType */: + case 174 /* ThisType */: seenThisKeyword = true; return; - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: break; // Binding the children will handle everything - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return bindTypeParameter(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return bindParameter(node); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 181 /* BindingElement */: + case 182 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return bindPropertyWorker(node); - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 272 /* EnumMember */: + case 273 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* 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 */ : 67208127 /* MethodExcludes */); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67150783 /* GetAccessorExcludes */); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67183551 /* SetAccessorExcludes */); - case 162 /* FunctionType */: - case 283 /* JSDocFunctionType */: - case 287 /* JSDocSignature */: - case 163 /* ConstructorType */: + case 163 /* FunctionType */: + case 284 /* JSDocFunctionType */: + case 288 /* JSDocSignature */: + case 164 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 165 /* TypeLiteral */: - case 286 /* JSDocTypeLiteral */: - case 176 /* MappedType */: + case 166 /* TypeLiteral */: + case 287 /* JSDocTypeLiteral */: + case 177 /* MappedType */: return bindAnonymousTypeWorker(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return bindFunctionExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 204 /* ClassExpression */: - case 234 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 235 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67901832 /* InterfaceExcludes */); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return bindJsxAttributes(node); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 242 /* ImportEqualsDeclaration */: - case 245 /* NamespaceImport */: - case 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 243 /* ImportEqualsDeclaration */: + case 246 /* NamespaceImport */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return bindImportClause(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return bindExportDeclaration(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return bindExportAssignment(node); - case 273 /* SourceFile */: + case 274 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 212 /* Block */: + case 213 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 292 /* JSDocParameterTag */: - if (node.parent.kind === 287 /* JSDocSignature */) { + case 293 /* JSDocParameterTag */: + if (node.parent.kind === 288 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 286 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 287 /* JSDocTypeLiteral */) { break; } // falls through - case 297 /* JSDocPropertyTag */: + case 298 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 282 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -23812,7 +23879,7 @@ var ts; bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); } else { - var flags = node.kind === 248 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 249 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; ? 2097152 /* Alias */ // An export default clause with any other expression exports a value @@ -23826,7 +23893,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 273 /* SourceFile */) { + if (node.parent.kind !== 274 /* SourceFile */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -23872,13 +23939,11 @@ var ts; // expression is the declaration setCommonJsModuleIndicator(node); var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, function (id, original) { - if (!original) { - return undefined; + var symbol = forEachIdentifierInEntityName(lhs.expression, /*parent*/ undefined, function (id, symbol) { + if (symbol) { + addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* JSContainer */); } - var s = ts.getJSInitializerSymbol(original); - addDeclarationToSymbol(s, id, 1536 /* Module */ | 67108864 /* JSContainer */); - return s; + return symbol; }); if (symbol) { var flags = ts.isClassExpression(node.right) ? @@ -23909,14 +23974,14 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 192 /* 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 === 58 /* EqualsToken */) { var l = thisContainer.parent.left; if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { - constructorSymbol = getJSInitializerSymbolFromName(l.expression.expression, thisParentContainer); + constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } if (constructorSymbol) { @@ -23926,18 +23991,18 @@ var ts; declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } break; - case 154 /* Constructor */: - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 155 /* Constructor */: + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 273 /* SourceFile */: + case 274 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -23949,7 +24014,7 @@ var ts; if (node.expression.kind === 99 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 273 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -24003,43 +24068,65 @@ var ts; node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); } - function getJSInitializerSymbolFromName(name, lookupContainer) { - return ts.getJSInitializerSymbol(lookupSymbolForPropertyAccess(name, lookupContainer)); - } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { - var symbol = getJSInitializerSymbolFromName(name); + var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 273 /* SourceFile */ && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 /* SourceFile */ && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 273 /* SourceFile */; - if (!isPrototypeProperty && (!symbol || !(symbol.flags & 1920 /* Namespace */)) && isToplevelNamespaceableInitializer) { + : propertyAccess.parent.parent.kind === 274 /* SourceFile */; + if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */)) && isToplevelNamespaceableInitializer) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* JSContainer */; var excludeFlags_1 = 67215503 /* ValueModuleExcludes */ & ~67108864 /* JSContainer */; - forEachIdentifierInEntityName(propertyAccess.expression, function (id, original) { - if (original) { - // Note: add declaration to original symbol, not the special-syntax's symbol, so that namespaces work for type lookup - addDeclarationToSymbol(original, id, flags_1); - return original; + namespaceSymbol = forEachIdentifierInEntityName(propertyAccess.expression, namespaceSymbol, function (id, symbol, parent) { + if (symbol) { + addDeclarationToSymbol(symbol, id, flags_1); + return symbol; } else { - return symbol = declareSymbol(symbol ? symbol.exports : container.locals, symbol, id, flags_1, excludeFlags_1); + return declareSymbol(parent ? parent.exports : container.locals, parent, id, flags_1, excludeFlags_1); } }); } - if (!symbol || !(symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */ | 4096 /* ObjectLiteral */))) { + if (!namespaceSymbol || !isJavascriptContainer(namespaceSymbol)) { return; } // Set up the members collection if it doesn't exist already var symbolTable = isPrototypeProperty ? - (symbol.members || (symbol.members = ts.createSymbolTable())) : - (symbol.exports || (symbol.exports = ts.createSymbolTable())); + (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : + (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); // Declare the method/property var jsContainerFlag = isToplevelNamespaceableInitializer ? 67108864 /* JSContainer */ : 0; var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedJavascriptInitializer(propertyAccess)); var symbolFlags = (isMethod ? 8192 /* Method */ : 4 /* Property */) | jsContainerFlag; var symbolExcludes = (isMethod ? 67208127 /* MethodExcludes */ : 0 /* PropertyExcludes */) & ~jsContainerFlag; - declareSymbol(symbolTable, symbol, propertyAccess, symbolFlags, symbolExcludes); + declareSymbol(symbolTable, namespaceSymbol, propertyAccess, symbolFlags, symbolExcludes); + } + /** + * Javascript containers are: + * - Functions + * - classes + * - namespaces + * - variables initialized with function expressions + * - with class expressions + * - with empty object literals + * - with non-empty object literals if assigned to the prototype property + */ + function isJavascriptContainer(symbol) { + if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) { + return true; + } + var node = symbol.valueDeclaration; + var init = !node ? undefined : + ts.isVariableDeclaration(node) ? node.initializer : + ts.isBinaryExpression(node) ? node.right : + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) ? node.parent.right : + undefined; + if (init) { + var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); + return !!ts.getJavascriptInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 54 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + } + return false; } function getParentOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.parent)) { @@ -24053,21 +24140,22 @@ var ts; return lookupSymbolForNameWorker(lookupContainer, node.escapedText); } else { - var symbol = ts.getJSInitializerSymbol(lookupSymbolForPropertyAccess(node.expression)); + var symbol = lookupSymbolForPropertyAccess(node.expression); return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); } } - function forEachIdentifierInEntityName(e, action) { + function forEachIdentifierInEntityName(e, parent, action) { if (isExportsOrModuleExportsOrAlias(file, e)) { return file.symbol; } else if (ts.isIdentifier(e)) { - return action(e, lookupSymbolForPropertyAccess(e)); + return action(e, lookupSymbolForPropertyAccess(e), parent); } else { - var s = ts.getJSInitializerSymbol(forEachIdentifierInEntityName(e.expression, action)); - ts.Debug.assert(!!s && !!s.exports); - return action(e.name, s.exports.get(e.name.escapedText)); + var s = forEachIdentifierInEntityName(e.expression, parent, action); + if (!s || !s.exports) + return ts.Debug.fail(); + return action(e.name, s.exports.get(e.name.escapedText), s); } } function bindCallExpression(node) { @@ -24078,7 +24166,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 234 /* ClassDeclaration */) { + if (node.kind === 235 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -24124,7 +24212,7 @@ var ts; bindBlockScopedVariableDeclaration(node); } else if (ts.isParameterDeclaration(node)) { - // It is safe to walk up parent chain to find whether the node is a destructing parameter declaration + // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration // because its parent chain has already been set up, since parents are set before descending into children. // // If node is a binding element in parameter declaration, we need to use ParameterExcludes. @@ -24141,7 +24229,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 292 /* JSDocParameterTag */ && container.kind !== 287 /* JSDocSignature */) { + if (node.kind === 293 /* JSDocParameterTag */ && container.kind !== 288 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -24207,7 +24295,7 @@ var ts; } function bindTypeParameter(node) { if (ts.isJSDocTemplateTag(node.parent)) { - var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent); + var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent); // TODO: GH#18217 if (container_1) { if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); @@ -24218,7 +24306,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 171 /* InferType */) { + else if (node.parent.kind === 172 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -24227,7 +24315,7 @@ var ts; declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */); } else { - bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { @@ -24237,7 +24325,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 */ && !!options.preserveConstEnums); } function checkUnreachable(node) { if (!(currentFlow.flags & 1 /* Unreachable */)) { @@ -24246,31 +24334,31 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 214 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 215 /* EmptyStatement */) || // report error on class declarations - node.kind === 234 /* ClassDeclaration */ || + node.kind === 235 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 238 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 239 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 237 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 238 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; - // unreachable code is reported if - // - user has explicitly asked about it AND - // - statement is in not ambient context (statements in ambient context is already an error - // so we should not report extras) AND - // - node is not variable statement OR - // - node is block scoped variable statement OR - // - node is not block scoped variable statement and at least one variable declaration has initializer - // Rationale: we don't want to report errors on non-initialized var's since they are hoisted - // On the other side we do want to report errors on non-initialized 'lets' because of TDZ - var reportUnreachableCode = !options.allowUnreachableCode && - !(node.flags & 4194304 /* Ambient */) && - (node.kind !== 213 /* VariableStatement */ || - ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || - ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); - if (reportUnreachableCode) { - errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); + if (!options.allowUnreachableCode) { + // unreachable code is reported if + // - user has explicitly asked about it AND + // - statement is in not ambient context (statements in ambient context is already an error + // so we should not report extras) AND + // - node is not variable statement OR + // - node is block scoped variable statement OR + // - node is not block scoped variable statement and at least one variable declaration has initializer + // Rationale: we don't want to report errors on non-initialized var's since they are hoisted + // On the other side we do want to report errors on non-initialized 'lets' because of TDZ + var isError = ts.unreachableCodeIsError(options) && + !(node.flags & 4194304 /* Ambient */) && + (!ts.isVariableStatement(node) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || + node.declarationList.declarations.some(function (d) { return !!d.initializer; })); + errorOrSuggestionOnFirstToken(isError, node, ts.Diagnostics.Unreachable_code_detected); } } } @@ -24286,8 +24374,8 @@ var ts; ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias; function isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node) { var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText); - return symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && - symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer); + return !!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && + !!symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer); } function isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node) { return isExportsOrModuleExportsOrAlias(sourceFile, node) || @@ -24309,58 +24397,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 186 /* CallExpression */: + case 187 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 148 /* Parameter */: + case 149 /* Parameter */: return computeParameter(node, subtreeFlags); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 154 /* Constructor */: + case 155 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -24412,12 +24500,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 183 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 184 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ESNext if they contain rest transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 182 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 183 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -24466,8 +24554,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 207 /* AsExpression */ - || expressionKind === 189 /* TypeAssertionExpression */) { + if (expressionKind === 208 /* AsExpression */ + || expressionKind === 190 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -24844,13 +24932,13 @@ var ts; var excludeFlags = 939525441 /* NodeExcludes */; switch (kind) { case 120 /* AsyncKeyword */: - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: - case 300 /* PartiallyEmittedExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: + case 301 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -24861,25 +24949,25 @@ var ts; case 117 /* AbstractKeyword */: case 124 /* DeclareKeyword */: case 76 /* ConstKeyword */: - case 237 /* EnumDeclaration */: - case 272 /* EnumMember */: - case 208 /* NonNullExpression */: + case 238 /* EnumDeclaration */: + case 273 /* EnumMember */: + case 209 /* NonNullExpression */: case 132 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: - case 256 /* JsxOpeningElement */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: case 10 /* JsxText */: - case 257 /* JsxClosingElement */: - case 258 /* JsxFragment */: - case 259 /* JsxOpeningFragment */: - case 260 /* JsxClosingFragment */: - case 261 /* JsxAttribute */: - case 262 /* JsxAttributes */: - case 263 /* JsxSpreadAttribute */: - case 264 /* JsxExpression */: + case 258 /* JsxClosingElement */: + case 259 /* JsxFragment */: + case 260 /* JsxOpeningFragment */: + case 261 /* JsxClosingFragment */: + case 262 /* JsxAttribute */: + case 263 /* JsxAttributes */: + case 264 /* JsxSpreadAttribute */: + case 265 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; @@ -24887,11 +24975,11 @@ var ts; case 14 /* TemplateHead */: case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: - case 201 /* TemplateExpression */: - case 188 /* TaggedTemplateExpression */: - case 270 /* ShorthandPropertyAssignment */: + case 202 /* TemplateExpression */: + case 189 /* TaggedTemplateExpression */: + case 271 /* ShorthandPropertyAssignment */: case 115 /* StaticKeyword */: - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -24905,14 +24993,14 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 8 /* AssertESNext */; } transformFlags |= 192 /* AssertES2015 */; break; - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; @@ -24925,38 +25013,38 @@ var ts; case 122 /* BooleanKeyword */: case 138 /* SymbolKeyword */: case 105 /* VoidKeyword */: - case 147 /* TypeParameter */: - case 150 /* PropertySignature */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 160 /* TypePredicate */: - case 161 /* TypeReference */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 164 /* TypeQuery */: - case 165 /* TypeLiteral */: - case 166 /* ArrayType */: - case 167 /* TupleType */: - case 168 /* UnionType */: - case 169 /* IntersectionType */: - case 170 /* ConditionalType */: - case 171 /* InferType */: - case 172 /* ParenthesizedType */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 173 /* ThisType */: - case 174 /* TypeOperator */: - case 175 /* IndexedAccessType */: - case 176 /* MappedType */: - case 177 /* LiteralType */: - case 241 /* NamespaceExportDeclaration */: + case 148 /* TypeParameter */: + case 151 /* PropertySignature */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 161 /* TypePredicate */: + case 162 /* TypeReference */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 165 /* TypeQuery */: + case 166 /* TypeLiteral */: + case 167 /* ArrayType */: + case 168 /* TupleType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: + case 171 /* ConditionalType */: + case 172 /* InferType */: + case 173 /* ParenthesizedType */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 174 /* ThisType */: + case 175 /* TypeOperator */: + case 176 /* IndexedAccessType */: + case 177 /* MappedType */: + case 178 /* LiteralType */: + case 242 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. @@ -24973,10 +25061,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 97 /* SuperKeyword */: @@ -24988,28 +25076,28 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 181 /* BindingElement */: + case 182 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; } break; - case 149 /* Decorator */: + case 150 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: excludeFlags = 942740801 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -25027,8 +25115,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 182 /* ArrayLiteralExpression */: - case 187 /* NewExpression */: + case 183 /* ArrayLiteralExpression */: + case 188 /* NewExpression */: excludeFlags = 940049729 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -25036,23 +25124,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 224 /* ReturnStatement */: - case 222 /* ContinueStatement */: - case 223 /* BreakStatement */: + case 225 /* ReturnStatement */: + // Return statements may require an `await` in ESNext. + transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; + break; + case 223 /* ContinueStatement */: + case 224 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -25068,33 +25159,33 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 160 /* FirstTypeNode */ && kind <= 178 /* LastTypeNode */) { + if (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 182 /* ArrayLiteralExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 183 /* ArrayLiteralExpression */: return 940049729 /* ArrayLiteralOrCallOrNewExcludes */; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return 977327425 /* ModuleExcludes */; - case 148 /* Parameter */: + case 149 /* Parameter */: return 939525441 /* ParameterExcludes */; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return 1003902273 /* ArrowFunctionExcludes */; - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: return 1003935041 /* FunctionExcludes */; - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return 948962625 /* VariableDeclarationListExcludes */; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: return 942011713 /* ClassExcludes */; - case 154 /* Constructor */: + case 155 /* Constructor */: return 1003668801 /* ConstructorExcludes */; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return 1003668801 /* MethodOrAccessorExcludes */; case 119 /* AnyKeyword */: case 134 /* NumberKeyword */: @@ -25104,30 +25195,30 @@ var ts; case 122 /* BooleanKeyword */: case 138 /* SymbolKeyword */: case 105 /* VoidKeyword */: - case 147 /* TypeParameter */: - case 150 /* PropertySignature */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 148 /* TypeParameter */: + case 151 /* PropertySignature */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return 942740801 /* ObjectLiteralExcludes */; - case 268 /* CatchClause */: + case 269 /* CatchClause */: return 940574017 /* CatchClauseExcludes */; - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: return 940049729 /* BindingPatternExcludes */; - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: - case 300 /* PartiallyEmittedExpression */: - case 190 /* ParenthesizedExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: + case 301 /* PartiallyEmittedExpression */: + case 191 /* ParenthesizedExpression */: case 97 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: return 671089985 /* PropertyAccessExcludes */; default: return 939525441 /* NodeExcludes */; @@ -25188,7 +25279,7 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var objectType = type; var objectFlags = objectType.objectFlags; if (objectFlags & 4 /* Reference */) { @@ -25204,16 +25295,16 @@ var ts; visitObjectType(objectType); } } - if (type.flags & 32768 /* TypeParameter */) { + if (type.flags & 65536 /* TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 393216 /* UnionOrIntersection */) { + if (type.flags & 786432 /* UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 524288 /* Index */) { + if (type.flags & 1048576 /* Index */) { visitIndexType(type); } - if (type.flags & 1048576 /* IndexedAccess */) { + if (type.flags & 2097152 /* IndexedAccess */) { visitIndexedAccessType(type); } } @@ -25282,11 +25373,11 @@ var ts; } function visitSymbol(symbol) { if (!symbol) { - return; + return false; } var symbolId = ts.getSymbolId(symbol); if (visitedSymbols[symbolId]) { - return; + return false; } visitedSymbols[symbolId] = symbol; if (!accept(symbol)) { @@ -25302,12 +25393,13 @@ 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 === 164 /* TypeQuery */) { + if (d.type && d.type.kind === 165 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); } }); + return false; } } } @@ -25321,7 +25413,7 @@ var ts; ts.trace = trace; /* @internal */ function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; + return !!compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; function withPackageId(packageId, r) { @@ -25501,7 +25593,6 @@ var ts; } } function secondaryLookup() { - var resolvedFile; var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); if (initialLocationForSecondaryLookup !== undefined) { // check secondary locations @@ -25509,7 +25600,7 @@ var ts; trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*cache*/ undefined); - resolvedFile = resolvedTypeScriptOnly(result && result.value); + var resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -25582,7 +25673,7 @@ var ts; } function getOrCreateCacheForModuleName(nonRelativeModuleName) { if (ts.isExternalModuleNameRelative(nonRelativeModuleName)) { - return undefined; + return undefined; // TODO: GH#18217 } var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); if (!perModuleNameCache) { @@ -25694,7 +25785,7 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); break; default: - ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } if (perFolderCache) { perFolderCache.set(moduleName, result); @@ -25947,7 +26038,7 @@ var ts; var originalPath = void 0; if (!compilerOptions.preserveSymlinks && resolvedValue) { originalPath = resolvedValue.path; - var path = realPath(resolved_1.value.path, host, traceEnabled); + var path = realPath(resolvedValue.path, host, traceEnabled); if (path === originalPath) { originalPath = undefined; } @@ -26066,7 +26157,7 @@ var ts; function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (extensions === Extensions.Json) { var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); - return extensionLess && tryAddingExtensions(extensionLess, extensions, failedLookupLocations, onlyRecordFailures, state); + return extensionLess === undefined ? undefined : tryAddingExtensions(extensionLess, extensions, failedLookupLocations, onlyRecordFailures, state); } // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); @@ -26105,7 +26196,7 @@ var ts; } function tryExtension(ext) { var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); - return path && { path: path, ext: ext }; + return path === undefined ? undefined : { path: path, ext: ext }; } } /** Return the file if it exists. */ @@ -26525,11 +26616,12 @@ var ts; getGlobalDiagnostics: getGlobalDiagnostics, getTypeOfSymbolAtLocation: function (symbol, location) { location = ts.getParseTreeNode(location); - return location ? getTypeOfSymbolAtLocation(symbol, location) : unknownType; + return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType; }, - getSymbolsOfParameterPropertyDeclaration: function (parameter, parameterName) { - parameter = ts.getParseTreeNode(parameter, ts.isParameter); - ts.Debug.assert(parameter !== undefined, "Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); + getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) { + var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter); + if (parameter === undefined) + return ts.Debug.fail("Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); return getSymbolsOfParameterPropertyDeclaration(parameter, ts.escapeLeadingUnderscores(parameterName)); }, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, @@ -26541,9 +26633,9 @@ var ts; getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, getWidenedType: getWidenedType, - getTypeFromTypeNode: function (node) { - node = ts.getParseTreeNode(node, ts.isTypeNode); - return node ? getTypeFromTypeNode(node) : unknownType; + getTypeFromTypeNode: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode); + return node ? getTypeFromTypeNode(node) : errorType; }, getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, @@ -26569,8 +26661,8 @@ var ts; node = ts.getParseTreeNode(node); return node ? getShorthandAssignmentValueSymbol(node) : undefined; }, - getExportSpecifierLocalTargetSymbol: function (node) { - node = ts.getParseTreeNode(node, ts.isExportSpecifier); + getExportSpecifierLocalTargetSymbol: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isExportSpecifier); return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; }, getExportSymbolOfSymbol: function (symbol) { @@ -26578,10 +26670,10 @@ var ts; }, getTypeAtLocation: function (node) { node = ts.getParseTreeNode(node); - return node ? getTypeOfNode(node) : unknownType; + return node ? getTypeOfNode(node) : errorType; }, - getPropertySymbolOfDestructuringAssignment: function (location) { - location = ts.getParseTreeNode(location, ts.isIdentifier); + getPropertySymbolOfDestructuringAssignment: function (locationIn) { + var location = ts.getParseTreeNode(locationIn, ts.isIdentifier); return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined; }, signatureToString: function (signature, enclosingDeclaration, flags, kind) { @@ -26611,41 +26703,41 @@ var ts; getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: function (node) { - node = ts.getParseTreeNode(node, ts.isExpression); + getContextualType: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isExpression); return node ? getContextualType(node) : undefined; }, - getContextualTypeForArgumentAtIndex: function (node, argIndex) { - node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) { + var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); return node && getContextualTypeForArgumentAtIndex(node, argIndex); }, - getContextualTypeForJsxAttribute: function (node) { - node = ts.getParseTreeNode(node, ts.isJsxAttributeLike); + getContextualTypeForJsxAttribute: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike); return node && getContextualTypeForJsxAttribute(node); }, isContextSensitive: isContextSensitive, getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: function (node, candidatesOutArray, theArgumentCount) { - node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + getResolvedSignature: function (nodeIn, candidatesOutArray, theArgumentCount) { + var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); apparentArgumentCount = theArgumentCount; var res = node ? getResolvedSignature(node, candidatesOutArray) : undefined; apparentArgumentCount = undefined; return res; }, - getConstantValue: function (node) { - node = ts.getParseTreeNode(node, canHaveConstantValue); + getConstantValue: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue); return node ? getConstantValue(node) : undefined; }, - isValidPropertyAccess: function (node, propertyName) { - node = ts.getParseTreeNode(node, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode); + isValidPropertyAccess: function (nodeIn, propertyName) { + var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode); return !!node && isValidPropertyAccess(node, ts.escapeLeadingUnderscores(propertyName)); }, - isValidPropertyAccessForCompletions: function (node, type, property) { - node = ts.getParseTreeNode(node, ts.isPropertyAccessExpression); + isValidPropertyAccessForCompletions: function (nodeIn, type, property) { + var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessExpression); return !!node && isValidPropertyAccessForCompletions(node, type, property); }, - getSignatureFromDeclaration: function (declaration) { - declaration = ts.getParseTreeNode(declaration, ts.isFunctionLike); + getSignatureFromDeclaration: function (declarationIn) { + var declaration = ts.getParseTreeNode(declarationIn, ts.isFunctionLike); return declaration ? getSignatureFromDeclaration(declaration) : undefined; }, isImplementationOfOverload: function (node) { @@ -26657,7 +26749,8 @@ var ts; var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); + if (!node) + return ts.Debug.fail(); links.immediateTarget = getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true); } return links.immediateTarget; @@ -26668,13 +26761,13 @@ var ts; getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { - node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); + getAllAttributesTypeFromJsxOpeningLikeElement: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isJsxOpeningLikeElement); return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; }, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, - isOptionalParameter: function (node) { - node = ts.getParseTreeNode(node, ts.isParameter); + isOptionalParameter: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isParameter); return node ? isOptionalParameter(node) : false; }, tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); }, @@ -26708,7 +26801,7 @@ var ts; getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, getSuggestionForNonexistentModule: function (node, target) { return getSuggestionForNonexistentModule(node, target); }, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 32768 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 65536 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -26720,24 +26813,35 @@ var ts; node = ts.getParseTreeNode(node); return node && tryGetThisTypeAt(node); }, - getTypeArgumentConstraint: function (node) { - node = ts.getParseTreeNode(node, ts.isTypeNode); + getTypeArgumentConstraint: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode); return node && getTypeArgumentConstraint(node); }, - getSuggestionDiagnostics: function (file) { - return (suggestionDiagnostics.get(file.fileName) || ts.emptyArray).concat(getUnusedDiagnostics()); - function getUnusedDiagnostics() { - if (file.isDeclarationFile) - return ts.emptyArray; + getSuggestionDiagnostics: function (file, ct) { + var diagnostics; + try { + // Record the cancellation token so it can be checked later on during checkSourceElement. + // Do this in a finally block so we can ensure that it gets reset back to nothing after + // this call is done. + cancellationToken = ct; + // Ensure file is type checked checkSourceFile(file); - var diagnostics = []; ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + if (!file.isDeclarationFile && (!unusedIsError(0 /* Local */) || !unusedIsError(1 /* Parameter */))) { + addUnusedDiagnostics(); + } + return diagnostics || ts.emptyArray; + } + finally { + cancellationToken = undefined; + } + function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (kind, diag) { if (!unusedIsError(kind)) { - diagnostics.push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); } }); - return diagnostics; } }, runWithCancellationToken: function (token, callback) { @@ -26762,22 +26866,23 @@ var ts; var anyType = createIntrinsicType(1 /* Any */, "any"); var autoType = createIntrinsicType(1 /* Any */, "any"); var wildcardType = createIntrinsicType(1 /* Any */, "any"); - var unknownType = createIntrinsicType(1 /* Any */, "unknown"); - var undefinedType = createIntrinsicType(4096 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(4096 /* Undefined */ | 16777216 /* ContainsWideningType */, "undefined"); - var nullType = createIntrinsicType(8192 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(8192 /* Null */ | 16777216 /* ContainsWideningType */, "null"); - var stringType = createIntrinsicType(2 /* String */, "string"); - var numberType = createIntrinsicType(4 /* Number */, "number"); - var trueType = createIntrinsicType(128 /* BooleanLiteral */, "true"); - var falseType = createIntrinsicType(128 /* BooleanLiteral */, "false"); + var errorType = createIntrinsicType(1 /* Any */, "error"); + var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); + var undefinedType = createIntrinsicType(8192 /* Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(8192 /* Undefined */ | 134217728 /* ContainsWideningType */, "undefined"); + var nullType = createIntrinsicType(16384 /* Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(16384 /* Null */ | 134217728 /* ContainsWideningType */, "null"); + var stringType = createIntrinsicType(4 /* String */, "string"); + var numberType = createIntrinsicType(8 /* Number */, "number"); + var trueType = createIntrinsicType(256 /* BooleanLiteral */, "true"); + var falseType = createIntrinsicType(256 /* BooleanLiteral */, "false"); var booleanType = createBooleanType([trueType, falseType]); - var esSymbolType = createIntrinsicType(512 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(2048 /* Void */, "void"); - var neverType = createIntrinsicType(16384 /* Never */, "never"); - var silentNeverType = createIntrinsicType(16384 /* Never */, "never"); - var implicitNeverType = createIntrinsicType(16384 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(134217728 /* NonPrimitive */, "object"); + var esSymbolType = createIntrinsicType(1024 /* ESSymbol */, "symbol"); + var voidType = createIntrinsicType(4096 /* Void */, "void"); + var neverType = createIntrinsicType(32768 /* Never */, "never"); + var silentNeverType = createIntrinsicType(32768 /* Never */, "never"); + var implicitNeverType = createIntrinsicType(32768 /* Never */, "never"); + var nonPrimitiveType = createIntrinsicType(16777216 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -26789,17 +26894,17 @@ 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.flags |= 67108864 /* ContainsAnyFunctionType */; + anyFunctionType.flags |= 536870912 /* ContainsAnyFunctionType */; 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); - var markerSuperType = createType(32768 /* TypeParameter */); - var markerSubType = createType(32768 /* TypeParameter */); + var markerSuperType = createType(65536 /* TypeParameter */); + var markerSubType = createType(65536 /* TypeParameter */); markerSubType.constraint = markerSuperType; - var markerOtherType = createType(32768 /* TypeParameter */); + var markerOtherType = createType(65536 /* TypeParameter */); var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, unknownType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignaturesArray = [resolvingSignature]; @@ -27028,6 +27133,7 @@ var ts; typeToString(type, enclosingDeclaration, flags, emitTextWriterWrapper(writer)); }, buildSymbolDisplay: function (symbol, writer, enclosingDeclaration, meaning, flags) { + if (flags === void 0) { flags = 0 /* None */; } symbolToString(symbol, enclosingDeclaration, meaning, flags | 4 /* AllowAnyNodeKind */, emitTextWriterWrapper(writer)); }, buildSignatureDisplay: function (signature, writer, enclosing, flags, kind) { @@ -27041,12 +27147,12 @@ var ts; buildParameterDisplay: function (symbol, writer, enclosing, flags) { var node = nodeBuilder.symbolToParameterDeclaration(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); + printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 }, buildTypeParameterDisplay: function (tp, writer, enclosing, flags) { var node = nodeBuilder.typeParameterToDeclaration(tp, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 8192 /* OmitParameterModifiers */, writer); var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); + printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 }, buildTypePredicateDisplay: function (predicate, writer, enclosing, flags) { typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); @@ -27059,13 +27165,13 @@ var ts; buildDisplayForParametersAndDelimiters: function (thisParameter, parameters, writer, enclosing, originalFlags) { var printer = ts.createPrinter({ removeComments: true }); var flags = 8192 /* OmitParameterModifiers */ | 3112960 /* IgnoreErrors */ | toNodeBuilderFlags(originalFlags); - var thisParameterArray = thisParameter ? [nodeBuilder.symbolToParameterDeclaration(thisParameter, enclosing, flags)] : []; - var params = ts.createNodeArray(thisParameterArray.concat(ts.map(parameters, function (param) { return nodeBuilder.symbolToParameterDeclaration(param, enclosing, flags); }))); + var thisParameterArray = thisParameter ? [nodeBuilder.symbolToParameterDeclaration(thisParameter, enclosing, flags)] : []; // TODO: GH#18217 + var params = ts.createNodeArray(thisParameterArray.concat(ts.map(parameters, function (param) { return nodeBuilder.symbolToParameterDeclaration(param, enclosing, flags); }))); // TODO: GH#18217 printer.writeList(1296 /* CallExpressionArguments */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); }, buildDisplayForTypeParametersAndDelimiters: function (typeParameters, writer, enclosing, flags) { var printer = ts.createPrinter({ removeComments: true }); - var args = ts.createNodeArray(ts.map(typeParameters, function (p) { return nodeBuilder.typeParameterToDeclaration(p, enclosing, toNodeBuilderFlags(flags)); })); + var args = ts.createNodeArray(ts.map(typeParameters, function (p) { return nodeBuilder.typeParameterToDeclaration(p, enclosing, toNodeBuilderFlags(flags)); })); // TODO: GH#18217 printer.writeList(26896 /* TypeParameters */, args, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); }, buildReturnTypeDisplay: function (signature, writer, enclosing, flags) { @@ -27077,7 +27183,7 @@ var ts; } var node = nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); + printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 } }; function emitTextWriterWrapper(underlying) { @@ -27164,7 +27270,7 @@ var ts; } var jsxPragma = file_1.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 file_1.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file_1.localJsxFactory) { return file_1.localJsxNamespace = getFirstIdentifier(file_1.localJsxFactory).escapedText; @@ -27276,11 +27382,17 @@ var ts; recordMergedSymbol(result, symbol); return result; } + /** + * Note: if target is transient, then it is mutable, and mergeSymbol with both mutate and return it. + * If target is not transient, mergeSymbol will produce a transient clone, mutate that and return it. + */ function mergeSymbol(target, source) { if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864 /* JSContainer */) { - var targetValueDeclaration = target.valueDeclaration; - ts.Debug.assert(!!(target.flags & 33554432 /* Transient */)); + ts.Debug.assert(source !== target); + if (!(target.flags & 33554432 /* Transient */)) { + target = cloneSymbol(target); + } // Javascript static-property-assignment declarations always merge, even though they are also values if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { // reset flag when merging instantiated module into value module that has only const enums @@ -27289,7 +27401,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 238 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 238 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 239 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 239 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -27304,18 +27416,6 @@ var ts; target.exports = ts.createSymbolTable(); mergeSymbolTable(target.exports, source.exports); } - if ((source.flags | target.flags) & 67108864 /* JSContainer */) { - var sourceInitializer = ts.getJSInitializerSymbol(source); - var init = ts.getDeclaredJavascriptInitializer(targetValueDeclaration) || ts.getAssignedJavascriptInitializer(targetValueDeclaration); - var targetInitializer = init && init.symbol ? init.symbol : target; - if (!(targetInitializer.flags & 33554432 /* Transient */)) { - var mergedInitializer = getMergedSymbol(targetInitializer); - targetInitializer = mergedInitializer === targetInitializer ? cloneSymbol(targetInitializer) : mergedInitializer; - } - if (sourceInitializer !== source || targetInitializer !== target) { - mergeSymbol(targetInitializer, sourceInitializer); - } - } recordMergedSymbol(target, source); } else if (target.flags & 1024 /* NamespaceModule */) { @@ -27336,11 +27436,12 @@ var ts; error(errorNode, message_2, symbolToString(source)); }); } + return target; } function combineSymbolTables(first, second) { - if (!first || first.size === 0) + if (!ts.hasEntries(first)) return second; - if (!second || second.size === 0) + if (!ts.hasEntries(second)) return first; var combined = ts.createSymbolTable(); mergeSymbolTable(combined, first); @@ -27349,17 +27450,7 @@ var ts; } function mergeSymbolTable(target, source) { source.forEach(function (sourceSymbol, id) { - var targetSymbol = target.get(id); - if (!targetSymbol) { - target.set(id, sourceSymbol); - } - else { - if (!(targetSymbol.flags & 33554432 /* Transient */)) { - targetSymbol = cloneSymbol(targetSymbol); - target.set(id, targetSymbol); - } - mergeSymbol(targetSymbol, sourceSymbol); - } + target.set(id, target.has(id) ? mergeSymbol(target.get(id), sourceSymbol) : sourceSymbol); }); } function mergeModuleAugmentation(moduleName) { @@ -27387,10 +27478,7 @@ var ts; // obtain item referenced by 'export=' mainModule = resolveExternalModuleSymbol(mainModule); if (mainModule.flags & 1920 /* Namespace */) { - // if module symbol has already been merged - it is safe to use it. - // otherwise clone it - mainModule = mainModule.flags & 33554432 /* Transient */ ? mainModule : cloneSymbol(mainModule); - mergeSymbol(mainModule, moduleAugmentation.symbol); + mainModule = mergeSymbol(mainModule, moduleAugmentation.symbol); } else { // moduleName will be a StringLiteral since this is not `declare global`. @@ -27424,7 +27512,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 273 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -27459,7 +27547,7 @@ var ts; if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } - ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration"); + return ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration"); } function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { var declarationFile = ts.getSourceFileOfNode(declaration); @@ -27482,17 +27570,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 181 /* BindingElement */) { + if (declaration.kind === 182 /* 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, 181 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 182 /* 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, 231 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 232 /* VariableDeclaration */), usage); } - else if (declaration.kind === 231 /* VariableDeclaration */) { + else if (declaration.kind === 232 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -27510,12 +27598,12 @@ var ts; // 5. inside a TS export= declaration (since we will move the export statement during emit to avoid TDZ) // or if usage is in a type context: // 1. inside a type query (typeof in type position) - if (usage.parent.kind === 251 /* ExportSpecifier */ || (usage.parent.kind === 248 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 252 /* ExportSpecifier */ || (usage.parent.kind === 249 /* 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 === 248 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 249 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -27523,9 +27611,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 213 /* VariableStatement */: - case 219 /* ForStatement */: - case 221 /* ForOfStatement */: + case 214 /* VariableStatement */: + case 220 /* ForStatement */: + case 222 /* 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, container)) { @@ -27534,7 +27622,8 @@ var ts; break; } // ForIn/ForOf case - use site should not be used in expression part - return ts.isForInOrOfStatement(declaration.parent.parent) && isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container); + var grandparent = declaration.parent.parent; + return ts.isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, container); } function isUsedInFunctionOrInstanceProperty(usage, declaration, container) { return !!ts.findAncestor(usage, function (current) { @@ -27545,21 +27634,22 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 151 /* PropertyDeclaration */ && + current.parent.kind === 152 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 153 /* MethodDeclaration */) { + if (declaration.kind === 154 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 151 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 152 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } } } + return false; }); } } @@ -27595,12 +27685,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 & 67901928 /* Type */ && lastLocation.kind !== 285 /* JSDocComment */) { + if (meaning & result.flags & 67901928 /* Type */ && lastLocation.kind !== 286 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 148 /* Parameter */ || - lastLocation.kind === 147 /* TypeParameter */ + lastLocation.kind === 149 /* Parameter */ || + lastLocation.kind === 148 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -27610,12 +27700,12 @@ 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 === 148 /* Parameter */ || + lastLocation.kind === 149 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 170 /* ConditionalType */) { + else if (location.kind === 171 /* 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; @@ -27629,14 +27719,14 @@ var ts; } } switch (location.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 273 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 274 /* SourceFile */ || ts.isAmbientModule(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 */)) { @@ -27660,21 +27750,27 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 251 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 252 /* ExportSpecifier */)) { 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 */))) { - break loop; + if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) { + result = undefined; + } + else { + break loop; + } } break; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: // 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 @@ -27691,9 +27787,9 @@ var ts; } } break; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container @@ -27709,7 +27805,7 @@ var ts; } break loop; } - if (location.kind === 204 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 205 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -27717,7 +27813,7 @@ var ts; } } break; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 85 /* ExtendsKeyword */) { var container = location.parent.parent; @@ -27737,9 +27833,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 235 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 236 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67901928 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -27747,19 +27843,19 @@ var ts; } } break; - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -27772,7 +27868,7 @@ var ts; } } break; - case 149 /* Decorator */: + case 150 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -27781,7 +27877,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 === 148 /* Parameter */) { + if (location.parent && location.parent.kind === 149 /* Parameter */) { location = location.parent; } // @@ -27794,12 +27890,11 @@ var ts; location = location.parent; } break; - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it - lastLocation = location; - location = ts.getJSDocHost(location).parent; - continue; + location = ts.getJSDocHost(location); + break; } if (isSelfReferenceLocation(location)) { lastSelfReferenceLocation = location; @@ -27815,7 +27910,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 273 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 274 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -27838,7 +27933,7 @@ var ts; if (!result) { if (nameNotFoundMessage) { if (!errorLocation || - !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && + !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217 !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) && @@ -27889,8 +27984,8 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 67216319 /* Value */) === 67216319 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 241 /* NamespaceExportDeclaration */) { - error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); + if (decls && decls.length === 1 && decls[0].kind === 242 /* NamespaceExportDeclaration */) { + error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); // TODO: GH#18217 } } } @@ -27898,12 +27993,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 238 /* ModuleDeclaration */: // For `namespace N { N; }` + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 239 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -27915,10 +28010,10 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 147 /* TypeParameter */) { + if (decl.kind === 148 /* 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)); + return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 } } } @@ -27945,7 +28040,7 @@ var ts; // No static member is present. // Check if we're in an instance method and look for a relevant instance member. if (location === container && !ts.hasModifier(location, 32 /* Static */)) { - var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; + var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; // TODO: GH#18217 if (getPropertyOfType(instanceType, name)) { error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg)); return true; @@ -27958,11 +28053,11 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - var isError = !!(expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)); - if (isError) { + if (expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); + return true; } - return isError; + return false; } /** * Climbs up parents to an ExpressionWithTypeArguments, and returns its expression, @@ -27971,9 +28066,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71 /* Identifier */: - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -28037,8 +28132,9 @@ var ts; function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); // Block-scoped variables cannot be used before their definition - var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 237 /* EnumDeclaration */) ? d : undefined; }); - ts.Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined"); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 238 /* EnumDeclaration */) ? d : undefined; }); + if (declaration === undefined) + return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { if (result.flags & 2 /* BlockScopedVariable */) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); @@ -28056,17 +28152,17 @@ var ts; * Return false if 'stopAt' node is reached or isFunctionLike(current) === true. */ function isSameScopeDescendentOf(initial, parent, stopAt) { - return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); + return !!parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); } function getAnyImportSyntax(node) { switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return node; - case 244 /* ImportClause */: + case 245 /* ImportClause */: return node.parent; - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return node.parent.parent; - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -28076,7 +28172,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 253 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -28088,7 +28184,7 @@ var ts; : resolveSymbol(moduleSymbol.exports.get(name), dontResolveAlias); } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasModifier(node, 512 /* Default */)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasModifier(node, 512 /* Default */) || ts.isExportSpecifier(node)); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias) { if (!allowSyntheticDefaultImports) { @@ -28191,12 +28287,13 @@ var ts; if (symbol.flags & 3 /* Variable */) { var typeAnnotation = symbol.valueDeclaration.type; if (typeAnnotation) { - return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); + return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); // TODO: GH#18217 } } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + if (dontResolveAlias === void 0) { dontResolveAlias = false; } + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); if (targetSymbol) { var name = specifier.propertyName || specifier.name; @@ -28261,22 +28358,25 @@ var ts; return getNodeLinks(expression).resolvedSymbol; } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { + if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 251 /* ExportSpecifier */: + case 252 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 248 /* ExportAssignment */: - case 199 /* BinaryExpression */: + case 249 /* ExportAssignment */: + case 200 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + default: + return ts.Debug.fail(); } } /** @@ -28287,11 +28387,10 @@ var ts; if (excludes === void 0) { excludes = 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */; } if (!symbol) return false; - return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || (symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* JSContainer */); + return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* JSContainer */); } function resolveSymbol(symbol, dontResolveAlias) { - var shouldResolve = !dontResolveAlias && isNonLocalAlias(symbol); - return shouldResolve ? resolveAlias(symbol) : symbol; + return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); @@ -28299,7 +28398,8 @@ var ts; if (!links.target) { links.target = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); + if (!node) + return ts.Debug.fail(); var target = getTargetOfAliasDeclaration(node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; @@ -28332,12 +28432,13 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); - if (node.kind === 248 /* ExportAssignment */) { + if (!node) + return ts.Debug.fail(); + if (node.kind === 249 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 251 /* ExportSpecifier */) { + else if (node.kind === 252 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -28359,13 +28460,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 71 /* Identifier */ || entityName.parent.kind === 145 /* QualifiedName */) { + if (entityName.kind === 71 /* Identifier */ || entityName.parent.kind === 146 /* 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 === 242 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 243 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -28389,9 +28490,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 145 /* QualifiedName */ || name.kind === 184 /* PropertyAccessExpression */) { - var left = name.kind === 145 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 145 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 146 /* QualifiedName */ || name.kind === 185 /* PropertyAccessExpression */) { + var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; var namespace_1 = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace_1 || ts.nodeIsMissing(right)) { return undefined; @@ -28400,14 +28501,6 @@ var ts; return namespace_1; } if (ts.isInJavaScriptFile(name)) { - var initializer = ts.getDeclaredJavascriptInitializer(namespace_1.valueDeclaration) || ts.getAssignedJavascriptInitializer(namespace_1.valueDeclaration); - if (initializer) { - namespace_1 = getSymbolOfNode(initializer); - } - // Currently, IIFEs may not have a symbol and we don't know about their contents. Give up in this case. - if (!namespace_1) { - return undefined; - } if (namespace_1.valueDeclaration && ts.isVariableDeclaration(namespace_1.valueDeclaration) && namespace_1.valueDeclaration.initializer && @@ -28431,7 +28524,7 @@ var ts; } } else { - ts.Debug.assertNever(name, "Unknown entity name kind."); + 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."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -28492,7 +28585,7 @@ var ts; return ambientModule; } var currentSourceFile = ts.getSourceFileOfNode(location); - var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference); + var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference); // TODO: GH#18217 var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule); var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { @@ -28566,8 +28659,6 @@ var ts; /*details*/ undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, ts.getMangledNameForScopedPackage(packageId.name)); errorOrSuggestion(isError, errorNode, ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedFileName)); } - // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, - // and an external module with no 'export =' declaration resolves to the module itself. function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; } @@ -28583,14 +28674,7 @@ var ts; moduleSymbol.exports.forEach(function (s, name) { if (name === "export=" /* ExportEquals */) return; - if (!merged.exports.has(name)) { - merged.exports.set(name, s); - } - else { - var ms = cloneSymbol(merged.exports.get(name)); - mergeSymbol(ms, s); - merged.exports.set(name, ms); - } + merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); return merged; } @@ -28668,7 +28752,7 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 16382 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); + return type.flags & 32764 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : @@ -28758,6 +28842,43 @@ var ts; function getParentOfSymbol(symbol) { return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent)); } + /** + * Attempts to find the symbol corresponding to the container a symbol is in - usually this + * is just its' `.parent`, but for locals, this value is `undefined` + */ + function getContainerOfSymbol(symbol) { + var container = getParentOfSymbol(symbol); + if (container) { + return container; + } + var candidate = ts.forEach(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + if (!candidate) { + return undefined; + } + var alias = getAliasForSymbolInContainer(candidate, symbol); + return alias ? candidate : undefined; + } + function getAliasForSymbolInContainer(container, symbol) { + if (container === getParentOfSymbol(symbol)) { + // fast path, `symbol` is either already the alias or isn't aliased + return symbol; + } + var exports = getExportsOfSymbol(container); + var quick = exports.get(symbol.escapedName); + if (quick && symbolRefersToTarget(quick)) { + return quick; + } + return ts.forEachEntry(exports, function (exported) { + if (symbolRefersToTarget(exported)) { + return exported; + } + }); + function symbolRefersToTarget(s) { + if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { + return s; + } + } + } function getExportSymbolOfValueSymbolIfExported(symbol) { return symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? getMergedSymbol(symbol.exportSymbol) @@ -28770,7 +28891,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 154 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 155 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -28788,12 +28909,12 @@ var ts; } function createBooleanType(trueFalseTypes) { var type = getUnionType(trueFalseTypes); - type.flags |= 8 /* Boolean */; + type.flags |= 16 /* Boolean */; type.intrinsicName = "boolean"; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(65536 /* Object */); + var type = createType(131072 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; return type; @@ -28848,12 +28969,12 @@ var ts; } } switch (location.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -28899,7 +29020,7 @@ var ts; // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible - !ts.some(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); } function trySymbolTable(symbols, ignoreQualification) { @@ -28927,6 +29048,11 @@ var ts; return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); } } + if (symbolFromSymbolTable.escapedName === symbol.escapedName && symbolFromSymbolTable.exportSymbol) { + if (isAccessible(getMergedSymbol(symbolFromSymbolTable.exportSymbol), /*aliasSymbol*/ undefined, ignoreQualification)) { + return [symbol]; + } + } }); } } @@ -28934,7 +29060,7 @@ var ts; var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { // If symbol of this name is not available in the symbol table we are ok - var symbolFromSymbolTable = symbolTable.get(symbol.escapedName); + var symbolFromSymbolTable = getMergedSymbol(symbolTable.get(symbol.escapedName)); if (!symbolFromSymbolTable) { // Continue to the next symbol table return false; @@ -28945,7 +29071,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, 251 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 252 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -28960,10 +29086,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: continue; default: return false; @@ -29008,7 +29134,7 @@ var ts; return hasAccessibleDeclarations; } else { - if (ts.some(symbol.declarations, hasExternalModuleSymbol)) { + if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // Any meaning of a module symbol is always accessible via an `import` type return { accessibility: 0 /* Accessible */ @@ -29028,7 +29154,7 @@ var ts; // But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible // It is accessible if the parent m is accessible because then m.c can be accessed through qualification meaningToLook = getQualifiedLeftMeaning(meaning); - symbol = getParentOfSymbol(symbol); + symbol = getContainerOfSymbol(symbol); } // This could be a symbol that is not exported in the external module // or it could be a symbol from different external module that is not aliased and hence cannot be named @@ -29057,7 +29183,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 273 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + } + function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -29104,14 +29233,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 164 /* TypeQuery */ || + if (entityName.parent.kind === 165 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 146 /* ComputedPropertyName */) { + entityName.parent.kind === 147 /* ComputedPropertyName */) { // Typeof value meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 145 /* QualifiedName */ || entityName.kind === 184 /* PropertyAccessExpression */ || - entityName.parent.kind === 242 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 185 /* PropertyAccessExpression */ || + entityName.parent.kind === 243 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -29144,7 +29273,7 @@ var ts; var builder = flags & 4 /* AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker); function symbolToStringWorker(writer) { - var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); + var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); @@ -29152,27 +29281,29 @@ var ts; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { + if (flags === void 0) { flags = 0 /* None */; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 163 /* ConstructorType */ : 162 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 164 /* ConstructorType */ : 163 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 158 /* ConstructSignature */ : 157 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 159 /* ConstructSignature */ : 158 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, writer); // TODO: GH#18217 return writer; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */; } + if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; } if (writer === void 0) { writer = ts.createTextWriter(""); } var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - ts.Debug.assert(typeNode !== undefined, "should always get typenode"); + if (typeNode === undefined) + return ts.Debug.fail("should always get typenode"); var options = { removeComments: true }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); @@ -29185,6 +29316,7 @@ var ts; return result; } function toNodeBuilderFlags(flags) { + if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; } function createNodeBuilder() { @@ -29201,7 +29333,7 @@ var ts; var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); var result = context.encounteredError ? undefined : resultingNode; - return result; + return result; // TODO: GH#18217 }, signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); @@ -29249,7 +29381,7 @@ var ts; function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { return { enclosingDeclaration: enclosingDeclaration, - flags: flags, + flags: flags || 0 /* None */, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, encounteredError: false, visitedSymbols: undefined, @@ -29264,40 +29396,43 @@ var ts; context.flags &= ~8388608 /* InTypeAlias */; if (!type) { context.encounteredError = true; - return undefined; + return undefined; // TODO: GH#18217 } if (type.flags & 1 /* Any */) { return ts.createKeywordTypeNode(119 /* AnyKeyword */); } - if (type.flags & 2 /* String */) { + if (type.flags & 2 /* Unknown */) { + return ts.createKeywordTypeNode(142 /* UnknownKeyword */); + } + if (type.flags & 4 /* String */) { return ts.createKeywordTypeNode(137 /* StringKeyword */); } - if (type.flags & 4 /* Number */) { + if (type.flags & 8 /* Number */) { return ts.createKeywordTypeNode(134 /* NumberKeyword */); } - if (type.flags & 8 /* Boolean */) { + if (type.flags & 16 /* Boolean */) { return ts.createKeywordTypeNode(122 /* BooleanKeyword */); } - if (type.flags & 256 /* EnumLiteral */ && !(type.flags & 131072 /* Union */)) { + if (type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); var parentName = symbolToName(parentSymbol, context, 67901928 /* Type */, /*expectsIdentifier*/ false); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : ts.createQualifiedName(parentName, ts.symbolName(type.symbol)); return ts.createTypeReferenceNode(enumLiteralName, /*typeArguments*/ undefined); } - if (type.flags & 272 /* EnumLike */) { + if (type.flags & 544 /* EnumLike */) { var name = symbolToName(type.symbol, context, 67901928 /* Type */, /*expectsIdentifier*/ false); return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); } - if (type.flags & (32 /* StringLiteral */)) { + if (type.flags & (64 /* StringLiteral */)) { return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value), 16777216 /* NoAsciiEscaping */)); } - if (type.flags & (64 /* NumberLiteral */)) { + if (type.flags & (128 /* NumberLiteral */)) { return ts.createLiteralTypeNode((ts.createLiteral(type.value))); } - if (type.flags & 128 /* BooleanLiteral */) { + if (type.flags & 256 /* BooleanLiteral */) { return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); } - if (type.flags & 1024 /* UniqueESSymbol */) { + if (type.flags & 2048 /* UniqueESSymbol */) { if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return symbolToTypeNode(type.symbol, context, 67216319 /* Value */); @@ -29308,25 +29443,25 @@ var ts; } return ts.createTypeOperatorNode(141 /* UniqueKeyword */, ts.createKeywordTypeNode(138 /* SymbolKeyword */)); } - if (type.flags & 2048 /* Void */) { + if (type.flags & 4096 /* Void */) { return ts.createKeywordTypeNode(105 /* VoidKeyword */); } - if (type.flags & 4096 /* Undefined */) { + if (type.flags & 8192 /* Undefined */) { return ts.createKeywordTypeNode(140 /* UndefinedKeyword */); } - if (type.flags & 8192 /* Null */) { + if (type.flags & 16384 /* Null */) { return ts.createKeywordTypeNode(95 /* NullKeyword */); } - if (type.flags & 16384 /* Never */) { + if (type.flags & 32768 /* Never */) { return ts.createKeywordTypeNode(131 /* NeverKeyword */); } - if (type.flags & 512 /* ESSymbol */) { + if (type.flags & 1024 /* ESSymbol */) { return ts.createKeywordTypeNode(138 /* SymbolKeyword */); } - if (type.flags & 134217728 /* NonPrimitive */) { + if (type.flags & 16777216 /* NonPrimitive */) { return ts.createKeywordTypeNode(135 /* ObjectKeyword */); } - if (type.flags & 32768 /* TypeParameter */ && type.isThisType) { + if (type.flags & 65536 /* TypeParameter */ && type.isThisType) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { context.encounteredError = true; @@ -29339,24 +29474,25 @@ var ts; } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 65536 /* Object */)); + ts.Debug.assert(!!(type.flags & 131072 /* Object */)); return typeReferenceToTypeNode(type); } - if (type.flags & 32768 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 32768 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 65536 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { + if (type.flags & 65536 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 32768 /* TypeParameter */ && + type.flags & 65536 /* TypeParameter */ && ts.length(type.symbol.declarations) && ts.isTypeParameterDeclaration(type.symbol.declarations[0]) && typeParameterShadowsNameInScope(type, context) && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return ts.createTypeReferenceNode(ts.getGeneratedNameForNode(type.symbol.declarations[0].name, 16 /* Optimistic */ | 8 /* ReservedInNestedScopes */), /*typeArguments*/ undefined); } - var name = type.symbol ? symbolToName(type.symbol, context, 67901928 /* Type */, /*expectsIdentifier*/ false) : ts.createIdentifier("?"); // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. - return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + return type.symbol + ? symbolToTypeNode(type.symbol, context, 67901928 /* Type */) + : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); @@ -29364,36 +29500,36 @@ var ts; return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); return symbolToTypeNode(type.aliasSymbol, context, 67901928 /* Type */, typeArgumentNodes); } - if (type.flags & (131072 /* Union */ | 262144 /* Intersection */)) { - var types = type.flags & 131072 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (262144 /* Union */ | 524288 /* Intersection */)) { + var types = type.flags & 262144 /* Union */ ? formatUnionTypes(type.types) : type.types; var typeNodes = mapToTypeNodes(types, context); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 131072 /* Union */ ? 168 /* UnionType */ : 169 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 169 /* UnionType */ : 170 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { if (!context.encounteredError && !(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; } - return undefined; + return undefined; // TODO: GH#18217 } } if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 65536 /* Object */)); + ts.Debug.assert(!!(type.flags & 131072 /* Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 524288 /* Index */) { + if (type.flags & 1048576 /* Index */) { var indexedType = type.type; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); return ts.createTypeOperatorNode(indexTypeNode); } - if (type.flags & 1048576 /* IndexedAccess */) { + if (type.flags & 2097152 /* IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 2097152 /* Conditional */) { + if (type.flags & 4194304 /* Conditional */) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -29403,12 +29539,12 @@ var ts; var falseTypeNode = typeToTypeNodeHelper(getFalseTypeFromConditionalType(type), context); return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } - if (type.flags & 4194304 /* Substitution */) { + if (type.flags & 8388608 /* Substitution */) { return typeToTypeNodeHelper(type.typeVariable, context); } - ts.Debug.fail("Should be unreachable."); + return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 65536 /* Object */)); + ts.Debug.assert(!!(type.flags & 131072 /* Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -29437,7 +29573,7 @@ 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 === 204 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 205 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319 /* Value */); @@ -29475,12 +29611,12 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 273 /* SourceFile */ || declaration.parent.kind === 239 /* ModuleBlock */; + return declaration.parent.kind === 274 /* SourceFile */ || declaration.parent.kind === 240 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedSymbols && context.visitedSymbols.has(id))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } @@ -29495,12 +29631,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 162 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 163 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 163 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 164 /* ConstructorType */, context); return signatureNode; } } @@ -29532,7 +29668,7 @@ var ts; return ts.createTupleTypeNode([]); } context.encounteredError = true; - return undefined; + return undefined; // TODO: GH#18217 } else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && @@ -29621,11 +29757,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 157 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 158 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 158 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 159 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexInfo = resolvedType.objectFlags & 2048 /* ReverseMapped */ ? @@ -29655,7 +29791,7 @@ var ts; var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; if (ts.getCheckFlags(propertySymbol) & 1024 /* Late */) { - var decl = ts.firstOrUndefined(propertySymbol.declarations); + var decl = ts.first(propertySymbol.declarations); var name = hasLateBindableName(decl) && resolveEntityName(decl.name.expression, 67216319 /* Value */); if (name && context.tracker.trackSymbol) { context.tracker.trackSymbol(name, saveEnclosingDeclaration, 67216319 /* Value */); @@ -29668,7 +29804,7 @@ var ts; var signatures = getSignaturesOfType(propertyType, 0 /* Call */); for (var _e = 0, signatures_1 = signatures; _e < signatures_1.length; _e++) { var signature = signatures_1[_e]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 152 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 153 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -29718,7 +29854,7 @@ var ts; /*dotDotDotToken*/ undefined, name, /*questionToken*/ undefined, indexerTypeNode, /*initializer*/ undefined); - var typeNode = indexInfo.type ? typeToTypeNodeHelper(indexInfo.type, context) : typeToTypeNodeHelper(anyType, context); + var typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); if (!indexInfo.type && !(context.flags & 2097152 /* AllowEmptyIndexInfoType */)) { context.encounteredError = true; } @@ -29734,7 +29870,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 154 /* Constructor */); }); + var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -29786,22 +29922,22 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 148 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 292 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); - var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(ts.getSynthesizedClone); + var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration ? ts.isRestParameter(parameterDeclaration) : parameterSymbol.isRestParameter; var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? parameterDeclaration.name.kind === 71 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 145 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 146 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -29815,7 +29951,7 @@ var ts; function elideInitializerAndSetEmitFlags(node) { var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 181 /* BindingElement */) { + if (clone.kind === 182 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -29823,12 +29959,12 @@ var ts; } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { - context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); + context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); // TODO: GH#18217 // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */)) { - chain = getSymbolChain(symbol, meaning, /*endOfChain*/ true); + chain = ts.Debug.assertDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); ts.Debug.assert(chain && chain.length > 0); } else { @@ -29842,12 +29978,12 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + var parent = getContainerOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); if (parent) { var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { parentSymbol = parent; - accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); } } } @@ -29858,7 +29994,7 @@ var ts; // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) - (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol))) && + (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol))) && // If a parent symbol is an anonymous type, don't write it. !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { return [symbol]; @@ -30035,6 +30171,7 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { + if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */)); @@ -30050,10 +30187,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 12288 /* Nullable */)) { - if (t.flags & (128 /* BooleanLiteral */ | 256 /* EnumLiteral */)) { - var baseType = t.flags & 128 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 131072 /* Union */) { + if (!(t.flags & 24576 /* Nullable */)) { + if (t.flags & (256 /* BooleanLiteral */ | 512 /* EnumLiteral */)) { + var baseType = t.flags & 256 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 262144 /* Union */) { var count = baseType.types.length; if (i + count <= types.length && types[i + count - 1] === baseType.types[count - 1]) { result.push(baseType); @@ -30065,9 +30202,9 @@ var ts; result.push(t); } } - if (flags & 8192 /* Null */) + if (flags & 16384 /* Null */) result.push(nullType); - if (flags & 4096 /* Undefined */) + if (flags & 8192 /* Undefined */) result.push(undefinedType); return result || types; } @@ -30082,8 +30219,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 172 /* ParenthesizedType */; }); - if (node.kind === 236 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 173 /* ParenthesizedType */; }); + if (node.kind === 237 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -30091,11 +30228,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 239 /* ModuleBlock */ && + node.parent.kind === 240 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 273 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -30115,15 +30252,15 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { - var file_3 = ts.getDeclarationOfKind(symbol, 273 /* SourceFile */); + if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { // TODO: GH#18217 + var file_3 = ts.getDeclarationOfKind(symbol, 274 /* SourceFile */); if (!file_3 || !context.tracker.moduleResolverHost) { 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]; - context.tracker.trackReferencedAmbientModule(decl); + context.tracker.trackReferencedAmbientModule(decl); // TODO: GH#18217 } } } @@ -30138,26 +30275,26 @@ var ts; if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 231 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 232 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } switch (declaration.kind) { - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return "(Anonymous class)"; - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return "(Anonymous function)"; } } var nameType = symbol.nameType; if (nameType) { - if (nameType.flags & 32 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { + if (nameType.flags & 64 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { return "\"" + ts.escapeString(nameType.value, 34 /* doubleQuote */) + "\""; } - if (nameType && nameType.flags & 1024 /* UniqueESSymbol */) { + if (nameType && nameType.flags & 2048 /* UniqueESSymbol */) { return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; } } @@ -30174,27 +30311,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 291 /* JSDocCallbackTag */: - case 296 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: // 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 181 /* BindingElement */: + case 182 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 231 /* VariableDeclaration */: + case 232 /* 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 238 /* ModuleDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 233 /* FunctionDeclaration */: - case 237 /* EnumDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 239 /* ModuleDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 234 /* FunctionDeclaration */: + case 238 /* EnumDeclaration */: + case 243 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -30202,53 +30339,53 @@ 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 !== 242 /* ImportEqualsDeclaration */ && parent.kind !== 273 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 243 /* ImportEqualsDeclaration */ && parent.kind !== 274 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.hasModifier(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 154 /* Constructor */: - case 158 /* ConstructSignature */: - case 157 /* CallSignature */: - case 159 /* IndexSignature */: - case 148 /* Parameter */: - case 239 /* ModuleBlock */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 165 /* TypeLiteral */: - case 161 /* TypeReference */: - case 166 /* ArrayType */: - case 167 /* TupleType */: - case 168 /* UnionType */: - case 169 /* IntersectionType */: - case 172 /* ParenthesizedType */: + case 155 /* Constructor */: + case 159 /* ConstructSignature */: + case 158 /* CallSignature */: + case 160 /* IndexSignature */: + case 149 /* Parameter */: + case 240 /* ModuleBlock */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 166 /* TypeLiteral */: + case 162 /* TypeReference */: + case 167 /* ArrayType */: + case 168 /* TupleType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: + case 173 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 244 /* ImportClause */: - case 245 /* NamespaceImport */: - case 247 /* ImportSpecifier */: + case 245 /* ImportClause */: + case 246 /* NamespaceImport */: + case 248 /* ImportSpecifier */: return false; // Type parameters are always visible - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: // Source file and namespace export are always visible - case 273 /* SourceFile */: - case 241 /* NamespaceExportDeclaration */: + case 274 /* SourceFile */: + case 242 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return false; default: return false; @@ -30257,10 +30394,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 248 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 249 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 251 /* ExportSpecifier */) { + else if (node.parent.kind === 252 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -30329,22 +30466,22 @@ var ts; } function hasType(target, propertyName) { if (propertyName === 0 /* Type */) { - return getSymbolLinks(target).type; + return !!getSymbolLinks(target).type; } if (propertyName === 2 /* DeclaredType */) { - return getSymbolLinks(target).declaredType; + return !!getSymbolLinks(target).declaredType; } if (propertyName === 1 /* ResolvedBaseConstructorType */) { - return target.resolvedBaseConstructorType; + return !!target.resolvedBaseConstructorType; } if (propertyName === 3 /* ResolvedReturnType */) { - return target.resolvedReturnType; + return !!target.resolvedReturnType; } if (propertyName === 4 /* ResolvedBaseConstraint */) { var bc = target.resolvedBaseConstraint; - return bc && bc !== circularConstraintType; + return !!bc && bc !== circularConstraintType; } - ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + return ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); } // Pop an entry from the type resolution stack and return its associated result value. The result value will // be true if no circularities were detected, or false if a circularity was found. @@ -30354,20 +30491,19 @@ var ts; return resolutionResults.pop(); } function getDeclarationContainer(node) { - node = ts.findAncestor(ts.getRootDeclaration(node), function (node) { + return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 231 /* VariableDeclaration */: - case 232 /* VariableDeclarationList */: - case 247 /* ImportSpecifier */: - case 246 /* NamedImports */: - case 245 /* NamespaceImport */: - case 244 /* ImportClause */: + case 232 /* VariableDeclaration */: + case 233 /* VariableDeclarationList */: + case 248 /* ImportSpecifier */: + case 247 /* NamedImports */: + case 246 /* NamespaceImport */: + case 245 /* ImportClause */: return false; default: return true; } - }); - return node && node.parent; + }).parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -30392,14 +30528,14 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 146 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 147 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 12288 /* Nullable */); }); - if (source.flags & 16384 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 24576 /* Nullable */); }); + if (source.flags & 32768 /* Never */) { return emptyObjectType; } - if (source.flags & 131072 /* Union */) { + if (source.flags & 262144 /* Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var members = ts.createSymbolTable(); @@ -30426,8 +30562,8 @@ var ts; var pattern = declaration.parent; var parentType = getTypeForBindingElementParent(pattern.parent); // If parent has the unknown (error) type, then so does this binding element - if (parentType === unknownType) { - return unknownType; + if (parentType === errorType) { + return errorType; } // If no type was specified or inferred for parent, // infer from the initializer of the binding element if one is present. @@ -30439,11 +30575,11 @@ var ts; return parentType; } var type; - if (pattern.kind === 179 /* ObjectBindingPattern */) { + if (pattern.kind === 180 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { - if (!isValidSpreadType(parentType)) { + if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); - return unknownType; + return errorType; } var literalMembers = []; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { @@ -30461,13 +30597,13 @@ var ts; var isWellKnown = ts.isComputedPropertyName(name) && ts.isWellKnownSymbolSyntactically(name.expression); if (!isLate && !isWellKnown && isComputedNonLiteralName(name)) { var exprType = checkExpression(name.expression); - if (isTypeAssignableToKind(exprType, 1536 /* ESSymbolLike */)) { + if (isTypeAssignableToKind(exprType, 3072 /* ESSymbolLike */)) { if (noImplicitAny) { error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(exprType), typeToString(parentType)); } return anyType; } - var indexerType = isTypeAssignableToKind(exprType, 84 /* NumberLike */) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); + var indexerType = isTypeAssignableToKind(exprType, 168 /* NumberLike */) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); if (!indexerType && noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { if (getIndexTypeOfType(parentType, 1 /* Number */)) { error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); @@ -30480,7 +30616,7 @@ var ts; } // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. - var nameType = isLate && checkComputedPropertyName(name); + var nameType = isLate ? checkComputedPropertyName(name) : undefined; var text = isLate ? getLateBoundNameFromType(nameType) : isWellKnown ? ts.getPropertyNameForKnownSymbolName(ts.idText(name.expression.name)) : ts.getTextOfPropertyName(name); @@ -30488,7 +30624,7 @@ var ts; if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } - if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 1536 /* ESSymbolLike */)) { + if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */)) { if (noImplicitAny) { error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(nameType), typeToString(parentType)); } @@ -30500,7 +30636,7 @@ var ts; getIndexTypeOfType(parentType, 0 /* String */); if (!type) { error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); - return unknownType; + return errorType; } } } @@ -30526,13 +30662,13 @@ var ts; else { error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); } - return unknownType; + return errorType; } } } // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 4096 /* Undefined */)) { + if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192 /* Undefined */)) { type = getTypeWithFacts(type, 131072 /* NEUndefined */); } return declaration.initializer ? @@ -30552,7 +30688,7 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 182 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 183 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -30562,11 +30698,11 @@ var ts; 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 === 220 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 221 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); - return indexType.flags & (32768 /* TypeParameter */ | 524288 /* Index */) ? getExtractStringType(indexType) : stringType; + return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 221 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 222 /* 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, @@ -30585,7 +30721,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 231 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 232 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -30599,11 +30735,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 148 /* Parameter */) { + if (declaration.kind === 149 /* Parameter */) { 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 === 156 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 155 /* GetAccessor */); + if (func.kind === 157 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 156 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -30657,20 +30793,20 @@ var ts; var jsDocType; var _loop_3 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 199 /* BinaryExpression */ ? declaration : - declaration.kind === 184 /* PropertyAccessExpression */ ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = declaration.kind === 200 /* BinaryExpression */ ? declaration : + declaration.kind === 185 /* PropertyAccessExpression */ ? ts.cast(declaration.parent, ts.isBinaryExpression) : undefined; if (!expression) { - return { value: unknownType }; + return { value: errorType }; } var special = ts.getSpecialPropertyAssignmentKind(expression); if (special === 4 /* ThisProperty */) { 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. - declarationInConstructor = thisContainer.kind === 154 /* Constructor */ || - thisContainer.kind === 233 /* FunctionDeclaration */ || - (thisContainer.kind === 191 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + declarationInConstructor = thisContainer.kind === 155 /* Constructor */ || + thisContainer.kind === 234 /* FunctionDeclaration */ || + (thisContainer.kind === 192 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -30685,7 +30821,7 @@ var ts; if (!jsDocType) { jsDocType = declarationType; } - else if (jsDocType !== unknownType && declarationType !== unknownType && + else if (jsDocType !== errorType && declarationType !== errorType && !isTypeIdenticalTo(jsDocType, declarationType) && !(symbol.flags & 67108864 /* JSContainer */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); @@ -30742,11 +30878,11 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(12288 /* Nullable */ | 16777216 /* ContainsWideningType */)); }) ? constructorTypes : types; + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(24576 /* Nullable */ | 134217728 /* ContainsWideningType */)); }) ? constructorTypes : types; // TODO: GH#18217 type = getUnionType(sourceTypes, 2 /* Subtype */); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~12288 /* Nullable */); }) === neverType) { + if (filterType(widened, function (t) { return !!(t.flags & ~24576 /* Nullable */); }) === neverType) { if (noImplicitAny) { reportImplicitAnyError(symbol.valueDeclaration, anyType); } @@ -30807,7 +30943,7 @@ var ts; members.set(symbol.escapedName, symbol); }); var result = createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); - result.flags |= 33554432 /* ContainsObjectLiteral */; + result.flags |= 268435456 /* ContainsObjectLiteral */; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; @@ -30818,7 +30954,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (elements.length === 0 || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. @@ -30838,7 +30974,9 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 179 /* ObjectBindingPattern */ + if (includePatternInType === void 0) { includePatternInType = false; } + if (reportErrors === void 0) { reportErrors = false; } + return pattern.kind === 180 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -30858,7 +30996,7 @@ var ts; reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 1024 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 2048 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -30875,7 +31013,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 148 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 149 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -30905,7 +31043,7 @@ var ts; var jsonSourceFile = ts.cast(declaration, ts.isJsonSourceFile); return links.type = jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType; } - if (declaration.kind === 248 /* ExportAssignment */) { + if (declaration.kind === 249 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } if (ts.isInJavaScriptFile(declaration) && ts.isJSDocPropertyLikeTag(declaration) && declaration.typeExpression) { @@ -30913,7 +31051,7 @@ var ts; } // Handle variable, parameter or property if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; + return errorType; } var type = void 0; // Handle certain special assignment kinds, which happen to union across multiple declarations: @@ -30921,13 +31059,15 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 199 /* BinaryExpression */ || - declaration.kind === 184 /* PropertyAccessExpression */ && declaration.parent.kind === 199 /* BinaryExpression */) { + if (declaration.kind === 200 /* BinaryExpression */ || + declaration.kind === 185 /* PropertyAccessExpression */ && declaration.parent.kind === 200 /* BinaryExpression */) { type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isClassDeclaration(declaration) + || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) || ts.isMethodSignature(declaration)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` @@ -30956,7 +31096,7 @@ var ts; type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); } else { - ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration)); + return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol)); } if (!popTypeResolution()) { type = reportCircularityError(symbol); @@ -30967,7 +31107,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 155 /* GetAccessor */) { + if (accessor.kind === 156 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation && getTypeFromTypeNode(getterTypeAnnotation); } @@ -30988,8 +31128,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 155 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 156 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 157 /* SetAccessor */); if (getter && ts.isInJavaScriptFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -30997,7 +31137,7 @@ var ts; } } if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; + return errorType; } var type = void 0; // First try to see if the user specified a return type on the get-accessor. @@ -31034,7 +31174,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 155 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); error(getter_1, 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)); } } @@ -31044,16 +31184,33 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 1081344 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 2162688 /* TypeVariable */ ? baseConstructorType : undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { + var jsDeclaration = ts.getDeclarationOfJSInitializer(symbol.valueDeclaration); + if (jsDeclaration) { + var jsSymbol = getSymbolOfNode(jsDeclaration); + if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { + symbol = cloneSymbol(symbol); + // note:we overwrite links because we just cloned the symbol + links = symbol; + if (ts.hasEntries(jsSymbol.exports)) { + symbol.exports = symbol.exports || ts.createSymbolTable(); + mergeSymbolTable(symbol.exports, jsSymbol.exports); + } + if (ts.hasEntries(jsSymbol.members)) { + symbol.members = symbol.members || ts.createSymbolTable(); + mergeSymbolTable(symbol.members, jsSymbol.members); + } + } + } if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 199 /* BinaryExpression */ || - symbol.valueDeclaration.kind === 184 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 199 /* BinaryExpression */) { + else if (symbol.valueDeclaration.kind === 200 /* BinaryExpression */ || + symbol.valueDeclaration.kind === 185 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 200 /* BinaryExpression */) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -31087,7 +31244,7 @@ var ts; // up recursively calling getTypeOfAlias, causing a stack overflow. links.type = targetSymbol.flags & 67216319 /* Value */ ? getTypeOfSymbol(targetSymbol) - : unknownType; + : errorType; } return links.type; } @@ -31096,11 +31253,11 @@ var ts; if (!links.type) { if (symbolInstantiationDepth === 100) { error(symbol.valueDeclaration, ts.Diagnostics.Generic_type_instantiation_is_excessively_deep_and_possibly_infinite); - links.type = unknownType; + links.type = errorType; } else { if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; + return errorType; } symbolInstantiationDepth++; var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); @@ -31117,7 +31274,7 @@ var ts; // Check if variable has type annotation that circularly references the variable itself if (ts.getEffectiveTypeAnnotationNode(symbol.valueDeclaration)) { error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); - return unknownType; + return errorType; } // Otherwise variable has initializer that circularly references the variable itself if (noImplicitAny) { @@ -31147,7 +31304,7 @@ var ts; if (symbol.flags & 2097152 /* Alias */) { return getTypeOfAlias(symbol); } - return unknownType; + return errorType; } function isReferenceToType(type, target) { return type !== undefined @@ -31158,16 +31315,18 @@ var ts; function getTargetType(type) { return ts.getObjectFlags(type) & 4 /* Reference */ ? type.target : type; } + // TODO: GH#18217 If `checkBase` is undefined, we should not call this because this will always return false. function hasBaseType(type, checkBase) { return check(type); function check(type) { if (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 262144 /* Intersection */) { - return ts.forEach(type.types, check); + else if (type.flags & 524288 /* Intersection */) { + return ts.some(type.types, check); } + return false; } } // Appends the type parameters given by a list of declarations to a set of type parameters and returns the resulting set. @@ -31183,40 +31342,40 @@ var ts; // Return the outer type parameters of a node or undefined if the node has no outer type parameters. function getOuterTypeParameters(node, includeThisTypes) { while (true) { - node = node.parent; + node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead if (!node) { return undefined; } switch (node.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 152 /* MethodSignature */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 283 /* JSDocFunctionType */: - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 236 /* TypeAliasDeclaration */: - case 295 /* JSDocTemplateTag */: - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: - case 176 /* MappedType */: - case 170 /* ConditionalType */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 153 /* MethodSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 284 /* JSDocFunctionType */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 237 /* TypeAliasDeclaration */: + case 296 /* JSDocTemplateTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 177 /* MappedType */: + case 171 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 176 /* MappedType */) { + if (node.kind === 177 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 170 /* ConditionalType */) { + else if (node.kind === 171 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 234 /* ClassDeclaration */ || node.kind === 204 /* ClassExpression */ || node.kind === 235 /* InterfaceDeclaration */) && + (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */ || node.kind === 236 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -31224,7 +31383,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 235 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 236 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -31233,9 +31392,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 235 /* InterfaceDeclaration */ || - node.kind === 234 /* ClassDeclaration */ || - node.kind === 204 /* ClassExpression */ || + if (node.kind === 236 /* InterfaceDeclaration */ || + node.kind === 235 /* ClassDeclaration */ || + node.kind === 205 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -31262,9 +31421,9 @@ var ts; if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } - if (type.flags & 1081344 /* TypeVariable */) { + if (type.flags & 2162688 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } return false; } @@ -31306,25 +31465,25 @@ var ts; return type.resolvedBaseConstructorType = undefinedType; } if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { - return unknownType; + return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); if (extended && baseTypeNode !== extended) { ts.Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag checkExpression(extended.expression); } - if (baseConstructorType.flags & (65536 /* Object */ | 262144 /* Intersection */)) { + if (baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */)) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); - return type.resolvedBaseConstructorType = unknownType; + return type.resolvedBaseConstructorType = errorType; } if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - return type.resolvedBaseConstructorType = unknownType; + return type.resolvedBaseConstructorType = errorType; } type.resolvedBaseConstructorType = baseConstructorType; } @@ -31352,7 +31511,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (65536 /* Object */ | 262144 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 1 /* Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -31380,7 +31539,7 @@ var ts; } baseType = getReturnTypeOfSignature(constructors[0]); } - if (baseType === unknownType) { + if (baseType === errorType) { return type.resolvedBaseTypes = ts.emptyArray; } if (!isValidBaseType(baseType)) { @@ -31396,7 +31555,7 @@ var ts; // (otherwise there'd be an error from hasBaseType) - this is fine, but `.members` should be reset // as `getIndexedAccessType` via `instantiateType` via `getTypeFromClassOrInterfaceReference` forces a // partial instantiation of the members without the base types fully resolved - type.members = undefined; + type.members = undefined; // TODO: GH#18217 } return type.resolvedBaseTypes = [baseType]; } @@ -31414,18 +31573,18 @@ var ts; // A valid base type is `any`, any non-generic object type or intersection of non-generic // object types. function isValidBaseType(type) { - return type.flags & (65536 /* Object */ | 134217728 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || - type.flags & 262144 /* Intersection */ && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + return !!(type.flags & (131072 /* Object */ | 16777216 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || + !!(type.flags & 524288 /* Intersection */) && !ts.some(type.types, function (t) { return !isValidBaseType(t); }); } 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 === 235 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 236 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); - if (baseType !== unknownType) { + if (baseType !== errorType) { if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === ts.emptyArray) { @@ -31457,7 +31616,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 235 /* InterfaceDeclaration */) { + if (declaration.kind === 236 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -31498,7 +31657,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(32768 /* TypeParameter */); + type.thisType = createType(65536 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; @@ -31512,14 +31671,14 @@ var ts; // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { - return unknownType; + return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 236 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 237 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. - var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType; + var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { @@ -31531,7 +31690,7 @@ var ts; } } else { - type = unknownType; + type = errorType; error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; @@ -31542,7 +31701,7 @@ var ts; if (expr.kind === 9 /* StringLiteral */) { return true; } - else if (expr.kind === 199 /* BinaryExpression */) { + else if (expr.kind === 200 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -31556,12 +31715,12 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 71 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -31575,7 +31734,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 237 /* EnumDeclaration */) { + if (declaration.kind === 238 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { @@ -31590,7 +31749,7 @@ var ts; return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 256 /* EnumLiteral */ && !(type.flags & 131072 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); @@ -31602,10 +31761,10 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 237 /* EnumDeclaration */) { + if (declaration.kind === 238 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); + var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); // TODO: GH#18217 getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; memberTypeList.push(memberType); } @@ -31613,14 +31772,14 @@ var ts; } if (memberTypeList.length) { var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 131072 /* Union */) { - enumType_1.flags |= 256 /* EnumLiteral */; + if (enumType_1.flags & 262144 /* Union */) { + enumType_1.flags |= 512 /* EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(16 /* Enum */); + var enumType = createType(32 /* Enum */); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -31637,7 +31796,7 @@ var ts; function getDeclaredTypeOfTypeParameter(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(32768 /* TypeParameter */); + var type = createType(65536 /* TypeParameter */); type.symbol = symbol; links.declaredType = type; } @@ -31651,7 +31810,7 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - return tryGetDeclaredTypeOfSymbol(symbol) || unknownType; + return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { @@ -31682,6 +31841,7 @@ var ts; function isThislessType(node) { switch (node.kind) { case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 137 /* StringKeyword */: case 134 /* NumberKeyword */: case 122 /* BooleanKeyword */: @@ -31691,11 +31851,11 @@ var ts; case 140 /* UndefinedKeyword */: case 95 /* NullKeyword */: case 131 /* NeverKeyword */: - case 177 /* LiteralType */: + case 178 /* LiteralType */: return true; - case 166 /* ArrayType */: + case 167 /* ArrayType */: return isThislessType(node.elementType); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -31720,7 +31880,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 154 /* Constructor */ || (returnType && isThislessType(returnType))) && + return (node.kind === 155 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -31736,12 +31896,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -31785,7 +31945,7 @@ var ts; * Indicates whether a type can be used as a late-bound name. */ function isTypeUsableAsLateBoundName(type) { - return !!(type.flags & 1120 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 2240 /* StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -31805,7 +31965,7 @@ var ts; */ function hasLateBindableName(node) { var name = ts.getNameOfDeclaration(node); - return name && isLateBindableName(name); + return !!name && isLateBindableName(name); } /** * Indicates whether a declaration has a dynamic name that cannot be late-bound. @@ -31823,12 +31983,13 @@ var ts; * Gets the symbolic name for a late-bound member from its type. */ function getLateBoundNameFromType(type) { - if (type.flags & 1024 /* UniqueESSymbol */) { + if (type.flags & 2048 /* UniqueESSymbol */) { return "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); } - if (type.flags & 96 /* StringOrNumberLiteral */) { + if (type.flags & 192 /* StringOrNumberLiteral */) { return ts.escapeLeadingUnderscores("" + type.value); } + return ts.Debug.fail(); } /** * Adds a declaration to a late-bound dynamic member. This performs the same function for @@ -31846,8 +32007,7 @@ var ts; symbol.declarations.push(member); } if (symbolFlags & 67216319 /* Value */) { - var valueDeclaration = symbol.valueDeclaration; - if (!valueDeclaration || valueDeclaration.kind !== member.kind) { + if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } } @@ -31991,7 +32151,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 262144 /* Intersection */) { + else if (type.flags & 524288 /* Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); })); } return needApparentType ? getApparentType(type) : type; @@ -32075,7 +32235,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJavaScriptFile(baseTypeNode); @@ -32147,6 +32307,7 @@ var ts; if (unionSignatures.length > 1) { var thisParameter = signature.thisParameter; if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { + // TODO: GH#18217 We tested that *some* has thisParameter and now act as if *all* do var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */); thisParameter = createSymbolWithType(signature.thisParameter, thisType); } @@ -32273,7 +32434,7 @@ var ts; if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (65536 /* Object */ | 262144 /* Intersection */ | 1081344 /* TypeVariable */)) { + if (baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 2162688 /* TypeVariable */)) { members = ts.createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -32334,7 +32495,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 32 /* StringLiteral */ : 1120 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 64 /* StringLiteral */ : 2240 /* StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { @@ -32352,8 +32513,8 @@ var ts; // First, if the constraint type is a type parameter, obtain the base constraint. Then, // if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. // Finally, iterate over the constituents of the resulting iteration type. - var keyType = constraintType.flags & 7372800 /* InstantiableNonPrimitive */ ? getApparentType(constraintType) : constraintType; - var iterationType = keyType.flags & 524288 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType; + var keyType = constraintType.flags & 14745600 /* InstantiableNonPrimitive */ ? getApparentType(constraintType) : constraintType; + var iterationType = keyType.flags & 1048576 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); @@ -32365,7 +32526,7 @@ var ts; var propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. // Otherwise, for type string create a string index signature. - if (t.flags & 1120 /* StringOrNumberLiteralOrUnique */) { + if (t.flags & 2240 /* StringOrNumberLiteralOrUnique */) { var propName = getLateBoundNameFromType(t); var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || @@ -32386,10 +32547,10 @@ var ts; prop.nameType = t; members.set(propName, prop); } - else if (t.flags & (1 /* Any */ | 2 /* String */)) { + else if (t.flags & (1 /* Any */ | 4 /* String */)) { stringIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1 /* IncludeReadonly */)); } - else if (t.flags & 4 /* Number */) { + else if (t.flags & 8 /* Number */) { numberIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1 /* IncludeReadonly */)); } } @@ -32400,20 +32561,20 @@ var ts; } function getConstraintTypeFromMappedType(type) { return type.constraintType || - (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || unknownType); + (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || errorType); } function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper || identityMapper) : - unknownType); + errorType); } function getConstraintDeclarationForMappedType(type) { return type.declaration.typeParameter.constraint; } function isMappedTypeWithKeyofConstraintDeclaration(type) { - var constraintDeclaration = getConstraintDeclarationForMappedType(type); - return constraintDeclaration.kind === 174 /* TypeOperator */ && + var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 + return constraintDeclaration.kind === 175 /* TypeOperator */ && constraintDeclaration.operator === 128 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -32430,8 +32591,8 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is {}. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 32768 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 524288 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 1048576 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -32454,11 +32615,11 @@ var ts; return !!(ts.getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */); } function isGenericMappedType(type) { - return ts.getObjectFlags(type) & 32 /* Mapped */ && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { if (type.objectFlags & 4 /* Reference */) { resolveTypeReferenceMembers(type); } @@ -32475,10 +32636,10 @@ var ts; resolveMappedTypeMembers(type); } } - else if (type.flags & 131072 /* Union */) { + else if (type.flags & 262144 /* Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 262144 /* Intersection */) { + else if (type.flags & 524288 /* Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -32486,7 +32647,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -32495,7 +32656,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -32519,7 +32680,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { break; } } @@ -32529,13 +32690,13 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 393216 /* UnionOrIntersection */ ? + return type.flags & 786432 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 131072 /* Union */)) { + if (!(unionType.flags & 262144 /* Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -32554,9 +32715,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 32768 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 1048576 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 2097152 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 2097152 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 4194304 /* Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -32566,12 +32727,12 @@ var ts; var objectType = getBaseConstraintOfType(type.objectType) || type.objectType; var indexType = getBaseConstraintOfType(type.indexType) || type.indexType; var constraint = !isGenericObjectType(objectType) && !isGenericIndexType(indexType) ? getIndexedAccessType(objectType, indexType) : undefined; - return constraint && constraint !== unknownType ? constraint : undefined; + return constraint && constraint !== errorType ? constraint : undefined; } function getDefaultConstraintOfConditionalType(type) { if (!type.resolvedDefaultConstraint) { var rootTrueType = type.root.trueType; - var rootTrueConstraint = rootTrueType.flags & 4194304 /* Substitution */ ? rootTrueType.substitute : rootTrueType; + var rootTrueConstraint = rootTrueType.flags & 8388608 /* Substitution */ ? rootTrueType.substitute : rootTrueType; type.resolvedDefaultConstraint = getUnionType([instantiateType(rootTrueConstraint, type.combinedMapper || type.mapper), getFalseTypeFromConditionalType(type)]); } return type.resolvedDefaultConstraint; @@ -32587,7 +32748,7 @@ var ts; if (constraint) { var mapper = makeUnaryTypeMapper(type.root.checkType, constraint); var instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper)); - if (!(instantiated.flags & 16384 /* Never */)) { + if (!(instantiated.flags & 32768 /* Never */)) { return instantiated; } } @@ -32602,23 +32763,23 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 7897088 /* Instantiable */) { + if (t.flags & 15794176 /* Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (32768 /* TypeParameter */ | 524288 /* Index */ | 2097152 /* Conditional */)) { + while (constraint && constraint.flags & (65536 /* TypeParameter */ | 1048576 /* Index */ | 4194304 /* Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { // A constraint that isn't a union type implies that the final type would be a non-union // type as well. Since non-union constraints are of no interest, we can exit here. - if (!(constraint.flags & 131072 /* Union */)) { + if (!(constraint.flags & 262144 /* Union */)) { return undefined; } constraints = ts.append(constraints, constraint); } } - else if (t.flags & 134233854 /* DisjointDomains */) { + else if (t.flags & 16809468 /* DisjointDomains */) { hasDisjointDomainType = true; } } @@ -32630,7 +32791,7 @@ var ts; // intersection operation to reduce the union constraints. for (var _b = 0, _c = type.types; _b < _c.length; _b++) { var t = _c[_b]; - if (t.flags & 134233854 /* DisjointDomains */) { + if (t.flags & 16809468 /* DisjointDomains */) { constraints = ts.append(constraints, t); } } @@ -32640,7 +32801,7 @@ var ts; return undefined; } function getBaseConstraintOfInstantiableNonPrimitiveUnionOrIntersection(type) { - if (type.flags & (7372800 /* InstantiableNonPrimitive */ | 393216 /* UnionOrIntersection */)) { + if (type.flags & (14745600 /* InstantiableNonPrimitive */ | 786432 /* UnionOrIntersection */)) { var constraint = getResolvedBaseConstraint(type); if (constraint !== noConstraintType && constraint !== circularConstraintType) { return constraint; @@ -32649,7 +32810,7 @@ var ts; } function getBaseConstraintOfType(type) { var constraint = getBaseConstraintOfInstantiableNonPrimitiveUnionOrIntersection(type); - if (!constraint && type.flags & 524288 /* Index */) { + if (!constraint && type.flags & 1048576 /* Index */) { return keyofConstraintType; } return constraint; @@ -32689,13 +32850,13 @@ var ts; return result; } function computeBaseConstraint(t) { - if (t.flags & 32768 /* TypeParameter */) { + if (t.flags & 65536 /* TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 393216 /* UnionOrIntersection */) { + if (t.flags & 786432 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { @@ -32705,24 +32866,24 @@ var ts; baseTypes.push(baseType); } } - return t.flags & 131072 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 262144 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 262144 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 524288 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 524288 /* Index */) { + if (t.flags & 1048576 /* Index */) { return keyofConstraintType; } - if (t.flags & 1048576 /* IndexedAccess */) { + if (t.flags & 2097152 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; - return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + return baseIndexedAccess && baseIndexedAccess !== errorType ? getBaseConstraint(baseIndexedAccess) : undefined; } - if (t.flags & 2097152 /* Conditional */) { + if (t.flags & 4194304 /* Conditional */) { var constraint = getConstraintOfConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 4194304 /* Substitution */) { + if (t.flags & 8388608 /* Substitution */) { return getBaseConstraint(t.substitute); } if (isGenericMappedType(t)) { @@ -32783,19 +32944,19 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - var t = type.flags & 7897088 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; - return t.flags & 262144 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 34 /* StringLike */ ? globalStringType : - t.flags & 84 /* NumberLike */ ? globalNumberType : - t.flags & 136 /* BooleanLike */ ? globalBooleanType : - t.flags & 1536 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : - t.flags & 134217728 /* NonPrimitive */ ? emptyObjectType : - t.flags & 524288 /* Index */ ? keyofConstraintType : + var t = type.flags & 15794176 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 524288 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 68 /* StringLike */ ? globalStringType : + t.flags & 168 /* NumberLike */ ? globalNumberType : + t.flags & 272 /* BooleanLike */ ? globalBooleanType : + t.flags & 3072 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : + t.flags & 16777216 /* NonPrimitive */ ? emptyObjectType : + t.flags & 1048576 /* Index */ ? keyofConstraintType : t; } function createUnionOrIntersectionProperty(containingType, name) { var props; - var isUnion = containingType.flags & 131072 /* Union */; + var isUnion = containingType.flags & 262144 /* Union */; var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols var commonFlags = isUnion ? 0 /* None */ : 16777216 /* Optional */; @@ -32804,7 +32965,7 @@ var ts; for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var current = _a[_i]; var type = getApparentType(current); - if (type !== unknownType) { + if (type !== errorType) { var prop = getPropertyOfType(type, name); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop && !(modifiers & excludeModifiers)) { @@ -32900,7 +33061,7 @@ var ts; */ function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -32914,13 +33075,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 393216 /* UnionOrIntersection */) { + if (type.flags & 786432 /* UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 458752 /* StructuredType */) { + if (type.flags & 917504 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -32934,7 +33095,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 458752 /* StructuredType */) { + if (type.flags & 917504 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -32990,10 +33151,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJavaScriptFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 282 /* JSDocOptionalType */ + node.type && node.type.kind === 283 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 282 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -33027,7 +33188,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 282 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -33061,14 +33222,6 @@ var ts; } return minTypeArgumentCount; } - /** - * Fill in default types for unsupplied type arguments. If `typeArguments` is undefined - * when a default type is supplied, a new array will be created and returned. - * - * @param typeArguments The supplied type arguments. - * @param typeParameters The requested type parameters. - * @param minTypeArgumentCount The minimum number of required type arguments. - */ function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) { var numTypeParameters = ts.length(typeParameters); if (numTypeParameters) { @@ -33103,7 +33256,7 @@ var ts; var hasLiteralTypes = false; var minArgumentCount = 0; var thisParameter = void 0; - var hasThisParameter = void 0; + var hasThisParameter = false; var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); var isUntypedSignatureInJSFile = !iife && @@ -33130,7 +33283,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 177 /* LiteralType */) { + if (type && type.kind === 178 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -33144,16 +33297,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 === 155 /* GetAccessor */ || declaration.kind === 156 /* SetAccessor */) && + if ((declaration.kind === 156 /* GetAccessor */ || declaration.kind === 157 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 155 /* GetAccessor */ ? 156 /* SetAccessor */ : 155 /* GetAccessor */; + var otherKind = declaration.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 154 /* Constructor */ ? + var classType = declaration.kind === 155 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -33190,7 +33343,7 @@ var ts; } function getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType) { if (isJSConstructSignature) { - return getTypeFromTypeNode(declaration.parameters[0].type); + return getTypeFromTypeNode(declaration.parameters[0].type); // TODO: GH#18217 } else if (classType) { return classType; @@ -33201,8 +33354,8 @@ var ts; } // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 155 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 156 /* SetAccessor */); + if (declaration.kind === 156 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 157 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -33226,14 +33379,14 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - return node.name.kind === 146 /* ComputedPropertyName */ + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + return node.name.kind === 147 /* ComputedPropertyName */ && traverse(node.name); default: - return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && ts.forEachChild(node, traverse); + return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); } } } @@ -33243,19 +33396,18 @@ var ts; var result = []; for (var i = 0; i < symbol.declarations.length; i++) { var decl = symbol.declarations[i]; - var node = ts.isPropertyAccessExpression(decl) ? ts.getAssignedJavascriptInitializer(decl) : decl; - if (!ts.isFunctionLike(node)) + if (!ts.isFunctionLike(decl)) continue; // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). - if (i > 0 && node.body) { + if (i > 0 && decl.body) { var previous = symbol.declarations[i - 1]; - if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { + if (decl.parent === previous.parent && decl.kind === previous.kind && decl.pos === previous.end) { continue; } } - result.push(getSignatureFromDeclaration(node)); + result.push(getSignatureFromDeclaration(decl)); } return result; } @@ -33288,7 +33440,7 @@ var ts; } else { var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 160 /* TypePredicate */ ? + signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : noTypePredicate; } @@ -33299,7 +33451,7 @@ var ts; function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { - return unknownType; + return errorType; } var type = void 0; if (signature.target) { @@ -33333,7 +33485,7 @@ var ts; } function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); + var type = getTypeOfSymbol(ts.last(signature.parameters)); if (ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType) { return type.typeArguments[0]; } @@ -33394,7 +33546,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 154 /* Constructor */ || signature.declaration.kind === 158 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 155 /* Constructor */ || signature.declaration.kind === 159 /* ConstructSignature */; // TODO: GH#18217 var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -33435,7 +33587,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 147 /* TypeParameter */); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 148 /* TypeParameter */); return decl && decl.constraint; } function getInferredTypeParameterConstraint(typeParameter) { @@ -33447,7 +33599,7 @@ var ts; // (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. - if (declaration.parent.kind === 171 /* InferType */ && declaration.parent.parent.kind === 161 /* TypeReference */) { + if (declaration.parent.kind === 172 /* InferType */ && declaration.parent.parent.kind === 162 /* TypeReference */) { var typeReference = declaration.parent.parent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -33489,7 +33641,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 147 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 148 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; @@ -33526,7 +33678,7 @@ var ts; result |= type.flags; } } - return result & 117440512 /* PropagatingFlags */; + return result & 939524096 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -33563,7 +33715,7 @@ var ts; var isJs = ts.isInJavaScriptFile(node); var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { - var missingAugmentsTag = isJs && node.parent.kind !== 289 /* JSDocAugmentsTag */; + var missingAugmentsTag = isJs && node.parent.kind !== 290 /* JSDocAugmentsTag */; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -33575,7 +33727,7 @@ var ts; error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) - return unknownType; + return errorType; } } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -33584,7 +33736,7 @@ var ts; var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } - return checkNoTypeArguments(node, symbol) ? type : unknownType; + return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeAliasInstantiation(symbol, typeArguments) { var type = getDeclaredTypeOfSymbol(symbol); @@ -33612,17 +33764,17 @@ var ts; error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); - return unknownType; + return errorType; } return getTypeAliasInstantiation(symbol, typeArguments); } - return checkNoTypeArguments(node, symbol) ? type : unknownType; + return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return node.typeName; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -33642,7 +33794,7 @@ var ts; function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { - return unknownType; + return errorType; } var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); if (type) { @@ -33652,11 +33804,11 @@ var ts; var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { return checkNoTypeArguments(node, symbol) ? - res.flags & 32768 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : res : - unknownType; + res.flags & 65536 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : res : + errorType; } if (!(symbol.flags & 67216319 /* Value */ && isJSDocTypeReference(node))) { - return unknownType; + return errorType; } var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); if (jsdocType) { @@ -33676,7 +33828,8 @@ var ts; var valueType = getTypeOfSymbol(symbol); var referenceType = valueType.symbol && valueType.symbol !== symbol && !isInferredClassType(valueType) && getTypeReferenceTypeWorker(node, valueType.symbol, typeArguments); if (referenceType || assignedType) { - return referenceType && assignedType ? getIntersectionType([assignedType, referenceType]) : referenceType || assignedType; + // TODO: GH#18217 (should the `|| assignedType` be at a lower precedence?) + return (referenceType && assignedType ? getIntersectionType([assignedType, referenceType]) : referenceType || assignedType); } } function getTypeReferenceTypeWorker(node, symbol, typeArguments) { @@ -33699,13 +33852,13 @@ var ts; } } function getSubstitutionType(typeVariable, substitute) { - var result = createType(4194304 /* Substitution */); + var result = createType(8388608 /* Substitution */); result.typeVariable = typeVariable; result.substitute = substitute; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 167 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 168 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -33714,9 +33867,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 285 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 286 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 170 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 171 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -33727,7 +33880,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return node.flags & 2097152 /* JSDoc */ && node.kind === 161 /* TypeReference */; + return !!(node.flags & 2097152 /* JSDoc */) && node.kind === 162 /* TypeReference */; } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -33774,7 +33927,7 @@ var ts; var indexed = getTypeFromTypeNode(typeArgs[0]); var target = getTypeFromTypeNode(typeArgs[1]); var index = createIndexInfo(target, /*isReadonly*/ false); - return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType && index, indexed === numberType && index); + return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType ? index : undefined, indexed === numberType ? index : undefined); } return anyType; } @@ -33785,7 +33938,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 8192 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 16384 /* Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -33828,9 +33981,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: return declaration; } } @@ -33839,7 +33992,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 65536 /* Object */)) { + if (!(type.flags & 131072 /* Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -33911,7 +34064,7 @@ var ts; return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { - return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); + return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 } /** * Instantiates a global type that is generic with some element type, and returns that instantiation. @@ -33955,7 +34108,7 @@ var ts; var typeParameters = []; var properties = []; for (var i = 0; i < arity; i++) { - var typeParameter = createType(32768 /* TypeParameter */); + var typeParameter = createType(65536 /* TypeParameter */); typeParameters.push(typeParameter); var property = createSymbol(4 /* Property */, "" + i); property.type = typeParameter; @@ -33972,7 +34125,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(32768 /* TypeParameter */); + type.thisType = createType(65536 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; @@ -34013,16 +34166,16 @@ var ts; var combined = 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 13536 /* Unit */ && combined & 13536 /* Unit */) { + if (t.flags & 27072 /* Unit */ && combined & 27072 /* Unit */) { return true; } combined |= t.flags; - if (combined & 12288 /* Nullable */ && combined & (65536 /* Object */ | 134217728 /* NonPrimitive */) || - combined & 134217728 /* NonPrimitive */ && combined & (134233854 /* DisjointDomains */ & ~134217728 /* NonPrimitive */) || - combined & 34 /* StringLike */ && combined & (134233854 /* DisjointDomains */ & ~34 /* StringLike */) || - combined & 84 /* NumberLike */ && combined & (134233854 /* DisjointDomains */ & ~84 /* NumberLike */) || - combined & 1536 /* ESSymbolLike */ && combined & (134233854 /* DisjointDomains */ & ~1536 /* ESSymbolLike */) || - combined & 6144 /* VoidLike */ && combined & (134233854 /* DisjointDomains */ & ~6144 /* VoidLike */)) { + if (combined & 24576 /* Nullable */ && combined & (131072 /* Object */ | 16777216 /* NonPrimitive */) || + combined & 16777216 /* NonPrimitive */ && combined & (16809468 /* DisjointDomains */ & ~16777216 /* NonPrimitive */) || + combined & 68 /* StringLike */ && combined & (16809468 /* DisjointDomains */ & ~68 /* StringLike */) || + combined & 168 /* NumberLike */ && combined & (16809468 /* DisjointDomains */ & ~168 /* NumberLike */) || + combined & 3072 /* ESSymbolLike */ && combined & (16809468 /* DisjointDomains */ & ~3072 /* ESSymbolLike */) || + combined & 12288 /* VoidLike */ && combined & (16809468 /* DisjointDomains */ & ~12288 /* VoidLike */)) { return true; } } @@ -34030,28 +34183,28 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 131072 /* Union */) { + if (flags & 262144 /* Union */) { return addTypesToUnion(typeSet, includes, type.types); } // We ignore 'never' types in unions. Likewise, we ignore intersections of unit types as they are // another form of 'never' (in that they have an empty value domain). We could in theory turn // intersections of unit types into 'never' upon construction, but deferring the reduction makes it // easier to reason about their origin. - if (!(flags & 16384 /* Never */ || flags & 262144 /* Intersection */ && isEmptyIntersectionType(type))) { - includes |= flags & ~117440512 /* ConstructionFlags */; - if (flags & 1 /* Any */) { + if (!(flags & 32768 /* Never */ || flags & 524288 /* Intersection */ && isEmptyIntersectionType(type))) { + includes |= flags & ~939524096 /* ConstructionFlags */; + if (flags & 3 /* AnyOrUnknown */) { if (type === wildcardType) - includes |= 33554432 /* Wildcard */; + includes |= 268435456 /* Wildcard */; } - else if (!strictNullChecks && flags & 12288 /* Nullable */) { - if (!(flags & 16777216 /* ContainsWideningType */)) - includes |= 16777216 /* NonWideningType */; + else if (!strictNullChecks && flags & 24576 /* Nullable */) { + if (!(flags & 134217728 /* ContainsWideningType */)) + includes |= 134217728 /* NonWideningType */; } else { var len = typeSet.length; var index = len && type.id > typeSet[len - 1].id ? ~len : ts.binarySearch(typeSet, type, getTypeId, ts.compareValues); if (index < 0) { - if (!(flags & 65536 /* Object */ && type.objectFlags & 16 /* Anonymous */ && + if (!(flags & 131072 /* Object */ && type.objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */) && containsIdenticalType(typeSet, type))) { typeSet.splice(~index, 0, type); } @@ -34091,11 +34244,11 @@ var ts; } function isSetOfLiteralsFromSameEnum(types) { var first = types[0]; - if (first.flags & 256 /* EnumLiteral */) { + if (first.flags & 512 /* EnumLiteral */) { var firstEnum = getParentOfSymbol(first.symbol); for (var i = 1; i < types.length; i++) { var other = types[i]; - if (!(other.flags & 256 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { + if (!(other.flags & 512 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { return false; } } @@ -34120,10 +34273,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 32 /* StringLiteral */ && includes & 2 /* String */ || - t.flags & 64 /* NumberLiteral */ && includes & 4 /* Number */ || - t.flags & 1024 /* UniqueESSymbol */ && includes & 512 /* ESSymbol */ || - t.flags & 96 /* StringOrNumberLiteral */ && t.flags & 8388608 /* FreshLiteral */ && containsType(types, t.regularType); + var remove = t.flags & 64 /* StringLiteral */ && includes & 4 /* String */ || + t.flags & 128 /* NumberLiteral */ && includes & 8 /* Number */ || + t.flags & 2048 /* UniqueESSymbol */ && includes & 1024 /* ESSymbol */ || + t.flags & 192 /* StringOrNumberLiteral */ && t.flags & 33554432 /* FreshLiteral */ && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -34146,12 +34299,12 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (includes & 1 /* Any */) { - return includes & 33554432 /* Wildcard */ ? wildcardType : anyType; + if (includes & 3 /* AnyOrUnknown */) { + return includes & 1 /* Any */ ? includes & 268435456 /* Wildcard */ ? wildcardType : anyType : unknownType; } switch (unionReduction) { case 1 /* Literal */: - if (includes & 1120 /* StringOrNumberLiteralOrUnique */) { + if (includes & 2240 /* StringOrNumberLiteralOrUnique */) { removeRedundantLiteralTypes(typeSet, includes); } break; @@ -34160,11 +34313,11 @@ var ts; break; } if (typeSet.length === 0) { - return includes & 8192 /* Null */ ? includes & 16777216 /* NonWideningType */ ? nullType : nullWideningType : - includes & 4096 /* Undefined */ ? includes & 16777216 /* NonWideningType */ ? undefinedType : undefinedWideningType : + return includes & 16384 /* Null */ ? includes & 134217728 /* NonWideningType */ ? nullType : nullWideningType : + includes & 8192 /* Undefined */ ? includes & 134217728 /* NonWideningType */ ? undefinedType : undefinedWideningType : neverType; } - return getUnionTypeFromSortedList(typeSet, includes & 8374815 /* NotUnit */ ? 0 : 268435456 /* UnionOfUnitTypes */, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, includes & 16749629 /* NotUnit */ ? 0 : 67108864 /* UnionOfUnitTypes */, aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -34211,8 +34364,8 @@ var ts; var id = getTypeListId(types); var type = unionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 12288 /* Nullable */); - type = createType(131072 /* Union */ | propagatedFlags | unionOfUnitTypes); + var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 24576 /* Nullable */); + type = createType(262144 /* Union */ | propagatedFlags | unionOfUnitTypes); unionTypes.set(id, type); type.types = types; /* @@ -34236,20 +34389,20 @@ var ts; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 262144 /* Intersection */) { + if (flags & 524288 /* Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } if (ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type)) { - includes |= 67108864 /* EmptyObject */; + includes |= 536870912 /* EmptyObject */; } else { - includes |= flags & ~117440512 /* ConstructionFlags */; - if (flags & 1 /* Any */) { + includes |= flags & ~939524096 /* ConstructionFlags */; + if (flags & 3 /* AnyOrUnknown */) { if (type === wildcardType) - includes |= 33554432 /* Wildcard */; + includes |= 268435456 /* Wildcard */; } - else if ((strictNullChecks || !(flags & 12288 /* Nullable */)) && !ts.contains(typeSet, type) && - !(flags & 65536 /* Object */ && type.objectFlags & 16 /* Anonymous */ && + else if ((strictNullChecks || !(flags & 24576 /* Nullable */)) && !ts.contains(typeSet, type) && + !(flags & 131072 /* Object */ && type.objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */) && containsIdenticalType(typeSet, type))) { typeSet.push(type); @@ -34271,9 +34424,9 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 2 /* String */ && includes & 32 /* StringLiteral */ || - t.flags & 4 /* Number */ && includes & 64 /* NumberLiteral */ || - t.flags & 512 /* ESSymbol */ && includes & 1024 /* UniqueESSymbol */; + var remove = t.flags & 4 /* String */ && includes & 64 /* StringLiteral */ || + t.flags & 8 /* Number */ && includes & 128 /* NumberLiteral */ || + t.flags & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -34283,13 +34436,13 @@ var ts; // Here we remove all unions of unit types from the given list and replace them with a // a single union containing an intersection of the unit types. function intersectUnionsOfUnitTypes(types) { - var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 268435456 /* UnionOfUnitTypes */) !== 0; }); + var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 67108864 /* UnionOfUnitTypes */) !== 0; }); var unionType = types[unionIndex]; var intersection = unionType.types; var i = types.length - 1; var _loop_5 = function () { var t = types[i]; - if (t.flags & 268435456 /* UnionOfUnitTypes */) { + if (t.flags & 67108864 /* UnionOfUnitTypes */) { intersection = ts.filter(intersection, function (u) { return containsType(t.types, u); }); ts.orderedRemoveItemAt(types, i); } @@ -34301,7 +34454,7 @@ var ts; if (intersection === unionType.types) { return false; } - types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 268435456 /* UnionOfUnitTypes */); + types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 67108864 /* UnionOfUnitTypes */); return true; } // We normalize combinations of intersection and union types based on the distributive property of the '&' @@ -34315,30 +34468,33 @@ var ts; // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution // for intersections of types with signatures can be deterministic. function getIntersectionType(types, aliasSymbol, aliasTypeArguments) { - if (types.length === 0) { - return emptyObjectType; - } var typeSet = []; var includes = addTypesToIntersection(typeSet, 0, types); - if (includes & 16384 /* Never */) { + if (includes & 32768 /* Never */) { return neverType; } if (includes & 1 /* Any */) { - return includes & 33554432 /* Wildcard */ ? wildcardType : anyType; + return includes & 268435456 /* Wildcard */ ? wildcardType : anyType; } - if (includes & 2 /* String */ && includes & 32 /* StringLiteral */ || - includes & 4 /* Number */ && includes & 64 /* NumberLiteral */ || - includes & 512 /* ESSymbol */ && includes & 1024 /* UniqueESSymbol */) { + if (!strictNullChecks && includes & 24576 /* Nullable */) { + return includes & 8192 /* Undefined */ ? undefinedType : nullType; + } + if (includes & 4 /* String */ && includes & 64 /* StringLiteral */ || + includes & 8 /* Number */ && includes & 128 /* NumberLiteral */ || + includes & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 67108864 /* EmptyObject */ && !(includes & 65536 /* Object */)) { + if (includes & 536870912 /* EmptyObject */ && !(includes & 131072 /* Object */)) { typeSet.push(emptyObjectType); } + if (typeSet.length === 0) { + return unknownType; + } if (typeSet.length === 1) { return typeSet[0]; } - if (includes & 131072 /* Union */) { - if (includes & 268435456 /* UnionOfUnitTypes */ && intersectUnionsOfUnitTypes(typeSet)) { + if (includes & 262144 /* Union */) { + if (includes & 67108864 /* UnionOfUnitTypes */ && intersectUnionsOfUnitTypes(typeSet)) { // When the intersection creates a reduced set (which might mean that *all* union types have // disappeared), we restart the operation to get a new set of combined flags. Once we have // reduced we'll never reduce again, so this occurs at most once. @@ -34346,15 +34502,15 @@ var ts; } // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. - var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 131072 /* Union */) !== 0; }); + var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 262144 /* Union */) !== 0; }); var unionType = typeSet[unionIndex_1]; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); var type = intersectionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 12288 /* Nullable */); - type = createType(262144 /* Intersection */ | propagatedFlags); + var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 24576 /* Nullable */); + type = createType(524288 /* Intersection */ | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. @@ -34371,7 +34527,7 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(524288 /* Index */); + var result = createType(1048576 /* Index */); result.type = type; result.stringsOnly = stringsOnly; return result; @@ -34387,7 +34543,7 @@ var ts; if (!type && !ts.isKnownSymbol(prop)) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : - name && name.kind === 146 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : + name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); } if (type && type.flags & include) { @@ -34405,16 +34561,16 @@ var ts; } function getIndexType(type, stringsOnly) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } - return type.flags & 131072 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - type.flags & 262144 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - maybeTypeOfKind(type, 7372800 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : + return type.flags & 262144 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + type.flags & 524288 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 /* Mapped */ ? getConstraintTypeFromMappedType(type) : type === wildcardType ? wildcardType : type.flags & 1 /* Any */ ? keyofConstraintType : - stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromPropertyNames(type, 32 /* StringLiteral */) : - getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 1024 /* UniqueESSymbol */)]) : - getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 32 /* StringLiteral */ | 1024 /* UniqueESSymbol */)]) : - getLiteralTypeFromPropertyNames(type, 1120 /* StringOrNumberLiteralOrUnique */); + stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */) : + getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 2048 /* UniqueESSymbol */)]) : + getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */ | 2048 /* UniqueESSymbol */)]) : + getLiteralTypeFromPropertyNames(type, 2240 /* StringOrNumberLiteralOrUnique */); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -34425,7 +34581,7 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 16384 /* Never */ ? stringType : indexType; + return indexType.flags & 32768 /* Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); @@ -34437,20 +34593,20 @@ var ts; case 141 /* UniqueKeyword */: links.resolvedType = node.type.kind === 138 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) - : unknownType; + : errorType; break; } } - return links.resolvedType; + return links.resolvedType; // TODO: GH#18217 } function createIndexedAccessType(objectType, indexType) { - var type = createType(1048576 /* IndexedAccess */); + var type = createType(2097152 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 185 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -34462,7 +34618,7 @@ var ts; markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 99 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); - return unknownType; + return errorType; } if (cacheSymbol) { getNodeLinks(accessNode).resolvedSymbol = prop; @@ -34471,16 +34627,16 @@ var ts; return getTypeOfSymbol(prop); } } - if (!(indexType.flags & 12288 /* Nullable */) && isTypeAssignableToKind(indexType, 34 /* StringLike */ | 84 /* NumberLike */ | 1536 /* ESSymbolLike */)) { + if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { if (isTypeAny(objectType)) { return objectType; } - var indexInfo = isTypeAssignableToKind(indexType, 84 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(indexType, 168 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { - if (accessNode && !isTypeAssignableToKind(indexType, 2 /* String */ | 4 /* Number */)) { - var indexNode = accessNode.kind === 185 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -34488,7 +34644,7 @@ var ts; } return indexInfo.type; } - if (indexType.flags & 16384 /* Never */) { + if (indexType.flags & 32768 /* Never */) { return neverType; } if (accessExpression && !isConstEnumObjectType(objectType)) { @@ -34504,41 +34660,41 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 185 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; - if (indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */)) { + var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + if (indexType.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (2 /* String */ | 4 /* Number */)) { + else if (indexType.flags & (4 /* String */ | 8 /* Number */)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } } - return unknownType; + return errorType; } function isGenericObjectType(type) { - return maybeTypeOfKind(type, 7372800 /* InstantiableNonPrimitive */ | 536870912 /* GenericMappedType */); + return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 134217728 /* GenericMappedType */); } function isGenericIndexType(type) { - return maybeTypeOfKind(type, 7372800 /* InstantiableNonPrimitive */ | 524288 /* Index */); + return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 1048576 /* Index */); } // Return true if the given type is a non-generic object type with a string index signature and no // other members. function isStringIndexOnlyType(type) { - if (type.flags & 65536 /* Object */ && !isGenericMappedType(type)) { + if (type.flags & 131072 /* Object */ && !isGenericMappedType(type)) { var t = resolveStructuredTypeMembers(type); return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && - t.stringIndexInfo && !t.numberIndexInfo; + !!t.stringIndexInfo && !t.numberIndexInfo; } return false; } function isMappedTypeToNever(type) { - return ts.getObjectFlags(type) & 32 /* Mapped */ && getTemplateTypeFromMappedType(type) === neverType; + return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && getTemplateTypeFromMappedType(type) === neverType; } function getSimplifiedType(type) { - return type.flags & 1048576 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; + return type.flags & 2097152 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; } // Transform an indexed access to a simpler form, if possible. Return the simpler form, or return // the type itself if no transformation is possible. @@ -34547,8 +34703,10 @@ var ts; return type.simplified === circularConstraintType ? type : type.simplified; } type.simplified = circularConstraintType; - var objectType = type.objectType; - if (objectType.flags & 262144 /* Intersection */ && isGenericObjectType(objectType)) { + // We recursively simplify the object type as it may in turn be an indexed access type. For example, with + // '{ [P in T]: { [Q in U]: number } }[T][U]' we want to first simplify the inner indexed access type. + var objectType = getSimplifiedType(type.objectType); + if (objectType.flags & 524288 /* Intersection */ && isGenericObjectType(objectType)) { // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or // more object types with only a string index signature, e.g. '(U & V & { [x: string]: D })[K]', return a // transformed type of the form '(U & V)[K] | D'. This allows us to properly reason about higher order indexed @@ -34586,7 +34744,7 @@ var ts; if (isGenericMappedType(objectType)) { return type.simplified = substituteIndexedMappedType(objectType, type); } - if (objectType.flags & 32768 /* TypeParameter */) { + if (objectType.flags & 65536 /* TypeParameter */) { var constraint = getConstraintFromTypeParameter(objectType); if (constraint && isGenericMappedType(constraint)) { return type.simplified = substituteIndexedMappedType(constraint, type); @@ -34608,8 +34766,8 @@ var ts; // 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 === 185 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { - if (objectType.flags & 1 /* Any */) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 186 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. @@ -34624,13 +34782,13 @@ var ts; // We treat boolean as different from other unions to improve errors; // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getApparentType(objectType); - if (indexType.flags & 131072 /* Union */ && !(indexType.flags & 8 /* Boolean */)) { + if (indexType.flags & 262144 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { var propTypes = []; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; var propType = getPropertyTypeForIndexType(apparentObjectType, t, accessNode, /*cacheSymbol*/ false); - if (propType === unknownType) { - return unknownType; + if (propType === errorType) { + return errorType; } propTypes.push(propType); } @@ -34644,7 +34802,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var resolved = getIndexedAccessType(objectType, indexType, node); - links.resolvedType = resolved.flags & 1048576 /* IndexedAccess */ && + links.resolvedType = resolved.flags & 2097152 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConstrainedTypeVariable(resolved, node) : resolved; @@ -34666,7 +34824,7 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - return type.flags & 4194304 /* Substitution */ ? type.typeVariable : type; + return type.flags & 8388608 /* Substitution */ ? type.typeVariable : type; } function getConditionalType(root, mapper) { var checkType = instantiateType(root.checkType, mapper); @@ -34677,7 +34835,7 @@ var ts; // If this is a distributive conditional type and the check type is generic we need to defer // resolution of the conditional type such that a later instantiation will properly distribute // over union types. - var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 7897088 /* Instantiable */); + var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 15794176 /* Instantiable */); var combinedMapper; if (root.inferTypeParameters) { var context_1 = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */); @@ -34690,6 +34848,9 @@ var ts; combinedMapper = combineTypeMappers(mapper, context_1); } if (!isDeferred) { + if (extendsType.flags & 3 /* AnyOrUnknown */) { + return instantiateType(root.trueType, mapper); + } // Return union of trueType and falseType for 'any' since it matches anything if (checkType.flags & 1 /* Any */) { return getUnionType([instantiateType(root.trueType, combinedMapper || mapper), instantiateType(root.falseType, mapper)]); @@ -34713,14 +34874,14 @@ var ts; } // Return a deferred type for a check that is neither definitely true nor definitely false var erasedCheckType = getActualTypeVariable(checkType); - var result = createType(2097152 /* Conditional */); + var result = createType(4194304 /* Conditional */); result.root = root; result.checkType = erasedCheckType; result.extendsType = extendsType; result.mapper = mapper; result.combinedMapper = combinedMapper; result.aliasSymbol = root.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper); + result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 return result; } function getTrueTypeFromConditionalType(type) { @@ -34745,7 +34906,7 @@ var ts; return true; } while (node) { - if (node.kind === 170 /* ConditionalType */) { + if (node.kind === 171 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -34768,7 +34929,7 @@ var ts; extendsType: getTypeFromTypeNode(node.extendsType), trueType: getTypeFromTypeNode(node.trueType), falseType: getTypeFromTypeNode(node.falseType), - isDistributive: !!(checkType.flags & 32768 /* TypeParameter */), + isDistributive: !!(checkType.flags & 65536 /* TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -34804,12 +34965,12 @@ var ts; if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments error(node, ts.Diagnostics.Type_arguments_cannot_be_used_here); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } if (!ts.isLiteralImportTypeNode(node)) { error(node.argument, ts.Diagnostics.String_literal_expected); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } var argumentType = getTypeFromTypeNode(node.argument); var targetMeaning = node.isTypeOf ? 67216319 /* Value */ : 67901928 /* Type */; @@ -34818,7 +34979,7 @@ var ts; var innerModuleSymbol = resolveExternalModule(node, moduleName, ts.Diagnostics.Cannot_find_module_0, node, /*isForAugmentation*/ false); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } var moduleSymbol_1 = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false); if (!ts.nodeIsMissing(node.qualifier)) { @@ -34830,7 +34991,7 @@ var ts; var next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning); if (!next) { error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current)); - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } getNodeLinks(current).resolvedSymbol = next; getNodeLinks(current.parent).resolvedSymbol = next; @@ -34845,11 +35006,11 @@ var ts; else { error(node, targetMeaning === 67216319 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); links.resolvedSymbol = unknownSymbol; - links.resolvedType = unknownType; + links.resolvedType = errorType; } } } - return links.resolvedType; + return links.resolvedType; // TODO: GH#18217 } function resolveImportSymbolType(node, links, symbol, meaning) { links.resolvedSymbol = symbol; @@ -34895,19 +35056,22 @@ var ts; if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { return anyType; } - if (left.flags & 16384 /* Never */) { + if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { + return unknownType; + } + if (left.flags & 32768 /* Never */) { return right; } - if (right.flags & 16384 /* Never */) { + if (right.flags & 32768 /* Never */) { return left; } - if (left.flags & 131072 /* Union */) { + if (left.flags & 262144 /* Union */) { return mapType(left, function (t) { return getSpreadType(t, right, symbol, typeFlags, objectFlags); }); } - if (right.flags & 131072 /* Union */) { + if (right.flags & 262144 /* Union */) { return mapType(right, function (t) { return getSpreadType(left, t, symbol, typeFlags, objectFlags); }); } - if (right.flags & (136 /* BooleanLike */ | 84 /* NumberLike */ | 34 /* StringLike */ | 272 /* EnumLike */ | 134217728 /* NonPrimitive */ | 524288 /* Index */)) { + if (right.flags & (272 /* BooleanLike */ | 168 /* NumberLike */ | 68 /* StringLike */ | 544 /* EnumLike */ | 16777216 /* NonPrimitive */ | 1048576 /* Index */)) { return left; } var members = ts.createSymbolTable(); @@ -34961,7 +35125,7 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getNonReadonlyIndexSignature(stringIndexInfo), getNonReadonlyIndexSignature(numberIndexInfo)); - spread.flags |= typeFlags | 33554432 /* ContainsObjectLiteral */; + spread.flags |= typeFlags | 268435456 /* ContainsObjectLiteral */; spread.objectFlags |= objectFlags | (128 /* ObjectLiteral */ | 1024 /* ContainsSpread */); return spread; } @@ -34993,9 +35157,9 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 96 /* StringOrNumberLiteral */ && !(type.flags & 8388608 /* FreshLiteral */)) { + if (type.flags & 192 /* StringOrNumberLiteral */ && !(type.flags & 33554432 /* FreshLiteral */)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 8388608 /* FreshLiteral */, type.value, type.symbol); + var freshType = createLiteralType(type.flags | 33554432 /* FreshLiteral */, type.value, type.symbol); freshType.regularType = type; type.freshType = freshType; } @@ -35004,7 +35168,9 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 8388608 /* FreshLiteral */ ? type.regularType : type; + return type.flags & 192 /* StringOrNumberLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? type.regularType : + type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : + type; } function getLiteralType(value, enumId, symbol) { // We store all literal types in a single map with keys of the form '#NNN' and '@SSS', @@ -35015,7 +35181,7 @@ var ts; var key = enumId ? enumId + qualifier + value : qualifier + value; var type = literalTypes.get(key); if (!type) { - var flags = (typeof value === "number" ? 64 /* NumberLiteral */ : 32 /* StringLiteral */) | (enumId ? 256 /* EnumLiteral */ : 0); + var flags = (typeof value === "number" ? 128 /* NumberLiteral */ : 64 /* StringLiteral */) | (enumId ? 512 /* EnumLiteral */ : 0); literalTypes.set(key, type = createLiteralType(flags, value, symbol)); } return type; @@ -35028,7 +35194,7 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(1024 /* UniqueESSymbol */); + var type = createType(2048 /* UniqueESSymbol */); type.symbol = symbol; return type; } @@ -35043,14 +35209,14 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 235 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 236 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 154 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); - return unknownType; + return errorType; } function getTypeFromThisTypeNode(node) { var links = getNodeLinks(node); @@ -35062,9 +35228,11 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119 /* AnyKeyword */: - case 278 /* JSDocAllType */: - case 279 /* JSDocUnknownType */: + case 279 /* JSDocAllType */: + case 280 /* JSDocUnknownType */: return anyType; + case 142 /* UnknownKeyword */: + return unknownType; case 137 /* StringKeyword */: return stringType; case 134 /* NumberKeyword */: @@ -35083,64 +35251,64 @@ var ts; return neverType; case 135 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 173 /* ThisType */: + case 174 /* ThisType */: case 99 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 177 /* LiteralType */: + case 178 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return getTypeFromTypeReference(node); - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return booleanType; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 167 /* TupleType */: + case 168 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 168 /* UnionType */: + case 169 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 169 /* IntersectionType */: + case 170 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 280 /* JSDocNullableType */: + case 281 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 282 /* JSDocOptionalType */: + case 283 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 172 /* ParenthesizedType */: - case 281 /* JSDocNonNullableType */: - case 277 /* JSDocTypeExpression */: + case 173 /* ParenthesizedType */: + case 282 /* JSDocNonNullableType */: + case 278 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 165 /* TypeLiteral */: - case 286 /* JSDocTypeLiteral */: - case 283 /* JSDocFunctionType */: - case 287 /* JSDocSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 166 /* TypeLiteral */: + case 287 /* JSDocTypeLiteral */: + case 284 /* JSDocFunctionType */: + case 288 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 174 /* TypeOperator */: + case 175 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 176 /* MappedType */: + case 177 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 171 /* InferType */: + case 172 /* InferType */: return getTypeFromInferTypeNode(node); - case 178 /* ImportType */: + case 179 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 71 /* Identifier */: - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: var symbol = getSymbolAtLocation(node); - return symbol && getDeclaredTypeOfSymbol(symbol); + return (symbol && getDeclaredTypeOfSymbol(symbol)); // TODO: GH#18217 default: - return unknownType; + return errorType; } } function instantiateList(items, mapper, instantiator) { @@ -35217,10 +35385,10 @@ var ts; return function (t) { return t === source ? target : baseMapper(t); }; } function wildcardMapper(type) { - return type.flags & 32768 /* TypeParameter */ ? wildcardType : type; + return type.flags & 65536 /* TypeParameter */ ? wildcardType : type; } function cloneTypeParameter(typeParameter) { - var result = createType(32768 /* TypeParameter */); + var result = createType(65536 /* TypeParameter */); result.symbol = typeParameter.symbol; result.target = typeParameter; return result; @@ -35266,7 +35434,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 65536 /* Object */ | 7897088 /* Instantiable */)) { + if (links.type && !maybeTypeOfKind(links.type, 131072 /* Object */ | 15794176 /* Instantiable */)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -35351,8 +35519,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 145 /* QualifiedName */ || - node.parent.kind === 161 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 146 /* QualifiedName */ || + node.parent.kind === 162 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -35360,22 +35528,22 @@ var ts; // type parameter, or if the node contains type queries, we consider the type parameter possibly referenced. if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 212 /* Block */ ? "quit" : n === container_3; })) { - return ts.forEachChild(node, containsReference); + if (ts.findAncestor(node, function (n) { return n.kind === 213 /* Block */ ? "quit" : n === container_3; })) { + return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 173 /* ThisType */: - return tp.isThisType; + case 174 /* ThisType */: + return !!tp.isThisType; case 71 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return true; } - return ts.forEachChild(node, containsReference); + return !!ts.forEachChild(node, containsReference); } } function instantiateMappedType(type, mapper) { @@ -35385,9 +35553,9 @@ var ts; // homomorphic mapped types we leave primitive types alone. For example, when T is instantiated to a // union type A | undefined, we produce { [P in keyof A]: X } | undefined. var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 524288 /* Index */) { + if (constraintType.flags & 1048576 /* Index */) { var typeVariable_1 = constraintType.type; - if (typeVariable_1.flags & 32768 /* TypeParameter */) { + if (typeVariable_1.flags & 65536 /* TypeParameter */) { var mappedTypeVariable = instantiateType(typeVariable_1, mapper); if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { @@ -35402,7 +35570,7 @@ var ts; return instantiateAnonymousType(type, mapper); } function isMappableType(type) { - return type.flags & (1 /* Any */ | 7372800 /* InstantiableNonPrimitive */ | 65536 /* Object */ | 262144 /* Intersection */); + return type.flags & (3 /* AnyOrUnknown */ | 14745600 /* InstantiableNonPrimitive */ | 131072 /* Object */ | 524288 /* Intersection */); } function instantiateAnonymousType(type, mapper) { var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); @@ -35440,7 +35608,7 @@ var ts; if (root.isDistributive) { var checkType_1 = root.checkType; var instantiatedType = mapper(checkType_1); - if (checkType_1 !== instantiatedType && instantiatedType.flags & (131072 /* Union */ | 16384 /* Never */)) { + if (checkType_1 !== instantiatedType && instantiatedType.flags & (262144 /* Union */ | 32768 /* Never */)) { return mapType(instantiatedType, function (t) { return getConditionalType(root, createReplacementMapper(checkType_1, t, mapper)); }); } } @@ -35448,10 +35616,10 @@ var ts; } function instantiateType(type, mapper) { if (type && mapper && mapper !== identityMapper) { - if (type.flags & 32768 /* TypeParameter */) { + if (type.flags & 65536 /* TypeParameter */) { return mapper(type); } - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { if (type.objectFlags & 16 /* Anonymous */) { // If the anonymous type originates in a declaration of a function, method, class, or // interface, in an object type literal, or in an object literal expression, we may need @@ -35468,33 +35636,33 @@ var ts; return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; } } - if (type.flags & 131072 /* Union */ && !(type.flags & 16382 /* Primitive */)) { + if (type.flags & 262144 /* Union */ && !(type.flags & 32764 /* Primitive */)) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (type.flags & 262144 /* Intersection */) { + if (type.flags & 524288 /* Intersection */) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (type.flags & 524288 /* Index */) { + if (type.flags & 1048576 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (type.flags & 1048576 /* IndexedAccess */) { + if (type.flags & 2097152 /* IndexedAccess */) { return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - if (type.flags & 2097152 /* Conditional */) { + if (type.flags & 4194304 /* Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); } - if (type.flags & 4194304 /* Substitution */) { + if (type.flags & 8388608 /* Substitution */) { return instantiateType(type.typeVariable, mapper); } } return type; } function getWildcardInstantiation(type) { - return type.flags & (16382 /* Primitive */ | 1 /* Any */ | 16384 /* Never */) ? type : + return type.flags & (32764 /* Primitive */ | 3 /* AnyOrUnknown */ | 32768 /* Never */) ? type : type.wildcardInstantiation || (type.wildcardInstantiation = instantiateType(type, wildcardMapper)); } function instantiateIndexInfo(info, mapper) { @@ -35503,34 +35671,38 @@ 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 !== 153 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 183 /* ObjectLiteralExpression */: - return ts.forEach(node.properties, isContextSensitive); - case 182 /* ArrayLiteralExpression */: - return ts.forEach(node.elements, isContextSensitive); - case 200 /* ConditionalExpression */: + case 184 /* ObjectLiteralExpression */: + return ts.some(node.properties, isContextSensitive); + case 183 /* ArrayLiteralExpression */: + return ts.some(node.elements, isContextSensitive); + case 201 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return node.operatorToken.kind === 54 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 262 /* JsxAttributes */: - return ts.forEach(node.properties, isContextSensitive); - case 261 /* JsxAttribute */: + case 263 /* JsxAttributes */: + return ts.some(node.properties, isContextSensitive); + case 262 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. - return node.initializer && isContextSensitive(node.initializer); - case 264 /* JsxExpression */: + var initializer = node.initializer; + return !!initializer && isContextSensitive(initializer); + } + case 265 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) - return node.expression && isContextSensitive(node.expression); + var expression = node.expression; + return !!expression && isContextSensitive(expression); + } } return false; } @@ -35540,10 +35712,10 @@ var ts; return false; } // Functions with any parameters that lack type annotations are context sensitive. - if (ts.forEach(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { + if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 192 /* ArrowFunction */) { + if (node.kind !== 193 /* 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); @@ -35552,14 +35724,15 @@ var ts; } } // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return node.body.kind === 212 /* Block */ ? false : isContextSensitive(node.body); + var body = node.body; + return body.kind === 213 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(16 /* Anonymous */, type.symbol); @@ -35570,7 +35743,7 @@ var ts; return result; } } - else if (type.flags & 262144 /* Intersection */) { + else if (type.flags & 524288 /* Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -35600,9 +35773,9 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 131072 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 131072 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 7372800 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : + return source.flags & 262144 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 262144 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 14745600 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : target === globalObjectType || target === globalFunctionType ? isTypeSubtypeOf(source, target) : hasBaseType(source, getTargetType(target)); } @@ -35652,8 +35825,8 @@ var ts; source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 153 /* MethodDeclaration */ && - kind !== 152 /* MethodSignature */ && kind !== 154 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && + kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -35690,8 +35863,9 @@ var ts; var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && - (getFalsyFlags(sourceType) & 12288 /* Nullable */) === (getFalsyFlags(targetType) & 12288 /* Nullable */); + (getFalsyFlags(sourceType) & 24576 /* Nullable */) === (getFalsyFlags(targetType) & 24576 /* Nullable */); var related = callbacks ? + // TODO: GH#18217 It will work if they're both `undefined`, but not if only one is compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { @@ -35713,7 +35887,7 @@ var ts; if (targetTypePredicate) { var sourceTypePredicate = getTypePredicateOfSignature(source); if (sourceTypePredicate) { - result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, source.declaration, target.declaration, reportErrors, errorReporter, compareTypes); + result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, source.declaration, target.declaration, reportErrors, errorReporter, compareTypes); // TODO: GH#18217 } else if (ts.isIdentifierTypePredicate(targetTypePredicate)) { if (reportErrors) { @@ -35803,10 +35977,10 @@ var ts; !t.numberIndexInfo; } function isEmptyObjectType(type) { - return type.flags & 65536 /* Object */ ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 134217728 /* NonPrimitive */ ? true : - type.flags & 131072 /* Union */ ? ts.forEach(type.types, isEmptyObjectType) : - type.flags & 262144 /* Intersection */ ? !ts.forEach(type.types, function (t) { return !isEmptyObjectType(t); }) : + return type.flags & 131072 /* Object */ ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 16777216 /* NonPrimitive */ ? true : + type.flags & 262144 /* Union */ ? ts.some(type.types, isEmptyObjectType) : + type.flags & 524288 /* Intersection */ ? !ts.some(type.types, function (t) { return !isEmptyObjectType(t); }) : false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -35842,43 +36016,43 @@ var ts; function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 1 /* Any */ || s & 16384 /* Never */ || source === wildcardType) + if (t & 3 /* AnyOrUnknown */ || s & 32768 /* Never */ || source === wildcardType) return true; - if (t & 16384 /* Never */) + if (t & 32768 /* Never */) return false; - if (s & 34 /* StringLike */ && t & 2 /* String */) + if (s & 68 /* StringLike */ && t & 4 /* String */) return true; - if (s & 32 /* StringLiteral */ && s & 256 /* EnumLiteral */ && - t & 32 /* StringLiteral */ && !(t & 256 /* EnumLiteral */) && + if (s & 64 /* StringLiteral */ && s & 512 /* EnumLiteral */ && + t & 64 /* StringLiteral */ && !(t & 512 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 84 /* NumberLike */ && t & 4 /* Number */) + if (s & 168 /* NumberLike */ && t & 8 /* Number */) return true; - if (s & 64 /* NumberLiteral */ && s & 256 /* EnumLiteral */ && - t & 64 /* NumberLiteral */ && !(t & 256 /* EnumLiteral */) && + if (s & 128 /* NumberLiteral */ && s & 512 /* EnumLiteral */ && + t & 128 /* NumberLiteral */ && !(t & 512 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 136 /* BooleanLike */ && t & 8 /* Boolean */) + if (s & 272 /* BooleanLike */ && t & 16 /* Boolean */) return true; - if (s & 1536 /* ESSymbolLike */ && t & 512 /* ESSymbol */) + if (s & 3072 /* ESSymbolLike */ && t & 1024 /* ESSymbol */) return true; - if (s & 16 /* Enum */ && t & 16 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 256 /* EnumLiteral */ && t & 256 /* EnumLiteral */) { - if (s & 131072 /* Union */ && t & 131072 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 512 /* EnumLiteral */ && t & 512 /* EnumLiteral */) { + if (s & 262144 /* Union */ && t & 262144 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 224 /* Literal */ && t & 224 /* Literal */ && + if (s & 448 /* Literal */ && t & 448 /* Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } - if (s & 4096 /* Undefined */ && (!strictNullChecks || t & (4096 /* Undefined */ | 2048 /* Void */))) + if (s & 8192 /* Undefined */ && (!strictNullChecks || t & (8192 /* Undefined */ | 4096 /* Void */))) return true; - if (s & 8192 /* Null */ && (!strictNullChecks || t & 8192 /* Null */)) + if (s & 16384 /* Null */ && (!strictNullChecks || t & 16384 /* Null */)) return true; - if (s & 65536 /* Object */ && t & 134217728 /* NonPrimitive */) + if (s & 131072 /* Object */ && t & 16777216 /* NonPrimitive */) return true; - if (s & 1024 /* UniqueESSymbol */ || t & 1024 /* UniqueESSymbol */) + if (s & 2048 /* UniqueESSymbol */ || t & 2048 /* UniqueESSymbol */) return false; if (relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) { if (s & 1 /* Any */) @@ -35886,30 +36060,30 @@ 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 & (4 /* Number */ | 64 /* NumberLiteral */) && !(s & 256 /* EnumLiteral */) && (t & 16 /* Enum */ || t & 64 /* NumberLiteral */ && t & 256 /* EnumLiteral */)) + if (s & (8 /* Number */ | 128 /* NumberLiteral */) && !(s & 512 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 128 /* NumberLiteral */ && t & 512 /* EnumLiteral */)) return true; } return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 8388608 /* FreshLiteral */) { + if (source.flags & 192 /* StringOrNumberLiteral */ && source.flags & 33554432 /* FreshLiteral */) { source = source.regularType; } - if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 8388608 /* FreshLiteral */) { + if (target.flags & 192 /* StringOrNumberLiteral */ && target.flags & 33554432 /* FreshLiteral */) { target = target.regularType; } if (source === target || - relation === comparableRelation && !(target.flags & 16384 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 65536 /* Object */ && target.flags & 65536 /* Object */) { + if (source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1 /* Succeeded */; } } - if (source.flags & 8355840 /* StructuredOrInstantiable */ || target.flags & 8355840 /* StructuredOrInstantiable */) { + if (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; @@ -35949,7 +36123,7 @@ var ts; errorInfo = ts.concatenateDiagnosticMessageChains(chain_1, errorInfo); } } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); // TODO: GH#18217 } // Check if we should issue an extra diagnostic to produce a quickfix for a slightly incorrect import statement if (headMessage && errorNode && !result && source.symbol) { @@ -35998,7 +36172,7 @@ var ts; } } function isUnionOrIntersectionTypeWithoutNullableConstituents(type) { - if (!(type.flags & 393216 /* UnionOrIntersection */)) { + if (!(type.flags & 786432 /* UnionOrIntersection */)) { return false; } // at this point we know that this is union or intersection type possibly with nullable constituents. @@ -36006,7 +36180,7 @@ var ts; var seenNonNullable = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 12288 /* Nullable */) { + if (t.flags & 24576 /* Nullable */) { continue; } if (seenNonNullable) { @@ -36023,22 +36197,23 @@ var ts; * * Ternary.False if they are not related. */ function isRelatedTo(source, target, reportErrors, headMessage) { - if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 8388608 /* FreshLiteral */) { + if (reportErrors === void 0) { reportErrors = false; } + if (source.flags & 192 /* StringOrNumberLiteral */ && source.flags & 33554432 /* FreshLiteral */) { source = source.regularType; } - if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 8388608 /* FreshLiteral */) { + if (target.flags & 192 /* StringOrNumberLiteral */ && target.flags & 33554432 /* FreshLiteral */) { target = target.regularType; } - if (source.flags & 4194304 /* Substitution */) { + if (source.flags & 8388608 /* Substitution */) { source = relation === definitelyAssignableRelation ? source.typeVariable : source.substitute; } - if (target.flags & 4194304 /* Substitution */) { + if (target.flags & 8388608 /* Substitution */) { target = target.typeVariable; } - if (source.flags & 1048576 /* IndexedAccess */) { + if (source.flags & 2097152 /* IndexedAccess */) { source = getSimplifiedType(source); } - if (target.flags & 1048576 /* IndexedAccess */) { + if (target.flags & 2097152 /* IndexedAccess */) { target = getSimplifiedType(target); } // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases @@ -36047,11 +36222,11 @@ var ts; if (relation === identityRelation) { return isIdenticalTo(source, target); } - if (relation === comparableRelation && !(target.flags & 16384 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - if (isObjectLiteralType(source) && source.flags & 8388608 /* FreshLiteral */) { - var discriminantType = target.flags & 131072 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; + if (isObjectLiteralType(source) && source.flags & 33554432 /* FreshLiteral */) { + var discriminantType = target.flags & 262144 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -36067,8 +36242,8 @@ var ts; } } if (relation !== comparableRelation && - !(source.flags & 393216 /* UnionOrIntersection */) && - !(target.flags & 131072 /* Union */) && + !(source.flags & 786432 /* UnionOrIntersection */) && + !(target.flags & 262144 /* Union */) && !isIntersectionConstituent && source !== globalObjectType && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && @@ -36094,20 +36269,20 @@ var ts; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. - if (source.flags & 131072 /* Union */) { + if (source.flags & 262144 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 16382 /* Primitive */)) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 16382 /* Primitive */)); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)); } else { - if (target.flags & 131072 /* Union */) { - result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 16382 /* Primitive */) && !(target.flags & 16382 /* Primitive */)); + if (target.flags & 262144 /* Union */) { + result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */) && !(target.flags & 32764 /* Primitive */)); } - else if (target.flags & 262144 /* Intersection */) { + else if (target.flags & 524288 /* Intersection */) { isIntersectionConstituent = true; result = typeRelatedToEachType(source, target, reportErrors); } - else if (source.flags & 262144 /* Intersection */) { + else if (source.flags & 524288 /* Intersection */) { // 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 @@ -36123,13 +36298,13 @@ var ts; // breaking the intersection apart. result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } - if (!result && (source.flags & 8355840 /* StructuredOrInstantiable */ || target.flags & 8355840 /* StructuredOrInstantiable */)) { + if (!result && (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { errorInfo = saveErrorInfo; } } } - if (!result && source.flags & 262144 /* Intersection */) { + if (!result && source.flags & 524288 /* Intersection */) { // The combined constraint of an intersection type is the intersection of the constraints of // the constituents. When an intersection type contains instantiable types with union type // constraints, there are situations where we need to examine the combined constraint. One is @@ -36139,7 +36314,7 @@ var ts; // we need to check this constraint against a union on the target side. Also, given a type // variable V constrained to 'string | number', 'V & number' has a combined constraint of // 'string & number | number & number' which reduces to just 'number'. - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 131072 /* Union */)); + var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 262144 /* Union */)); if (constraint) { if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; @@ -36148,12 +36323,22 @@ var ts; } isIntersectionConstituent = saveIsIntersectionConstituent; if (!result && reportErrors) { - if (source.flags & 65536 /* Object */ && target.flags & 16382 /* Primitive */) { + if (source.flags & 131072 /* Object */ && target.flags & 32764 /* Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 65536 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 131072 /* Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } + else if (ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && target.flags & 524288 /* Intersection */) { + var targetTypes = target.types; + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); + var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); + if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType && + (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) { + // do not report top error + return result; + } + } reportRelationError(headMessage, source, target); } return result; @@ -36161,27 +36346,27 @@ var ts; function isIdenticalTo(source, target) { var result; var flags = source.flags & target.flags; - if (flags & 65536 /* Object */) { + if (flags & 131072 /* Object */) { return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false); } - if (flags & (131072 /* Union */ | 262144 /* Intersection */)) { + if (flags & (262144 /* Union */ | 524288 /* Intersection */)) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } } - if (flags & 524288 /* Index */) { + if (flags & 1048576 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } - if (flags & 1048576 /* IndexedAccess */) { + if (flags & 2097152 /* IndexedAccess */) { if (result = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { if (result &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { return result; } } } - if (flags & 2097152 /* Conditional */) { + if (flags & 4194304 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { if (result = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { if (result &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { @@ -36194,13 +36379,13 @@ var ts; } } } - if (flags & 4194304 /* Substitution */) { + if (flags & 8388608 /* Substitution */) { return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false); } return 0 /* False */; } function hasExcessProperties(source, target, discriminant, reportErrors) { - if (maybeTypeOfKind(target, 65536 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + if (maybeTypeOfKind(target, 131072 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); if ((relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { @@ -36216,7 +36401,8 @@ var ts; // We know *exactly* where things went wrong when comparing the types. // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. - ts.Debug.assert(!!errorNode); + if (!errorNode) + return { value: ts.Debug.fail() }; if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. @@ -36230,8 +36416,9 @@ var ts; var propDeclaration = prop.valueDeclaration; ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike); errorNode = propDeclaration; - if (ts.isIdentifier(propDeclaration.name)) { - suggestion = getSuggestionForNonexistentProperty(propDeclaration.name, target); + var name = propDeclaration.name; + if (ts.isIdentifier(name)) { + suggestion = getSuggestionForNonexistentProperty(name, target); } } if (suggestion !== undefined) { @@ -36269,7 +36456,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 131072 /* Union */ && containsType(targetTypes, source)) { + if (target.flags & 262144 /* Union */ && containsType(targetTypes, source)) { return -1 /* True */; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { @@ -36327,7 +36514,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 131072 /* Union */ && containsType(sourceTypes, target)) { + if (source.flags & 262144 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; @@ -36479,7 +36666,7 @@ var ts; var result; var originalErrorInfo; var saveErrorInfo = errorInfo; - if (target.flags & 32768 /* TypeParameter */) { + if (target.flags & 65536 /* TypeParameter */) { // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. if (ts.getObjectFlags(source) & 32 /* Mapped */ && getConstraintTypeFromMappedType(source) === getIndexType(target)) { if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { @@ -36491,9 +36678,9 @@ var ts; } } } - else if (target.flags & 524288 /* Index */) { + else if (target.flags & 1048576 /* Index */) { // A keyof S is related to a keyof T if T is related to S. - if (source.flags & 524288 /* Index */) { + if (source.flags & 1048576 /* Index */) { if (result = isRelatedTo(target.type, source.type, /*reportErrors*/ false)) { return result; } @@ -36510,7 +36697,7 @@ var ts; } } } - else if (target.flags & 1048576 /* IndexedAccess */) { + else if (target.flags & 2097152 /* IndexedAccess */) { // A type S is related to a type T[K] if S is related to C, where C is the // constraint of T[K] var constraint = getConstraintForRelation(target); @@ -36526,7 +36713,7 @@ var ts; var template = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); if (!(modifiers & 8 /* ExcludeOptional */)) { - if (template.flags & 1048576 /* IndexedAccess */ && template.objectType === source && + if (template.flags & 2097152 /* IndexedAccess */ && template.objectType === source && template.indexType === getTypeParameterFromMappedType(target)) { return -1 /* True */; } @@ -36541,8 +36728,8 @@ var ts; } } } - if (source.flags & 1081344 /* TypeVariable */) { - if (source.flags & 1048576 /* IndexedAccess */ && target.flags & 1048576 /* IndexedAccess */) { + if (source.flags & 2162688 /* TypeVariable */) { + if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* 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); @@ -36553,9 +36740,9 @@ var ts; } } var constraint = getConstraintForRelation(source); - if (!constraint || (source.flags & 32768 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { + if (!constraint || (source.flags & 65536 /* TypeParameter */ && constraint.flags & 3 /* AnyOrUnknown */)) { // A type variable with no constraint is not related to the non-primitive object type. - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~134217728 /* NonPrimitive */))) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~16777216 /* NonPrimitive */))) { errorInfo = saveErrorInfo; return result; } @@ -36568,14 +36755,14 @@ var ts; } } } - else if (source.flags & 524288 /* Index */) { + else if (source.flags & 1048576 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 2097152 /* Conditional */) { - if (target.flags & 2097152 /* Conditional */) { + else if (source.flags & 4194304 /* Conditional */) { + if (target.flags & 4194304 /* Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. @@ -36643,14 +36830,14 @@ var ts; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. - var sourceIsPrimitive = !!(source.flags & 16382 /* Primitive */); + var sourceIsPrimitive = !!(source.flags & 32764 /* Primitive */); if (relation !== identityRelation) { source = getApparentType(source); } // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (source.flags & (65536 /* Object */ | 262144 /* Intersection */) && target.flags & 65536 /* Object */) { + if (source.flags & (131072 /* Object */ | 524288 /* Intersection */) && target.flags & 131072 /* Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; // An empty object type is related to any mapped type that includes a '?' modifier. @@ -36805,14 +36992,14 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo && resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); } - if (type.flags & 262144 /* Intersection */) { + if (type.flags & 524288 /* Intersection */) { return ts.every(type.types, isWeakType); } return false; @@ -36828,7 +37015,7 @@ var ts; return false; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 65536 /* Object */ && target.flags & 65536 /* Object */)) { + if (!(source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */)) { return 0 /* False */; } var sourceProperties = getPropertiesOfObjectType(source); @@ -36896,7 +37083,7 @@ var ts; // in the context of the target signature before checking the relationship. Ideally we'd do // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. - var eraseGenerics = relation === comparableRelation || compilerOptions.noStrictGenericChecks; + var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); } else { @@ -36952,7 +37139,7 @@ var ts; continue; } // Skip over symbol-named members - if (prop.nameType && prop.nameType.flags & 1024 /* UniqueESSymbol */) { + if (prop.nameType && prop.nameType.flags & 2048 /* UniqueESSymbol */) { continue; } if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { @@ -36980,7 +37167,7 @@ var ts; return indexTypesIdenticalTo(source, target, kind); } var targetInfo = getIndexInfoOfType(target, kind); - if (!targetInfo || targetInfo.type.flags & 1 /* Any */ && !sourceIsPrimitive) { + if (!targetInfo || targetInfo.type.flags & 3 /* AnyOrUnknown */ && !sourceIsPrimitive) { // Index signature of type any permits assignment from everything but primitives return -1 /* True */; } @@ -36992,7 +37179,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors); + return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -37102,17 +37289,17 @@ var ts; // See comment at call in recursiveTypeRelatedTo for when this case matters. function hasCovariantVoidArgument(type, variances) { for (var i = 0; i < variances.length; i++) { - if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 2048 /* Void */) { + if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 4096 /* Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 32768 /* TypeParameter */ && !getConstraintFromTypeParameter(type); + return type.flags & 65536 /* TypeParameter */ && !getConstraintFromTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -37202,13 +37389,13 @@ var ts; // levels, but unequal at some level beyond that. function isDeeplyNestedType(type, stack, depth) { // We track all object types that have an associated symbol (representing the origin of the type) - if (depth >= 5 && type.flags & 65536 /* Object */) { + if (depth >= 5 && type.flags & 131072 /* Object */) { var symbol = type.symbol; if (symbol) { var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 65536 /* Object */ && t.symbol === symbol) { + if (t.flags & 131072 /* Object */ && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -37356,9 +37543,9 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 12288 /* Nullable */); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 24576 /* Nullable */); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 12288 /* Nullable */) : + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 24576 /* Nullable */) : getUnionType(types, 2 /* Subtype */); } // Return the leftmost type for which no type to the right is a subtype. @@ -37366,13 +37553,13 @@ var ts; return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType; + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalArrayType; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray return ts.getObjectFlags(type) & 4 /* Reference */ && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || - !(type.flags & 12288 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + !(type.flags & 24576 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; @@ -37382,35 +37569,35 @@ var ts; return !!getPropertyOfType(type, "0"); } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (13536 /* Unit */ | 16384 /* Never */)); + return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); } function isUnitType(type) { - return !!(type.flags & 13536 /* Unit */); + return !!(type.flags & 27072 /* Unit */); } function isLiteralType(type) { - return type.flags & 8 /* Boolean */ ? true : - type.flags & 131072 /* Union */ ? type.flags & 256 /* EnumLiteral */ ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : + return type.flags & 16 /* Boolean */ ? true : + type.flags & 262144 /* Union */ ? type.flags & 512 /* EnumLiteral */ ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 256 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 32 /* StringLiteral */ ? stringType : - type.flags & 64 /* NumberLiteral */ ? numberType : - type.flags & 128 /* BooleanLiteral */ ? booleanType : - type.flags & 131072 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + return type.flags & 512 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 64 /* StringLiteral */ ? stringType : + type.flags & 128 /* NumberLiteral */ ? numberType : + type.flags & 256 /* BooleanLiteral */ ? booleanType : + type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { - return type.flags & 256 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 32 /* StringLiteral */ && type.flags & 8388608 /* FreshLiteral */ ? stringType : - type.flags & 64 /* NumberLiteral */ && type.flags & 8388608 /* FreshLiteral */ ? numberType : - type.flags & 128 /* BooleanLiteral */ ? booleanType : - type.flags & 131072 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + return type.flags & 512 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 64 /* StringLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? stringType : + type.flags & 128 /* NumberLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? numberType : + type.flags & 256 /* BooleanLiteral */ ? booleanType : + type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 1024 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 131072 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : + return type.flags & 2048 /* UniqueESSymbol */ ? esSymbolType : + type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -37438,27 +37625,27 @@ var ts; // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns // no flags for all other types (including non-falsy literal types). function getFalsyFlags(type) { - return type.flags & 131072 /* Union */ ? getFalsyFlagsOfTypes(type.types) : - type.flags & 32 /* StringLiteral */ ? type.value === "" ? 32 /* StringLiteral */ : 0 : - type.flags & 64 /* NumberLiteral */ ? type.value === 0 ? 64 /* NumberLiteral */ : 0 : - type.flags & 128 /* BooleanLiteral */ ? type === falseType ? 128 /* BooleanLiteral */ : 0 : - type.flags & 14574 /* PossiblyFalsy */; + return type.flags & 262144 /* Union */ ? getFalsyFlagsOfTypes(type.types) : + type.flags & 64 /* StringLiteral */ ? type.value === "" ? 64 /* StringLiteral */ : 0 : + type.flags & 128 /* NumberLiteral */ ? type.value === 0 ? 128 /* NumberLiteral */ : 0 : + type.flags & 256 /* BooleanLiteral */ ? type === falseType ? 256 /* BooleanLiteral */ : 0 : + type.flags & 29148 /* PossiblyFalsy */; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 14560 /* DefinitelyFalsy */ ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 14560 /* DefinitelyFalsy */); }) : + return getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 29120 /* DefinitelyFalsy */); }) : type; } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 2 /* String */ ? emptyStringType : - type.flags & 4 /* Number */ ? zeroType : - type.flags & 8 /* Boolean */ || type === falseType ? falseType : - type.flags & (2048 /* Void */ | 4096 /* Undefined */ | 8192 /* Null */) || - type.flags & 32 /* StringLiteral */ && type.value === "" || - type.flags & 64 /* NumberLiteral */ && type.value === 0 ? type : + return type.flags & 4 /* String */ ? emptyStringType : + type.flags & 8 /* Number */ ? zeroType : + type.flags & 16 /* Boolean */ || type === falseType ? falseType : + type.flags & (4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */) || + type.flags & 64 /* StringLiteral */ && type.value === "" || + type.flags & 128 /* NumberLiteral */ && type.value === 0 ? type : neverType; } /** @@ -37467,15 +37654,15 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (4096 /* Undefined */ | 8192 /* Null */); + var missing = (flags & ~type.flags) & (8192 /* Undefined */ | 16384 /* Null */); return missing === 0 ? type : - missing === 4096 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 8192 /* Null */ ? getUnionType([type, nullType]) : + missing === 8192 /* Undefined */ ? getUnionType([type, undefinedType]) : + missing === 16384 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type) { ts.Debug.assert(strictNullChecks); - return type.flags & 4096 /* Undefined */ ? type : getUnionType([type, undefinedType]); + return type.flags & 8192 /* Undefined */ ? type : getUnionType([type, undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { @@ -37528,7 +37715,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && type.flags & 8388608 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && type.flags & 33554432 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -37538,7 +37725,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~8388608 /* FreshLiteral */; + regularNew.flags = resolved.flags & ~33554432 /* FreshLiteral */; regularNew.objectFlags |= 128 /* ObjectLiteral */; type.regularType = regularNew; return regularNew; @@ -37620,16 +37807,16 @@ var ts; return getWidenedTypeWithContext(type, /*context*/ undefined); } function getWidenedTypeWithContext(type, context) { - if (type.flags & 50331648 /* RequiresWidening */) { - if (type.flags & 12288 /* Nullable */) { + if (type.flags & 402653184 /* RequiresWidening */) { + if (type.flags & 24576 /* Nullable */) { return anyType; } if (isObjectLiteralType(type)) { return getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 12288 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 24576 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). @@ -37654,8 +37841,8 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (type.flags & 16777216 /* ContainsWideningType */) { - if (type.flags & 131072 /* Union */) { + if (type.flags & 134217728 /* ContainsWideningType */) { + if (type.flags & 262144 /* Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -37680,7 +37867,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 16777216 /* ContainsWideningType */) { + if (t.flags & 134217728 /* ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -37695,33 +37882,33 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 199 /* BinaryExpression */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 200 /* BinaryExpression */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 148 /* Parameter */: + case 149 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 181 /* BindingElement */: + case 182 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 176 /* MappedType */: + case 177 /* MappedType */: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -37730,7 +37917,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && noImplicitAny && type.flags & 16777216 /* ContainsWideningType */) { + if (produceDiagnostics && noImplicitAny && type.flags & 134217728 /* ContainsWideningType */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -37803,26 +37990,26 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - return !!(type.flags & 7897088 /* Instantiable */ || + return !!(type.flags & 15794176 /* Instantiable */ || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) || objectFlags & 32 /* Mapped */ || - type.flags & 393216 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 786432 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { - type.couldContainTypeVariables = ts.forEach(type.types, couldContainTypeVariables); + type.couldContainTypeVariables = ts.some(type.types, couldContainTypeVariables); } return type.couldContainTypeVariables; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || type.flags & 393216 /* UnionOrIntersection */ && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || !!(type.flags & 786432 /* UnionOrIntersection */) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); } /** Create an object with properties named in the string literal type. Every property has type `any` */ function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 32 /* StringLiteral */)) { + if (!(t.flags & 64 /* StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); @@ -37834,7 +38021,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfo = type.flags & 2 /* String */ ? createIndexInfo(emptyObjectType, /*isReadonly*/ false) : undefined; + var indexInfo = type.flags & 4 /* String */ ? createIndexInfo(emptyObjectType, /*isReadonly*/ false) : undefined; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfo, undefined); } /** @@ -37862,7 +38049,7 @@ var ts; // is incomplete and we can't infer a meaningful input type. for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; - if (getTypeOfSymbol(prop).flags & 67108864 /* ContainsAnyFunctionType */) { + if (getTypeOfSymbol(prop).flags & 536870912 /* ContainsAnyFunctionType */) { return undefined; } } @@ -37882,7 +38069,7 @@ var ts; return getTypeFromInference(inference); } function getUnmatchedProperty(source, target, requireOptionalProperties) { - var properties = target.flags & 262144 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); + var properties = target.flags & 524288 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { var targetProp = properties_5[_i]; if (requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */)) { @@ -37936,8 +38123,8 @@ var ts; } return; } - if (source.flags & 131072 /* Union */ && target.flags & 131072 /* Union */ && !(source.flags & 256 /* EnumLiteral */ && target.flags & 256 /* EnumLiteral */) || - source.flags & 262144 /* Intersection */ && target.flags & 262144 /* Intersection */) { + if (source.flags & 262144 /* Union */ && target.flags & 262144 /* Union */ && !(source.flags & 512 /* EnumLiteral */ && target.flags & 512 /* EnumLiteral */) || + source.flags & 524288 /* Intersection */ && target.flags & 524288 /* Intersection */) { // Source and target are both unions or both intersections. If source and target // are the same type, just relate each constituent type to itself. if (source === target) { @@ -37960,7 +38147,7 @@ var ts; (matchingTypes || (matchingTypes = [])).push(t); inferFromTypes(t, t); } - else if (t.flags & (64 /* NumberLiteral */ | 32 /* StringLiteral */)) { + else if (t.flags & (128 /* NumberLiteral */ | 64 /* StringLiteral */)) { var b = getBaseTypeOfLiteralType(t); if (typeIdenticalToSomeType(b, target.types)) { (matchingTypes || (matchingTypes = [])).push(t, b); @@ -37975,7 +38162,7 @@ var ts; target = removeTypesFromUnionOrIntersection(target, matchingTypes); } } - if (target.flags & 1081344 /* TypeVariable */) { + if (target.flags & 2162688 /* TypeVariable */) { // If target is a type parameter, make an inference, unless the source type contains // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). // Because the anyFunctionType is internal, it should not be exposed to the user by adding @@ -37983,7 +38170,7 @@ 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 (source.flags & 67108864 /* ContainsAnyFunctionType */ || source === silentNeverType) { + if (source.flags & 536870912 /* ContainsAnyFunctionType */ || source === silentNeverType) { return; } var inference = getInferenceInfoForType(target); @@ -38003,7 +38190,7 @@ var ts; inference.candidates = ts.append(inference.candidates, candidate); } } - if (!(priority & 8 /* ReturnType */) && target.flags & 32768 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 8 /* ReturnType */) && target.flags & 65536 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; } } @@ -38025,12 +38212,12 @@ var ts; } } } - else if (source.flags & 524288 /* Index */ && target.flags & 524288 /* Index */) { + else if (source.flags & 1048576 /* Index */ && target.flags & 1048576 /* Index */) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 2 /* String */) && target.flags & 524288 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 1048576 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; var savePriority = priority; @@ -38039,17 +38226,17 @@ var ts; priority = savePriority; contravariant = !contravariant; } - else if (source.flags & 1048576 /* IndexedAccess */ && target.flags & 1048576 /* IndexedAccess */) { + else if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 2097152 /* Conditional */ && target.flags & 2097152 /* Conditional */) { + else if (source.flags & 4194304 /* Conditional */ && target.flags & 4194304 /* Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } - else if (target.flags & 393216 /* UnionOrIntersection */) { + else if (target.flags & 786432 /* UnionOrIntersection */) { var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; @@ -38074,7 +38261,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 131072 /* Union */) { + else if (source.flags & 262144 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { @@ -38083,10 +38270,10 @@ var ts; } } else { - if (!(priority & 32 /* NoConstraints */ && source.flags & (262144 /* Intersection */ | 7897088 /* Instantiable */))) { + if (!(priority & 32 /* NoConstraints */ && source.flags & (524288 /* Intersection */ | 15794176 /* Instantiable */))) { source = getApparentType(source); } - if (source.flags & (65536 /* Object */ | 262144 /* Intersection */)) { + if (source.flags & (131072 /* Object */ | 524288 /* Intersection */)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -38096,7 +38283,7 @@ var ts; // an instantiation of the same generic type), we do not explore this target as it would yield // no further inferences. We exclude the static side of classes from this check since it shares // its symbol with the instance side which would lead to false positives. - var isNonConstructorObject = target.flags & 65536 /* Object */ && + var isNonConstructorObject = target.flags & 131072 /* Object */ && !(ts.getObjectFlags(target) & 16 /* Anonymous */ && target.symbol && target.symbol.flags & 32 /* Class */); var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { @@ -38124,7 +38311,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 1081344 /* TypeVariable */) { + if (type.flags & 2162688 /* TypeVariable */) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { var inference = inferences_1[_i]; if (type === inference.typeParameter) { @@ -38143,7 +38330,7 @@ var ts; } if (ts.getObjectFlags(target) & 32 /* Mapped */) { var constraintType = getConstraintTypeFromMappedType(target); - if (constraintType.flags & 524288 /* Index */) { + if (constraintType.flags & 1048576 /* Index */) { // We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X }, // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference @@ -38160,7 +38347,7 @@ var ts; } return; } - if (constraintType.flags & 32768 /* TypeParameter */) { + if (constraintType.flags & 65536 /* TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. var savePriority = priority; @@ -38251,11 +38438,11 @@ var ts; reducedTypes.push(t); } } - return type.flags & 131072 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 262144 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return constraint && maybeTypeOfKind(constraint, 16382 /* Primitive */ | 524288 /* Index */); + return !!constraint && maybeTypeOfKind(constraint, 32764 /* Primitive */ | 1048576 /* Index */); } function isObjectLiteralType(type) { return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); @@ -38280,10 +38467,12 @@ var ts; // all inferences were made to top-level occurrences of the type parameter, and // the type parameter has no constraint or its constraint includes no primitive or literal types, and // the type parameter was fixed during inference or does not occur at top-level in the return type. - var widenLiteralTypes = inference.topLevel && - !hasPrimitiveConstraint(inference.typeParameter) && + var primitiveConstraint = hasPrimitiveConstraint(inference.typeParameter); + var widenLiteralTypes = !primitiveConstraint && inference.topLevel && (inference.isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), inference.typeParameter)); - var baseCandidates = widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) : candidates; + var baseCandidates = primitiveConstraint ? ts.sameMap(candidates, getRegularTypeOfLiteralType) : + widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) : + candidates; // If all inferences were made from contravariant positions, infer a common subtype. Otherwise, if // union types were requested or if all inferences were made from the return type position, infer a // union type. Otherwise, infer a common supertype. @@ -38302,7 +38491,7 @@ var ts; inferredType = getCovariantInference(inference, context, signature); // If we have inferred 'never' but have contravariant candidates. To get a more specific type we // infer from the contravariant candidates instead. - if (inferredType.flags & 16384 /* Never */ && inference.contraCandidates) { + if (inferredType.flags & 32768 /* Never */ && inference.contraCandidates) { inferredType = getContravariantInference(inference); } } @@ -38369,7 +38558,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 164 /* TypeQuery */ ? true : n.kind === 71 /* Identifier */ || n.kind === 145 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 165 /* TypeQuery */ ? true : n.kind === 71 /* Identifier */ || n.kind === 146 /* 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 @@ -38385,13 +38574,13 @@ var ts; if (node.kind === 99 /* ThisKeyword */) { return "0"; } - if (node.kind === 184 /* PropertyAccessExpression */) { + if (node.kind === 185 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 181 /* BindingElement */) { + if (node.kind === 182 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 181 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 182 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -38399,12 +38588,13 @@ var ts; return undefined; } function getBindingElementNameText(element) { - if (element.parent.kind === 179 /* ObjectBindingPattern */) { + var parent = element.parent; + if (parent.kind === 180 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { case 71 /* Identifier */: return ts.idText(name); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return ts.isStringOrNumericLiteral(name.expression) ? name.expression.text : undefined; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -38415,41 +38605,41 @@ var ts; } } else { - return "" + element.parent.elements.indexOf(element); + return "" + parent.elements.indexOf(element); } } function isMatchingReference(source, target) { switch (source.kind) { case 71 /* Identifier */: return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 231 /* VariableDeclaration */ || target.kind === 181 /* BindingElement */) && + (target.kind === 232 /* VariableDeclaration */ || target.kind === 182 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99 /* ThisKeyword */: return target.kind === 99 /* ThisKeyword */; case 97 /* SuperKeyword */: return target.kind === 97 /* SuperKeyword */; - case 184 /* PropertyAccessExpression */: - return target.kind === 184 /* PropertyAccessExpression */ && + case 185 /* PropertyAccessExpression */: + return target.kind === 185 /* PropertyAccessExpression */ && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 181 /* BindingElement */: - if (target.kind !== 184 /* PropertyAccessExpression */) + case 182 /* BindingElement */: + if (target.kind !== 185 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 181 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 182 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 231 /* VariableDeclaration */) { + if (source.parent.parent.kind === 232 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; - return maybeId && isMatchingReference(maybeId, t.expression); + return !!maybeId && isMatchingReference(maybeId, t.expression); } } return false; } function containsMatchingReference(source, target) { - while (source.kind === 184 /* PropertyAccessExpression */) { + while (source.kind === 185 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -38462,7 +38652,7 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 184 /* PropertyAccessExpression */ && + return target.kind === 185 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -38470,18 +38660,18 @@ var ts; if (expr.kind === 71 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 184 /* PropertyAccessExpression */) { + if (expr.kind === 185 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } return undefined; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 131072 /* Union */) { + if (type && type.flags & 262144 /* Union */) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.checkFlags & 32 /* HasNonUniformType */ && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = !!(prop.checkFlags & 32 /* HasNonUniformType */) && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -38514,7 +38704,7 @@ var ts; } } } - if (callExpression.expression.kind === 184 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 185 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -38528,7 +38718,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 131072 /* Union */)) { + if (!(source.flags & 262144 /* Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -38544,11 +38734,11 @@ var ts; // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 16384 /* Never */) { + if (assignedType.flags & 32768 /* Never */) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (!(reducedType.flags & 16384 /* Never */)) { + if (!(reducedType.flags & 32768 /* Never */)) { return reducedType; } } @@ -38571,53 +38761,53 @@ var ts; } function getTypeFacts(type) { var flags = type.flags; - if (flags & 2 /* String */) { + if (flags & 4 /* String */) { return strictNullChecks ? 4079361 /* StringStrictFacts */ : 4194049 /* StringFacts */; } - if (flags & 32 /* StringLiteral */) { + if (flags & 64 /* StringLiteral */) { var isEmpty = type.value === ""; return strictNullChecks ? isEmpty ? 3030785 /* EmptyStringStrictFacts */ : 1982209 /* NonEmptyStringStrictFacts */ : isEmpty ? 3145473 /* EmptyStringFacts */ : 4194049 /* NonEmptyStringFacts */; } - if (flags & (4 /* Number */ | 16 /* Enum */)) { + if (flags & (8 /* Number */ | 32 /* Enum */)) { return strictNullChecks ? 4079234 /* NumberStrictFacts */ : 4193922 /* NumberFacts */; } - if (flags & 64 /* NumberLiteral */) { + if (flags & 128 /* NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? isZero ? 3030658 /* ZeroStrictFacts */ : 1982082 /* NonZeroStrictFacts */ : isZero ? 3145346 /* ZeroFacts */ : 4193922 /* NonZeroFacts */; } - if (flags & 8 /* Boolean */) { + if (flags & 16 /* Boolean */) { return strictNullChecks ? 4078980 /* BooleanStrictFacts */ : 4193668 /* BooleanFacts */; } - if (flags & 136 /* BooleanLike */) { + if (flags & 272 /* BooleanLike */) { return strictNullChecks ? type === falseType ? 3030404 /* FalseStrictFacts */ : 1981828 /* TrueStrictFacts */ : type === falseType ? 3145092 /* FalseFacts */ : 4193668 /* TrueFacts */; } - if (flags & 65536 /* Object */) { + if (flags & 131072 /* Object */) { return isFunctionObjectType(type) ? strictNullChecks ? 1970144 /* FunctionStrictFacts */ : 4181984 /* FunctionFacts */ : strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; } - if (flags & (2048 /* Void */ | 4096 /* Undefined */)) { + if (flags & (4096 /* Void */ | 8192 /* Undefined */)) { return 2457472 /* UndefinedFacts */; } - if (flags & 8192 /* Null */) { + if (flags & 16384 /* Null */) { return 2340752 /* NullFacts */; } - if (flags & 1536 /* ESSymbolLike */) { + if (flags & 3072 /* ESSymbolLike */) { return strictNullChecks ? 1981320 /* SymbolStrictFacts */ : 4193160 /* SymbolFacts */; } - if (flags & 134217728 /* NonPrimitive */) { + if (flags & 16777216 /* NonPrimitive */) { return strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; } - if (flags & 7897088 /* Instantiable */) { + if (flags & 15794176 /* Instantiable */) { return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } - if (flags & 393216 /* UnionOrIntersection */) { + if (flags & 786432 /* UnionOrIntersection */) { return getTypeFactsOfTypes(type.types); } return 4194303 /* All */; @@ -38637,26 +38827,26 @@ var ts; return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || isNumericLiteralName(text) && getIndexTypeOfType(type, 1 /* Number */) || getIndexTypeOfType(type, 0 /* String */) || - unknownType; + errorType; } function getTypeOfDestructuredArrayElement(type, index) { return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || - unknownType; + errorType; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType); + return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 182 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 269 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 183 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 270 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 199 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 221 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 200 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 222 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -38673,29 +38863,29 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return stringType; - case 221 /* ForOfStatement */: - return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || unknownType; - case 199 /* BinaryExpression */: + case 222 /* ForOfStatement */: + return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; + case 200 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return undefinedType; - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } - return unknownType; + return errorType; } function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 179 /* ObjectBindingPattern */ ? + var type = pattern.kind === 180 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -38713,35 +38903,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 220 /* ForInStatement */) { + if (node.parent.parent.kind === 221 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 221 /* ForOfStatement */) { - return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || unknownType; + if (node.parent.parent.kind === 222 /* ForOfStatement */) { + return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } - return unknownType; + return errorType; } function getInitialType(node) { - return node.kind === 231 /* VariableDeclaration */ ? + return node.kind === 232 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 231 /* VariableDeclaration */ || node.kind === 181 /* BindingElement */ ? + return node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 231 /* VariableDeclaration */ && node.initializer && + return node.kind === 232 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 181 /* BindingElement */ && node.parent.kind === 199 /* BinaryExpression */ && + node.kind !== 182 /* BindingElement */ && node.parent.kind === 200 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: switch (node.operatorToken.kind) { case 58 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -38753,13 +38943,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 190 /* ParenthesizedExpression */ || - parent.kind === 199 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || - parent.kind === 199 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? + return parent.kind === 191 /* ParenthesizedExpression */ || + parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || + parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 265 /* CaseClause */) { + if (clause.kind === 266 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -38776,13 +38966,13 @@ var ts; return links.switchTypes; } function eachTypeContainedIn(source, types) { - return source.flags & 131072 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 262144 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 131072 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 262144 /* Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 131072 /* Union */) { + if (source.flags & 262144 /* Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -38791,30 +38981,27 @@ var ts; } return true; } - if (source.flags & 256 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 512 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 131072 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 262144 /* Union */ ? ts.forEach(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 268435456 /* UnionOfUnitTypes */); + return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 67108864 /* UnionOfUnitTypes */); } return f(type) ? type : neverType; } - // Apply a mapping function to a type and return the resulting type. If the source type - // is a union type, the mapping function is applied to each constituent type and a union - // of the resulting types is returned. function mapType(type, mapper, noReductions) { - if (type.flags & 16384 /* Never */) { + if (type.flags & 32768 /* Never */) { return type; } - if (!(type.flags & 131072 /* Union */)) { + if (!(type.flags & 262144 /* Union */)) { return mapper(type); } var types = type.types; @@ -38844,11 +39031,11 @@ var ts; // typeWithPrimitives have been replaced with occurrences of string literals and numeric // literals in typeWithLiterals, respectively. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 32 /* StringLiteral */) || - isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64 /* NumberLiteral */)) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64 /* StringLiteral */) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* NumberLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 2 /* String */ ? extractTypesOfKind(typeWithLiterals, 2 /* String */ | 32 /* StringLiteral */) : - t.flags & 4 /* Number */ ? extractTypesOfKind(typeWithLiterals, 4 /* Number */ | 64 /* NumberLiteral */) : + return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 64 /* StringLiteral */) : + t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 128 /* NumberLiteral */) : t; }); } @@ -38883,9 +39070,9 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 16384 /* Never */ ? + return elementType.flags & 32768 /* Never */ ? autoArrayType : - createArrayType(elementType.flags & 131072 /* Union */ ? + createArrayType(elementType.flags & 262144 /* Union */ ? getUnionType(elementType.types, 2 /* Subtype */) : elementType); } @@ -38903,7 +39090,7 @@ var ts; var hasEvolvingArrayType = false; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var t = types_14[_i]; - if (!(t.flags & 16384 /* Never */)) { + if (!(t.flags & 32768 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; } @@ -38925,15 +39112,15 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 184 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 186 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 185 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 185 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 187 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 186 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 199 /* BinaryExpression */ && + parent.parent.kind === 200 /* BinaryExpression */ && parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 84 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 168 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -38948,7 +39135,7 @@ var ts; var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); - return apparentType !== unknownType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); + return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); } } return false; @@ -38964,9 +39151,9 @@ var ts; var key; var flowDepth = 0; if (flowAnalysisDisabled) { - return unknownType; + return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 142575359 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 33492479 /* Narrowable */)) { return declaredType; } var sharedFlowStart = sharedFlowCount; @@ -38977,7 +39164,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) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 208 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 16384 /* Never */) { + if (reference.parent && reference.parent.kind === 209 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { return declaredType; } return resultType; @@ -38987,7 +39174,7 @@ var ts; // and disable further control flow analysis in the containing function or module body. flowAnalysisDisabled = true; reportFlowControlError(reference); - return unknownType; + return errorType; } flowDepth++; while (true) { @@ -39048,7 +39235,7 @@ var ts; else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 184 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { + if (container && container !== flowContainer && reference.kind !== 185 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -39086,7 +39273,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 131072 /* Union */) { + if (declaredType.flags & 262144 /* Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); } return declaredType; @@ -39104,7 +39291,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 186 /* CallExpression */ ? + var expr = node.kind === 187 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -39112,7 +39299,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 186 /* CallExpression */) { + if (node.kind === 187 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -39120,7 +39307,7 @@ var ts; } else { var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 84 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 168 /* NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -39134,7 +39321,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 16384 /* Never */) { + if (type.flags & 32768 /* Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -39151,7 +39338,7 @@ var ts; return flowType; } var incomplete = isIncomplete(flowType); - var resultType = incomplete && narrowedType.flags & 16384 /* Never */ ? silentNeverType : narrowedType; + var resultType = incomplete && narrowedType.flags & 32768 /* Never */ ? silentNeverType : narrowedType; return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { @@ -39277,8 +39464,8 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 184 /* PropertyAccessExpression */ && - computedType.flags & 131072 /* Union */ && + return expr.kind === 185 /* PropertyAccessExpression */ && + computedType.flags & 262144 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); } @@ -39311,7 +39498,7 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if ((type.flags & (131072 /* Union */ | 65536 /* Object */)) || (type.flags & 32768 /* TypeParameter */ && type.isThisType)) { + if ((type.flags & (262144 /* Union */ | 131072 /* Object */)) || (type.flags & 65536 /* TypeParameter */ && type.isThisType)) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); }); } @@ -39328,10 +39515,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 194 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 194 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -39371,24 +39558,24 @@ var ts; assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (valueType.flags & 12288 /* Nullable */) { + if (valueType.flags & 24576 /* Nullable */) { if (!strictNullChecks) { return type; } var doubleEquals = operator === 32 /* EqualsEqualsToken */ || operator === 33 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ : - valueType.flags & 8192 /* Null */ ? + valueType.flags & 16384 /* Null */ ? assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ : assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 134283777 /* NotUnionOrUnit */) { + if (type.flags & 16909315 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 16384 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); + return narrowedType.flags & 32768 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -39410,16 +39597,19 @@ var ts; if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } - if (assumeTrue && !(type.flags & 131072 /* Union */)) { + if (type.flags & 1 /* Any */ && literal.text === "function") { + return type; + } + if (assumeTrue && !(type.flags & 262144 /* Union */)) { // We narrow a non-union type to an exact primitive type if the non-union type // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. - var targetType = typeofTypesByName.get(literal.text); + var targetType = literal.text === "function" ? globalFunctionType : typeofTypesByName.get(literal.text); if (targetType) { if (isTypeSubtypeOf(targetType, type)) { return targetType; } - if (type.flags & 7897088 /* Instantiable */) { + if (type.flags & 15794176 /* Instantiable */) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(targetType, constraint)) { return getIntersectionType([type, targetType]); @@ -39441,13 +39631,13 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 16384 /* Never */ ? neverType : + var caseType = discriminantType.flags & 32768 /* Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); - return caseType.flags & 16384 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 32768 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); } function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); @@ -39501,9 +39691,9 @@ var ts; } // If the current type is a union type, remove all constituents that couldn't be instances of // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 16384 /* Never */)) { + if (!(assignableType.flags & 32768 /* Never */)) { return assignableType; } } @@ -39543,7 +39733,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 185 /* ElementAccessExpression */ || invokedExpression.kind === 184 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 186 /* ElementAccessExpression */ || invokedExpression.kind === 185 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -39563,15 +39753,15 @@ var ts; case 71 /* Identifier */: case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: if (expr.operator === 51 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -39607,9 +39797,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 239 /* ModuleBlock */ || - node.kind === 273 /* SourceFile */ || - node.kind === 151 /* PropertyDeclaration */; + node.kind === 240 /* ModuleBlock */ || + node.kind === 274 /* SourceFile */ || + node.kind === 152 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -39631,7 +39821,7 @@ var ts; if (node.kind === 71 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 148 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 149 /* Parameter */) { symbol.isAssigned = true; } } @@ -39646,21 +39836,21 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 148 /* Parameter */ && + declaration.kind === 149 /* Parameter */ && declaration.initializer && - getFalsyFlags(declaredType) & 4096 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 4096 /* Undefined */); + getFalsyFlags(declaredType) & 8192 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 8192 /* Undefined */); return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072 /* NEUndefined */) : declaredType; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 184 /* PropertyAccessExpression */ || - parent.kind === 186 /* CallExpression */ && parent.expression === node || - parent.kind === 185 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 181 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 185 /* PropertyAccessExpression */ || + parent.kind === 187 /* CallExpression */ && parent.expression === node || + parent.kind === 186 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 182 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { - return type.flags & 7372800 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 12288 /* Nullable */); + return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); } function getConstraintForLocation(type, node) { // When a node is the left hand expression of a property access, element access, or call expression, @@ -39680,7 +39870,7 @@ var ts; function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { - return unknownType; + return errorType; } // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. // Although in down-level emit of arrow function, we emit it using function expression which means that @@ -39691,7 +39881,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 192 /* ArrowFunction */) { + if (container.kind === 193 /* 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.hasModifier(container, 256 /* Async */)) { @@ -39712,7 +39902,7 @@ var ts; // 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 === 234 /* ClassDeclaration */ + if (declaration.kind === 235 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -39724,14 +39914,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 204 /* ClassExpression */) { + else if (declaration.kind === 205 /* 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 !== undefined) { + while (container.kind !== 274 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 151 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -39748,11 +39938,11 @@ var ts; if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(ts.isInJavaScriptFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); - return unknownType; + return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(symbol)); - return unknownType; + return errorType; } } var isAlias = localOrExportSymbol.flags & 2097152 /* Alias */; @@ -39775,7 +39965,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 148 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 149 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -39783,8 +39973,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 === 191 /* FunctionExpression */ || - flowContainer.kind === 192 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 192 /* FunctionExpression */ || + flowContainer.kind === 193 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -39792,10 +39982,10 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAsignmentTarget || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 251 /* ExportSpecifier */) || - node.parent.kind === 208 /* NonNullExpression */ || - declaration.kind === 231 /* VariableDeclaration */ && declaration.exclamationToken || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || + isInTypeQuery(node) || node.parent.kind === 252 /* ExportSpecifier */) || + node.parent.kind === 209 /* NonNullExpression */ || + declaration.kind === 232 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -39813,7 +40003,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 4096 /* Undefined */) && getFalsyFlags(flowType) & 4096 /* Undefined */) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); // Return the declared type to reduce follow-on errors return type; @@ -39826,7 +40016,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 268 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 269 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -39851,8 +40041,8 @@ var ts; } // 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 (container.kind === 219 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 232 /* VariableDeclarationList */).parent === container && + if (container.kind === 220 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 233 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -39866,7 +40056,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 190 /* ParenthesizedExpression */) { + while (current.parent.kind === 191 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -39874,7 +40064,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 197 /* PrefixUnaryExpression */ || current.parent.kind === 198 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 198 /* PrefixUnaryExpression */ || current.parent.kind === 199 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; } @@ -39887,7 +40077,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 151 /* PropertyDeclaration */ || container.kind === 154 /* Constructor */) { + if (container.kind === 152 /* PropertyDeclaration */ || container.kind === 155 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -39955,38 +40145,38 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 154 /* Constructor */) { + if (container.kind === 155 /* 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 === 192 /* ArrowFunction */) { + if (container.kind === 193 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES2015 */); } switch (container.kind) { - case 238 /* ModuleDeclaration */: + case 239 /* 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 237 /* EnumDeclaration */: + case 238 /* 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 154 /* Constructor */: + case 155 /* 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 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { 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 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -40007,8 +40197,8 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } - if (container.kind === 191 /* FunctionExpression */ && - container.parent.kind === 199 /* BinaryExpression */ && + if (container.kind === 192 /* FunctionExpression */ && + container.parent.kind === 200 /* BinaryExpression */ && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') var className = container.parent // x.prototype.y = f @@ -40032,14 +40222,14 @@ var ts; } if (ts.isInJavaScriptFile(node)) { var type = getTypeForThisExpressionFromJSDoc(container); - if (type && type !== unknownType) { + if (type && type !== errorType) { return getFlowTypeOfReference(node, type); } } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 283 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 284 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -40049,15 +40239,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 148 /* Parameter */; }); + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 186 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 187 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); 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 === 192 /* ArrowFunction */) { + while (container && container.kind === 193 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -40070,22 +40260,22 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 146 /* ComputedPropertyName */; }); - if (current && current.kind === 146 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 147 /* ComputedPropertyName */; }); + if (current && current.kind === 147 /* 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 === 183 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 184 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); } - return unknownType; + return errorType; } - if (!isCallExpression && container.kind === 154 /* Constructor */) { + if (!isCallExpression && container.kind === 155 /* 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.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -40151,7 +40341,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 153 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 154 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -40165,10 +40355,10 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 183 /* ObjectLiteralExpression */) { + if (container.parent.kind === 184 /* 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 unknownType; + return errorType; } else { // for object literal assume that type of 'super' is 'any' @@ -40179,17 +40369,17 @@ var ts; var classLikeDeclaration = container.parent; if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); - return unknownType; + return errorType; } var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classLikeDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; if (!baseClassType) { - return unknownType; + return errorType; } - if (container.kind === 154 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 155 /* 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 unknownType; + return errorType; } return nodeCheckFlag === 512 /* SuperStatic */ ? getBaseConstructorTypeOfClass(classType) @@ -40201,7 +40391,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 === 154 /* Constructor */; + return container.kind === 155 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -40209,21 +40399,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 === 183 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 184 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 153 /* MethodDeclaration */ || - container.kind === 152 /* MethodSignature */ || - container.kind === 155 /* GetAccessor */ || - container.kind === 156 /* SetAccessor */; + return container.kind === 154 /* MethodDeclaration */ || + container.kind === 153 /* MethodSignature */ || + container.kind === 156 /* GetAccessor */ || + container.kind === 157 /* SetAccessor */; } else { - return container.kind === 153 /* MethodDeclaration */ || - container.kind === 152 /* MethodSignature */ || - container.kind === 155 /* GetAccessor */ || - container.kind === 156 /* SetAccessor */ || - container.kind === 151 /* PropertyDeclaration */ || - container.kind === 150 /* PropertySignature */ || - container.kind === 154 /* Constructor */; + return container.kind === 154 /* MethodDeclaration */ || + container.kind === 153 /* MethodSignature */ || + container.kind === 156 /* GetAccessor */ || + container.kind === 157 /* SetAccessor */ || + container.kind === 152 /* PropertyDeclaration */ || + container.kind === 151 /* PropertySignature */ || + container.kind === 155 /* Constructor */; } } } @@ -40231,10 +40421,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 153 /* MethodDeclaration */ || - func.kind === 155 /* GetAccessor */ || - func.kind === 156 /* SetAccessor */) && func.parent.kind === 183 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 191 /* FunctionExpression */ && func.parent.kind === 269 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 154 /* MethodDeclaration */ || + func.kind === 156 /* GetAccessor */ || + func.kind === 157 /* SetAccessor */) && func.parent.kind === 184 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 192 /* FunctionExpression */ && func.parent.kind === 270 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -40242,11 +40432,11 @@ var ts; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 262144 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 524288 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 192 /* ArrowFunction */) { + if (func.kind === 193 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -40273,7 +40463,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 269 /* PropertyAssignment */) { + if (literal.parent.kind !== 270 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -40287,9 +40477,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 199 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { var target = parent.left; - if (target.kind === 184 /* PropertyAccessExpression */ || target.kind === 185 /* ElementAccessExpression */) { + if (target.kind === 185 /* PropertyAccessExpression */ || target.kind === 186 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -40345,7 +40535,7 @@ var ts; if (funcHasRestParameters && indexOfParameter === (func.parameters.length - 1) && isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); + return getTypeOfSymbol(ts.last(contextualSignature.parameters)); } } } @@ -40364,7 +40554,7 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 148 /* Parameter */) { + if (declaration.kind === 149 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -40376,7 +40566,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 181 /* BindingElement */) { + if (parentDeclaration.kind !== 182 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -40432,7 +40622,7 @@ var ts; function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed - if (functionDecl.kind === 154 /* Constructor */ || + if (functionDecl.kind === 155 /* Constructor */ || ts.getEffectiveReturnTypeNode(functionDecl) || isGetAccessorWithAnnotatedSetAccessor(functionDecl)) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); @@ -40447,7 +40637,7 @@ var ts; } // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. function getContextualTypeForArgument(callTarget, arg) { - var args = getEffectiveCallArguments(callTarget); + var args = getEffectiveCallArguments(callTarget); // TODO: GH#18217 var argIndex = args.indexOf(arg); // -1 for e.g. the expression of a CallExpression, or the tag of a TaggedTemplateExpression return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex); } @@ -40458,7 +40648,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 188 /* TaggedTemplateExpression */) { + if (template.parent.kind === 189 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -40474,7 +40664,7 @@ var ts; // expression has no contextual type, the right operand is contextually typed by the type of the left operand, // except for the special case of Javascript declarations of the form `namespace.prop = namespace.prop || {}` var type = getContextualType(binaryExpression); - return !type && node === right && !ts.getDeclaredJavascriptInitializer(binaryExpression.parent) && !ts.getAssignedJavascriptInitializer(binaryExpression) ? + return !type && node === right && !ts.isDefaultedJavascriptInitializer(binaryExpression) ? getTypeOfExpression(left) : type; case 53 /* AmpersandAmpersandToken */: case 26 /* CommaToken */: @@ -40501,12 +40691,12 @@ var ts; case 6 /* Prototype */: return false; default: - ts.Debug.assertNever(kind); + return ts.Debug.assertNever(kind); } } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 458752 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; + var prop = t.flags & 917504 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }, /*noReductions*/ true); } @@ -40515,7 +40705,7 @@ var ts; } // Return true if the given contextual type is a tuple-like type function contextualTypeIsTupleLikeType(type) { - return !!(type.flags & 131072 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); + return !!(type.flags & 262144 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one @@ -40590,12 +40780,31 @@ var ts; return getContextualType(attribute.parent); } } + // Return true if the given expression is possibly a discriminant value. We limit the kinds of + // expressions we check to those that don't depend on their contextual type in order not to cause + // recursive (and possibly infinite) invocations of getContextualType. + function isPossiblyDiscriminantValue(node) { + switch (node.kind) { + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: + case 95 /* NullKeyword */: + case 71 /* Identifier */: + return true; + case 185 /* PropertyAccessExpression */: + case 191 /* ParenthesizedExpression */: + return isPossiblyDiscriminantValue(node.expression); + } + return false; + } // 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. function getApparentTypeOfContextualType(node) { var contextualType = getContextualType(node); contextualType = contextualType && mapType(contextualType, getApparentType); - if (!(contextualType && contextualType.flags & 131072 /* Union */ && ts.isObjectLiteralExpression(node))) { + if (!(contextualType && contextualType.flags & 262144 /* Union */ && ts.isObjectLiteralExpression(node))) { return contextualType; } // Keep the below up-to-date with the work done within `isRelatedTo` by `findMatchingDiscriminantType` @@ -40604,10 +40813,10 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 269 /* PropertyAssignment */) + if (prop.kind !== 270 /* PropertyAssignment */) continue; - if (isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { - var discriminatingType = getTypeOfNode(prop.initializer); + if (isPossiblyDiscriminantValue(prop.initializer) && isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { + var discriminatingType = checkExpression(prop.initializer); for (var _b = 0, _c = contextualType.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, prop.symbol.escapedName); @@ -40652,59 +40861,59 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 181 /* BindingElement */: + case 232 /* VariableDeclaration */: + case 149 /* Parameter */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 182 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 192 /* ArrowFunction */: - case 224 /* ReturnStatement */: + case 193 /* ArrowFunction */: + case 225 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 182 /* ArrayLiteralExpression */: { + case 183 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 210 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 201 /* TemplateExpression */); + case 211 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 202 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 190 /* ParenthesizedExpression */: { + case 191 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 261 /* JsxAttribute */: - case 263 /* JsxSpreadAttribute */: + case 262 /* JsxAttribute */: + case 264 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 256 /* JsxOpeningElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; } function getContextualMapper(node) { - node = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); - return node ? node.contextualMapper : identityMapper; + var ancestor = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); + return ancestor ? ancestor.contextualMapper : identityMapper; } function getContextualJsxElementAttributesType(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { @@ -40720,16 +40929,16 @@ var ts; } function getJsxSignaturesParameterTypes(valueType, isJs, context) { // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - if (valueType.flags & 2 /* String */) { + if (valueType.flags & 4 /* String */) { return anyType; } - else if (valueType.flags & 32 /* StringLiteral */) { + else if (valueType.flags & 64 /* StringLiteral */) { // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type // For example: // var CustomTag: "h1" = "h1"; // Hello World var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, context); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { var stringLiteralTypeName = valueType.value; var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); if (intrinsicProp) { @@ -40751,7 +40960,7 @@ var ts; ctor = false; if (signatures.length === 0) { // We found no signatures at all, which is an error - return unknownType; + return errorType; } } var links = getNodeLinks(context); @@ -40772,7 +40981,7 @@ var ts; function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); - if (intrinsicAttribs !== unknownType) { + if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); } return propsType; @@ -40806,7 +41015,7 @@ var ts; // Normal case -- add in IntrinsicClassElements and IntrinsicElements var apparentAttributesType = attributesType; var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context); - if (intrinsicClassAttribs !== unknownType) { + if (intrinsicClassAttribs !== errorType) { var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol); var hostClassType = getReturnTypeOfSignature(sig); apparentAttributesType = intersectTypes(typeParams @@ -40814,7 +41023,7 @@ var ts; : intrinsicClassAttribs, apparentAttributesType); } var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); - if (intrinsicAttribs !== unknownType) { + if (intrinsicAttribs !== errorType) { apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType); } return apparentAttributesType; @@ -40847,7 +41056,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 191 /* FunctionExpression */ || node.kind === 192 /* ArrowFunction */; + return node.kind === 192 /* FunctionExpression */ || node.kind === 193 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -40866,7 +41075,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 !== 153 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type; if (ts.isInJavaScriptFile(node)) { var jsdoc = ts.getJSDocType(node); @@ -40880,7 +41089,7 @@ var ts; if (!type) { return undefined; } - if (!(type.flags & 131072 /* Union */)) { + if (!(type.flags & 262144 /* Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -40919,8 +41128,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 181 /* BindingElement */ && !!node.initializer) || - (node.kind === 199 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 182 /* BindingElement */ && !!node.initializer) || + (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; @@ -40930,7 +41139,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); for (var index = 0; index < elements.length; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 203 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 204 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -40955,7 +41164,7 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 203 /* SpreadElement */; + hasSpreadElement = hasSpreadElement || e.kind === 204 /* SpreadElement */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -40969,7 +41178,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 180 /* ArrayBindingPattern */ || pattern.kind === 182 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 181 /* ArrayBindingPattern */ || pattern.kind === 183 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -40977,7 +41186,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 205 /* OmittedExpression */) { + if (patternElement.kind !== 206 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); @@ -40995,7 +41204,7 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return isNumericComputedName(name); case 71 /* Identifier */: return isNumericLiteralName(name.escapedText); @@ -41009,7 +41218,7 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAssignableToKind(checkComputedPropertyName(name), 84 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 168 /* NumberLike */); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -41044,8 +41253,8 @@ var ts; links.resolvedType = checkExpression(node.expression); // 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 & 12288 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 34 /* StringLike */ | 84 /* NumberLike */ | 1536 /* ESSymbolLike */) && + if (links.resolvedType.flags & 24576 /* Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -41072,23 +41281,26 @@ var ts; var propertiesTable; var propertiesArray = []; var spread = emptyObjectType; - var propagatedFlags = 8388608 /* FreshLiteral */; + var propagatedFlags = 33554432 /* FreshLiteral */; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 179 /* ObjectBindingPattern */ || contextualType.pattern.kind === 183 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 180 /* ObjectBindingPattern */ || contextualType.pattern.kind === 184 /* ObjectLiteralExpression */); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; var hasComputedNumberProperty = false; - if (isInJSFile && node.properties.length === 0) { - // an empty JS object literal that nonetheless has members is a JS namespace - var symbol = getSymbolOfNode(node); - if (symbol.exports) { - propertiesTable = symbol.exports; - symbol.exports.forEach(function (symbol) { return propertiesArray.push(getMergedSymbol(symbol)); }); - return createObjectLiteralType(); + if (isInJSFile) { + var decl = ts.getDeclarationOfJSInitializer(node); + if (decl) { + // a JS object literal whose declaration's symbol has exports is a JS namespace + var symbol = getMergedSymbol(decl.symbol); + if (symbol && ts.hasEntries(symbol.exports)) { + propertiesTable = symbol.exports; + symbol.exports.forEach(function (symbol) { return propertiesArray.push(getMergedSymbol(symbol)); }); + return createObjectLiteralType(); + } } } propertiesTable = ts.createSymbolTable(); @@ -41096,13 +41308,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 146 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 269 /* PropertyAssignment */ || - memberDecl.kind === 270 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 270 /* PropertyAssignment */ || + memberDecl.kind === 271 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 269 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 270 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 270 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 271 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -41112,7 +41324,7 @@ var ts; } } typeFlags |= type.flags; - var nameType = computedNameType && computedNameType.flags & 1120 /* StringOrNumberLiteralOrUnique */ ? + var nameType = computedNameType && computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */ ? computedNameType : undefined; var prop = nameType ? createSymbol(4 /* Property */ | member.flags, getLateBoundNameFromType(nameType), 1024 /* Late */) : @@ -41123,8 +41335,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 === 269 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 270 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 270 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 271 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -41149,7 +41361,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 271 /* SpreadAssignment */) { + else if (memberDecl.kind === 272 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -41164,7 +41376,7 @@ var ts; var type = checkExpression(memberDecl.expression); if (!isValidSpreadType(type)) { error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); - return unknownType; + return errorType; } spread = getSpreadType(spread, type, node.symbol, propagatedFlags, /*objectFlags*/ 0); offset = i + 1; @@ -41176,10 +41388,10 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 155 /* GetAccessor */ || memberDecl.kind === 156 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 156 /* GetAccessor */ || memberDecl.kind === 157 /* SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 1120 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -41222,8 +41434,8 @@ var ts; var stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0 /* String */) : undefined; var numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8388608 /* FreshLiteral */; - result.flags |= 33554432 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 117440512 /* PropagatingFlags */); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 33554432 /* FreshLiteral */; + result.flags |= 268435456 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 939524096 /* PropagatingFlags */); result.objectFlags |= 128 /* ObjectLiteral */; if (patternWithComputedProperties) { result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; @@ -41231,17 +41443,17 @@ var ts; if (inDestructuringPattern) { result.pattern = node; } - if (!(result.flags & 12288 /* Nullable */)) { - propagatedFlags |= (result.flags & 117440512 /* PropagatingFlags */); + if (!(result.flags & 24576 /* Nullable */)) { + propagatedFlags |= (result.flags & 939524096 /* PropagatingFlags */); } return result; } } function isValidSpreadType(type) { - return !!(type.flags & (1 /* Any */ | 134217728 /* NonPrimitive */) || - getFalsyFlags(type) & 14560 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || - type.flags & 65536 /* Object */ && !isGenericMappedType(type) || - type.flags & 393216 /* UnionOrIntersection */ && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); + return !!(type.flags & (3 /* AnyOrUnknown */ | 16777216 /* NonPrimitive */) || + getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || + type.flags & 131072 /* Object */ && !isGenericMappedType(type) || + type.flags & 786432 /* UnionOrIntersection */ && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } function checkJsxSelfClosingElement(node, checkMode) { checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); @@ -41281,13 +41493,13 @@ var ts; function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment switch (tagName.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: case 99 /* ThisKeyword */: return false; case 71 /* Identifier */: return ts.isIntrinsicJsxName(tagName.escapedText); default: - ts.Debug.fail(); + return ts.Debug.fail(); } } function checkJsxAttribute(node, checkMode) { @@ -41331,7 +41543,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 263 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 264 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, /*typeFlags*/ 0, 4096 /* JsxAttributes */); attributesTable = ts.createSymbolTable(); @@ -41354,7 +41566,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 254 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 255 /* 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); @@ -41389,7 +41601,7 @@ var ts; */ function createJsxAttributesType() { var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.flags |= 33554432 /* ContainsObjectLiteral */; + result.flags |= 268435456 /* ContainsObjectLiteral */; result.objectFlags |= 128 /* ObjectLiteral */ | 4096 /* JsxAttributes */; return result; } @@ -41423,7 +41635,7 @@ var ts; var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); var typeSymbol = exports && getSymbol(exports, name, 67901928 /* Type */); - return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : unknownType; + return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** * Looks up an intrinsic tag name and returns a symbol that either points to an intrinsic @@ -41435,7 +41647,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { // Property case if (!ts.isIdentifier(node.tagName)) return ts.Debug.fail(); @@ -41501,6 +41713,7 @@ var ts; return instantiatedSignatures; } function getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, reportErrors) { + if (reportErrors === void 0) { reportErrors = false; } if (!node.typeArguments) { return; } @@ -41523,7 +41736,7 @@ var ts; } } // JSX global fallback - return getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined); + return getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined); // TODO: GH#18217 } /** * Look into JSX namespace and then look for container with matching name as nameOfAttribPropContainer. @@ -41571,7 +41784,7 @@ var ts; if (!propsType) { return undefined; } - if (propsType.flags & 262144 /* Intersection */) { + if (propsType.flags & 524288 /* Intersection */) { var propsApparentType = []; for (var _i = 0, _a = propsType.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -41592,7 +41805,7 @@ var ts; * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global */ function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 131072 /* Union */)); + ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); if (jsxStatelessElementType) { @@ -41605,7 +41818,7 @@ var ts; if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { // Intersect in JSX.IntrinsicAttributes if it exists var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== unknownType) { + if (intrinsicAttributes !== errorType) { paramType = intersectTypes(intrinsicAttributes, paramType); } return paramType; @@ -41626,7 +41839,7 @@ var ts; * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global */ function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 131072 /* Union */)); + ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); @@ -41639,6 +41852,7 @@ var ts; for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { var candidate = candidatesOutArray_1[_i]; var callReturnType = getReturnTypeOfSignature(candidate); + // TODO: GH#18217: callReturnType should always be defined... var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); paramType = getApparentTypeOfJsxPropsType(paramType); if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { @@ -41647,7 +41861,7 @@ var ts; var attribute = _b[_a]; if (ts.isJsxAttribute(attribute) && isUnhyphenatedJsxName(attribute.name.escapedText) && - !getPropertyOfType(paramType, attribute.name.escapedText)) { + !getPropertyOfType(paramType, attribute.name.escapedText)) { // TODO: GH#18217 shouldBeCandidate = false; break; } @@ -41664,7 +41878,7 @@ var ts; } // Intersect in JSX.IntrinsicAttributes if it exists var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== unknownType) { + if (intrinsicAttributes !== errorType) { result = intersectTypes(intrinsicAttributes, result); } return result; @@ -41722,7 +41936,7 @@ var ts; * emptyObjectType if there is no "prop" in the element instance type */ function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (elementType.flags & 131072 /* Union */) { + if (elementType.flags & 262144 /* Union */) { var types = elementType.types; return getUnionType(types.map(function (type) { return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); @@ -41733,16 +41947,16 @@ var ts; return elementType; } // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - else if (elementType.flags & 2 /* String */) { + else if (elementType.flags & 4 /* String */) { return anyType; } - else if (elementType.flags & 32 /* StringLiteral */) { + else if (elementType.flags & 64 /* StringLiteral */) { // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type // For example: // var CustomTag: "h1" = "h1"; // Hello World var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, openingLikeElement); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { var stringLiteralTypeName = elementType.value; var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); if (intrinsicProp) { @@ -41760,9 +41974,9 @@ var ts; // Get the element instance type (the result of newing or invoking this tag) var instantiatedSignatures = getInstantiatedJsxSignatures(openingLikeElement, elementType, /*reportErrors*/ true); if (!ts.length(instantiatedSignatures)) { - return unknownType; + return errorType; } - var elemInstanceType = getUnionType(ts.map(instantiatedSignatures, getReturnTypeOfSignature), 2 /* Subtype */); + var elemInstanceType = getUnionType(instantiatedSignatures.map(getReturnTypeOfSignature), 2 /* Subtype */); // If we should include all stateless attributes type, then get all attributes type from all stateless function signature. // Otherwise get only attributes type from the signature picked by choose-overload logic. var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? @@ -41776,7 +41990,7 @@ var ts; checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } var isJs = ts.isInJavaScriptFile(openingLikeElement); - return getUnionType(ts.map(instantiatedSignatures, function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, /*reportErrors*/ true); })); + return getUnionType(instantiatedSignatures.map(function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, /*reportErrors*/ true); })); } /** * Get attributes type of the given intrinsic opening-like Jsx element by resolving the tag name. @@ -41795,7 +42009,7 @@ var ts; return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0 /* String */).type; } else { - return links.resolvedJsxElementAttributesType = unknownType; + return links.resolvedJsxElementAttributesType = errorType; } } return links.resolvedJsxElementAttributesType; @@ -41849,7 +42063,7 @@ var ts; } function getJsxElementClassTypeAt(location) { var type = getJsxType(JsxNames.ElementClass, location); - if (type === unknownType) + if (type === errorType) return undefined; return type; } @@ -41922,7 +42136,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 65536 /* Object */) { + if (targetType.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(targetType); if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || @@ -41932,7 +42146,7 @@ var ts; return true; } } - else if (targetType.flags & 393216 /* UnionOrIntersection */) { + else if (targetType.flags & 786432 /* UnionOrIntersection */) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -42018,13 +42232,13 @@ var ts; return type; } else { - return unknownType; + return errorType; } } // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 151 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 152 /* PropertyDeclaration */; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; @@ -42053,9 +42267,9 @@ var ts; */ function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 184 /* PropertyAccessExpression */ || node.kind === 231 /* VariableDeclaration */ ? + var errorNode = node.kind === 185 /* PropertyAccessExpression */ || node.kind === 232 /* VariableDeclaration */ ? node.name : - node.kind === 178 /* ImportType */ ? + node.kind === 179 /* ImportType */ ? node : node.right; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { @@ -42090,7 +42304,7 @@ var ts; if ((flags & 128 /* Abstract */) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeWithinConstructorOfClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); + 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; } } @@ -42128,9 +42342,9 @@ var ts; if (flags & 32 /* Static */) { return true; } - if (type.flags & 32768 /* TypeParameter */) { + if (type.flags & 65536 /* TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type - type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + 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)); @@ -42141,21 +42355,25 @@ var ts; function symbolHasNonMethodDeclaration(symbol) { return forEachProperty(symbol, function (prop) { var propKind = getDeclarationKindFromSymbol(prop); - return propKind !== 153 /* MethodDeclaration */ && propKind !== 152 /* MethodSignature */; + return propKind !== 154 /* MethodDeclaration */ && propKind !== 153 /* MethodSignature */; }); } function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 12288 /* Nullable */; + if (type.flags & 2 /* Unknown */) { + error(node, ts.Diagnostics.Object_is_of_type_unknown); + return errorType; + } + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 24576 /* Nullable */; if (kind) { - error(node, kind & 4096 /* Undefined */ ? kind & 8192 /* Null */ ? + error(node, kind & 8192 /* Undefined */ ? kind & 16384 /* Null */ ? (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); var t = getNonNullableType(type); - return t.flags & (12288 /* Nullable */ | 16384 /* Never */) ? unknownType : t; + return t.flags & (24576 /* Nullable */ | 32768 /* Never */) ? errorType : t; } return type; } @@ -42185,9 +42403,9 @@ var ts; var indexInfo = getIndexInfoOfType(apparentType, 0 /* String */); if (!(indexInfo && indexInfo.type)) { if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, leftType.flags & 32768 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); + reportNonexistentProperty(right, leftType.flags & 65536 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); } - return unknownType; + return errorType; } if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) { error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType)); @@ -42202,7 +42420,7 @@ var ts; if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, ts.idText(right)); - return unknownType; + return errorType; } } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); @@ -42210,9 +42428,9 @@ var ts; // 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. - if (node.kind !== 184 /* PropertyAccessExpression */ || + if (node.kind !== 185 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || - prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 131072 /* Union */)) { + prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { return propType; } // If strict null checks and strict property initialization checks are enabled, if we have @@ -42224,14 +42442,14 @@ var ts; var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 154 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 155 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 4096 /* Undefined */) && getFalsyFlags(flowType) & 4096 /* Undefined */) { - error(right, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); + if (assumeUninitialized && !(getFalsyFlags(propType) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { + error(right, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217 // Return the declared type to reduce follow-on errors return propType; } @@ -42247,8 +42465,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); } - else if (valueDeclaration.kind === 234 /* ClassDeclaration */ && - node.parent.kind !== 161 /* TypeReference */ && + else if (valueDeclaration.kind === 235 /* ClassDeclaration */ && + node.parent.kind !== 162 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.idText(right)); @@ -42257,9 +42475,9 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return true; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -42296,7 +42514,7 @@ var ts; } function reportNonexistentProperty(propNode, containingType) { var errorInfo; - if (containingType.flags & 131072 /* Union */ && !(containingType.flags & 16382 /* Primitive */)) { + if (containingType.flags & 262144 /* Union */ && !(containingType.flags & 32764 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText)) { @@ -42453,20 +42671,20 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 178 /* ImportType */: + case 179 /* ImportType */: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 178 /* ImportType */ ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 179 /* ImportType */ ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { - var propType = getTypeOfFuncClassEnumModule(method); + var propType = getTypeOfPropertyOfType(actualThisType, method.escapedName); var signatures = getSignaturesOfType(getNonNullableType(propType), 0 /* Call */); ts.Debug.assert(signatures.length !== 0); return signatures.some(function (sig) { @@ -42483,20 +42701,20 @@ var ts; return instantiateType(signatureThisType, createSignatureTypeMapper(sig, getInferredTypes(context))); } function isValidPropertyAccessWithType(node, left, propertyName, type) { - if (type === unknownType || isTypeAny(type)) { + if (type === errorType || isTypeAny(type)) { return true; } var prop = getPropertyOfType(type, propertyName); return prop ? checkPropertyAccessibility(node, left, type, prop) // In js files properties of unions are allowed in completion - : ts.isInJavaScriptFile(node) && (type.flags & 131072 /* Union */) && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, left, propertyName, elementType); }); + : ts.isInJavaScriptFile(node) && (type.flags & 262144 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, left, propertyName, elementType); }); } /** * Return the symbol of the for-in variable declared or referenced by the given for-in statement. */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 232 /* VariableDeclarationList */) { + if (initializer.kind === 233 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -42525,7 +42743,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 220 /* ForInStatement */ && + if (node.kind === 221 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -42543,7 +42761,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 187 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 188 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -42553,20 +42771,20 @@ var ts; var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); } - return unknownType; + return errorType; } var indexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : checkExpression(indexExpression); - if (objectType === unknownType || objectType === silentNeverType) { + if (objectType === errorType || objectType === silentNeverType) { return objectType; } if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9 /* StringLiteral */) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); - return unknownType; + return errorType; } return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === unknownType) { + if (expressionType === errorType) { // There is already an error, so no need to report one. return false; } @@ -42574,7 +42792,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 1536 /* ESSymbolLike */) === 0) { + if ((expressionType.flags & 3072 /* ESSymbolLike */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -42610,10 +42828,10 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 188 /* TaggedTemplateExpression */) { + if (node.kind === 189 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 149 /* Decorator */) { + else if (node.kind !== 150 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -42646,7 +42864,7 @@ var ts; var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { if (lastParent && parent === lastParent) { - index++; + index = index + 1; } else { lastParent = parent; @@ -42679,7 +42897,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 203 /* SpreadElement */) { + if (arg && arg.kind === 204 /* SpreadElement */) { return i; } } @@ -42689,22 +42907,21 @@ var ts; if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } var argCount; // Apparent number of arguments we will have in this call var typeArguments; // Type arguments (undefined if none) - var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments + var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var spreadArgIndex = -1; if (ts.isJsxOpeningLikeElement(node)) { // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". return true; } - if (node.kind === 188 /* TaggedTemplateExpression */) { + if (node.kind === 189 /* TaggedTemplateExpression */) { // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length argCount = args.length; - typeArguments = undefined; - if (node.template.kind === 201 /* TemplateExpression */) { + typeArguments = node.typeArguments; + if (node.template.kind === 202 /* 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.lastOrUndefined(node.template.templateSpans); - ts.Debug.assert(lastSpan !== undefined); // we should always have at least one span. + var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; } else { @@ -42716,14 +42933,14 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 149 /* Decorator */) { + else if (node.kind === 150 /* Decorator */) { typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); } else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 187 /* NewExpression */); + ts.Debug.assert(node.kind === 188 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -42758,7 +42975,7 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -42806,7 +43023,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 !== 149 /* Decorator */) { + if (node.kind !== 150 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the contextual mapper to avoid disturbing a resolution in progress for an @@ -42841,7 +43058,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 205 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 206 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -42882,7 +43099,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (!constraint) continue; - var errorInfo = reportErrors && headMessage && (function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }); + var errorInfo = reportErrors && headMessage ? (function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }) : undefined; var typeArgumentHeadMessage = headMessage || ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; if (!mapper) { mapper = createTypeMapper(typeParameters, typeArgumentTypes); @@ -42931,7 +43148,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 187 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 188 /* 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. @@ -42939,7 +43156,7 @@ var ts; var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; 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, getThisTypeOfSignature(signature), relation, errorNode, headMessage_1)) { + if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1)) { return false; } } @@ -42948,7 +43165,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 205 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 206 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); // If the effective argument type is undefined, there is no synthetic type for the argument. @@ -42972,9 +43189,9 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 186 /* CallExpression */) { + if (node.kind === 187 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 184 /* PropertyAccessExpression */ || callee.kind === 185 /* ElementAccessExpression */) { + if (callee.kind === 185 /* PropertyAccessExpression */ || callee.kind === 186 /* ElementAccessExpression */) { return callee.expression; } } @@ -42989,17 +43206,17 @@ var ts; * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. */ function getEffectiveCallArguments(node) { - if (node.kind === 188 /* TaggedTemplateExpression */) { + if (node.kind === 189 /* TaggedTemplateExpression */) { var template = node.template; - var args_4 = [undefined]; - if (template.kind === 201 /* TemplateExpression */) { + var args_4 = [undefined]; // TODO: GH#18217 + if (template.kind === 202 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); } return args_4; } - else if (node.kind === 149 /* Decorator */) { + else if (node.kind === 150 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -43026,19 +43243,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 149 /* Decorator */) { + if (node.kind === 150 /* Decorator */) { switch (node.parent.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* 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. @@ -43048,10 +43265,12 @@ var ts; // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 148 /* Parameter */: + case 149 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; + default: + return ts.Debug.fail(); } } else { @@ -43072,25 +43291,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 234 /* ClassDeclaration */) { + if (node.kind === 235 /* ClassDeclaration */) { // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 154 /* Constructor */) { + if (node.kind === 155 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 151 /* PropertyDeclaration */ || - node.kind === 153 /* MethodDeclaration */ || - node.kind === 155 /* GetAccessor */ || - node.kind === 156 /* SetAccessor */) { + if (node.kind === 152 /* PropertyDeclaration */ || + node.kind === 154 /* MethodDeclaration */ || + node.kind === 156 /* GetAccessor */ || + node.kind === 157 /* SetAccessor */) { // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -43098,7 +43317,7 @@ var ts; return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } /** * Returns the effective type for the second argument to a decorator. @@ -43117,37 +43336,38 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 234 /* ClassDeclaration */) { + if (node.kind === 235 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* Parameter */) { node = node.parent; - if (node.kind === 154 /* Constructor */) { + if (node.kind === 155 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. } - if (node.kind === 151 /* PropertyDeclaration */ || - node.kind === 153 /* MethodDeclaration */ || - node.kind === 155 /* GetAccessor */ || - node.kind === 156 /* SetAccessor */) { + if (node.kind === 152 /* PropertyDeclaration */ || + node.kind === 154 /* MethodDeclaration */ || + node.kind === 156 /* GetAccessor */ || + node.kind === 157 /* SetAccessor */) { // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; - switch (element.name.kind) { + var name = element.name; + switch (name.kind) { case 71 /* Identifier */: - return getLiteralType(ts.idText(element.name)); + return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - return getLiteralType(element.name.text); - case 146 /* ComputedPropertyName */: - var nameType = checkComputedPropertyName(element.name); - if (isTypeAssignableToKind(nameType, 1536 /* ESSymbolLike */)) { + return getLiteralType(name.text); + case 147 /* ComputedPropertyName */: + var nameType = checkComputedPropertyName(name); + if (isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */)) { return nameType; } else { @@ -43155,11 +43375,11 @@ var ts; } default: ts.Debug.fail("Unsupported property name."); - return unknownType; + return errorType; } } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } /** * Returns the effective argument type for the third argument to a decorator. @@ -43171,28 +43391,28 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 234 /* ClassDeclaration */) { + if (node.kind === 235 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 151 /* PropertyDeclaration */) { + if (node.kind === 152 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 153 /* MethodDeclaration */ || - node.kind === 155 /* GetAccessor */ || - node.kind === 156 /* SetAccessor */) { + if (node.kind === 154 /* MethodDeclaration */ || + node.kind === 156 /* GetAccessor */ || + node.kind === 157 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. - var propertyType = getTypeOfNode(node); + var propertyType = getTypeOfNode(node); // TODO: GH#18217 return createTypedPropertyDescriptorType(propertyType); } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } /** * Returns the effective argument type for the provided argument to a decorator. @@ -43208,7 +43428,7 @@ var ts; return getEffectiveDecoratorThirdArgumentType(node.parent); } ts.Debug.fail("Decorators should not have a fourth synthetic argument."); - return unknownType; + return errorType; } /** * Gets the effective argument type for an argument in a call expression. @@ -43217,10 +43437,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 149 /* Decorator */) { + if (node.kind === 150 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 188 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -43232,8 +43452,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 149 /* Decorator */ || - (argIndex === 0 && node.kind === 188 /* TaggedTemplateExpression */)) { + if (node.kind === 150 /* Decorator */ || + (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -43242,11 +43462,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 149 /* Decorator */) { + if (node.kind === 150 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 188 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -43266,8 +43486,8 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, fallbackError) { - var isTaggedTemplate = node.kind === 188 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 149 /* Decorator */; + var isTaggedTemplate = node.kind === 189 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 150 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; if (!isDecorator) { @@ -43341,7 +43561,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 = candidatesOutArray && node.kind === 186 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 187 /* 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 @@ -43423,7 +43643,7 @@ var ts; var candidate = candidates[bestIndex]; var typeParameters = candidate.typeParameters; if (typeParameters && callLikeExpressionMayHaveTypeArguments(node) && node.typeArguments) { - var typeArguments_1 = node.typeArguments.map(getTypeOfNode); + var typeArguments_1 = node.typeArguments.map(getTypeOfNode); // TODO: GH#18217 while (typeArguments_1.length > typeParameters.length) { typeArguments_1.pop(); } @@ -43520,9 +43740,10 @@ var ts; if (node.expression.kind === 97 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { + ts.forEach(node.arguments, checkExpression); // Still visit arguments so they get marked for visibility, etc return anySignature; } - if (superType !== unknownType) { + if (superType !== errorType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated // with the type arguments specified in the extends clause. var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -43538,7 +43759,7 @@ var ts; return silentNeverSignature; } var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { + if (apparentType === errorType) { // Another error has already been reported return resolveErrorCall(node); } @@ -43554,7 +43775,7 @@ var ts; if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, constructSignatures.length)) { // The unknownType indicates that an error already occurred (and was reported). No // need to report another error in this case. - if (funcType !== unknownType && node.typeArguments) { + if (funcType !== errorType && node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); } return resolveUntypedCall(node); @@ -43580,8 +43801,8 @@ 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 & 32768 /* TypeParameter */ || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (131072 /* Union */ | 16384 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && funcType.flags & 65536 /* TypeParameter */ || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (262144 /* Union */ | 32768 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray) { if (node.arguments && languageVersion < 1 /* ES5 */) { @@ -43600,7 +43821,7 @@ var ts; // signatures for overload resolution. The result type of the function call becomes // the result type of the operation. expressionType = getApparentType(expressionType); - if (expressionType === unknownType) { + if (expressionType === errorType) { // Another error has already been reported return resolveErrorCall(node); } @@ -43711,7 +43932,7 @@ var ts; function resolveTaggedTemplateExpression(node, candidatesOutArray) { var tagType = checkExpression(node.tag); var apparentType = getApparentType(tagType); - if (apparentType === unknownType) { + if (apparentType === errorType) { // Another error has already been reported return resolveErrorCall(node); } @@ -43731,17 +43952,19 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 148 /* Parameter */: + case 149 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; + default: + return ts.Debug.fail(); } } /** @@ -43750,7 +43973,7 @@ var ts; function resolveDecorator(node, candidatesOutArray) { var funcType = checkExpression(node.expression); var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { + if (apparentType === errorType) { return resolveErrorCall(node); } var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); @@ -43765,8 +43988,7 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorInfo = void 0; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); + var errorInfo = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); invocationErrorRecovery(apparentType, 0 /* Call */); @@ -43797,7 +44019,7 @@ var ts; * the function will fill it up with appropriate candidate signatures */ function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { - ts.Debug.assert(!(elementType.flags & 131072 /* Union */)); + ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); var callSignatures = elementType && getSignaturesOfType(elementType, 0 /* Call */); if (callSignatures && callSignatures.length > 0) { return resolveCall(openingLikeElement, callSignatures, candidatesOutArray); @@ -43806,16 +44028,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 186 /* CallExpression */: + case 187 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 149 /* Decorator */: + case 150 /* Decorator */: return resolveDecorator(node, candidatesOutArray); - case 256 /* JsxOpeningElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: // This code-path is called by language service var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { @@ -43830,7 +44052,7 @@ var ts; return ts.length(sigs) ? sigs[0] : unknownSignature; }) || unknownSignature; } - ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); + throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } /** * Resolve a signature of a given call-like expression. @@ -43870,15 +44092,11 @@ var ts; var symbol = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? getSymbolOfNode(node) : ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : undefined; - return symbol && symbol.members !== undefined; + return !!symbol && symbol.members !== undefined; } return false; } function getJavaScriptClassType(symbol) { - var initializer = ts.getDeclaredJavascriptInitializer(symbol.valueDeclaration); - if (initializer) { - symbol = getSymbolOfNode(initializer); - } var inferred; if (isJavaScriptConstructor(symbol.valueDeclaration)) { inferred = getInferredClassType(symbol); @@ -43909,7 +44127,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 184 /* PropertyAccessExpression */) { + while (parent && parent.kind === 185 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -43941,12 +44159,12 @@ var ts; if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; } - if (node.kind === 187 /* NewExpression */) { + if (node.kind === 188 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 154 /* Constructor */ && - declaration.kind !== 158 /* ConstructSignature */ && - declaration.kind !== 163 /* ConstructorType */ && + declaration.kind !== 155 /* Constructor */ && + declaration.kind !== 159 /* ConstructSignature */ && + declaration.kind !== 164 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations @@ -43974,10 +44192,20 @@ var ts; var returnType = getReturnTypeOfSignature(signature); // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property // as a fresh unique symbol literal type. - if (returnType.flags & 1536 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 3072 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - return returnType; + var jsAssignmentType; + if (ts.isInJavaScriptFile(node)) { + var decl = ts.getDeclarationOfJSInitializer(node); + if (decl) { + var jsSymbol = getSymbolOfNode(decl); + if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { + jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, jsObjectLiteralIndexInfo, undefined); + } + } + } + return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -44009,7 +44237,7 @@ var ts; for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 4096 /* Undefined */ || specifierType.flags & 8192 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 8192 /* Undefined */ || specifierType.flags & 16384 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -44023,7 +44251,7 @@ var ts; return createPromiseReturnType(node, anyType); } function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) { - if (allowSyntheticDefaultImports && type && type !== unknownType) { + if (allowSyntheticDefaultImports && type && type !== errorType) { var synthType = type; if (!synthType.syntheticType) { var file_4 = ts.find(originalSymbol.declarations, ts.isSourceFile); @@ -44053,7 +44281,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67216319 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67216319 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } @@ -44062,9 +44290,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 233 /* FunctionDeclaration */ + ? 234 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 231 /* VariableDeclaration */ + ? 232 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -44087,7 +44315,7 @@ var ts; var exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(checkExpression(expression, checkMode))); checkSourceElement(type); var targetType = getTypeFromTypeNode(type); - if (produceDiagnostics && targetType !== unknownType) { + if (produceDiagnostics && targetType !== errorType) { var widenedType = getWidenedType(exprType); if (!isTypeComparableTo(targetType, widenedType)) { checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Type_0_cannot_be_converted_to_type_1); @@ -44106,14 +44334,15 @@ var ts; if (node.keywordToken === 91 /* ImportKeyword */) { return checkImportMetaProperty(node); } + return ts.Debug.assertNever(node.keywordToken); } function checkNewTargetMetaProperty(node) { var container = ts.getNewTargetContainer(node); if (!container) { error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); - return unknownType; + return errorType; } - else if (container.kind === 154 /* Constructor */) { + else if (container.kind === 155 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -44129,7 +44358,7 @@ var ts; var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); - return node.name.escapedText === "meta" ? getGlobalImportMetaType() : unknownType; + return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); @@ -44185,9 +44414,9 @@ var ts; } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { // parameter might be a transient symbol generated by use of `arguments` in the function body. - var parameter = ts.lastOrUndefined(signature.parameters); + var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -44237,7 +44466,7 @@ var ts; error(func, ts.isImportCall(func) ? ts.Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option : ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); - return unknownType; + return errorType; } else if (!getGlobalPromiseConstructorSymbol(/*reportErrors*/ true)) { error(func, ts.isImportCall(func) ? @@ -44248,11 +44477,11 @@ var ts; } function getReturnTypeFromBody(func, checkMode) { if (!func.body) { - return unknownType; + return errorType; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 212 /* Block */) { + if (func.body.kind !== 213 /* Block */) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any @@ -44366,7 +44595,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 226 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -44388,7 +44617,7 @@ var ts; // the native Promise type by the caller. type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - if (type.flags & 16384 /* Never */) { + if (type.flags & 32768 /* Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -44409,11 +44638,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return true; - case 153 /* MethodDeclaration */: - return func.parent.kind === 183 /* ObjectLiteralExpression */; + case 154 /* MethodDeclaration */: + return func.parent.kind === 184 /* ObjectLiteralExpression */; default: return false; } @@ -44432,16 +44661,16 @@ var ts; return; } // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (returnType && maybeTypeOfKind(returnType, 1 /* Any */ | 2048 /* Void */)) { + if (returnType && maybeTypeOfKind(returnType, 3 /* AnyOrUnknown */ | 4096 /* Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 152 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 212 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 213 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; - if (returnType && returnType.flags & 16384 /* Never */) { + if (returnType && returnType.flags & 32768 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (returnType && !hasExplicitReturn) { @@ -44470,14 +44699,14 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 153 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode === 1 /* SkipContextSensitive */ && isContextSensitive(node)) { return anyFunctionType; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 191 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 192 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -44518,7 +44747,7 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 153 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnTypeNode = ts.getEffectiveReturnTypeNode(node); var returnOrPromisedType = returnTypeNode && @@ -44538,7 +44767,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 212 /* Block */) { + if (node.body.kind === 213 /* Block */) { checkSourceElement(node.body); } else { @@ -44561,7 +44790,7 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAssignableToKind(type, 84 /* NumberLike */)) { + if (!isTypeAssignableToKind(type, 168 /* NumberLike */)) { error(operand, diagnostic); return false; } @@ -44584,11 +44813,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 184 /* PropertyAccessExpression */ || expr.kind === 185 /* ElementAccessExpression */) && + (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) && expr.expression.kind === 99 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 154 /* Constructor */)) { + if (!(func && func.kind === 155 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -44601,13 +44830,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 184 /* PropertyAccessExpression */ || expr.kind === 185 /* ElementAccessExpression */) { + if (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 71 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 245 /* NamespaceImport */; + return !!declaration && declaration.kind === 246 /* NamespaceImport */; } } } @@ -44616,7 +44845,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 71 /* Identifier */ && node.kind !== 184 /* PropertyAccessExpression */ && node.kind !== 185 /* ElementAccessExpression */) { + if (node.kind !== 71 /* Identifier */ && node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -44625,7 +44854,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 184 /* PropertyAccessExpression */ && expr.kind !== 185 /* ElementAccessExpression */) { + if (expr.kind !== 185 /* PropertyAccessExpression */ && expr.kind !== 186 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -44675,7 +44904,7 @@ var ts; case 38 /* MinusToken */: case 52 /* TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKind(operandType, 1536 /* ESSymbolLike */)) { + if (maybeTypeOfKind(operandType, 3072 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; @@ -44693,7 +44922,7 @@ var ts; } return numberType; } - return unknownType; + return errorType; } function checkPostfixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -44710,10 +44939,10 @@ var ts; // Return true if type might be of the given kind. A union or intersection type might be of a given // kind if at least one constituent type is of the given kind. function maybeTypeOfKind(type, kind) { - if (type.flags & kind || kind & 536870912 /* GenericMappedType */ && isGenericMappedType(type)) { + if (type.flags & kind & ~134217728 /* GenericMappedType */ || kind & 134217728 /* GenericMappedType */ && isGenericMappedType(type)) { return true; } - if (type.flags & 393216 /* UnionOrIntersection */) { + if (type.flags & 786432 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; @@ -44728,26 +44957,26 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (1 /* Any */ | 2048 /* Void */ | 4096 /* Undefined */ | 8192 /* Null */)) { + if (strict && source.flags & (3 /* AnyOrUnknown */ | 4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */)) { return false; } - return (kind & 84 /* NumberLike */ && isTypeAssignableTo(source, numberType)) || - (kind & 34 /* StringLike */ && isTypeAssignableTo(source, stringType)) || - (kind & 136 /* BooleanLike */ && isTypeAssignableTo(source, booleanType)) || - (kind & 2048 /* Void */ && isTypeAssignableTo(source, voidType)) || - (kind & 16384 /* Never */ && isTypeAssignableTo(source, neverType)) || - (kind & 8192 /* Null */ && isTypeAssignableTo(source, nullType)) || - (kind & 4096 /* Undefined */ && isTypeAssignableTo(source, undefinedType)) || - (kind & 512 /* ESSymbol */ && isTypeAssignableTo(source, esSymbolType)) || - (kind & 134217728 /* NonPrimitive */ && isTypeAssignableTo(source, nonPrimitiveType)); + return !!(kind & 168 /* NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 68 /* StringLike */) && isTypeAssignableTo(source, stringType) || + !!(kind & 272 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || + !!(kind & 4096 /* Void */) && isTypeAssignableTo(source, voidType) || + !!(kind & 32768 /* Never */) && isTypeAssignableTo(source, neverType) || + !!(kind & 16384 /* Null */) && isTypeAssignableTo(source, nullType) || + !!(kind & 8192 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 1024 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 16777216 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 131072 /* Union */ ? + return source.flags & 262144 /* Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { return (symbol.flags & 128 /* ConstEnum */) !== 0; @@ -44762,7 +44991,7 @@ var ts; // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 16382 /* Primitive */)) { + allTypesAssignableToKind(leftType, 32764 /* Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -44781,10 +45010,10 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 84 /* NumberLike */ | 1536 /* ESSymbolLike */))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 168 /* NumberLike */ | 3072 /* ESSymbolLike */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAssignableToKind(rightType, 134217728 /* NonPrimitive */ | 7372800 /* InstantiableNonPrimitive */)) { + if (!isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 14745600 /* 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); } return booleanType; @@ -44803,9 +45032,9 @@ var ts; } /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 269 /* PropertyAssignment */ || property.kind === 270 /* ShorthandPropertyAssignment */) { + if (property.kind === 270 /* PropertyAssignment */ || property.kind === 271 /* ShorthandPropertyAssignment */) { var name = property.name; - if (name.kind === 146 /* ComputedPropertyName */) { + if (name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -44818,7 +45047,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 270 /* ShorthandPropertyAssignment */) { + if (property.kind === 271 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -44830,7 +45059,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 271 /* SpreadAssignment */) { + else if (property.kind === 272 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -44856,7 +45085,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType; + var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; for (var i = 0; i < elements.length; i++) { checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); } @@ -44865,8 +45094,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 205 /* OmittedExpression */) { - if (element.kind !== 203 /* SpreadElement */) { + if (element.kind !== 206 /* OmittedExpression */) { + if (element.kind !== 204 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -44894,7 +45123,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 199 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 200 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -44907,13 +45136,13 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 270 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 271 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. if (strictNullChecks && - !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 4096 /* Undefined */)) { + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 8192 /* Undefined */)) { sourceType = getTypeWithFacts(sourceType, 131072 /* NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); @@ -44923,21 +45152,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 199 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 200 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 183 /* ObjectLiteralExpression */) { + if (target.kind === 184 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 182 /* ArrayLiteralExpression */) { + if (target.kind === 183 /* 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 === 271 /* SpreadAssignment */ ? + var error = target.parent.kind === 272 /* 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; if (checkReferenceExpression(target, error)) { @@ -44959,35 +45188,35 @@ var ts; case 71 /* Identifier */: case 9 /* StringLiteral */: case 12 /* RegularExpressionLiteral */: - case 188 /* TaggedTemplateExpression */: - case 201 /* TemplateExpression */: + case 189 /* TaggedTemplateExpression */: + case 202 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 140 /* UndefinedKeyword */: - case 191 /* FunctionExpression */: - case 204 /* ClassExpression */: - case 192 /* ArrowFunction */: - case 182 /* ArrayLiteralExpression */: - case 183 /* ObjectLiteralExpression */: - case 194 /* TypeOfExpression */: - case 208 /* NonNullExpression */: - case 255 /* JsxSelfClosingElement */: - case 254 /* JsxElement */: + case 192 /* FunctionExpression */: + case 205 /* ClassExpression */: + case 193 /* ArrowFunction */: + case 183 /* ArrayLiteralExpression */: + case 184 /* ObjectLiteralExpression */: + case 195 /* TypeOfExpression */: + case 209 /* NonNullExpression */: + case 256 /* JsxSelfClosingElement */: + case 255 /* JsxElement */: return true; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -44999,15 +45228,15 @@ var ts; } return false; // Some forms listed here for clarity - case 195 /* VoidExpression */: // Explicit opt-out - case 189 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 207 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 196 /* VoidExpression */: // Explicit opt-out + case 190 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 208 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 12288 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 24576 /* Nullable */) !== 0 || isTypeComparableTo(source, target); } function checkBinaryExpression(node, checkMode) { if (ts.isInJavaScriptFile(node) && ts.getAssignedJavascriptInitializer(node)) { @@ -45017,7 +45246,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 183 /* ObjectLiteralExpression */ || left.kind === 182 /* ArrayLiteralExpression */)) { + if (operator === 58 /* EqualsToken */ && (left.kind === 184 /* ObjectLiteralExpression */ || left.kind === 183 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -45053,8 +45282,8 @@ var ts; var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion - if ((leftType.flags & 136 /* BooleanLike */) && - (rightType.flags & 136 /* BooleanLike */) && + if ((leftType.flags & 272 /* BooleanLike */) && + (rightType.flags & 272 /* BooleanLike */) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } @@ -45072,24 +45301,24 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 34 /* StringLike */) && !isTypeAssignableToKind(rightType, 34 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 68 /* StringLike */) && !isTypeAssignableToKind(rightType, 68 /* StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 84 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 84 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 168 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 168 /* NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 34 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 34 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 68 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 68 /* StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } else if (isTypeAny(leftType) || isTypeAny(rightType)) { // Otherwise, the result is of type Any. // NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we. - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + resultType = leftType === errorType || rightType === errorType ? errorType : anyType; } // Symbols are not allowed at all in arithmetic expressions if (resultType && !checkForDisallowedESSymbolOperand(operator)) { @@ -45150,6 +45379,8 @@ var ts; error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } return rightType; + default: + return ts.Debug.fail(); } function checkSpecialAssignment(left, right) { var special = ts.getSpecialPropertyAssignmentKind(left.parent); @@ -45161,7 +45392,7 @@ var ts; if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; var symbol = resolveName(prop.valueDeclaration, name, 67901928 /* Type */, undefined, name, /*isUse*/ false); - if (symbol) { + if (symbol && symbol.declarations.some(function (d) { return d.kind === 297 /* JSDocTypedefTag */; })) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); } @@ -45174,8 +45405,8 @@ var ts; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKind(leftType, 1536 /* ESSymbolLike */) ? left : - maybeTypeOfKind(rightType, 1536 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 3072 /* ESSymbolLike */) ? left : + maybeTypeOfKind(rightType, 3072 /* ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -45243,7 +45474,9 @@ var ts; } } var func = ts.getContainingFunction(node); - var functionFlags = func ? ts.getFunctionFlags(func) : 0 /* Normal */; + if (!func) + return anyType; + var functionFlags = ts.getFunctionFlags(func); if (!(functionFlags & 1 /* Generator */)) { // If the user's code is syntactically correct, the func should always have a star. After all, we are in a yield context. return anyType; @@ -45262,7 +45495,7 @@ var ts; } } var isAsync = (functionFlags & 2 /* Async */) !== 0; - var yieldedType = getYieldedTypeOfYieldExpression(node, isAsync); + var yieldedType = getYieldedTypeOfYieldExpression(node, isAsync); // TODO: GH#18217 // There is no point in doing an assignability check if the function // has no explicit return type because the return type is directly computed // from the yield expressions. @@ -45287,14 +45520,14 @@ var ts; // A place where we actually *are* concerned with the expressions' types are // in tagged templates. ts.forEach(node.templateSpans, function (templateSpan) { - if (maybeTypeOfKind(checkExpression(templateSpan.expression), 1536 /* ESSymbolLike */)) { + if (maybeTypeOfKind(checkExpression(templateSpan.expression), 3072 /* ESSymbolLike */)) { error(templateSpan.expression, ts.Diagnostics.Type_0_cannot_be_converted_to_type_1, typeToString(esSymbolType), typeToString(stringType)); } }); return stringType; } function getContextNode(node) { - if (node.kind === 262 /* JsxAttributes */) { + if (node.kind === 263 /* JsxAttributes */) { 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; @@ -45330,17 +45563,16 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 189 /* TypeAssertionExpression */ || node.kind === 207 /* AsExpression */; + return node.kind === 190 /* TypeAssertionExpression */ || node.kind === 208 /* AsExpression */; } function checkDeclarationInitializer(declaration) { - var inJs = ts.isInJavaScriptFile(declaration); - var initializer = inJs && ts.getDeclaredJavascriptInitializer(declaration) || declaration.initializer; + var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || (ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)) || isTypeAssertion(initializer) ? type : getWidenedLiteralType(type); - if (inJs) { - if (widened.flags & 12288 /* Nullable */) { + if (ts.isInJavaScriptFile(declaration)) { + if (widened.flags & 24576 /* Nullable */) { if (noImplicitAny) { reportImplicitAnyError(declaration, anyType); } @@ -45355,38 +45587,28 @@ var ts; } return widened; } - function isTypeParameterWithKeyofConstraint(type) { - if (type.flags & 32768 /* TypeParameter */) { - var constraintDeclaration = getConstraintDeclaration(type); - return constraintDeclaration && constraintDeclaration.kind === 174 /* TypeOperator */ && - constraintDeclaration.operator === 128 /* KeyOfKeyword */; - } - return false; - } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 393216 /* UnionOrIntersection */) { + if (contextualType.flags & 786432 /* UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 7372800 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 14745600 /* InstantiableNonPrimitive */) { // If the contextual type is a type variable constrained to a primitive type, consider // this a literal context for literals of that primitive type. For example, given a // type parameter 'T extends string', infer string literal types for T. var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; - return isTypeParameterWithKeyofConstraint(contextualType) && maybeTypeOfKind(candidateType, 32 /* StringLiteral */ | 64 /* NumberLiteral */ | 1024 /* UniqueESSymbol */) || - constraint.flags & 2 /* String */ && maybeTypeOfKind(candidateType, 32 /* StringLiteral */) || - constraint.flags & 4 /* Number */ && maybeTypeOfKind(candidateType, 64 /* NumberLiteral */) || - constraint.flags & 8 /* Boolean */ && maybeTypeOfKind(candidateType, 128 /* BooleanLiteral */) || - constraint.flags & 512 /* ESSymbol */ && maybeTypeOfKind(candidateType, 1024 /* UniqueESSymbol */) || + return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || + maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || + maybeTypeOfKind(constraint, 1024 /* ESSymbol */) && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint); } // If the contextual type is a literal of a particular primitive type, we consider this a // literal context for all literals of that primitive type. - return contextualType.flags & (32 /* StringLiteral */ | 524288 /* Index */) && maybeTypeOfKind(candidateType, 32 /* StringLiteral */) || - contextualType.flags & 64 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 64 /* NumberLiteral */) || - contextualType.flags & 128 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 128 /* BooleanLiteral */) || - contextualType.flags & 1024 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 1024 /* UniqueESSymbol */); + return !!(contextualType.flags & (64 /* StringLiteral */ | 1048576 /* Index */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || + contextualType.flags & 128 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || + contextualType.flags & 256 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 256 /* BooleanLiteral */) || + contextualType.flags & 2048 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */)); } return false; } @@ -45402,7 +45624,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 === 146 /* ComputedPropertyName */) { + if (node.name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -45413,7 +45635,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 === 146 /* ComputedPropertyName */) { + if (node.name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -45443,7 +45665,7 @@ var ts; function getTypeOfExpression(node, cache) { // 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 (node.kind === 186 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 187 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -45478,7 +45700,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, checkMode) { var type; - if (node.kind === 145 /* QualifiedName */) { + if (node.kind === 146 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -45490,10 +45712,10 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 185 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 71 /* Identifier */ || node.kind === 145 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 164 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 186 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 165 /* TypeQuery */ && node.parent.exprName === node)); 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); } @@ -45527,77 +45749,77 @@ var ts; return trueType; case 86 /* FalseKeyword */: return falseType; - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* RegularExpressionLiteral */: return globalRegExpType; - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (node.expression.kind === 91 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 187 /* NewExpression */: + case 188 /* NewExpression */: return checkCallExpression(node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return checkClassExpression(node); - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 194 /* TypeOfExpression */: + case 195 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: return checkAssertion(node); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: return checkNonNullAssertion(node); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return checkMetaProperty(node); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return checkDeleteExpression(node); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return checkVoidExpression(node); - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return checkAwaitExpression(node); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 205 /* OmittedExpression */: + case 206 /* OmittedExpression */: return undefinedWideningType; - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return checkYieldExpression(node); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 254 /* JsxElement */: + case 255 /* JsxElement */: return checkJsxElement(node, checkMode); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return checkJsxFragment(node, checkMode); - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 256 /* JsxOpeningElement */: + case 257 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } - return unknownType; + return errorType; } // DECLARATION AND STATEMENT TYPE CHECKING function checkTypeParameter(node) { @@ -45632,7 +45854,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 154 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 155 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -45643,7 +45865,7 @@ 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 === 154 /* Constructor */ || func.kind === 158 /* ConstructSignature */ || func.kind === 163 /* ConstructorType */) { + if (func.kind === 155 /* Constructor */ || func.kind === 159 /* ConstructSignature */ || func.kind === 164 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -45687,7 +45909,8 @@ var ts; } else { var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), node.type, + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), // TODO: GH#18217 + node.type, /*headMessage*/ undefined, leadingError); } } @@ -45709,13 +45932,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 192 /* ArrowFunction */: - case 157 /* CallSignature */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 162 /* FunctionType */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 193 /* ArrowFunction */: + case 158 /* CallSignature */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 163 /* FunctionType */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -45733,7 +45956,7 @@ var ts; error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 180 /* ArrayBindingPattern */ || name.kind === 179 /* ObjectBindingPattern */) { + else if (name.kind === 181 /* ArrayBindingPattern */ || name.kind === 180 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -45742,13 +45965,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 159 /* IndexSignature */) { + if (node.kind === 160 /* 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 === 162 /* FunctionType */ || node.kind === 233 /* FunctionDeclaration */ || node.kind === 163 /* ConstructorType */ || - node.kind === 157 /* CallSignature */ || node.kind === 154 /* Constructor */ || - node.kind === 158 /* ConstructSignature */) { + else if (node.kind === 163 /* FunctionType */ || node.kind === 234 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || + node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || + node.kind === 159 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -45778,10 +46001,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 157 /* CallSignature */: + case 158 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -45811,7 +46034,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 159 /* IndexSignature */ && node.kind !== 283 /* JSDocFunctionType */) { + if (node.kind !== 160 /* IndexSignature */ && node.kind !== 284 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -45828,7 +46051,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* Constructor */) { + if (member.kind === 155 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { @@ -45839,20 +46062,21 @@ var ts; else { var isStatic = ts.hasModifier(member, 32 /* Static */); var names = isStatic ? staticNames : instanceNames; - var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); - if (memberName) { + var name = member.name; + var memberName = name && ts.getPropertyNameForPropertyNameNode(name); + if (name && memberName) { switch (member.kind) { - case 155 /* GetAccessor */: - addName(names, member.name, memberName, 1 /* Getter */); + case 156 /* GetAccessor */: + addName(names, name, memberName, 1 /* Getter */); break; - case 156 /* SetAccessor */: - addName(names, member.name, memberName, 2 /* Setter */); + case 157 /* SetAccessor */: + addName(names, name, memberName, 2 /* Setter */); break; - case 151 /* PropertyDeclaration */: - addName(names, member.name, memberName, 3 /* Property */); + case 152 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* Property */); break; - case 153 /* MethodDeclaration */: - addName(names, member.name, memberName, 4 /* Method */); + case 154 /* MethodDeclaration */: + addName(names, name, memberName, 4 /* Method */); break; } } @@ -45914,15 +46138,16 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 /* PropertySignature */) { + if (member.kind === 151 /* PropertySignature */) { var memberName = void 0; - switch (member.name.kind) { + var name = member.name; + switch (name.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - memberName = member.name.text; + memberName = name.text; break; case 71 /* Identifier */: - memberName = ts.idText(member.name); + memberName = ts.idText(name); break; default: continue; @@ -45938,7 +46163,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 235 /* InterfaceDeclaration */) { + if (node.kind === 236 /* 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 @@ -45993,7 +46218,7 @@ var ts; 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.hasModifier(node, 128 /* Abstract */) && node.kind === 153 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 154 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -46018,7 +46243,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 151 /* PropertyDeclaration */ && + return n.kind === 152 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -46048,7 +46273,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 215 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -46073,7 +46298,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 155 /* GetAccessor */) { + if (node.kind === 156 /* GetAccessor */) { if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -46083,13 +46308,13 @@ 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 === 146 /* ComputedPropertyName */) { + if (node.name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(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 === 155 /* GetAccessor */ ? 156 /* SetAccessor */ : 155 /* GetAccessor */; + var otherKind = node.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -46107,7 +46332,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 155 /* GetAccessor */) { + if (node.kind === 156 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -46144,7 +46369,7 @@ var ts; } function getTypeParametersForTypeReference(node) { var type = getTypeFromTypeReference(node); - if (type !== unknownType) { + if (type !== errorType) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters || @@ -46155,11 +46380,11 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 161 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 162 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } var type = getTypeFromTypeReference(node); - if (type !== unknownType) { + if (type !== errorType) { if (node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved ts.forEach(node.typeArguments, checkSourceElement); @@ -46170,7 +46395,7 @@ var ts; } } } - if (type.flags & 16 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { + if (type.flags & 32 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -46179,7 +46404,7 @@ var ts; var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType); if (!typeReferenceNode) return undefined; - var typeParameters = getTypeParametersForTypeReference(typeReferenceNode); + var typeParameters = getTypeParametersForTypeReference(typeReferenceNode); // TODO: GH#18217 var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]); return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters))); } @@ -46210,14 +46435,14 @@ var ts; ts.forEach(node.types, checkSourceElement); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 1048576 /* IndexedAccess */)) { + if (!(type.flags & 2097152 /* IndexedAccess */)) { return type; } // Check if the index type is assignable to 'keyof T' for the object type. var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 185 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 186 /* 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)); } @@ -46225,7 +46450,7 @@ var ts; } // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. - if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 84 /* NumberLike */)) { + if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 168 /* NumberLike */)) { return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); @@ -46254,7 +46479,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 170 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 /* 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); @@ -46270,9 +46495,9 @@ var ts; 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 !== 235 /* InterfaceDeclaration */ && - n.parent.kind !== 234 /* ClassDeclaration */ && - n.parent.kind !== 204 /* ClassExpression */ && + if (n.parent.kind !== 236 /* InterfaceDeclaration */ && + n.parent.kind !== 235 /* ClassDeclaration */ && + n.parent.kind !== 205 /* ClassExpression */ && n.flags & 4194304 /* 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 @@ -46363,7 +46588,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 153 /* MethodDeclaration */ || node.kind === 152 /* MethodSignature */) && + var reportError = (node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -46402,7 +46627,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 235 /* InterfaceDeclaration */ || node.parent.kind === 165 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 236 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -46413,7 +46638,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 233 /* FunctionDeclaration */ || node.kind === 153 /* MethodDeclaration */ || node.kind === 152 /* MethodSignature */ || node.kind === 154 /* Constructor */) { + if (node.kind === 234 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -46542,22 +46767,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 273 /* SourceFile */: + case 274 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; @@ -46565,20 +46790,20 @@ var ts; d = d.expression; /* falls through */ // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 242 /* ImportEqualsDeclaration */: - case 245 /* NamespaceImport */: - case 244 /* ImportClause */: + case 243 /* ImportEqualsDeclaration */: + case 246 /* NamespaceImport */: + case 245 /* ImportClause */: var result_3 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); return result_3; - case 231 /* VariableDeclaration */: - case 181 /* BindingElement */: - case 233 /* FunctionDeclaration */: - case 247 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 232 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 234 /* FunctionDeclaration */: + case 248 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: - ts.Debug.fail(ts.Debug.showSyntaxKind(d)); + return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); } } } @@ -46611,7 +46836,7 @@ var ts; if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; } - var thenFunction = getTypeOfPropertyOfType(promise, "then"); + var thenFunction = getTypeOfPropertyOfType(promise, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; } @@ -46643,7 +46868,7 @@ var ts; * The runtime behavior of the `await` keyword. */ function checkAwaitedType(type, errorNode, diagnosticMessage) { - return getAwaitedType(type, errorNode, diagnosticMessage) || unknownType; + return getAwaitedType(type, errorNode, diagnosticMessage) || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage) { var typeAsAwaitable = type; @@ -46653,7 +46878,7 @@ var ts; if (isTypeAny(type)) { return typeAsAwaitable.awaitedTypeOfType = type; } - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { var types = void 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -46732,7 +46957,8 @@ var ts; var thenFunction = getTypeOfPropertyOfType(type, "then"); if (thenFunction && getSignaturesOfType(thenFunction, 0 /* Call */).length > 0) { if (errorNode) { - ts.Debug.assert(!!diagnosticMessage); + if (!diagnosticMessage) + return ts.Debug.fail(); error(errorNode, diagnosticMessage); } return undefined; @@ -46777,58 +47003,58 @@ var ts; // then(...): Promise; // } // - var returnTypeNode = ts.getEffectiveReturnTypeNode(node); + var returnTypeNode = ts.getEffectiveReturnTypeNode(node); // TODO: GH#18217 var returnType = getTypeFromTypeNode(returnTypeNode); if (languageVersion >= 2 /* ES2015 */) { - if (returnType === unknownType) { - return unknownType; + if (returnType === errorType) { + return errorType; } var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true); if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { // The promise type was not a valid type reference to the global promise type, so we // report an error and return the unknown type. error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); - return unknownType; + return errorType; } } else { // Always mark the type node as referenced if it points to a value markTypeNodeAsReferenced(returnTypeNode); - if (returnType === unknownType) { - return unknownType; + if (returnType === errorType) { + return errorType; } var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode); if (promiseConstructorName === undefined) { error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); - return unknownType; + return errorType; } var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67216319 /* Value */, /*ignoreErrors*/ true); - var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; - if (promiseConstructorType === unknownType) { + var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; + if (promiseConstructorType === errorType) { if (promiseConstructorName.kind === 71 /* 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 { error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); } - return unknownType; + return errorType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(/*reportErrors*/ true); if (globalPromiseConstructorLikeType === emptyObjectType) { // If we couldn't resolve the global PromiseConstructorLike type we cannot verify // compatibility with __awaiter. error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); - return unknownType; + return errorType; } if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value)) { - return unknownType; + return errorType; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67216319 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); - return unknownType; + return errorType; } } // Get and return the awaited type of the return type. @@ -46845,26 +47071,30 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 148 /* Parameter */: + case 149 /* Parameter */: expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); + errorInfo = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); + errorInfo = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - var methodType = getTypeOfNode(node.parent); + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + var methodType = getTypeOfNode(node.parent); // TODO: GH#18217 var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); break; + default: + return ts.Debug.fail(); } checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; }); } @@ -46904,12 +47134,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 169 /* IntersectionType */: - case 168 /* UnionType */: + case 170 /* IntersectionType */: + case 169 /* UnionType */: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 172 /* ParenthesizedType */) { + while (typeNode.kind === 173 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -46941,9 +47171,9 @@ var ts; } } return commonEntityName; - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return node.typeName; } } @@ -46967,14 +47197,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* 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 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -46983,19 +47213,19 @@ var ts; } } break; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 148 /* Parameter */: + case 149 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -47038,12 +47268,12 @@ var ts; return; } if (!containsArgumentsReference(decl)) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 145 /* 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, ts.idText(node.name.kind === 146 /* QualifiedName */ ? node.name.right : node.name)); } 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 === 145 /* 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 === 146 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -47072,7 +47302,7 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -47085,7 +47315,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 146 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 147 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -47114,7 +47344,7 @@ var ts; } } } - var body = node.kind === 152 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 153 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if ((functionFlags & 1 /* Generator */) === 0) { // Async function or normal function @@ -47155,41 +47385,41 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 273 /* SourceFile */: - case 238 /* ModuleDeclaration */: - case 212 /* Block */: - case 240 /* CaseBlock */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 274 /* SourceFile */: + case 239 /* ModuleDeclaration */: + case 213 /* Block */: + case 241 /* CaseBlock */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 154 /* Constructor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 155 /* Constructor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 236 /* TypeAliasDeclaration */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 237 /* TypeAliasDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -47199,15 +47429,8 @@ var ts; } function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; - if (isIdentifierThatStartsWithUnderScore(node)) { - var declaration_2 = ts.getRootDeclaration(node.parent); - if ((declaration_2.kind === 231 /* VariableDeclaration */ && ts.isForInOrOfStatement(declaration_2.parent.parent)) || - declaration_2.kind === 147 /* TypeParameter */) { - return; - } - } var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(0 /* Local */, ts.createDiagnosticForNodeSpan(ts.getSourceFileOfNode(declaration), declaration, node, message, name)); + addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(node, message, name)); } function parameterNameStartsWithUnderscore(parameterName) { return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); @@ -47220,11 +47443,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 153 /* MethodDeclaration */: - case 151 /* PropertyDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - if (member.kind === 156 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 154 /* MethodDeclaration */: + case 152 /* PropertyDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + if (member.kind === 157 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -47233,7 +47456,7 @@ var ts; addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 154 /* Constructor */: + case 155 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -47241,8 +47464,8 @@ var ts; } } break; - case 159 /* IndexSignature */: - case 211 /* SemicolonClassElement */: + case 160 /* IndexSignature */: + case 212 /* SemicolonClassElement */: // Can't be private break; default: @@ -47283,6 +47506,7 @@ var ts; // Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value. var unusedImports = ts.createMap(); var unusedDestructures = ts.createMap(); + var unusedVariables = ts.createMap(); nodeWithLocals.locals.forEach(function (local) { // If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`. // If it's a type parameter merged with a parameter, check if the parameter-side is used. @@ -47303,6 +47527,11 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } } + else if (ts.isVariableDeclaration(declaration)) { + if (!isIdentifierThatStartsWithUnderScore(declaration.name) || !ts.isForInOrOfStatement(declaration.parent.parent)) { + addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); + } + } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); if (parameter) { @@ -47320,50 +47549,77 @@ var ts; unusedImports.forEach(function (_a) { var importClause = _a[0], unuseds = _a[1]; var importDecl = importClause.parent; - if (forEachImportedDeclaration(importClause, function (d) { return !ts.contains(unuseds, d); })) { + var nDeclarations = (importClause.name ? 1 : 0) + + (importClause.namedBindings ? + (importClause.namedBindings.kind === 246 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + : 0); + if (nDeclarations === unuseds.length) { + addDiagnostic(0 /* Local */, unuseds.length === 1 + ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) + : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); + } + else { for (var _i = 0, unuseds_1 = unuseds; _i < unuseds_1.length; _i++) { var unused = unuseds_1[_i]; errorUnusedLocal(unused, ts.idText(unused.name), addDiagnostic); } } - else if (unuseds.length === 1) { - addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name))); - } - else { - addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); - } }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; - if (!bindingPattern.elements.every(function (e) { return ts.contains(bindingElements, e); })) { + if (bindingPattern.elements.length === bindingElements.length) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 233 /* VariableDeclarationList */) { + addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); + } + else { + addDiagnostic(kind, bindingElements.length === 1 + ? ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(ts.first(bindingElements).name, ts.isIdentifier))) + : ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused)); + } + } + else { for (var _i = 0, bindingElements_1 = bindingElements; _i < bindingElements_1.length; _i++) { var e = bindingElements_1[_i]; addDiagnostic(kind, ts.createDiagnosticForNode(e, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(e.name, ts.isIdentifier)))); } } - else if (bindingElements.length === 1) { - addDiagnostic(kind, ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(ts.first(bindingElements).name, ts.isIdentifier)))); + }); + unusedVariables.forEach(function (_a) { + var declarationList = _a[0], declarations = _a[1]; + if (declarationList.declarations.length === declarations.length) { + addDiagnostic(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 === 214 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { - addDiagnostic(kind, ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused)); + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var decl = declarations_5[_i]; + addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(decl.name, ts.isIdentifier)))); + } } }); } + function bindingNameText(name) { + switch (name.kind) { + case 71 /* Identifier */: + return ts.idText(name); + case 181 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); + default: + return ts.Debug.assertNever(name); + } + } function isImportedDeclaration(node) { - return node.kind === 244 /* ImportClause */ || node.kind === 247 /* ImportSpecifier */ || node.kind === 245 /* NamespaceImport */; + return node.kind === 245 /* ImportClause */ || node.kind === 248 /* ImportSpecifier */ || node.kind === 246 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 244 /* ImportClause */ ? decl : decl.kind === 245 /* NamespaceImport */ ? decl.parent : decl.parent.parent; - } - function forEachImportedDeclaration(importClause, cb) { - var defaultName = importClause.name, namedBindings = importClause.namedBindings; - return (defaultName && cb(importClause)) || - namedBindings && (namedBindings.kind === 245 /* NamespaceImport */ ? cb(namedBindings) : ts.forEach(namedBindings.elements, cb)); + return decl.kind === 245 /* ImportClause */ ? decl : decl.kind === 246 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 212 /* Block */) { + if (node.kind === 213 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -47393,12 +47649,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 151 /* PropertyDeclaration */ || - node.kind === 150 /* PropertySignature */ || - node.kind === 153 /* MethodDeclaration */ || - node.kind === 152 /* MethodSignature */ || - node.kind === 155 /* GetAccessor */ || - node.kind === 156 /* SetAccessor */) { + if (node.kind === 152 /* PropertyDeclaration */ || + node.kind === 151 /* PropertySignature */ || + node.kind === 154 /* MethodDeclaration */ || + node.kind === 153 /* MethodSignature */ || + node.kind === 156 /* GetAccessor */ || + node.kind === 157 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -47407,7 +47663,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 148 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 149 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -47426,6 +47682,7 @@ var ts; } return true; } + return false; }); } function checkIfNewTargetIsCapturedInEnclosingScope(node) { @@ -47440,6 +47697,7 @@ var ts; } return true; } + return false; }); } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { @@ -47456,7 +47714,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 === 273 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -47471,7 +47729,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 === 273 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(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)); } @@ -47506,7 +47764,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 === 231 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 232 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -47518,17 +47776,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 232 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 213 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 214 /* 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 === 212 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 239 /* ModuleBlock */ || - container.kind === 238 /* ModuleDeclaration */ || - container.kind === 273 /* SourceFile */); + (container.kind === 213 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 240 /* ModuleBlock */ || + container.kind === 239 /* ModuleDeclaration */ || + container.kind === 274 /* 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 @@ -47543,7 +47801,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 148 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 149 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -47554,7 +47812,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 184 /* PropertyAccessExpression */) { + if (n.kind === 185 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -47573,8 +47831,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 148 /* Parameter */ || - symbol.valueDeclaration.kind === 181 /* BindingElement */) { + if (symbol.valueDeclaration.kind === 149 /* Parameter */ || + symbol.valueDeclaration.kind === 182 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -47588,7 +47846,7 @@ var ts; return ts.isFunctionLike(current.parent) || // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - (current.parent.kind === 151 /* PropertyDeclaration */ && + (current.parent.kind === 152 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)); })) { @@ -47621,18 +47879,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 === 146 /* ComputedPropertyName */) { + if (node.name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 181 /* BindingElement */) { - if (node.parent.kind === 179 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 182 /* BindingElement */) { + if (node.parent.kind === 180 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 146 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -47640,7 +47898,7 @@ var ts; var parentType = getTypeForBindingElementParent(parent); var name = node.propertyName || node.name; if (!ts.isBindingPattern(name)) { - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); // TODO: GH#18217 markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. if (parent.initializer && property) { checkPropertyAccessibility(parent, parent.initializer, parentType, property); @@ -47649,20 +47907,20 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 180 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 181 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 148 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 149 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 220 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 221 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); @@ -47679,8 +47937,8 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 220 /* ForInStatement */) { - var initializer = ts.isInJavaScriptFile(node) && ts.getDeclaredJavascriptInitializer(node) || node.initializer; + var initializer = ts.getEffectiveInitializer(node); + if (initializer && node.parent.parent.kind !== 221 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -47689,7 +47947,7 @@ var ts; // Node is a secondary declaration, check that type is identical to primary declaration and check that // initializer is consistent with type associated with the node var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); - if (type !== unknownType && declarationType !== unknownType && + if (type !== errorType && declarationType !== errorType && !isTypeIdenticalTo(type, declarationType) && !(symbol.flags & 67108864 /* JSContainer */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); @@ -47702,10 +47960,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 151 /* PropertyDeclaration */ && node.kind !== 150 /* PropertySignature */) { + if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 231 /* VariableDeclaration */ || node.kind === 181 /* BindingElement */) { + if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -47714,14 +47972,14 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 151 /* PropertyDeclaration */ || nextDeclaration.kind === 150 /* PropertySignature */ + var message = nextDeclaration.kind === 152 /* PropertyDeclaration */ || nextDeclaration.kind === 151 /* 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; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 148 /* Parameter */ && right.kind === 231 /* VariableDeclaration */) || - (left.kind === 231 /* VariableDeclaration */ && right.kind === 148 /* Parameter */)) { + if ((left.kind === 149 /* Parameter */ && right.kind === 232 /* VariableDeclaration */) || + (left.kind === 232 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -47760,7 +48018,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 214 /* EmptyStatement */) { + if (node.thenStatement.kind === 215 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -47780,12 +48038,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 232 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 233 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 232 /* VariableDeclarationList */) { + if (node.initializer.kind === 233 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -47819,18 +48077,18 @@ 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 === 232 /* VariableDeclarationList */) { + if (node.initializer.kind === 233 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 182 /* ArrayLiteralExpression */ || varExpr.kind === 183 /* ObjectLiteralExpression */) { + if (varExpr.kind === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* 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. - checkDestructuringAssignment(varExpr, iteratedType || unknownType); + checkDestructuringAssignment(varExpr, iteratedType || errorType); } else { var leftType = checkExpression(varExpr); @@ -47858,7 +48116,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 === 232 /* VariableDeclarationList */) { + if (node.initializer.kind === 233 /* 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); @@ -47872,7 +48130,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 === 182 /* ArrayLiteralExpression */ || varExpr.kind === 183 /* ObjectLiteralExpression */) { + if (varExpr.kind === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* 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)) { @@ -47885,7 +48143,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (rightType === neverType || !isTypeAssignableToKind(rightType, 134217728 /* NonPrimitive */ | 7372800 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 14745600 /* InstantiableNonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -47918,7 +48176,7 @@ var ts; */ function getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterables, checkAssignability) { if (inputType === neverType) { - reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); + reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); // TODO: GH#18217 return undefined; } var uplevelIteration = languageVersion >= 2 /* ES2015 */; @@ -47940,16 +48198,16 @@ var ts; // This allows us to find other non-string element types from an array unioned with // a string. if (allowStringInput) { - if (arrayType.flags & 131072 /* Union */) { + if (arrayType.flags & 262144 /* Union */) { // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the result of filter is a new array. var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 34 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 68 /* StringLike */); }); if (filteredTypes !== arrayTypes) { arrayType = getUnionType(filteredTypes, 2 /* Subtype */); } } - else if (arrayType.flags & 34 /* StringLike */) { + else if (arrayType.flags & 68 /* StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; @@ -47962,7 +48220,7 @@ var ts; } // Now that we've removed all the StringLike types, if no constituents remain, then the entire // arrayOrStringType was a string. - if (arrayType.flags & 16384 /* Never */) { + if (arrayType.flags & 32768 /* Never */) { return stringType; } } @@ -47993,7 +48251,7 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 34 /* StringLike */) { + if (arrayElementType.flags & 68 /* StringLike */) { return stringType; } return getUnionType([arrayElementType, stringType], 2 /* Subtype */); @@ -48068,11 +48326,11 @@ var ts; } } var asyncMethodType = allowAsyncIterables && getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); - var methodType = asyncMethodType || (allowSyncIterables && getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator"))); + var methodType = asyncMethodType || (allowSyncIterables ? getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")) : undefined); if (isTypeAny(methodType)) { return undefined; } - var signatures = methodType && getSignaturesOfType(methodType, 0 /* Call */); + var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined; if (!ts.some(signatures)) { if (errorNode) { // only report on the first error @@ -48198,14 +48456,14 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return node.kind === 155 /* GetAccessor */ - && ts.getEffectiveSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 156 /* SetAccessor */)) !== undefined; + return node.kind === 156 /* GetAccessor */ + && ts.getEffectiveSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 157 /* SetAccessor */)) !== undefined; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = (ts.getFunctionFlags(func) & 3 /* AsyncGenerator */) === 2 /* Async */ ? getPromisedTypeOfPromise(returnType) // Async function : returnType; // AsyncGenerator function, Generator function, or normal function - return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 2048 /* Void */ | 1 /* Any */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 4096 /* Void */ | 3 /* AnyOrUnknown */); } function checkReturnStatement(node) { // Grammar checking @@ -48221,7 +48479,7 @@ var ts; var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(func); var isGenerator = functionFlags & 1 /* Generator */; - if (strictNullChecks || node.expression || returnType.flags & 16384 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 32768 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; if (isGenerator) { // AsyncGenerator function or Generator function // A generator does not need its return expressions checked against its return type. @@ -48230,12 +48488,12 @@ var ts; // for generators. return; } - else if (func.kind === 156 /* SetAccessor */) { + else if (func.kind === 157 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 154 /* Constructor */) { + else if (func.kind === 155 /* Constructor */) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -48256,7 +48514,7 @@ var ts; } } } - else if (func.kind !== 154 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { + else if (func.kind !== 155 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { // 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); } @@ -48285,7 +48543,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 === 266 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 267 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -48297,7 +48555,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 265 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 266 /* 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. @@ -48326,10 +48584,11 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 227 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 228 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } + return false; }); } // ensure that label is unique @@ -48389,8 +48648,8 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); - if (ts.getObjectFlags(type) & 1 /* Class */ && ts.isClassLike(type.symbol.valueDeclaration)) { - var classDeclaration = type.symbol.valueDeclaration; + 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]; // Only process instance properties with computed names here. @@ -48414,7 +48673,7 @@ var ts; errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; } } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { + if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { // TODO: GH#18217 error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); } function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { @@ -48431,8 +48690,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 && - (propDeclaration.kind === 199 /* BinaryExpression */ || - ts.getNameOfDeclaration(propDeclaration).kind === 146 /* ComputedPropertyName */ || + (propDeclaration.kind === 200 /* BinaryExpression */ || + ts.getNameOfDeclaration(propDeclaration).kind === 147 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -48459,6 +48718,7 @@ var ts; // The predefined type keywords are reserved and cannot be used as names of user defined types. switch (name.escapedText) { case "any": + case "unknown": case "number": case "boolean": case "string": @@ -48468,6 +48728,15 @@ var ts; error(name, message, name.escapedText); } } + /** + * The name cannot be used as 'Object' of user defined types with special target. + */ + function checkClassNameCollisionWithObject(name) { + if (languageVersion === 1 /* ES5 */ && name.escapedText === "Object" + && moduleKind !== ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.ESNext) { + error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 + } + } /** * Check each type parameter and check that type parameters have no duplicate type parameter declarations */ @@ -48509,8 +48778,8 @@ var ts; if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } @@ -48519,8 +48788,8 @@ var ts; function areTypeParametersIdentical(declarations, targetParameters) { var maxTypeArgumentCount = ts.length(targetParameters); var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters); - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; // If this declaration has too few or too many type parameters, we report an error var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration); var numTypeParameters = sourceParameters.length; @@ -48580,6 +48849,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + if (!(node.flags & 4194304 /* Ambient */)) { + checkClassNameCollisionWithObject(node.name); + } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); checkExportsOnMergedDeclarations(node); @@ -48619,10 +48891,10 @@ var ts; issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); } checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseConstructorType.flags & 1081344 /* TypeVariable */ && !isMixinConstructorType(staticType)) { + if (baseConstructorType.flags & 2162688 /* TypeVariable */ && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 1081344 /* TypeVariable */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 2162688 /* TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. We can simply compare the type // references (as opposed to checking the structure of the types) because elsewhere we have already checked @@ -48645,7 +48917,7 @@ var ts; checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); - if (t !== unknownType) { + if (t !== errorType) { if (isValidBaseType(t)) { var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : @@ -48716,7 +48988,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 234 /* ClassDeclaration */ || d.kind === 235 /* InterfaceDeclaration */; + return d.kind === 235 /* ClassDeclaration */ || d.kind === 236 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -48741,7 +49013,7 @@ var ts; if (base.flags & 4194304 /* Prototype */) { continue; } - var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); + var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); // TODO: GH#18217 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { @@ -48755,7 +49027,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 204 /* ClassExpression */) { + if (derivedClassDecl.kind === 205 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -48770,7 +49042,7 @@ var ts; // either base or derived property is private - not override, skip it continue; } - if (isPrototypeProperty(base) && isPrototypeProperty(derived) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { + if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { // method is overridden with method or property/accessor is overridden with property/accessor - correct case continue; } @@ -48837,7 +49109,7 @@ var ts; var propName = member.name; if (ts.isIdentifier(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 1 /* Any */ || getFalsyFlags(type) & 4096 /* Undefined */)) { + if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 8192 /* Undefined */)) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -48847,7 +49119,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 151 /* PropertyDeclaration */ && + return node.kind === 152 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -48856,7 +49128,7 @@ var ts; var reference = ts.createPropertyAccess(ts.createThis(), propName); reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 4096 /* Undefined */); + return !(getFalsyFlags(flowType) & 8192 /* Undefined */); } function checkInterfaceDeclaration(node) { // Grammar checking @@ -48869,7 +49141,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 235 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -48974,7 +49246,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -48984,7 +49256,7 @@ var ts; } } break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -49012,18 +49284,22 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return evaluate(expr.expression); case 71 /* Identifier */: - return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), expr.escapedText); - case 185 /* ElementAccessExpression */: - case 184 /* PropertyAccessExpression */: + var identifier = expr; + if (isInfinityOrNaNString(identifier.escapedText)) { + return +(identifier.escapedText); + } + return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); + case 186 /* ElementAccessExpression */: + case 185 /* 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 === 184 /* PropertyAccessExpression */) { + if (ex.kind === 185 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -49055,8 +49331,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 /* Identifier */ || - node.kind === 184 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 185 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 185 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 186 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -49094,7 +49370,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 !== 237 /* EnumDeclaration */) { + if (declaration.kind !== 238 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -49115,10 +49391,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; - if ((declaration.kind === 234 /* ClassDeclaration */ || - (declaration.kind === 233 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 235 /* ClassDeclaration */ || + (declaration.kind === 234 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -49169,7 +49445,7 @@ var ts; if (symbol.flags & 512 /* ValueModule */ && symbol.declarations.length > 1 && !inAmbientContext - && isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { + && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -49181,7 +49457,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, 234 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 235 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -49231,23 +49507,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* 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]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 248 /* ExportAssignment */: - case 249 /* ExportDeclaration */: + case 249 /* ExportAssignment */: + case 250 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 242 /* ImportEqualsDeclaration */: - case 243 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 181 /* BindingElement */: - case 231 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 232 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -49258,12 +49534,12 @@ var ts; break; } // falls through - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: - case 233 /* FunctionDeclaration */: - case 235 /* InterfaceDeclaration */: - case 238 /* ModuleDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 234 /* FunctionDeclaration */: + case 236 /* InterfaceDeclaration */: + case 239 /* ModuleDeclaration */: + case 237 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -49286,12 +49562,12 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node; - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: do { node = node.left; } while (node.kind !== 71 /* Identifier */); return node; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 71 /* Identifier */); @@ -49300,7 +49576,7 @@ var ts; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (ts.nodeIsMissing(moduleName)) { + if (!moduleName || ts.nodeIsMissing(moduleName)) { // Should be a parse error. return false; } @@ -49308,9 +49584,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 239 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 273 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 249 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 250 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -49343,14 +49619,14 @@ var ts; (symbol.flags & 67901928 /* Type */ ? 67901928 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 251 /* ExportSpecifier */ ? + var message = node.kind === 252 /* 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 === 251 /* ExportSpecifier */ + && node.kind === 252 /* ExportSpecifier */ && !(target.flags & 67216319 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -49377,7 +49653,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 245 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -49401,7 +49677,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 253 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 254 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319 /* Value */) { @@ -49437,10 +49713,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 239 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 239 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 273 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -49457,7 +49733,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 273 /* SourceFile */ || node.parent.kind === 239 /* ModuleBlock */ || node.parent.kind === 238 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 274 /* SourceFile */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 239 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -49486,8 +49762,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 273 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 238 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -49558,8 +49834,8 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; + 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))); } @@ -49575,168 +49851,168 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 233 /* FunctionDeclaration */ && declaration.kind !== 153 /* MethodDeclaration */) || + return (declaration.kind !== 234 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { if (!node) { return; } - if (ts.isInJavaScriptFile(node) && node.jsDoc) { - for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { - var tags = _a[_i].tags; - ts.forEach(tags, checkSourceElement); - } + if (ts.isInJavaScriptFile(node)) { + ts.forEach(node.jsDoc, function (_a) { + var tags = _a.tags; + return ts.forEach(tags, checkSourceElement); + }); } var kind = node.kind; if (cancellationToken) { // 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 238 /* ModuleDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 233 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 234 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return checkTypeParameter(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return checkParameter(node); - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return checkPropertyDeclaration(node); - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: return checkSignatureDeclaration(node); - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: return checkMethodDeclaration(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return checkConstructorDeclaration(node); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return checkAccessorDeclaration(node); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return checkTypeReferenceNode(node); - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return checkTypePredicate(node); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return checkTypeQuery(node); - case 165 /* TypeLiteral */: + case 166 /* TypeLiteral */: return checkTypeLiteral(node); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return checkArrayType(node); - case 167 /* TupleType */: + case 168 /* TupleType */: return checkTupleType(node); - case 168 /* UnionType */: - case 169 /* IntersectionType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return checkSourceElement(node.type); - case 174 /* TypeOperator */: + case 175 /* TypeOperator */: return checkTypeOperator(node); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return checkConditionalType(node); - case 171 /* InferType */: + case 172 /* InferType */: return checkInferType(node); - case 178 /* ImportType */: + case 179 /* ImportType */: return checkImportType(node); - case 289 /* JSDocAugmentsTag */: + case 290 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 292 /* JSDocParameterTag */: + case 293 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: checkSignatureDeclaration(node); // falls through - case 281 /* JSDocNonNullableType */: - case 280 /* JSDocNullableType */: - case 278 /* JSDocAllType */: - case 279 /* JSDocUnknownType */: - case 286 /* JSDocTypeLiteral */: + case 282 /* JSDocNonNullableType */: + case 281 /* JSDocNullableType */: + case 279 /* JSDocAllType */: + case 280 /* JSDocUnknownType */: + case 287 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 277 /* JSDocTypeExpression */: + case 278 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 176 /* MappedType */: + case 177 /* MappedType */: return checkMappedType(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 212 /* Block */: - case 239 /* ModuleBlock */: + case 213 /* Block */: + case 240 /* ModuleBlock */: return checkBlock(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return checkVariableStatement(node); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return checkExpressionStatement(node); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return checkIfStatement(node); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return checkDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return checkWhileStatement(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return checkForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return checkForInStatement(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return checkForOfStatement(node); - case 222 /* ContinueStatement */: - case 223 /* BreakStatement */: + case 223 /* ContinueStatement */: + case 224 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return checkReturnStatement(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return checkWithStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return checkSwitchStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return checkLabeledStatement(node); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return checkThrowStatement(node); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return checkTryStatement(node); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return checkBindingElement(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return checkClassDeclaration(node); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return checkImportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return checkExportDeclaration(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return checkExportAssignment(node); - case 214 /* EmptyStatement */: - case 230 /* DebuggerStatement */: + case 215 /* EmptyStatement */: + case 231 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 252 /* MissingDeclaration */: + case 253 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -49759,7 +50035,7 @@ var ts; if (!ts.isJSDocTypeExpression(parent)) { error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature); } - var paramTag = parent.parent; + var paramTag = node.parent.parent; if (!ts.isJSDocParameterTag(paramTag)) { error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature); return; @@ -49777,8 +50053,8 @@ var ts; function getTypeFromJSDocVariadicType(node) { var type = getTypeFromTypeNode(node.type); var parent = node.parent; - var paramTag = parent.parent; - if (ts.isJSDocTypeExpression(parent) && ts.isJSDocParameterTag(paramTag)) { + var paramTag = node.parent.parent; + 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) { @@ -49817,20 +50093,20 @@ var ts; } } function checkDeferredNodes() { - for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { - var node = deferredNodes_1[_i]; + for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { + var node = _a[_i]; switch (node.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -49845,9 +50121,9 @@ var ts; function unusedIsError(kind) { switch (kind) { case 0 /* Local */: - return compilerOptions.noUnusedLocals; + return !!compilerOptions.noUnusedLocals; case 1 /* Parameter */: - return compilerOptions.noUnusedParameters; + return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); } @@ -49963,13 +50239,13 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -49977,8 +50253,8 @@ var ts; // falls through // 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 - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* 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. @@ -49987,7 +50263,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928 /* Type */); } break; - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -50035,28 +50311,28 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 147 /* TypeParameter */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 237 /* EnumDeclaration */: + case 148 /* TypeParameter */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 238 /* EnumDeclaration */: return true; + default: + return false; } } // True if the given identifier is part of a type reference - function isTypeReferenceIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 145 /* QualifiedName */) { + function isTypeReferenceIdentifier(node) { + while (node.parent.kind === 146 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 161 /* TypeReference */; + return node.parent.kind === 162 /* TypeReference */; } - function isHeritageClauseElementIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 184 /* PropertyAccessExpression */) { + function isHeritageClauseElementIdentifier(node) { + while (node.parent.kind === 185 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 206 /* ExpressionWithTypeArguments */; + return node.parent.kind === 207 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -50084,14 +50360,14 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 145 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 242 /* ImportEqualsDeclaration */) { - return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; + if (nodeOnRightSide.parent.kind === 243 /* ImportEqualsDeclaration */) { + return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 248 /* ExportAssignment */) { - return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; + if (nodeOnRightSide.parent.kind === 249 /* ExportAssignment */) { + return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; } @@ -50116,7 +50392,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 178 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 179 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -50126,7 +50402,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 184 /* PropertyAccessExpression */ && + entityName.parent.kind === 185 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -50134,7 +50410,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 248 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 249 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -50144,7 +50420,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 242 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 243 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -50162,7 +50438,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 206 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 207 /* ExpressionWithTypeArguments */) { meaning = 67901928 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -50178,10 +50454,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 292 /* JSDocParameterTag */) { + if (entityName.parent.kind === 293 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 147 /* TypeParameter */ && entityName.parent.parent.kind === 295 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 296 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -50198,12 +50474,12 @@ var ts; } return resolveEntityName(entityName, 67216319 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 184 /* PropertyAccessExpression */ || entityName.kind === 145 /* QualifiedName */) { + else if (entityName.kind === 185 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 184 /* PropertyAccessExpression */) { + if (entityName.kind === 185 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -50213,41 +50489,43 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 161 /* TypeReference */ ? 67901928 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67901928 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 261 /* JsxAttribute */) { + else if (entityName.parent.kind === 262 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 160 /* TypePredicate */) { + if (entityName.parent.kind === 161 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } + var parent = node.parent; + var grandParent = parent.parent; if (node.flags & 8388608 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } if (isDeclarationNameOrImportPropertyName(node)) { // This is a declaration, call getSymbolOfNode - return getSymbolOfNode(node.parent); + return getSymbolOfNode(parent); } else if (ts.isLiteralComputedPropertyDeclarationName(node)) { - return getSymbolOfNode(node.parent.parent); + return getSymbolOfNode(parent.parent); } if (node.kind === 71 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 181 /* BindingElement */ && - node.parent.parent.kind === 179 /* ObjectBindingPattern */ && - node === node.parent.propertyName) { - var typeOfPattern = getTypeOfNode(node.parent.parent); + else if (parent.kind === 182 /* BindingElement */ && + grandParent.kind === 180 /* ObjectBindingPattern */ && + node === parent.propertyName) { + var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); if (propertyDeclaration) { return propertyDeclaration; @@ -50256,8 +50534,8 @@ var ts; } switch (node.kind) { case 71 /* Identifier */: - case 184 /* PropertyAccessExpression */: - case 145 /* QualifiedName */: + case 185 /* PropertyAccessExpression */: + case 146 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -50271,14 +50549,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 173 /* ThisType */: + case 174 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 97 /* SuperKeyword */: return checkExpression(node).symbol; case 123 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 154 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 155 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -50289,7 +50567,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 === 243 /* ImportDeclaration */ || node.parent.kind === 249 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 244 /* ImportDeclaration */ || node.parent.kind === 250 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJavaScriptFile(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); @@ -50297,24 +50575,24 @@ var ts; // falls through case 8 /* NumericLiteral */: // index access - var objectType = ts.isElementAccessExpression(node.parent) - ? node.parent.argumentExpression === node ? getTypeOfExpression(node.parent.expression) : undefined - : ts.isLiteralTypeNode(node.parent) && ts.isIndexedAccessTypeNode(node.parent.parent) - ? getTypeFromTypeNode(node.parent.parent.objectType) + var objectType = ts.isElementAccessExpression(parent) + ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined + : ts.isLiteralTypeNode(parent) && ts.isIndexedAccessTypeNode(grandParent) + ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); case 79 /* DefaultKeyword */: case 89 /* FunctionKeyword */: case 36 /* EqualsGreaterThanToken */: return getSymbolOfNode(node.parent); - case 178 /* ImportType */: + case 179 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 270 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 271 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67216319 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -50328,7 +50606,7 @@ var ts; function getTypeOfNode(node) { if (node.flags & 8388608 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further - return unknownType; + return errorType; } if (ts.isPartOfTypeNode(node)) { var typeFromTypeNode = getTypeFromTypeNode(node); @@ -50375,10 +50653,10 @@ var ts; var symbol = getSymbolAtLocation(node); if (symbol) { var declaredType = getDeclaredTypeOfSymbol(symbol); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); + return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol); } } - return unknownType; + return errorType; } // Gets the type of object literal or array literal of destructuring assignment. // { a } from @@ -50387,32 +50665,32 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 183 /* ObjectLiteralExpression */ || expr.kind === 182 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 184 /* ObjectLiteralExpression */ || expr.kind === 183 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 221 /* ForOfStatement */) { + if (expr.parent.kind === 222 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); - return checkDestructuringAssignment(expr, iteratedType || unknownType); + return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 199 /* BinaryExpression */) { + if (expr.parent.kind === 200 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); - return checkDestructuringAssignment(expr, iteratedType || unknownType); + 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 === 269 /* PropertyAssignment */) { + if (expr.parent.kind === 270 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); - return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 182 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 183 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); - var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType; - return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || unknownType); + var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; + return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || errorType); // TODO: GH#18217 } // Gets the property symbol corresponding to the property in destructuring assignment // 'property1' from @@ -50483,11 +50761,11 @@ var ts; return target; } // Emitter support - function isArgumentsLocalBinding(node) { - if (!ts.isGeneratedIdentifier(node)) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function isArgumentsLocalBinding(nodeIn) { + if (!ts.isGeneratedIdentifier(nodeIn)) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -50518,13 +50796,12 @@ var ts; } } function isNameOfModuleOrEnumDeclaration(node) { - var parent = node.parent; - return parent && ts.isModuleOrEnumDeclaration(parent) && node === parent.name; + return ts.isModuleOrEnumDeclaration(node.parent) && node === node.parent.name; } // 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(node, prefixLocals) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedExportContainer(nodeIn, prefixLocals) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { // When resolving the export container for the name of a module or enum // declaration, we need to start resolution at the declaration's container. @@ -50544,7 +50821,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 273 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 274 /* 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. @@ -50558,8 +50835,8 @@ var ts; } // When resolved as an expression identifier, if the given node references an import, return the declaration of // that import. Otherwise, return undefined. - function getReferencedImportDeclaration(node) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedImportDeclaration(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value @@ -50599,7 +50876,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 212 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 213 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -50614,9 +50891,9 @@ var ts; // When resolved as an expression identifier, if the given node references a nested block scoped entity with // a name that either hides an existing name or might hide it when compiled downlevel, // return the declaration of that entity. Otherwise, return undefined. - function getReferencedDeclarationWithCollidingName(node) { - if (!ts.isGeneratedIdentifier(node)) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedDeclarationWithCollidingName(nodeIn) { + if (!ts.isGeneratedIdentifier(nodeIn)) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node); if (symbol && isSymbolOfDeclarationWithCollidingName(symbol)) { @@ -50628,8 +50905,8 @@ var ts; } // Return true if the given node is a declaration of a nested block scoped entity with a name that either hides an // existing name or might hide a name when compiled downlevel - function isDeclarationWithCollidingName(node) { - node = ts.getParseTreeNode(node, ts.isDeclaration); + function isDeclarationWithCollidingName(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); if (node) { var symbol = getSymbolOfNode(node); if (symbol) { @@ -50640,16 +50917,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: - case 244 /* ImportClause */: - case 245 /* NamespaceImport */: - case 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 243 /* ImportEqualsDeclaration */: + case 245 /* ImportClause */: + case 246 /* NamespaceImport */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: var exportClause = node.exportClause; - return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 248 /* ExportAssignment */: + return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); + case 249 /* ExportAssignment */: return node.expression && node.expression.kind === 71 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -50657,9 +50934,9 @@ var ts; } return false; } - function isTopLevelValueImportEqualsWithEntityName(node) { - node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 273 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + function isTopLevelValueImportEqualsWithEntityName(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); + if (node === undefined || node.parent.kind !== 274 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -50673,11 +50950,11 @@ 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 & 67216319 /* Value */ && + return !!(target.flags & 67216319 /* Value */) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { - return isConstEnumSymbol(s) || s.constEnumOnlyModule; + return isConstEnumSymbol(s) || !!s.constEnumOnlyModule; } function isReferencedAliasDeclaration(node, checkChildren) { if (ts.isAliasSymbolDeclaration(node)) { @@ -50685,14 +50962,14 @@ var ts; if (symbol && getSymbolLinks(symbol).referenced) { return true; } - var target = getSymbolLinks(symbol).target; + var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getModifierFlags(node) & 1 /* Export */ && target.flags & 67216319 /* Value */) { // An `export import ... =` of a value symbol is always considered referenced return true; } } if (checkChildren) { - return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); + return !!ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); } return false; } @@ -50719,10 +50996,10 @@ var ts; return false; } function isRequiredInitializedParameter(parameter) { - return strictNullChecks && + return !!strictNullChecks && !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && - parameter.initializer && + !!parameter.initializer && !ts.hasModifier(parameter, 92 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { @@ -50732,7 +51009,7 @@ var ts; ts.hasModifier(parameter, 92 /* ParameterPropertyModifier */); } function getNodeCheckFlags(node) { - return getNodeLinks(node).flags; + return getNodeLinks(node).flags || 0; } function getEnumMemberValue(node) { computeEnumMemberValues(node.parent); @@ -50740,15 +51017,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 272 /* EnumMember */: - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: + case 273 /* EnumMember */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 272 /* EnumMember */) { + if (node.kind === 273 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -50761,11 +51038,11 @@ var ts; return undefined; } function isFunctionType(type) { - return type.flags & 65536 /* Object */ && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 131072 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; } - function getTypeReferenceSerializationKind(typeName, location) { + function getTypeReferenceSerializationKind(typeNameIn, location) { // ensure both `typeName` and `location` are parse tree nodes. - typeName = ts.getParseTreeNode(typeName, ts.isEntityName); + var typeName = ts.getParseTreeNode(typeNameIn, ts.isEntityName); if (!typeName) return ts.TypeReferenceSerializationKind.Unknown; if (location) { @@ -50789,31 +51066,31 @@ var ts; } // We might not be able to resolve type symbol so use unknown type in that case (eg error case) if (!typeSymbol) { - return ts.TypeReferenceSerializationKind.ObjectType; - } - var type = getDeclaredTypeOfSymbol(typeSymbol); - if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 1 /* Any */) { + var type = getDeclaredTypeOfSymbol(typeSymbol); + if (type === errorType) { + return ts.TypeReferenceSerializationKind.Unknown; + } + else if (type.flags & 3 /* AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 2048 /* Void */ | 12288 /* Nullable */ | 16384 /* Never */)) { + else if (isTypeAssignableToKind(type, 4096 /* Void */ | 24576 /* Nullable */ | 32768 /* Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 136 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 272 /* BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 84 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 168 /* NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 34 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 68 /* StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 1536 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 3072 /* ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -50826,8 +51103,8 @@ var ts; return ts.TypeReferenceSerializationKind.ObjectType; } } - function createTypeOfDeclaration(declaration, enclosingDeclaration, flags, tracker, addUndefined) { - declaration = ts.getParseTreeNode(declaration, ts.isVariableLikeOrAccessor); + function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { + var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { return ts.createToken(119 /* AnyKeyword */); } @@ -50835,8 +51112,8 @@ var ts; var symbol = getSymbolOfNode(declaration); var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) - : unknownType; - if (type.flags & 1024 /* UniqueESSymbol */ && + : errorType; + if (type.flags & 2048 /* UniqueESSymbol */ && type.symbol === symbol) { flags |= 1048576 /* AllowUniqueESSymbolType */; } @@ -50845,16 +51122,16 @@ var ts; } return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); } - function createReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, tracker) { - signatureDeclaration = ts.getParseTreeNode(signatureDeclaration, ts.isFunctionLike); + function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { + var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { return ts.createToken(119 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); } - function createTypeOfExpression(expr, enclosingDeclaration, flags, tracker) { - expr = ts.getParseTreeNode(expr, ts.isExpression); + function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { + var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { return ts.createToken(119 /* AnyKeyword */); } @@ -50880,9 +51157,9 @@ var ts; } return resolveName(location, reference.escapedText, 67216319 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } - function getReferencedValueDeclaration(reference) { - if (!ts.isGeneratedIdentifier(reference)) { - reference = ts.getParseTreeNode(reference, ts.isIdentifier); + function getReferencedValueDeclaration(referenceIn) { + if (!ts.isGeneratedIdentifier(referenceIn)) { + var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier); if (reference) { var symbol = getReferencedValueSymbol(reference); if (symbol) { @@ -50895,7 +51172,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 8388608 /* FreshLiteral */); + return !!(type.flags & 192 /* StringOrNumberLiteral */ && type.flags & 33554432 /* FreshLiteral */); } return false; } @@ -50940,7 +51217,7 @@ var ts; }, getNodeCheckFlags: function (node) { node = ts.getParseTreeNode(node); - return node ? getNodeCheckFlags(node) : undefined; + return node ? getNodeCheckFlags(node) : 0; }, isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, @@ -50953,8 +51230,8 @@ var ts; createLiteralConstValue: createLiteralConstValue, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, - getConstantValue: function (node) { - node = ts.getParseTreeNode(node, canHaveConstantValue); + getConstantValue: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue); return node ? getConstantValue(node) : undefined; }, collectLinkedAliases: collectLinkedAliases, @@ -50967,20 +51244,20 @@ var ts; getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName, getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol, isLiteralConstDeclaration: isLiteralConstDeclaration, - isLateBound: function (node) { - node = ts.getParseTreeNode(node, ts.isDeclaration); + isLateBound: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); return !!(symbol && ts.getCheckFlags(symbol) & 1024 /* Late */); }, getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { - accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); - var otherKind = accessor.kind === 156 /* SetAccessor */ ? 155 /* GetAccessor */ : 156 /* SetAccessor */; + accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 + var otherKind = accessor.kind === 157 /* SetAccessor */ ? 156 /* GetAccessor */ : 157 /* 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 === 156 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 155 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 157 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 156 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -50990,7 +51267,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 206 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 267 /* HeritageClause */; + return node.parent && node.parent.kind === 207 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 268 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -51002,7 +51279,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 = 67901928 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 184 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 185 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -51053,7 +51330,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 273 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 274 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -51068,12 +51345,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 238 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); - var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); + var specifier = declaration.kind === 239 /* 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, 273 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 274 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -51104,7 +51381,7 @@ var ts; }); } } - // We do global augmentations seperately from module augmentations (and before creating global types) because they + // We do global augmentations separately from module augmentations (and before creating global types) because they // 1. Affect global types. We won't have the correct global types until global augmentations are merged. Also, // 2. Module augmentation instantiation requires creating the type of a module, which, in turn, can require // checking for an export or property on the module (if export=) which, in turn, can fall back to the @@ -51127,7 +51404,7 @@ var ts; addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); - getSymbolLinks(unknownSymbol).type = unknownType; + getSymbolLinks(unknownSymbol).type = errorType; // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); @@ -51199,7 +51476,7 @@ var ts; case 16384 /* AsyncValues */: return "__asyncValues"; case 32768 /* ExportStar */: return "__exportStar"; case 65536 /* MakeTemplateObject */: return "__makeTemplateObject"; - default: ts.Debug.fail("Unrecognized helper"); + default: return ts.Debug.fail("Unrecognized helper"); } } function resolveHelpersModule(node, errorNode) { @@ -51217,14 +51494,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 153 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 154 /* 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 === 155 /* GetAccessor */ || node.kind === 156 /* SetAccessor */) { + else if (node.kind === 156 /* GetAccessor */ || node.kind === 157 /* 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); @@ -51242,16 +51519,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 132 /* ReadonlyKeyword */) { - if (node.kind === 150 /* PropertySignature */ || node.kind === 152 /* MethodSignature */) { + if (node.kind === 151 /* PropertySignature */ || node.kind === 153 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 159 /* IndexSignature */) { + if (node.kind === 160 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 76 /* ConstKeyword */: - if (node.kind !== 237 /* EnumDeclaration */ && node.parent.kind === 234 /* ClassDeclaration */) { + if (node.kind !== 238 /* EnumDeclaration */ && node.parent.kind === 235 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); } break; @@ -51271,7 +51548,7 @@ 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 === 239 /* ModuleBlock */ || node.parent.kind === 273 /* SourceFile */) { + else if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -51294,10 +51571,10 @@ 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 === 239 /* ModuleBlock */ || node.parent.kind === 273 /* SourceFile */) { + else if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 148 /* Parameter */) { + else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -51310,7 +51587,7 @@ var ts; if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 151 /* PropertyDeclaration */ && node.kind !== 150 /* PropertySignature */ && node.kind !== 159 /* IndexSignature */ && node.kind !== 148 /* Parameter */) { + else if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */ && node.kind !== 160 /* IndexSignature */ && node.kind !== 149 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report 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); } @@ -51330,17 +51607,17 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 148 /* Parameter */) { + else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; case 79 /* DefaultKeyword */: - var container = node.parent.kind === 273 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 238 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -51352,13 +51629,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 148 /* Parameter */) { + else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 239 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 240 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -51368,14 +51645,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 234 /* ClassDeclaration */) { - if (node.kind !== 153 /* MethodDeclaration */ && - node.kind !== 151 /* PropertyDeclaration */ && - node.kind !== 155 /* GetAccessor */ && - node.kind !== 156 /* SetAccessor */) { + if (node.kind !== 235 /* ClassDeclaration */) { + if (node.kind !== 154 /* MethodDeclaration */ && + node.kind !== 152 /* PropertyDeclaration */ && + node.kind !== 156 /* GetAccessor */ && + node.kind !== 157 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 234 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 235 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -51394,7 +51671,7 @@ var ts; else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 148 /* Parameter */) { + else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -51402,12 +51679,12 @@ var ts; break; } } - if (node.kind === 154 /* Constructor */) { + if (node.kind === 155 /* 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"); + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217 } else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); @@ -51415,20 +51692,21 @@ var ts; else if (flags & 64 /* Readonly */) { return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly"); } - return; + return false; } - else if ((node.kind === 243 /* ImportDeclaration */ || node.kind === 242 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 244 /* ImportDeclaration */ || node.kind === 243 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 148 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 149 /* Parameter */ && (flags & 92 /* 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 === 148 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { return checkGrammarAsyncModifier(node, lastAsync); } + return false; } /** * true | false: Early return this value from checkGrammarModifiers. @@ -51443,37 +51721,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 154 /* Constructor */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 159 /* IndexSignature */: - case 238 /* ModuleDeclaration */: - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 249 /* ExportDeclaration */: - case 248 /* ExportAssignment */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 148 /* Parameter */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 155 /* Constructor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 160 /* IndexSignature */: + case 239 /* ModuleDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 250 /* ExportDeclaration */: + case 249 /* ExportAssignment */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 149 /* Parameter */: return false; default: - if (node.parent.kind === 239 /* ModuleBlock */ || node.parent.kind === 273 /* SourceFile */) { + if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { return false; } switch (node.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 235 /* InterfaceDeclaration */: - case 213 /* VariableStatement */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 214 /* VariableStatement */: + case 237 /* TypeAliasDeclaration */: return true; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); default: ts.Debug.fail(); @@ -51486,10 +51764,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 153 /* MethodDeclaration */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -51499,6 +51777,7 @@ var ts; if (list && list.hasTrailingComma) { return grammarErrorAtPos(list[0], list.end - ",".length, ",".length, diag); } + return false; } function checkGrammarTypeParameterList(typeParameters, file) { if (typeParameters && typeParameters.length === 0) { @@ -51506,6 +51785,7 @@ var ts; var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); } + return false; } function checkGrammarParameterList(parameters) { var seenOptionalParameter = false; @@ -51586,10 +51866,10 @@ var ts; } if (parameter.type.kind !== 137 /* StringKeyword */ && parameter.type.kind !== 134 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); - if (type.flags & 2 /* String */ || type.flags & 4 /* Number */) { + 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(getTypeFromTypeNode(node.type))); } - if (type.flags & 131072 /* Union */ && allTypesAssignableToKind(type, 32 /* StringLiteral */, /*strict*/ true)) { + if (type.flags & 262144 /* Union */ && allTypesAssignableToKind(type, 64 /* StringLiteral */, /*strict*/ true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); @@ -51597,6 +51877,7 @@ var ts; if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); } + return false; } function checkGrammarIndexSignature(node) { // Prevent cascading error by short-circuit @@ -51609,6 +51890,7 @@ var ts; var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); } + return false; } function checkGrammarTypeArguments(node, typeArguments) { return checkGrammarForDisallowedTrailingComma(typeArguments) || @@ -51618,11 +51900,12 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 205 /* OmittedExpression */) { + if (arg.kind === 206 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } + return false; } function checkGrammarArguments(args) { return checkGrammarForOmittedArgument(args); @@ -51636,7 +51919,7 @@ var ts; var listType = ts.tokenToString(node.token); return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); } - return ts.forEach(types, checkGrammarExpressionWithTypeArguments); + return ts.some(types, checkGrammarExpressionWithTypeArguments); } function checkGrammarExpressionWithTypeArguments(node) { return checkGrammarTypeArguments(node, node.typeArguments); @@ -51694,19 +51977,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 146 /* ComputedPropertyName */) { + if (node.kind !== 147 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 199 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 200 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* 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 === 233 /* FunctionDeclaration */ || - node.kind === 191 /* FunctionExpression */ || - node.kind === 153 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 234 /* FunctionDeclaration */ || + node.kind === 192 /* FunctionExpression */ || + node.kind === 154 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -51716,9 +52000,7 @@ var ts; } } function checkGrammarForInvalidQuestionMark(questionToken, message) { - if (questionToken) { - return grammarErrorOnNode(questionToken, message); - } + return !!questionToken && grammarErrorOnNode(questionToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { var Flags; @@ -51731,24 +52013,24 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 271 /* SpreadAssignment */) { + if (prop.kind === 272 /* SpreadAssignment */) { continue; } var name = prop.name; - if (name.kind === 146 /* ComputedPropertyName */) { + if (name.kind === 147 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 270 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 271 /* 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.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { - for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { + for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 120 /* AsyncKeyword */ || prop.kind !== 153 /* MethodDeclaration */) { + if (mod.kind !== 120 /* AsyncKeyword */ || prop.kind !== 154 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -51763,25 +52045,25 @@ 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 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name); } // falls through - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: currentKind = 1 /* Property */; break; - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: currentKind = 2 /* GetAccessor */; break; - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: currentKind = 4 /* SetAccessor */; break; default: - ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); + throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); } var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { @@ -51814,7 +52096,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 263 /* JsxSpreadAttribute */) { + if (attr.kind === 264 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -51824,7 +52106,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 264 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 265 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -51833,12 +52115,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 221 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 222 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 232 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 233 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -51853,20 +52135,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 220 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 221 /* 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 === 220 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 221 /* 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 === 220 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 221 /* 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); @@ -51893,11 +52175,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 155 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 156 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 156 /* SetAccessor */) { + else if (kind === 157 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -51914,16 +52196,17 @@ var ts; } } } + return false; } /** Does the accessor have the right number of parameters? * A get accessor has no parameters or a single `this` parameter. * 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 === 155 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 156 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 155 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 156 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -51934,7 +52217,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: var decl = parent; if (decl.name.kind !== 71 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -51946,13 +52229,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(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 150 /* PropertySignature */: + case 151 /* PropertySignature */: if (!ts.hasModifier(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); } @@ -51971,8 +52254,8 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 153 /* MethodDeclaration */) { - if (node.parent.kind === 183 /* ObjectLiteralExpression */) { + if (node.kind === 154 /* MethodDeclaration */) { + if (node.parent.kind === 184 /* 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 === 120 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -51997,14 +52280,14 @@ var ts; if (node.flags & 4194304 /* 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 === 153 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 154 /* 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 === 235 /* InterfaceDeclaration */) { + else if (node.parent.kind === 236 /* 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 === 165 /* TypeLiteral */) { + else if (node.parent.kind === 166 /* 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); } } @@ -52015,11 +52298,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 227 /* LabeledStatement */: + case 228 /* 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 === 222 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 223 /* 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); @@ -52027,8 +52310,8 @@ var ts; return false; } break; - case 226 /* SwitchStatement */: - if (node.kind === 223 /* BreakStatement */ && !node.label) { + case 227 /* SwitchStatement */: + if (node.kind === 224 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -52043,13 +52326,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 223 /* BreakStatement */ + var message = node.kind === 224 /* 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 === 223 /* BreakStatement */ + var message = node.kind === 224 /* 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); @@ -52062,7 +52345,7 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - if (node.name.kind === 180 /* ArrayBindingPattern */ || node.name.kind === 179 /* ObjectBindingPattern */) { + if (node.name.kind === 181 /* ArrayBindingPattern */ || node.name.kind === 180 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -52076,11 +52359,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 197 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + expr.kind === 198 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 220 /* ForInStatement */ && node.parent.parent.kind !== 221 /* ForOfStatement */) { + if (node.parent.parent.kind !== 221 /* ForInStatement */ && node.parent.parent.kind !== 222 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -52109,7 +52392,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 213 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 214 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -52140,6 +52423,7 @@ var ts; } } } + return false; } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 71 /* Identifier */) { @@ -52156,6 +52440,7 @@ var ts; } } } + return false; } function checkGrammarVariableDeclarationList(declarationList) { var declarations = declarationList.declarations; @@ -52165,18 +52450,19 @@ var ts; if (!declarationList.declarations.length) { return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); } + return false; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 216 /* IfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 225 /* WithStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 217 /* IfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 226 /* WithStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: return false; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -52216,6 +52502,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2)); return true; } + return false; } function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile); @@ -52223,6 +52510,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); return true; } + return false; } function grammarErrorOnNode(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); @@ -52230,11 +52518,12 @@ var ts; diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2)); return true; } + return false; } function checkGrammarConstructorTypeParameters(node) { - var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - if (ts.isNodeArray(typeParameters)) { - var pos = typeParameters.pos, end = typeParameters.end; + var jsdocTypeParameters = ts.isInJavaScriptFile(node) && ts.getJSDocTypeParameterDeclarations(node); + if (node.typeParameters || jsdocTypeParameters && jsdocTypeParameters.length) { + var _a = node.typeParameters || jsdocTypeParameters && jsdocTypeParameters[0] || node, pos = _a.pos, end = _a.end; return grammarErrorAtPos(node, pos, end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); } } @@ -52250,7 +52539,7 @@ var ts; return true; } } - else if (node.parent.kind === 235 /* InterfaceDeclaration */) { + else if (node.parent.kind === 236 /* 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; } @@ -52258,7 +52547,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 165 /* TypeLiteral */) { + else if (node.parent.kind === 166 /* 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; } @@ -52287,13 +52576,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 235 /* InterfaceDeclaration */ || - node.kind === 236 /* TypeAliasDeclaration */ || - node.kind === 243 /* ImportDeclaration */ || - node.kind === 242 /* ImportEqualsDeclaration */ || - node.kind === 249 /* ExportDeclaration */ || - node.kind === 248 /* ExportAssignment */ || - node.kind === 241 /* NamespaceExportDeclaration */ || + if (node.kind === 236 /* InterfaceDeclaration */ || + node.kind === 237 /* TypeAliasDeclaration */ || + node.kind === 244 /* ImportDeclaration */ || + node.kind === 243 /* ImportEqualsDeclaration */ || + node.kind === 250 /* ExportDeclaration */ || + node.kind === 249 /* ExportAssignment */ || + node.kind === 242 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -52302,12 +52591,13 @@ 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 === 213 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 214 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } } } + return false; } function checkGrammarSourceFile(node) { return !!(node.flags & 4194304 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); @@ -52328,7 +52618,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 === 212 /* Block */ || node.parent.kind === 239 /* ModuleBlock */ || node.parent.kind === 273 /* SourceFile */) { + if (node.parent.kind === 213 /* Block */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -52341,6 +52631,7 @@ var ts; // Debug.assert(isStatement(node.parent)); } } + return false; } function checkGrammarNumericLiteral(node) { // Grammar checking @@ -52349,10 +52640,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, 177 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 178 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 272 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 273 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -52361,6 +52652,7 @@ var ts; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + return false; } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); @@ -52369,6 +52661,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), /*length*/ 0, message, arg0, arg1, arg2)); return true; } + return false; } function getAmbientModules() { if (!ambientModulesCache) { @@ -52398,14 +52691,15 @@ var ts; if (ts.isSpreadElement(nodeArguments[0])) { return grammarErrorOnNode(nodeArguments[0], ts.Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element); } + return false; } } ts.createTypeChecker = createTypeChecker; /** 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 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -52413,14 +52707,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 244 /* ImportClause */: // For default import - case 242 /* ImportEqualsDeclaration */: - case 245 /* NamespaceImport */: - case 247 /* ImportSpecifier */: // For rename import `x as y` + case 245 /* ImportClause */: // For default import + case 243 /* ImportEqualsDeclaration */: + case 246 /* NamespaceImport */: + case 248 /* ImportSpecifier */: // For rename import `x as y` return true; case 71 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 247 /* ImportSpecifier */; + return decl.parent.kind === 248 /* ImportSpecifier */; default: return false; } @@ -52482,7 +52776,7 @@ var ts; // the original node. We also need to exclude specific properties and only include own- // properties (to skip members already defined on the shared prototype). if (node === undefined) { - return undefined; + return node; } var clone = createSynthesizedNode(node.kind); clone.flags |= node.flags; @@ -52587,7 +52881,6 @@ var ts; return name; } ts.createUniqueName = createUniqueName; - /** Create a unique name based on the supplied text. */ function createOptimisticUniqueName(text) { var name = createIdentifier(text); name.autoGenerateFlags = 3 /* Unique */ | 16 /* Optimistic */; @@ -52683,7 +52976,7 @@ var ts; ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(145 /* QualifiedName */); + var node = createSynthesizedNode(146 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -52698,12 +52991,12 @@ var ts; ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */) || - expression.kind === 301 /* CommaListExpression */ ? + expression.kind === 302 /* CommaListExpression */ ? createParen(expression) : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(146 /* ComputedPropertyName */); + var node = createSynthesizedNode(147 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -52716,7 +53009,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(147 /* TypeParameter */); + var node = createSynthesizedNode(148 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -52732,7 +53025,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(148 /* Parameter */); + var node = createSynthesizedNode(149 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -52756,7 +53049,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(149 /* Decorator */); + var node = createSynthesizedNode(150 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -52769,7 +53062,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(150 /* PropertySignature */); + var node = createSynthesizedNode(151 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -52789,7 +53082,7 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(151 /* PropertyDeclaration */); + var node = createSynthesizedNode(152 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -52813,7 +53106,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(152 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(153 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -52830,7 +53123,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(153 /* MethodDeclaration */); + var node = createSynthesizedNode(154 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -52858,7 +53151,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(154 /* Constructor */); + var node = createSynthesizedNode(155 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -52878,7 +53171,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(155 /* GetAccessor */); + var node = createSynthesizedNode(156 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -52901,7 +53194,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(156 /* SetAccessor */); + var node = createSynthesizedNode(157 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -52922,7 +53215,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(157 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(158 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -52930,7 +53223,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(158 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(159 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -52938,7 +53231,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(159 /* IndexSignature */); + var node = createSynthesizedNode(160 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -52978,7 +53271,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(160 /* TypePredicate */); + var node = createSynthesizedNode(161 /* TypePredicate */); node.parameterName = asName(parameterName); node.type = type; return node; @@ -52992,7 +53285,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(161 /* TypeReference */); + var node = createSynthesizedNode(162 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -53006,7 +53299,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(163 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -53014,7 +53307,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(163 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(164 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -53022,7 +53315,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(164 /* TypeQuery */); + var node = createSynthesizedNode(165 /* TypeQuery */); node.exprName = exprName; return node; } @@ -53034,7 +53327,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(165 /* TypeLiteral */); + var node = createSynthesizedNode(166 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -53046,7 +53339,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(166 /* ArrayType */); + var node = createSynthesizedNode(167 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -53058,7 +53351,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(167 /* TupleType */); + var node = createSynthesizedNode(168 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -53070,7 +53363,7 @@ var ts; } ts.updateTypleTypeNode = updateTypleTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(168 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(169 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -53078,7 +53371,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(170 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -53097,7 +53390,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(170 /* ConditionalType */); + var node = createSynthesizedNode(171 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -53115,7 +53408,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(171 /* InferType */); + var node = createSynthesizedNode(172 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -53127,7 +53420,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(178 /* ImportType */); + var node = createSynthesizedNode(179 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -53145,7 +53438,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(172 /* ParenthesizedType */); + var node = createSynthesizedNode(173 /* ParenthesizedType */); node.type = type; return node; } @@ -53157,11 +53450,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(173 /* ThisType */); + return createSynthesizedNode(174 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(174 /* TypeOperator */); + var node = createSynthesizedNode(175 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -53172,7 +53465,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(175 /* IndexedAccessType */); + var node = createSynthesizedNode(176 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -53186,7 +53479,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(176 /* MappedType */); + var node = createSynthesizedNode(177 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -53204,7 +53497,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(177 /* LiteralType */); + var node = createSynthesizedNode(178 /* LiteralType */); node.literal = literal; return node; } @@ -53217,7 +53510,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(179 /* ObjectBindingPattern */); + var node = createSynthesizedNode(180 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -53229,7 +53522,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(180 /* ArrayBindingPattern */); + var node = createSynthesizedNode(181 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -53241,7 +53534,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(181 /* BindingElement */); + var node = createSynthesizedNode(182 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -53260,7 +53553,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(182 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(183 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -53274,7 +53567,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(183 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(184 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -53288,9 +53581,9 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(184 /* PropertyAccessExpression */); + var node = createSynthesizedNode(185 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); - node.name = asName(name); + node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); return node; } @@ -53305,7 +53598,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(185 /* ElementAccessExpression */); + var node = createSynthesizedNode(186 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -53319,7 +53612,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(186 /* CallExpression */); + var node = createSynthesizedNode(187 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -53335,7 +53628,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187 /* NewExpression */); + var node = createSynthesizedNode(188 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -53351,7 +53644,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(188 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(189 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -53374,7 +53667,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(189 /* TypeAssertionExpression */); + var node = createSynthesizedNode(190 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -53388,7 +53681,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(190 /* ParenthesizedExpression */); + var node = createSynthesizedNode(191 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -53400,7 +53693,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(191 /* FunctionExpression */); + var node = createSynthesizedNode(192 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -53424,7 +53717,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(192 /* ArrowFunction */); + var node = createSynthesizedNode(193 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -53458,7 +53751,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(193 /* DeleteExpression */); + var node = createSynthesizedNode(194 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53470,7 +53763,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(194 /* TypeOfExpression */); + var node = createSynthesizedNode(195 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53482,7 +53775,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(195 /* VoidExpression */); + var node = createSynthesizedNode(196 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53494,7 +53787,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(196 /* AwaitExpression */); + var node = createSynthesizedNode(197 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53506,7 +53799,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(197 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(198 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -53519,7 +53812,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(198 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(199 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -53532,7 +53825,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(199 /* BinaryExpression */); + var node = createSynthesizedNode(200 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -53549,7 +53842,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(200 /* ConditionalExpression */); + var node = createSynthesizedNode(201 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -53579,7 +53872,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(201 /* TemplateExpression */); + var node = createSynthesizedNode(202 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -53617,7 +53910,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(202 /* YieldExpression */); + var node = createSynthesizedNode(203 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -53631,7 +53924,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(203 /* SpreadElement */); + var node = createSynthesizedNode(204 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -53643,7 +53936,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(204 /* ClassExpression */); + var node = createSynthesizedNode(205 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -53664,11 +53957,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(205 /* OmittedExpression */); + return createSynthesizedNode(206 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(206 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(207 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -53682,7 +53975,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(207 /* AsExpression */); + var node = createSynthesizedNode(208 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -53696,7 +53989,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(208 /* NonNullExpression */); + var node = createSynthesizedNode(209 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -53708,7 +54001,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(209 /* MetaProperty */); + var node = createSynthesizedNode(210 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -53722,7 +54015,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(210 /* TemplateSpan */); + var node = createSynthesizedNode(211 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -53736,12 +54029,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(211 /* SemicolonClassElement */); + return createSynthesizedNode(212 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(212 /* Block */); + var block = createSynthesizedNode(213 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -53750,7 +54043,7 @@ var ts; ts.createBlock = createBlock; /* @internal */ function createExpressionStatement(expression) { - var node = createSynthesizedNode(215 /* ExpressionStatement */); + var node = createSynthesizedNode(216 /* ExpressionStatement */); node.expression = expression; return node; } @@ -53762,7 +54055,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(213 /* VariableStatement */); + var node = createSynthesizedNode(214 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -53777,7 +54070,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(214 /* EmptyStatement */); + return createSynthesizedNode(215 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression) { @@ -53791,7 +54084,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(216 /* IfStatement */); + var node = createSynthesizedNode(217 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -53807,7 +54100,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(217 /* DoStatement */); + var node = createSynthesizedNode(218 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -53821,7 +54114,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(218 /* WhileStatement */); + var node = createSynthesizedNode(219 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -53835,7 +54128,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(219 /* ForStatement */); + var node = createSynthesizedNode(220 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -53853,7 +54146,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(220 /* ForInStatement */); + var node = createSynthesizedNode(221 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -53869,7 +54162,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(221 /* ForOfStatement */); + var node = createSynthesizedNode(222 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -53887,7 +54180,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(222 /* ContinueStatement */); + var node = createSynthesizedNode(223 /* ContinueStatement */); node.label = asName(label); return node; } @@ -53899,7 +54192,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(223 /* BreakStatement */); + var node = createSynthesizedNode(224 /* BreakStatement */); node.label = asName(label); return node; } @@ -53911,7 +54204,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(224 /* ReturnStatement */); + var node = createSynthesizedNode(225 /* ReturnStatement */); node.expression = expression; return node; } @@ -53923,7 +54216,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(225 /* WithStatement */); + var node = createSynthesizedNode(226 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -53937,7 +54230,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(226 /* SwitchStatement */); + var node = createSynthesizedNode(227 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -53951,7 +54244,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(227 /* LabeledStatement */); + var node = createSynthesizedNode(228 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -53965,7 +54258,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(228 /* ThrowStatement */); + var node = createSynthesizedNode(229 /* ThrowStatement */); node.expression = expression; return node; } @@ -53977,7 +54270,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(229 /* TryStatement */); + var node = createSynthesizedNode(230 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -53993,11 +54286,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(230 /* DebuggerStatement */); + return createSynthesizedNode(231 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(231 /* VariableDeclaration */); + var node = createSynthesizedNode(232 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -54013,7 +54306,8 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { - var node = createSynthesizedNode(232 /* VariableDeclarationList */); + if (flags === void 0) { flags = 0 /* None */; } + var node = createSynthesizedNode(233 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -54026,7 +54320,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(233 /* FunctionDeclaration */); + var node = createSynthesizedNode(234 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -54052,7 +54346,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(234 /* ClassDeclaration */); + var node = createSynthesizedNode(235 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54074,7 +54368,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235 /* InterfaceDeclaration */); + var node = createSynthesizedNode(236 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54096,7 +54390,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(236 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(237 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54116,7 +54410,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(237 /* EnumDeclaration */); + var node = createSynthesizedNode(238 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54134,7 +54428,8 @@ var ts; } ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { - var node = createSynthesizedNode(238 /* ModuleDeclaration */); + if (flags === void 0) { flags = 0 /* None */; } + var node = createSynthesizedNode(239 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -54153,7 +54448,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(239 /* ModuleBlock */); + var node = createSynthesizedNode(240 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -54165,7 +54460,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(240 /* CaseBlock */); + var node = createSynthesizedNode(241 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -54177,7 +54472,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(241 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(242 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -54189,7 +54484,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(242 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(243 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54207,7 +54502,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(243 /* ImportDeclaration */); + var node = createSynthesizedNode(244 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -54225,7 +54520,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(244 /* ImportClause */); + var node = createSynthesizedNode(245 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -54239,7 +54534,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(245 /* NamespaceImport */); + var node = createSynthesizedNode(246 /* NamespaceImport */); node.name = name; return node; } @@ -54251,7 +54546,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(246 /* NamedImports */); + var node = createSynthesizedNode(247 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -54263,7 +54558,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(247 /* ImportSpecifier */); + var node = createSynthesizedNode(248 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -54277,7 +54572,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(248 /* ExportAssignment */); + var node = createSynthesizedNode(249 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -54294,7 +54589,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(249 /* ExportDeclaration */); + var node = createSynthesizedNode(250 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -54312,7 +54607,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(250 /* NamedExports */); + var node = createSynthesizedNode(251 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -54324,7 +54619,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(251 /* ExportSpecifier */); + var node = createSynthesizedNode(252 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -54339,7 +54634,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(253 /* ExternalModuleReference */); + var node = createSynthesizedNode(254 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -54352,7 +54647,7 @@ var ts; ts.updateExternalModuleReference = updateExternalModuleReference; // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(254 /* JsxElement */); + var node = createSynthesizedNode(255 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -54368,7 +54663,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(255 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(256 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -54384,7 +54679,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256 /* JsxOpeningElement */); + var node = createSynthesizedNode(257 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -54400,7 +54695,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(257 /* JsxClosingElement */); + var node = createSynthesizedNode(258 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -54412,7 +54707,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(258 /* JsxFragment */); + var node = createSynthesizedNode(259 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -54428,7 +54723,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(261 /* JsxAttribute */); + var node = createSynthesizedNode(262 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -54442,7 +54737,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(262 /* JsxAttributes */); + var node = createSynthesizedNode(263 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -54454,7 +54749,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(263 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(264 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -54466,7 +54761,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(264 /* JsxExpression */); + var node = createSynthesizedNode(265 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -54480,7 +54775,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(265 /* CaseClause */); + var node = createSynthesizedNode(266 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -54494,7 +54789,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(266 /* DefaultClause */); + var node = createSynthesizedNode(267 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -54506,7 +54801,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(267 /* HeritageClause */); + var node = createSynthesizedNode(268 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -54519,7 +54814,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(268 /* CatchClause */); + var node = createSynthesizedNode(269 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -54534,7 +54829,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(269 /* PropertyAssignment */); + var node = createSynthesizedNode(270 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -54549,7 +54844,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(270 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(271 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -54563,8 +54858,8 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(271 /* SpreadAssignment */); - node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; + var node = createSynthesizedNode(272 /* SpreadAssignment */); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } ts.createSpreadAssignment = createSpreadAssignment; @@ -54576,7 +54871,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(272 /* EnumMember */); + var node = createSynthesizedNode(273 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -54596,7 +54891,7 @@ var ts; (referencedFiles !== undefined && node.referencedFiles !== referencedFiles) || (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(273 /* SourceFile */); + var updated = createSynthesizedNode(274 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -54635,6 +54930,8 @@ var ts; updated.parseDiagnostics = node.parseDiagnostics; if (node.bindDiagnostics !== undefined) updated.bindDiagnostics = node.bindDiagnostics; + if (node.bindSuggestionDiagnostics !== undefined) + updated.bindSuggestionDiagnostics = node.bindSuggestionDiagnostics; if (node.lineMap !== undefined) updated.lineMap = node.lineMap; if (node.classifiableNames !== undefined) @@ -54677,7 +54974,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(299 /* NotEmittedStatement */); + var node = createSynthesizedNode(300 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -54689,7 +54986,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(303 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(304 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -54701,7 +54998,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(302 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(303 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -54716,7 +55013,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(300 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(301 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -54732,7 +55029,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 301 /* CommaListExpression */) { + if (node.kind === 302 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { @@ -54742,7 +55039,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(301 /* CommaListExpression */); + var node = createSynthesizedNode(302 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -54755,20 +55052,20 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(274 /* Bundle */); + var node = ts.createNode(275 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text) { - var node = ts.createNode(275 /* UnparsedSource */); + var node = ts.createNode(276 /* UnparsedSource */); node.text = text; return node; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration) { - var node = ts.createNode(276 /* InputFiles */); + var node = ts.createNode(277 /* InputFiles */); node.javascriptText = javascript; node.declarationText = declaration; return node; @@ -54861,6 +55158,7 @@ var ts; return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(/*propertyName*/ undefined, exportName)])); } ts.createExternalModuleExport = createExternalModuleExport; + // Utilities function asName(name) { return ts.isString(name) ? createIdentifier(name) : name; } @@ -54906,7 +55204,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 === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -55391,7 +55689,7 @@ var ts; // Utilities function createForOfBindingStatement(node, boundValue) { if (ts.isVariableDeclarationList(node)) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); + var firstDeclaration = ts.first(node.declarations); var updatedDeclaration = ts.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, /*typeNode*/ undefined, boundValue); return ts.setTextRange(ts.createVariableStatement( @@ -55417,7 +55715,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 227 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -55435,19 +55733,20 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; } } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { + if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } var callee = skipOuterExpressions(expression, 7 /* All */); var thisArg; var target; @@ -55467,7 +55766,7 @@ var ts; } else { switch (callee.kind) { - case 184 /* PropertyAccessExpression */: { + case 185 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -55480,7 +55779,7 @@ var ts; } break; } - case 185 /* ElementAccessExpression */: { + case 186 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -55537,14 +55836,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 269 /* PropertyAssignment */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); + case 270 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -55558,7 +55857,8 @@ var ts; /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, getAccessor.parameters, - /*type*/ undefined, getAccessor.body); + /*type*/ undefined, getAccessor.body // TODO: GH#18217 + ); ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -55569,7 +55869,8 @@ var ts; /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, setAccessor.parameters, - /*type*/ undefined, setAccessor.body); + /*type*/ undefined, setAccessor.body // TODO: GH#18217 + ); ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); @@ -55600,7 +55901,8 @@ var ts; return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, /*name*/ undefined, /*typeParameters*/ undefined, method.parameters, - /*type*/ undefined, method.body), + /*type*/ undefined, method.body // TODO: GH#18217 + ), /*location*/ method), /*original*/ method)), /*location*/ method), @@ -55683,6 +55985,7 @@ var ts; } ts.getDeclarationName = getDeclarationName; function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (emitFlags === void 0) { emitFlags = 0; } var nodeName = ts.getNameOfDeclaration(node); if (nodeName && ts.isIdentifier(nodeName) && !ts.isGeneratedIdentifier(nodeName)) { var name = ts.getMutableClone(nodeName); @@ -55726,7 +56029,7 @@ var ts; function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); ts.setTextRange(qualifiedName, name); - var emitFlags; + var emitFlags = 0; if (!allowSourceMaps) emitFlags |= 48 /* NoSourceMap */; if (!allowComments) @@ -55741,7 +56044,8 @@ var ts; } ts.convertToFunctionBody = convertToFunctionBody; function convertFunctionDeclarationToExpression(node) { - ts.Debug.assert(!!node.body); + if (!node.body) + return ts.Debug.fail(); var updated = ts.createFunctionExpression(node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body); ts.setOriginalNode(updated, node); ts.setTextRange(updated, node); @@ -55801,15 +56105,9 @@ var ts; return statementOffset; } ts.addStandardPrologue = addStandardPrologue; - /** - * Add just the custom prologue-directives into target statement-array. - * The function needs to be called during each transformation step. - * This function needs to be called whenever we transform the statement - * list of a source file, namespace, or function-like body. - */ function addCustomPrologue(target, source, statementOffset, visitor) { var numStatements = source.length; - while (statementOffset < numStatements) { + while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); @@ -55868,7 +56166,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 === 190 /* ParenthesizedExpression */) { + if (skipped.kind === 191 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -55902,8 +56200,8 @@ 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(199 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(199 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(200 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(200 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -55912,7 +56210,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 202 /* YieldExpression */) { + && operand.kind === 203 /* YieldExpression */) { return false; } return true; @@ -56000,7 +56298,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 199 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -56015,7 +56313,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(200 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(201 /* ConditionalExpression */, 55 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -56029,8 +56327,8 @@ var ts; // so in case when comma expression is introduced as a part of previous transformations // if should be wrapped in parens since comma operator has the lowest precedence var emittedExpression = ts.skipPartiallyEmittedExpressions(e); - return emittedExpression.kind === 199 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ || - emittedExpression.kind === 301 /* CommaListExpression */ + return emittedExpression.kind === 200 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ || + emittedExpression.kind === 302 /* CommaListExpression */ ? ts.createParen(e) : e; } @@ -56048,9 +56346,9 @@ var ts; */ function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 204 /* ClassExpression */ || - check.kind === 191 /* FunctionExpression */ || - check.kind === 301 /* CommaListExpression */ || + return (check.kind === 205 /* ClassExpression */ || + check.kind === 192 /* FunctionExpression */ || + check.kind === 302 /* CommaListExpression */ || ts.isBinaryExpression(check) && check.operatorToken.kind === 26 /* CommaToken */) ? ts.createParen(e) : e; @@ -56065,9 +56363,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 186 /* CallExpression */: + case 187 /* CallExpression */: return ts.createParen(expression); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -56090,7 +56388,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 187 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 188 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -56128,7 +56426,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(199 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(200 /* BinaryExpression */, 26 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -56139,29 +56437,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 191 /* FunctionExpression */ || kind === 192 /* ArrowFunction */) { + if (kind === 192 /* FunctionExpression */ || kind === 193 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 183 /* ObjectLiteralExpression */ || leftmostExpressionKind === 191 /* FunctionExpression */) { + if (leftmostExpressionKind === 184 /* ObjectLiteralExpression */ || leftmostExpressionKind === 192 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 170 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 171 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 168 /* UnionType */: - case 169 /* IntersectionType */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -56169,9 +56467,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 164 /* TypeQuery */: - case 174 /* TypeOperator */: - case 171 /* InferType */: + case 165 /* TypeQuery */: + case 175 /* TypeOperator */: + case 172 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -56197,25 +56495,25 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: node = node.operand; continue; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: node = node.left; continue; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: node = node.condition; continue; - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 185 /* ElementAccessExpression */: - case 184 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: + case 185 /* PropertyAccessExpression */: node = node.expression; continue; - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -56223,7 +56521,7 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 183 /* ObjectLiteralExpression */) { + if (!ts.isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 184 /* ObjectLiteralExpression */) { return ts.setTextRange(ts.createParen(body), body); } return body; @@ -56239,13 +56537,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: - case 208 /* NonNullExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: + case 209 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -56270,7 +56568,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 208 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 209 /* NonNullExpression */) { node = node.expression; } return node; @@ -56278,11 +56576,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 190 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 189 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 207 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 208 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 300 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 191 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 190 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 208 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 209 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 301 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -56300,7 +56598,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 190 /* ParenthesizedExpression */ + return node.kind === 191 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -56365,10 +56663,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 243 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 244 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 249 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 250 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -56383,7 +56681,7 @@ var ts; * Otherwise, a new StringLiteral node representing the module name will be returned. */ function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) { - var moduleName = ts.getExternalModuleName(importNode); + var moduleName = ts.getExternalModuleName(importNode); // TODO: GH#18217 if (moduleName.kind === 9 /* StringLiteral */) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) @@ -56441,8 +56739,9 @@ var ts; // `1` in `({ a: b = 1 } = ...)` // `1` in `({ a: {b} = 1 } = ...)` // `1` in `({ a: [b] = 1 } = ...)` - return ts.isAssignmentExpression(bindingElement.initializer, /*excludeCompoundAssignment*/ true) - ? bindingElement.initializer.right + var initializer = bindingElement.initializer; + return ts.isAssignmentExpression(initializer, /*excludeCompoundAssignment*/ true) + ? initializer.right : undefined; } if (ts.isShorthandPropertyAssignment(bindingElement)) { @@ -56486,7 +56785,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -56498,11 +56797,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -56534,12 +56833,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 148 /* Parameter */: - case 181 /* BindingElement */: + case 149 /* Parameter */: + case 182 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 203 /* SpreadElement */: - case 271 /* SpreadAssignment */: + case 204 /* SpreadElement */: + case 272 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -56551,7 +56850,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 181 /* BindingElement */: + case 182 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -56563,7 +56862,7 @@ var ts; : propertyName; } break; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -56575,7 +56874,7 @@ var ts; : propertyName; } break; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -56593,13 +56892,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: - case 182 /* ArrayLiteralExpression */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: + case 183 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -56639,11 +56938,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 180 /* ArrayBindingPattern */: - case 182 /* ArrayLiteralExpression */: + case 181 /* ArrayBindingPattern */: + case 183 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 179 /* ObjectBindingPattern */: - case 183 /* ObjectLiteralExpression */: + case 180 /* ObjectBindingPattern */: + case 184 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -56804,272 +57103,272 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 144 /* LastToken */) || kind === 173 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 174 /* ThisType */) { return node; } switch (kind) { // Names case 71 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 148 /* Parameter */: + case 149 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 149 /* Decorator */: + case 150 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 150 /* PropertySignature */: + case 151 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 152 /* MethodSignature */: + case 153 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 154 /* Constructor */: + case 155 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 157 /* CallSignature */: + case 158 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 162 /* FunctionType */: + case 163 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* ConstructorType */: + case 164 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 165 /* TypeLiteral */: + case 166 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 167 /* TupleType */: + case 168 /* TupleType */: return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 168 /* UnionType */: + case 169 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 169 /* IntersectionType */: + case 170 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 171 /* InferType */: + case 172 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 178 /* ImportType */: + case 179 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* TypeOperator */: + case 175 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 176 /* MappedType */: + case 177 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 177 /* LiteralType */: + case 178 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 194 /* TypeOfExpression */: + case 195 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 207 /* AsExpression */: + case 208 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 212 /* Block */: + case 213 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 222 /* ContinueStatement */: + case 223 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 223 /* BreakStatement */: + case 224 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 246 /* NamedImports */: + case 247 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 250 /* NamedExports */: + case 251 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 251 /* ExportSpecifier */: + case 252 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 254 /* JsxElement */: + case 255 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 256 /* JsxOpeningElement */: + case 257 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 263 /* JsxSpreadAttribute */: + case 264 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 265 /* CaseClause */: + case 266 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 272 /* EnumMember */: + case 273 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 273 /* SourceFile */: + case 274 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -57111,58 +57410,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 144 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 160 /* TypePredicate */ && kind <= 177 /* LiteralType */)) { + if ((kind >= 161 /* TypePredicate */ && kind <= 178 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 211 /* SemicolonClassElement */: - case 214 /* EmptyStatement */: - case 205 /* OmittedExpression */: - case 230 /* DebuggerStatement */: - case 299 /* NotEmittedStatement */: + case 212 /* SemicolonClassElement */: + case 215 /* EmptyStatement */: + case 206 /* OmittedExpression */: + case 231 /* DebuggerStatement */: + case 300 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 148 /* Parameter */: + case 149 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149 /* Decorator */: + case 150 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 150 /* PropertySignature */: + case 151 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57171,12 +57470,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 154 /* Constructor */: + case 155 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57184,7 +57483,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57192,49 +57491,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 181 /* BindingElement */: + case 182 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 186 /* CallExpression */: + case 187 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 187 /* NewExpression */: + case 188 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -57242,123 +57541,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 190 /* ParenthesizedExpression */: - case 193 /* DeleteExpression */: - case 194 /* TypeOfExpression */: - case 195 /* VoidExpression */: - case 196 /* AwaitExpression */: - case 202 /* YieldExpression */: - case 203 /* SpreadElement */: - case 208 /* NonNullExpression */: + case 191 /* ParenthesizedExpression */: + case 194 /* DeleteExpression */: + case 195 /* TypeOfExpression */: + case 196 /* VoidExpression */: + case 197 /* AwaitExpression */: + case 203 /* YieldExpression */: + case 204 /* SpreadElement */: + case 209 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 207 /* AsExpression */: + case 208 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 212 /* Block */: + case 213 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 216 /* IfStatement */: + case 217 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 217 /* DoStatement */: + case 218 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 218 /* WhileStatement */: - case 225 /* WithStatement */: + case 219 /* WhileStatement */: + case 226 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 219 /* ForStatement */: + case 220 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 224 /* ReturnStatement */: - case 228 /* ThrowStatement */: + case 225 /* ReturnStatement */: + case 229 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 229 /* TryStatement */: + case 230 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57367,7 +57666,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57375,139 +57674,139 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 244 /* ImportClause */: + case 245 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 246 /* NamedImports */: - case 250 /* NamedExports */: + case 247 /* NamedImports */: + case 251 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 254 /* JsxElement */: + case 255 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 255 /* JsxSelfClosingElement */: - case 256 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 263 /* JsxSpreadAttribute */: + case 264 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 265 /* CaseClause */: + case 266 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 268 /* CatchClause */: + case 269 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 272 /* EnumMember */: + case 273 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 273 /* SourceFile */: + case 274 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -57521,8 +57820,8 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements) - : ts.prependRange(statements, declarations); + ? ts.setTextRange(ts.createNodeArray(ts.prependStatements(statements.slice(), declarations)), statements) + : ts.prependStatements(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; /** @@ -57580,7 +57879,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 206 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 207 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -57630,7 +57929,7 @@ var ts; }); Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, { __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 65536 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 131072 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { return this.checker.typeToString(this); } }, }); var nodeConstructors = [ @@ -57680,12 +57979,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName && e.propertyName.escapedText === "default" /* Default */; + return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* Default */; } function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 273 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 274 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -57715,7 +58014,7 @@ var ts; ts.getImportNeedsImportStarHelper = getImportNeedsImportStarHelper; function getImportNeedsImportDefaultHelper(node) { // Import default is needed if there's a default import or a default ref and no other refs (meaning an import star helper wasn't requested) - return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings))); + return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (!!node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings))); // TODO: GH#18217 } ts.getImportNeedsImportDefaultHelper = getImportNeedsImportDefaultHelper; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { @@ -57731,7 +58030,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -57739,13 +58038,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 242 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 253 /* ExternalModuleReference */) { + case 243 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -57775,13 +58074,13 @@ var ts; } } break; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -57789,7 +58088,7 @@ var ts; } } break; - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -57809,7 +58108,7 @@ var ts; } } break; - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -57942,7 +58241,7 @@ var ts; var flattenContext = { context: context, level: level, - downlevelIteration: context.getCompilerOptions().downlevelIteration, + downlevelIteration: !!context.getCompilerOptions().downlevelIteration, hoistTempVariables: true, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -58003,7 +58302,7 @@ var ts; } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; function bindingOrAssignmentElementAssignsToName(element, escapedName) { - var target = ts.getTargetOfBindingOrAssignmentElement(element); + var target = ts.getTargetOfBindingOrAssignmentElement(element); // TODO: GH#18217 if (ts.isBindingOrAssignmentPattern(target)) { return bindingOrAssignmentPatternAssignsToName(target, escapedName); } @@ -58034,13 +58333,14 @@ var ts; * @param level Indicates the extent to which flattening should occur. */ function flattenDestructuringBinding(node, visitor, context, level, rval, hoistTempVariables, skipInitializer) { + if (hoistTempVariables === void 0) { hoistTempVariables = false; } var pendingExpressions; var pendingDeclarations = []; var declarations = []; var flattenContext = { context: context, level: level, - downlevelIteration: context.getCompilerOptions().downlevelIteration, + downlevelIteration: !!context.getCompilerOptions().downlevelIteration, hoistTempVariables: hoistTempVariables, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -58068,7 +58368,7 @@ var ts; } else { context.hoistVariableDeclaration(temp); - var pendingDeclaration = ts.lastOrUndefined(pendingDeclarations); + var pendingDeclaration = ts.last(pendingDeclarations); pendingDeclaration.pendingExpressions = ts.append(pendingDeclaration.pendingExpressions, ts.createAssignment(temp, pendingDeclaration.value)); ts.addRange(pendingDeclaration.pendingExpressions, pendingExpressions); pendingDeclaration.value = temp; @@ -58122,7 +58422,7 @@ var ts; value = ts.createVoidZero(); } } - var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element); + var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element); // TODO: GH#18217 if (ts.isObjectBindingOrAssignmentPattern(bindingTarget)) { flattenObjectBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location); } @@ -58130,7 +58430,7 @@ var ts; flattenArrayBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location); } else { - flattenContext.emitBindingOrAssignment(bindingTarget, value, location, /*original*/ element); + flattenContext.emitBindingOrAssignment(bindingTarget, value, location, /*original*/ element); // TODO: GH#18217 } } /** @@ -58182,7 +58482,7 @@ var ts; flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern); bindingElements = undefined; } - var rhsValue = createRestCall(flattenContext.context, value, elements, computedTempVariables, pattern); + var rhsValue = createRestCall(flattenContext.context, value, elements, computedTempVariables, pattern); // TODO: GH#18217 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element); } } @@ -58424,8 +58724,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(184 /* PropertyAccessExpression */); - context.enableSubstitution(185 /* ElementAccessExpression */); + context.enableSubstitution(185 /* PropertyAccessExpression */); + context.enableSubstitution(186 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -58454,14 +58754,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 274 /* Bundle */) { + if (node.kind === 275 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 276 /* InputFiles */) { + if (prepend.kind === 277 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText); } return prepend; @@ -58508,15 +58808,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 273 /* SourceFile */: - case 240 /* CaseBlock */: - case 239 /* ModuleBlock */: - case 212 /* Block */: + case 274 /* SourceFile */: + case 241 /* CaseBlock */: + case 240 /* ModuleBlock */: + case 213 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 234 /* ClassDeclaration */: - case 233 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 234 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -58528,7 +58828,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 === 234 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 235 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } break; } @@ -58572,10 +58872,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 248 /* ExportAssignment */: - case 249 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 249 /* ExportAssignment */: + case 250 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -58596,13 +58896,13 @@ var ts; return node; } switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return visitImportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitExportAssignment(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -58622,11 +58922,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 249 /* ExportDeclaration */ || - node.kind === 243 /* ImportDeclaration */ || - node.kind === 244 /* ImportClause */ || - (node.kind === 242 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 253 /* ExternalModuleReference */)) { + if (node.kind === 250 /* ExportDeclaration */ || + node.kind === 244 /* ImportDeclaration */ || + node.kind === 245 /* ImportClause */ || + (node.kind === 243 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 254 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -58656,19 +58956,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 154 /* Constructor */: + case 155 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 151 /* PropertyDeclaration */: - case 159 /* IndexSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 153 /* MethodDeclaration */: + case 152 /* PropertyDeclaration */: + case 160 /* IndexSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 154 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 211 /* SemicolonClassElement */: + case 212 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -58707,52 +59007,53 @@ var ts; case 124 /* DeclareKeyword */: case 132 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 166 /* ArrayType */: - case 167 /* TupleType */: - case 165 /* TypeLiteral */: - case 160 /* TypePredicate */: - case 147 /* TypeParameter */: + case 167 /* ArrayType */: + case 168 /* TupleType */: + case 166 /* TypeLiteral */: + case 161 /* TypePredicate */: + case 148 /* TypeParameter */: case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 122 /* BooleanKeyword */: case 137 /* StringKeyword */: case 134 /* NumberKeyword */: case 131 /* NeverKeyword */: case 105 /* VoidKeyword */: case 138 /* SymbolKeyword */: - case 163 /* ConstructorType */: - case 162 /* FunctionType */: - case 164 /* TypeQuery */: - case 161 /* TypeReference */: - case 168 /* UnionType */: - case 169 /* IntersectionType */: - case 170 /* ConditionalType */: - case 172 /* ParenthesizedType */: - case 173 /* ThisType */: - case 174 /* TypeOperator */: - case 175 /* IndexedAccessType */: - case 176 /* MappedType */: - case 177 /* LiteralType */: + case 164 /* ConstructorType */: + case 163 /* FunctionType */: + case 165 /* TypeQuery */: + case 162 /* TypeReference */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: + case 171 /* ConditionalType */: + case 173 /* ParenthesizedType */: + case 174 /* ThisType */: + case 175 /* TypeOperator */: + case 176 /* IndexedAccessType */: + case 177 /* MappedType */: + case 178 /* LiteralType */: // TypeScript type nodes are elided. - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: // TypeScript index signatures are elided. - case 149 /* Decorator */: + case 150 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 151 /* PropertyDeclaration */: + case 152 /* 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 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 154 /* Constructor */: + case 155 /* Constructor */: return visitConstructor(node); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -58763,7 +59064,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -58774,35 +59075,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 148 /* Parameter */: + case 149 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -58812,35 +59113,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return visitCallExpression(node); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return visitNewExpression(node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -58849,7 +59150,8 @@ var ts; } function visitSourceFile(node) { var alwaysStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") && - !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015); + !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015) && + !ts.isJsonSourceFile(node); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); } /** @@ -58956,7 +59258,7 @@ var ts; statement.pos = closingBraceLocation.pos; ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); statements.push(statement); - ts.prependRange(statements, context.endLexicalEnvironment()); + ts.prependStatements(statements, context.endLexicalEnvironment()); var iife = ts.createImmediatelyInvokedArrowFunction(statements); ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); var varStatement = ts.createVariableStatement( @@ -59321,7 +59623,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 215 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -59392,7 +59694,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 151 /* PropertyDeclaration */ + return member.kind === 152 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -59530,12 +59832,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -59688,7 +59990,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 151 /* PropertyDeclaration */ + ? member.kind === 152 /* 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`. ? ts.createVoidZero() @@ -59811,10 +60113,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */ - || kind === 151 /* PropertyDeclaration */; + return kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */ + || kind === 152 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -59824,7 +60126,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 153 /* MethodDeclaration */; + return node.kind === 154 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -59835,12 +60137,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return true; } return false; @@ -59852,15 +60154,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 151 /* PropertyDeclaration */: - case 148 /* Parameter */: - case 155 /* GetAccessor */: + case 152 /* PropertyDeclaration */: + case 149 /* Parameter */: + case 156 /* GetAccessor */: return serializeTypeNode(node.type); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 153 /* MethodDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 154 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -59897,7 +60199,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 155 /* GetAccessor */) { + if (container && node.kind === 156 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -59947,22 +60249,22 @@ var ts; case 95 /* NullKeyword */: case 131 /* NeverKeyword */: return ts.createVoidZero(); - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 162 /* FunctionType */: - case 163 /* ConstructorType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: return ts.createIdentifier("Function"); - case 166 /* ArrayType */: - case 167 /* TupleType */: + case 167 /* ArrayType */: + case 168 /* TupleType */: return ts.createIdentifier("Array"); - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: case 122 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); case 137 /* StringKeyword */: return ts.createIdentifier("String"); case 135 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 177 /* LiteralType */: + case 178 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -59980,18 +60282,19 @@ var ts; return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return serializeTypeReferenceNode(node); - case 169 /* IntersectionType */: - case 168 /* UnionType */: + case 170 /* IntersectionType */: + case 169 /* UnionType */: return serializeUnionOrIntersectionType(node); - case 164 /* TypeQuery */: - case 174 /* TypeOperator */: - case 175 /* IndexedAccessType */: - case 176 /* MappedType */: - case 165 /* TypeLiteral */: + case 165 /* TypeQuery */: + case 175 /* TypeOperator */: + case 176 /* IndexedAccessType */: + case 177 /* MappedType */: + case 166 /* TypeLiteral */: case 119 /* AnyKeyword */: - case 173 /* ThisType */: + case 142 /* UnknownKeyword */: + case 174 /* ThisType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -60004,7 +60307,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 172 /* ParenthesizedType */) { + while (typeNode.kind === 173 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -60043,7 +60346,8 @@ var ts; * @param node The type reference node. */ function serializeTypeReferenceNode(node) { - switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) { + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, /*useFallback*/ true); var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -60069,8 +60373,9 @@ var ts; case ts.TypeReferenceSerializationKind.Promise: return ts.createIdentifier("Promise"); case ts.TypeReferenceSerializationKind.ObjectType: - default: return ts.createIdentifier("Object"); + default: + return ts.Debug.assertNever(kind); } } /** @@ -60093,7 +60398,7 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } return name; - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -60579,7 +60884,7 @@ var ts; var statements = []; startLexicalEnvironment(); var members = ts.map(node.members, transformEnumMember); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); ts.addRange(statements, members); currentNamespaceContainerName = savedCurrentNamespaceLocalName; return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ node.members), @@ -60628,7 +60933,7 @@ var ts; * @param node The module declaration node. */ function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules); } /** * Determines whether an exported declaration will have a qualified export name (e.g. `f.x` @@ -60678,12 +60983,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentScope.kind === 273 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentScope.kind === 274 /* 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 === 237 /* EnumDeclaration */) { + if (node.kind === 238 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -60802,7 +61107,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 239 /* ModuleBlock */) { + if (body.kind === 240 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -60820,7 +61125,7 @@ var ts; var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; statementsLocation = ts.moveRangePos(moduleBlock.statements, -1); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; @@ -60848,13 +61153,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 (body.kind !== 239 /* ModuleBlock */) { + if (body.kind !== 240 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 238 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -60895,7 +61200,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 245 /* NamespaceImport */) { + if (node.kind === 246 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -61127,16 +61432,16 @@ var ts; // 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(71 /* Identifier */); - context.enableSubstitution(270 /* ShorthandPropertyAssignment */); + context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(238 /* ModuleDeclaration */); + context.enableEmitNotification(239 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 238 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 239 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 237 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 238 /* EnumDeclaration */; } /** * Hook for node emit. @@ -61197,9 +61502,9 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -61219,7 +61524,7 @@ var ts; // constructor references in static property initializers. var declaration = resolver.getReferencedValueDeclaration(node); if (declaration) { - var classAlias = classAliases[declaration.id]; + var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { var clone_1 = ts.getSynthesizedClone(classAlias); ts.setSourceMapRange(clone_1, node); @@ -61237,9 +61542,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 !== 273 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 238 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 237 /* EnumDeclaration */); + if (container && container.kind !== 274 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 239 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 238 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -61374,15 +61679,15 @@ var ts; case 120 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return visitAwaitExpression(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -61391,27 +61696,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 212 /* Block */: - case 226 /* SwitchStatement */: - case 240 /* CaseBlock */: - case 265 /* CaseClause */: - case 266 /* DefaultClause */: - case 229 /* TryStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 216 /* IfStatement */: - case 225 /* WithStatement */: - case 227 /* LabeledStatement */: + case 213 /* Block */: + case 227 /* SwitchStatement */: + case 241 /* CaseBlock */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: + case 230 /* TryStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 217 /* IfStatement */: + case 226 /* WithStatement */: + case 228 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -61421,7 +61726,7 @@ var ts; } function visitCatchClauseInAsyncBody(node) { var catchClauseNames = ts.createUnderscoreEscapedMap(); - recordDeclarationName(node.variableDeclaration, catchClauseNames); + recordDeclarationName(node.variableDeclaration, catchClauseNames); // TODO: GH#18217 // names declared in a catch variable are block scoped var catchClauseUnshadowedNames; catchClauseNames.forEach(function (_, escapedName) { @@ -61461,8 +61766,9 @@ var ts; : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, ts.liftToBlock)); } function visitForStatementInAsyncBody(node) { - return ts.updateFor(node, isVariableDeclarationListWithCollidingName(node.initializer) - ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ false) + var initializer = node.initializer; // TODO: GH#18217 + return ts.updateFor(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, ts.liftToBlock)); } /** @@ -61554,10 +61860,10 @@ var ts; } } function isVariableDeclarationListWithCollidingName(node) { - return node + return !!node && ts.isVariableDeclarationList(node) && !(node.flags & 3 /* BlockScoped */) - && ts.forEach(node.declarations, collidesWithParameterName); + && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { hoistVariableDeclarationList(node); @@ -61611,7 +61917,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 === 192 /* ArrowFunction */; + var isArrowFunction = node.kind === 193 /* 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 @@ -61629,7 +61935,7 @@ var ts; var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.createBlock(statements, /*multiLine*/ true); ts.setTextRange(block, node.body); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. @@ -61684,15 +61990,15 @@ 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(186 /* CallExpression */); - context.enableSubstitution(184 /* PropertyAccessExpression */); - context.enableSubstitution(185 /* ElementAccessExpression */); + context.enableSubstitution(187 /* CallExpression */); + context.enableSubstitution(185 /* PropertyAccessExpression */); + context.enableSubstitution(186 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(234 /* ClassDeclaration */); - context.enableEmitNotification(153 /* MethodDeclaration */); - context.enableEmitNotification(155 /* GetAccessor */); - context.enableEmitNotification(156 /* SetAccessor */); - context.enableEmitNotification(154 /* Constructor */); + context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(154 /* MethodDeclaration */); + context.enableEmitNotification(156 /* GetAccessor */); + context.enableEmitNotification(157 /* SetAccessor */); + context.enableEmitNotification(155 /* Constructor */); } } /** @@ -61732,11 +62038,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -61768,11 +62074,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 234 /* ClassDeclaration */ - || kind === 154 /* Constructor */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */; + return kind === 235 /* ClassDeclaration */ + || kind === 155 /* Constructor */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */; } function createSuperAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -61867,45 +62173,47 @@ var ts; return node; } switch (node.kind) { - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return visitAwaitExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return visitYieldExpression(node); - case 227 /* LabeledStatement */: + case 225 /* ReturnStatement */: + return visitReturnStatement(node); + case 228 /* LabeledStatement */: return visitLabeledStatement(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return visitVoidExpression(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return visitConstructorDeclaration(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: return visitGetAccessorDeclaration(node); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return visitArrowFunction(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return visitParameter(node); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return visitExpressionStatement(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -61930,10 +62238,16 @@ var ts; } return ts.visitEachChild(node, visitor, context); } + function visitReturnStatement(node) { + if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + return ts.updateReturn(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : ts.createVoidZero())); + } + return ts.visitEachChild(node, visitor, context); + } function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 221 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 222 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -61945,7 +62259,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 === 271 /* SpreadAssignment */) { + if (e.kind === 272 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -61954,7 +62268,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 269 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 270 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -61972,7 +62286,7 @@ var ts; // If the first element is a spread element, then the first argument to __assign is {}: // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 183 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 184 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -62106,7 +62420,7 @@ var ts; ]), node.expression), 2097152 /* NoHoisting */), /*condition*/ ts.createComma(ts.createAssignment(result, createDownlevelAwait(callNext)), ts.createLogicalNot(getDone)), /*incrementor*/ undefined, - /*statement*/ convertForOfStatementHead(node, createDownlevelAwait(getValue))), + /*statement*/ convertForOfStatementHead(node, getValue)), /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) @@ -62228,7 +62542,7 @@ var ts; /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset)))))); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.updateBlock(node.body, statements); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. @@ -62256,7 +62570,7 @@ var ts; var leadingStatements = endLexicalEnvironment(); if (statementOffset > 0 || ts.some(statements) || ts.some(leadingStatements)) { var block = ts.convertToFunctionBody(body, /*multiLine*/ true); - ts.prependRange(statements, leadingStatements); + ts.prependStatements(statements, leadingStatements); ts.addRange(statements, block.statements.slice(statementOffset)); return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(statements), block.statements)); } @@ -62285,15 +62599,15 @@ 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(186 /* CallExpression */); - context.enableSubstitution(184 /* PropertyAccessExpression */); - context.enableSubstitution(185 /* ElementAccessExpression */); + context.enableSubstitution(187 /* CallExpression */); + context.enableSubstitution(185 /* PropertyAccessExpression */); + context.enableSubstitution(186 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(234 /* ClassDeclaration */); - context.enableEmitNotification(153 /* MethodDeclaration */); - context.enableEmitNotification(155 /* GetAccessor */); - context.enableEmitNotification(156 /* SetAccessor */); - context.enableEmitNotification(154 /* Constructor */); + context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(154 /* MethodDeclaration */); + context.enableEmitNotification(156 /* GetAccessor */); + context.enableEmitNotification(157 /* SetAccessor */); + context.enableEmitNotification(155 /* Constructor */); } } /** @@ -62333,11 +62647,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -62369,11 +62683,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 234 /* ClassDeclaration */ - || kind === 154 /* Constructor */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */; + return kind === 235 /* ClassDeclaration */ + || kind === 155 /* Constructor */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */; } function createSuperAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -62482,13 +62796,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 254 /* JsxElement */: + case 255 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -62498,13 +62812,13 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return visitJsxExpression(node); - case 254 /* JsxElement */: + case 255 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -62545,14 +62859,16 @@ var ts; objectProperties = ts.createAssignHelper(context, segments); } } - var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location); + var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217 + tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location); if (isChild) { ts.startOnNewLine(element); } return element; } function visitJsxOpeningFragment(node, children, isChild, location) { - var element = ts.createExpressionForJsxFragment(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, ts.mapDefined(children, transformJsxChildToExpression), node, location); + var element = ts.createExpressionForJsxFragment(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217 + ts.mapDefined(children, transformJsxChildToExpression), node, location); if (isChild) { ts.startOnNewLine(element); } @@ -62577,7 +62893,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 264 /* JsxExpression */) { + else if (node.kind === 265 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -62671,7 +62987,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 254 /* JsxElement */) { + if (node.kind === 255 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -62977,7 +63293,7 @@ var ts; return node; } switch (node.kind) { - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -63209,14 +63525,14 @@ var ts; hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ - && node.kind === 224 /* ReturnStatement */ + return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 + && node.kind === 225 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 212 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 213 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -63244,63 +63560,63 @@ var ts; switch (node.kind) { case 115 /* StaticKeyword */: return undefined; // elide static keyword - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return visitClassDeclaration(node); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return visitClassExpression(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return visitParameter(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return visitArrowFunction(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return visitVariableDeclaration(node); case 71 /* Identifier */: return visitIdentifier(node); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return visitSwitchStatement(node); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return visitCaseBlock(node); - case 212 /* Block */: + case 213 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return visitLabeledStatement(node); - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return visitExpressionStatement(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitCatchClause(node); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return visitCallExpression(node); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return visitNewExpression(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 13 /* NoSubstitutionTemplateLiteral */: case 14 /* TemplateHead */: @@ -63311,28 +63627,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return visitTemplateExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return visitYieldExpression(node); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return visitSpreadElement(node); case 97 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 99 /* ThisKeyword */: return visitThisKeyword(node); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return visitMetaProperty(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -63349,7 +63665,7 @@ var ts; if (taggedTemplateStringDeclarations) { statements.push(ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList(taggedTemplateStringDeclarations))); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -63419,13 +63735,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 === 223 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 224 /* 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; - if (!node.label) { - if (node.kind === 223 /* BreakStatement */) { + var label = node.label; + if (!label) { + if (node.kind === 224 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -63436,13 +63753,13 @@ var ts; } } else { - if (node.kind === 223 /* BreakStatement */) { - labelMarker = "break-" + node.label.escapedText; - setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(node.label), labelMarker); + if (node.kind === 224 /* BreakStatement */) { + labelMarker = "break-" + label.escapedText; + setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + node.label.escapedText; - setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(node.label), labelMarker); + labelMarker = "continue-" + label.escapedText; + setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(label), labelMarker); } } var returnExpression = ts.createLiteral(labelMarker); @@ -63603,7 +63920,7 @@ var ts; statement.pos = closingBraceLocation.pos; ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); statements.push(statement); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); ts.setEmitFlags(block, 1536 /* NoComments */); return block; @@ -63661,7 +63978,7 @@ var ts; // `super` call. // If this is the case, we do not include the synthetic `...args` parameter and // will instead use the `arguments` object in ES5/3. - return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) + return ts.visitParameterList(constructor && !hasSynthesizedSuper ? constructor.parameters : undefined, visitor, context) || []; } /** @@ -63697,7 +64014,7 @@ var ts; } // 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 !== 95 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { @@ -63716,7 +64033,7 @@ var ts; && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createFileLevelUniqueName("_this"))); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); if (constructor) { prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); } @@ -63736,11 +64053,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 224 /* ReturnStatement */) { + if (statement.kind === 225 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 216 /* IfStatement */) { + else if (statement.kind === 217 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -63748,7 +64065,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 212 /* Block */) { + else if (statement.kind === 213 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -63806,7 +64123,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 215 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -63816,8 +64133,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 199 /* BinaryExpression */ - || superCallExpression.left.kind !== 186 /* CallExpression */) { + if (superCallExpression.kind !== 200 /* BinaryExpression */ + || superCallExpression.left.kind !== 187 /* CallExpression */) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } // Shift comments from the original super call to the return statement. @@ -64014,7 +64331,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 192 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 193 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -64034,22 +64351,22 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return statements; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 154 /* Constructor */: + case 155 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 192 /* 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 = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 93 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); @@ -64080,20 +64397,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 211 /* SemicolonClassElement */: + case 212 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 154 /* Constructor */: + case 155 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -64163,7 +64480,7 @@ var ts; // arguments are both mapped contiguously to the accessor name. var target = ts.getMutableClone(receiver); ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); - ts.setSourceMapRange(target, firstAccessor.name); + ts.setSourceMapRange(target, firstAccessor.name); // TODO: GH#18217 var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 16 /* NoLeadingSourceMap */); ts.setSourceMapRange(propertyName, firstAccessor.name); @@ -64285,7 +64602,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 === 233 /* FunctionDeclaration */ || node.kind === 191 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 234 /* FunctionDeclaration */ || node.kind === 192 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -64333,7 +64650,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 192 /* ArrowFunction */); + ts.Debug.assert(node.kind === 193 /* 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 @@ -64359,7 +64676,7 @@ var ts; closeBraceLocation = body; } var lexicalEnvironment = context.endLexicalEnvironment(); - ts.prependRange(statements, lexicalEnvironment); + ts.prependStatements(statements, lexicalEnvironment); prependCaptureNewTargetIfNeeded(statements, node, /*copyOnWrite*/ false); // If we added any final generated statements, this must be a multi-line block if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { @@ -64401,9 +64718,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -64422,9 +64739,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -64497,13 +64814,12 @@ var ts; ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 /* ContainsBindingPattern */ - && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. var firstDeclaration = ts.firstOrUndefined(declarations); if (firstDeclaration) { - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, ts.last(declarations).end)); } } return declarationList; @@ -64626,14 +64942,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -64657,11 +64973,12 @@ var ts; } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; - if (ts.isVariableDeclarationList(node.initializer)) { + var initializer = node.initializer; + if (ts.isVariableDeclarationList(initializer)) { if (node.initializer.flags & 3 /* BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } - var firstOriginalDeclaration = ts.firstOrUndefined(node.initializer.declarations); + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. @@ -64670,9 +64987,7 @@ var ts; ts.setOriginalNode(declarationList, node.initializer); // Adjust the source map range for the first declaration to align with the old // emitter. - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(declarations[0].pos, ts.last(declarations).end)); statements.push(ts.createVariableStatement( /*modifiers*/ undefined, declarationList)); } @@ -64683,20 +64998,20 @@ var ts; /*modifiers*/ undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), /*type*/ undefined, boundValue) - ]), ts.moveRangePos(node.initializer, -1)), node.initializer)), ts.moveRangeEnd(node.initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. - var assignment = ts.createAssignment(node.initializer, boundValue); + var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); statements.push(ts.createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); } else { - assignment.end = node.initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(node.initializer, -1))); + assignment.end = initializer.end; + statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -64818,7 +65133,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 146 /* ComputedPropertyName */) { + if (property.name.kind === 147 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -64890,11 +65205,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 232 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 233 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -64940,7 +65255,7 @@ var ts; if (loopOutParameters.length) { copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_4); } - ts.prependRange(statements_4, lexicalEnvironment); + ts.prependStatements(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, /*multiline*/ true); } if (ts.isBlock(loopBody)) { @@ -65174,20 +65489,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -65298,7 +65613,7 @@ var ts; var body = node.transformFlags & (32768 /* ContainsCapturedLexicalThis */ | 128 /* ContainsES2015 */) ? transformFunctionBody(node) : visitFunctionBodyDownLevel(node); - if (node.kind === 155 /* GetAccessor */) { + if (node.kind === 156 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -65340,7 +65655,7 @@ var ts; function visitArrayLiteralExpression(node) { if (node.transformFlags & 64 /* ES2015 */) { // We are here because we contain a SpreadElementExpression. - return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, !!node.multiLine, /*hasTrailingComma*/ !!node.elements.hasTrailingComma); } return ts.visitEachChild(node, visitor, context); } @@ -65395,11 +65710,11 @@ var ts; var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock); // The class statements are the statements generated by visiting the first statement with initializer of the // body (1), while all other statements are added to remainingStatements (2) - var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.firstOrUndefined(stmt.declarationList.declarations).initializer; }; + var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.first(stmt.declarationList.declarations).initializer; }; var bodyStatements = ts.visitNodes(body.statements, visitor, ts.isStatement); var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer); var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); }); - var varStatement = ts.cast(ts.firstOrUndefined(classStatements), ts.isVariableStatement); + var varStatement = ts.cast(ts.first(classStatements), ts.isVariableStatement); // We know there is only one variable declaration here as we verified this in an // earlier call to isTypeScriptClassWrapper var variable = varStatement.declarationList.declarations[0]; @@ -65576,7 +65891,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 182 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -65839,13 +66154,13 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(99 /* ThisKeyword */); - context.enableEmitNotification(154 /* Constructor */); - context.enableEmitNotification(153 /* MethodDeclaration */); - context.enableEmitNotification(155 /* GetAccessor */); - context.enableEmitNotification(156 /* SetAccessor */); - context.enableEmitNotification(192 /* ArrowFunction */); - context.enableEmitNotification(191 /* FunctionExpression */); - context.enableEmitNotification(233 /* FunctionDeclaration */); + context.enableEmitNotification(155 /* Constructor */); + context.enableEmitNotification(154 /* MethodDeclaration */); + context.enableEmitNotification(156 /* GetAccessor */); + context.enableEmitNotification(157 /* SetAccessor */); + context.enableEmitNotification(193 /* ArrowFunction */); + context.enableEmitNotification(192 /* FunctionExpression */); + context.enableEmitNotification(234 /* FunctionDeclaration */); } } /** @@ -65885,14 +66200,13 @@ var ts; * @param node An original source tree node. */ function isNameOfDeclarationWithCollidingName(node) { - var parent = node.parent; - switch (parent.kind) { - case 181 /* BindingElement */: - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: - case 231 /* VariableDeclaration */: - return parent.name === node - && resolver.isDeclarationWithCollidingName(parent); + switch (node.parent.kind) { + case 182 /* BindingElement */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 232 /* VariableDeclaration */: + return node.parent.name === node + && resolver.isDeclarationWithCollidingName(node.parent); } return false; } @@ -65972,11 +66286,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 215 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 186 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -65984,7 +66298,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 203 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -66037,15 +66351,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(256 /* JsxOpeningElement */); - context.enableEmitNotification(257 /* JsxClosingElement */); - context.enableEmitNotification(255 /* JsxSelfClosingElement */); + context.enableEmitNotification(257 /* JsxOpeningElement */); + context.enableEmitNotification(258 /* JsxClosingElement */); + context.enableEmitNotification(256 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(184 /* PropertyAccessExpression */); - context.enableSubstitution(269 /* PropertyAssignment */); + context.enableSubstitution(185 /* PropertyAccessExpression */); + context.enableSubstitution(270 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -66064,9 +66378,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 256 /* JsxOpeningElement */: - case 257 /* JsxClosingElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 258 /* JsxClosingElement */: + case 256 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -66123,7 +66437,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */) { + if (token !== undefined && token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -66308,6 +66622,7 @@ var ts; case 4 /* Yield */: return "yield"; case 5 /* YieldStar */: return "yield*"; case 7 /* Endfinally */: return "endfinally"; + default: return undefined; // TODO: GH#18217 } } function transformGenerators(context) { @@ -66397,13 +66712,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 217 /* DoStatement */: + case 218 /* DoStatement */: return visitDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return visitWhileStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return visitSwitchStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -66416,24 +66731,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatement(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatement(node); - case 223 /* BreakStatement */: + case 224 /* BreakStatement */: return visitBreakStatement(node); - case 222 /* ContinueStatement */: + case 223 /* ContinueStatement */: return visitContinueStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -66454,21 +66769,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitBinaryExpression(node); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return visitConditionalExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return visitYieldExpression(node); - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return visitCallExpression(node); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -66481,9 +66796,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -66615,7 +66930,7 @@ var ts; var statementOffset = ts.addPrologue(statements, body.statements, /*ensureUseStrict*/ false, visitor); transformAndEmitStatements(body.statements, statementOffset); var buildResult = build(); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); statements.push(ts.createReturn(buildResult)); // Restore previous generator state inGeneratorFunctionBody = savedInGeneratorFunctionBody; @@ -66671,13 +66986,14 @@ var ts; * @param node The node to visit. */ function visitBinaryExpression(node) { - switch (ts.getExpressionAssociativity(node)) { + var assoc = ts.getExpressionAssociativity(node); + switch (assoc) { case 0 /* Left */: return visitLeftAssociativeBinaryExpression(node); case 1 /* Right */: return visitRightAssociativeBinaryExpression(node); default: - ts.Debug.fail("Unknown associativity."); + return ts.Debug.assertNever(assoc); } } function isCompoundAssignment(kind) { @@ -66710,7 +67026,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -66722,7 +67038,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -67098,35 +67414,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 212 /* Block */: + case 213 /* Block */: return transformAndEmitBlock(node); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return transformAndEmitIfStatement(node); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return transformAndEmitDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return transformAndEmitForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 222 /* ContinueStatement */: + case 223 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 223 /* BreakStatement */: + case 224 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return transformAndEmitWithStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -67556,7 +67872,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 266 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 267 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -67569,7 +67885,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 265 /* CaseClause */) { + if (clause.kind === 266 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -67685,7 +68001,7 @@ var ts; beginExceptionBlock(); transformAndEmitEmbeddedStatement(node.tryBlock); if (node.catchClause) { - beginCatchBlock(node.catchClause.variableDeclaration); + beginCatchBlock(node.catchClause.variableDeclaration); // TODO: GH#18217 transformAndEmitEmbeddedStatement(node.catchClause.block); } if (node.finallyBlock) { @@ -67699,7 +68015,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 16777216 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 16777216 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -67800,7 +68116,8 @@ var ts; */ function endBlock() { var block = peekBlock(); - ts.Debug.assert(block !== undefined, "beginBlock was never called."); + if (block === undefined) + return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; blockActions[index] = 1 /* Close */; blockOffsets[index] = operations ? operations.length : 0; @@ -68133,7 +68450,7 @@ var ts; * @param label A label. */ function createLabel(label) { - if (label > 0) { + if (label !== undefined && label > 0) { if (labelExpressions === undefined) { labelExpressions = []; } @@ -68772,7 +69089,7 @@ var ts; name: "typescript:generator", scoped: false, priority: 6, - text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" + text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; })(ts || (ts = {})); /*@internal*/ @@ -68797,11 +69114,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(199 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(197 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(198 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(270 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(273 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(200 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(198 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(199 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(274 /* 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. @@ -68851,7 +69168,7 @@ var ts; ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { // If we have any `export * from ...` declarations @@ -69045,7 +69362,7 @@ var ts; if (ts.isImportEqualsDeclaration(node) || ts.isExportDeclaration(node) || !ts.getExternalModuleNameLiteral(node, currentSourceFile, host, resolver, compilerOptions)) { return undefined; } - var name = ts.getLocalNameForExternalImport(node, currentSourceFile); + var name = ts.getLocalNameForExternalImport(node, currentSourceFile); // TODO: GH#18217 var expr = getHelperExpressionForImport(node, name); if (expr === name) { return undefined; @@ -69074,7 +69391,7 @@ var ts; addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); // End the lexical environment for the module body // and merge any new lexical declarations. - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var body = ts.createBlock(statements, /*multiLine*/ true); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { // If we have any `export * from ...` declarations @@ -69123,23 +69440,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return visitImportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return visitExportDeclaration(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitExportAssignment(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatement(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return visitClassDeclaration(node); - case 302 /* MergeDeclarationMarker */: + case 303 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 303 /* EndOfDeclarationMarker */: + case 304 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -69166,24 +69483,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -69658,7 +69975,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 213 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -69713,10 +70030,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 246 /* NamedImports */: + case 247 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -69915,7 +70232,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -69979,10 +70296,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return substituteBinaryExpression(node); - case 198 /* PostfixUnaryExpression */: - case 197 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -70003,7 +70320,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 273 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -70078,7 +70395,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 198 /* PostfixUnaryExpression */ + var expression = node.kind === 199 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -70154,11 +70471,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(270 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(199 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(197 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(198 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(273 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(200 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(198 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(199 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(274 /* 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. @@ -70343,8 +70660,8 @@ var ts; // We emit hoisted variables early to align roughly with our previous emit output. // Two key differences in this approach are: // - Temporary variables will appear at the top rather than at the bottom of the file - ts.prependRange(statements, endLexicalEnvironment()); - var exportStarFunction = addExportStarIfNeeded(statements); + ts.prependStatements(statements, endLexicalEnvironment()); + var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217 var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), ts.createPropertyAssignment("execute", ts.createFunctionExpression( @@ -70379,7 +70696,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 249 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 250 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -70404,7 +70721,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 249 /* ExportDeclaration */) { + if (externalImport.kind !== 250 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -70480,21 +70797,21 @@ var ts; var statements = []; for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; - var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); + var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -70544,15 +70861,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return visitImportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -70566,7 +70883,7 @@ var ts; function visitImportDeclaration(node) { var statements; if (node.importClause) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); // TODO: GH#18217 } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -70586,7 +70903,7 @@ var ts; function visitImportEqualsDeclaration(node) { ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); var statements; - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); // TODO: GH#18217 if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); @@ -70728,7 +71045,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 === 273 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 274 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -70792,7 +71109,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 === 213 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -70854,10 +71171,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 246 /* NamedImports */: + case 247 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -71037,43 +71354,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatement(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return visitClassDeclaration(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatement(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatement(node); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return visitDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return visitWhileStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return visitLabeledStatement(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return visitWithStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return visitSwitchStatement(node); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return visitCaseBlock(node); - case 265 /* CaseClause */: + case 266 /* CaseClause */: return visitCaseClause(node); - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: return visitDefaultClause(node); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return visitTryStatement(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitCatchClause(node); - case 212 /* Block */: + case 213 /* Block */: return visitBlock(node); - case 302 /* MergeDeclarationMarker */: + case 303 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 303 /* EndOfDeclarationMarker */: + case 304 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -71087,7 +71404,7 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateFor(node, 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 = ts.updateFor(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)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -71131,9 +71448,6 @@ var ts; * @param node The node to visit. */ function visitForInitializer(node) { - if (!node) { - return node; - } if (shouldHoistForInitializer(node)) { var expressions = void 0; for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { @@ -71259,7 +71573,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 199 /* BinaryExpression */) { + && node.kind === 200 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -71324,7 +71638,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 273 /* SourceFile */; + return container !== undefined && container.kind === 274 /* SourceFile */; } else { return false; @@ -71357,7 +71671,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -71405,7 +71719,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -71441,10 +71755,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return substituteBinaryExpression(node); - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -71537,14 +71851,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 198 /* PostfixUnaryExpression */ + var expression = node.kind === 199 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(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 === 198 /* PostfixUnaryExpression */) { + if (node.kind === 199 /* PostfixUnaryExpression */) { expression = node.operator === 43 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -71566,7 +71880,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 273 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -71605,7 +71919,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(273 /* SourceFile */); + context.enableEmitNotification(274 /* SourceFile */); context.enableSubstitution(71 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -71634,10 +71948,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -71744,7 +72058,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 === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* 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 : @@ -71773,7 +72087,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 === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* 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 : @@ -71817,10 +72131,10 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); + 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 === 231 /* VariableDeclaration */ || node.kind === 181 /* BindingElement */) { + if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* 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 : @@ -71829,8 +72143,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 === 151 /* PropertyDeclaration */ || node.kind === 150 /* PropertySignature */ || - (node.kind === 148 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 152 /* PropertyDeclaration */ || node.kind === 151 /* PropertySignature */ || + (node.kind === 149 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -71839,7 +72153,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 === 234 /* ClassDeclaration */ || node.kind === 148 /* Parameter */) { + else if (node.parent.kind === 235 /* ClassDeclaration */ || node.kind === 149 /* 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 : @@ -71864,7 +72178,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 156 /* SetAccessor */) { + if (node.kind === 157 /* 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.hasModifier(node, 32 /* Static */)) { @@ -71903,26 +72217,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 158 /* ConstructSignature */: + case 159 /* 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 157 /* CallSignature */: + case 158 /* 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 159 /* IndexSignature */: + case 160 /* 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 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -71930,7 +72244,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 === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* 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 : @@ -71944,7 +72258,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 233 /* FunctionDeclaration */: + case 234 /* 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 : @@ -71952,7 +72266,7 @@ var ts; ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; break; default: - ts.Debug.fail("This is unknown kind for signature: " + node.kind); + return ts.Debug.fail("This is unknown kind for signature: " + node.kind); } return { diagnosticMessage: diagnosticMessage, @@ -71969,30 +72283,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 154 /* Constructor */: + case 155 /* 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 158 /* ConstructSignature */: - case 163 /* ConstructorType */: + case 159 /* ConstructSignature */: + case 164 /* 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 157 /* CallSignature */: + case 158 /* 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 159 /* IndexSignature */: + case 160 /* 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 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -72000,7 +72314,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 === 234 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 235 /* 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 : @@ -72013,53 +72327,53 @@ 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 233 /* FunctionDeclaration */: - case 162 /* FunctionType */: + case 234 /* FunctionDeclaration */: + case 163 /* 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; default: - ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* CallSignature */: + case 158 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.hasModifier(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 === 234 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 235 /* 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 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: - ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); + return ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); } return { diagnosticMessage: diagnosticMessage, @@ -72070,7 +72384,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 234 /* ClassDeclaration */) { + if (node.parent.parent.kind === 235 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = node.parent.token === 108 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -72222,16 +72536,16 @@ var ts; } } function transformRoot(node) { - if (node.kind === 273 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 274 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 274 /* Bundle */) { + if (node.kind === 275 /* Bundle */) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { if (sourceFile.isDeclarationFile || ts.isSourceFileJavaScript(sourceFile)) - return; // Omit declaration files from bundle results, too + return undefined; // Omit declaration files from bundle results, too // TODO: GH#18217 hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; enclosingDeclaration = sourceFile; @@ -72253,7 +72567,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 276 /* InputFiles */) { + if (prepend.kind === 277 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText); } })); @@ -72351,7 +72665,7 @@ var ts; return name; } else { - if (name.kind === 180 /* ArrayBindingPattern */) { + if (name.kind === 181 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -72359,7 +72673,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 205 /* OmittedExpression */) { + if (elem.kind === 206 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -72397,7 +72711,7 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 148 /* Parameter */ && + var shouldUseResolverType = node.kind === 149 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { @@ -72406,7 +72720,7 @@ var ts; if (!ts.getParseTreeNode(node)) { return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(119 /* AnyKeyword */); } - if (node.kind === 156 /* SetAccessor */) { + if (node.kind === 157 /* 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 ts.createKeywordTypeNode(119 /* AnyKeyword */); @@ -72417,12 +72731,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 231 /* VariableDeclaration */ || node.kind === 181 /* BindingElement */) { + if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 148 /* Parameter */ - || node.kind === 151 /* PropertyDeclaration */ - || node.kind === 150 /* PropertySignature */) { + if (node.kind === 149 /* Parameter */ + || node.kind === 152 /* PropertyDeclaration */ + || node.kind === 151 /* 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)); @@ -72439,20 +72753,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 238 /* ModuleDeclaration */: - case 235 /* InterfaceDeclaration */: - case 234 /* ClassDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 237 /* EnumDeclaration */: + case 234 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 236 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 238 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 242 /* ImportEqualsDeclaration */: - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: - case 248 /* ExportAssignment */: + case 243 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: + case 249 /* ExportAssignment */: return false; } return false; @@ -72463,7 +72777,7 @@ var ts; } if (ts.isBindingPattern(elem.name)) { // If any child binding pattern element has been marked visible (usually by collect linked aliases), then this is visible - return ts.forEach(elem.name.elements, getBindingNameVisible); + return ts.some(elem.name.elements, getBindingNameVisible); } else { return resolver.isDeclarationVisible(elem); @@ -72471,11 +72785,11 @@ var ts; } function updateParamsList(node, params, modifierMask) { if (ts.hasModifier(node, 8 /* Private */)) { - return undefined; + return undefined; // TODO: GH#18217 } var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); }); if (!newParams) { - return undefined; + return undefined; // TODO: GH#18217 } return ts.createNodeArray(newParams, params.hasTrailingComma); } @@ -72505,8 +72819,8 @@ var ts; } function rewriteModuleSpecifier(parent, input) { if (!input) - return; - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 238 /* ModuleDeclaration */ && parent.kind !== 178 /* ImportType */); + return undefined; // TODO: GH#18217 + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 /* ModuleDeclaration */ && parent.kind !== 179 /* ImportType */); if (input.kind === 9 /* StringLiteral */ && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -72518,7 +72832,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 253 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 254 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -72545,7 +72859,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 245 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 246 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -72650,66 +72964,68 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 165 /* TypeLiteral */ || input.kind === 176 /* MappedType */) && input.parent.kind !== 236 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 177 /* MappedType */) && input.parent.kind !== 237 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 206 /* ExpressionWithTypeArguments */: { + case 207 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 161 /* TypeReference */: { + case 162 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 154 /* Constructor */: { + case 155 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(154 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), + var ctor = ts.createSignatureDeclaration(155 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + // TODO: GH#18217 + isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 153 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(152 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 154 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(153 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 155 /* GetAccessor */: { + case 156 /* GetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 156 /* SetAccessor */: { + case 157 /* SetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 150 /* PropertySignature */: + case 151 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 152 /* MethodSignature */: { + case 153 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 157 /* CallSignature */: { + case 158 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 159 /* IndexSignature */: { + case 160 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); } - case 231 /* VariableDeclaration */: { + case 232 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -72717,13 +73033,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(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 147 /* TypeParameter */: { + case 148 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 170 /* ConditionalType */: { + case 171 /* 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); @@ -72735,13 +73051,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 162 /* FunctionType */: { + case 163 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 163 /* ConstructorType */: { + case 164 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 178 /* ImportType */: { + case 179 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -72770,7 +73086,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 153 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 154 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -72780,7 +73096,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ExportDeclaration */: { + case 250 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -72789,7 +73105,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 248 /* ExportAssignment */: { + case 249 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -72819,10 +73135,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 242 /* ImportEqualsDeclaration */: { + case 243 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 243 /* ImportDeclaration */: { + case 244 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -72843,24 +73159,24 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 236 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 237 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 235 /* InterfaceDeclaration */: { + case 236 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 233 /* FunctionDeclaration */: { + case 234 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type return cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), /*body*/ undefined)); } - case 238 /* ModuleDeclaration */: { + case 239 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 239 /* ModuleBlock */) { + if (inner && inner.kind === 240 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -72874,14 +73190,14 @@ var ts; needsDeclare = false; ts.visitNode(inner, visitDeclarationStatements); // eagerly transform nested namespaces (the nesting doesn't need any elision or painting done) - var id = "" + ts.getOriginalNodeId(inner); + var id = "" + ts.getOriginalNodeId(inner); // TODO: GH#18217 var body = lateStatementReplacementMap.get(id); lateStatementReplacementMap.delete(id); return cleanup(ts.updateModuleDeclaration(input, /*decorators*/ undefined, mods, input.name, body)); } } - case 234 /* ClassDeclaration */: { + case 235 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -72924,7 +73240,7 @@ var ts; var extendsClause_1 = ts.getClassExtendsHeritageClauseElement(input); if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression - var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); + var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); // TODO: GH#18217 getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, @@ -72943,7 +73259,7 @@ var ts; return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 95 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, - /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; + /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 } else { var heritageClauses = transformHeritageClauses(input.heritageClauses); @@ -72951,10 +73267,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 213 /* VariableStatement */: { + case 214 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 237 /* EnumDeclaration */: { + case 238 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -72973,7 +73289,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 238 /* ModuleDeclaration */) { + if (input.kind === 239 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -72994,7 +73310,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 205 /* OmittedExpression */) { + if (e.kind === 206 /* OmittedExpression */) { return; } if (e.name) { @@ -73048,7 +73364,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 273 /* SourceFile */; + var parentIsFile = node.parent.kind === 274 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1 /* Export */) | 512 /* Default */ | 2 /* Ambient */); additions = 0 /* None */; @@ -73096,7 +73412,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 235 /* InterfaceDeclaration */) { + if (node.kind === 236 /* InterfaceDeclaration */) { return true; } return false; @@ -73116,7 +73432,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 155 /* GetAccessor */ + return accessor.kind === 156 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -73125,51 +73441,51 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 231 /* VariableDeclaration */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 148 /* Parameter */: + case 232 /* VariableDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 149 /* Parameter */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 238 /* ModuleDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 235 /* InterfaceDeclaration */: - case 234 /* ClassDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 237 /* EnumDeclaration */: - case 213 /* VariableStatement */: - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: - case 248 /* ExportAssignment */: + case 234 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 236 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 238 /* EnumDeclaration */: + case 214 /* VariableStatement */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: + case 249 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 158 /* ConstructSignature */: - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 159 /* IndexSignature */: - case 231 /* VariableDeclaration */: - case 147 /* TypeParameter */: - case 206 /* ExpressionWithTypeArguments */: - case 161 /* TypeReference */: - case 170 /* ConditionalType */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 178 /* ImportType */: + case 159 /* ConstructSignature */: + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 160 /* IndexSignature */: + case 232 /* VariableDeclaration */: + case 148 /* TypeParameter */: + case 207 /* ExpressionWithTypeArguments */: + case 162 /* TypeReference */: + case 171 /* ConditionalType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 179 /* ImportType */: return true; } return false; @@ -73245,7 +73561,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(304 /* Count */); + var enabledSyntaxKindFeatures = new Array(305 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -73554,7 +73870,7 @@ var ts; * @param sourceFileOrBundle The input source file or bundle for the program. */ function initialize(filePath, sourceMapFilePath, sourceFileOrBundle, outputSourceMapDataList) { - if (disabled) { + if (disabled || ts.fileExtensionIs(filePath, ".json" /* Json */)) { return; } if (sourceMapData) { @@ -73590,7 +73906,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 273 /* SourceFile */) { // emitting single module file + if (sourceFileOrBundle.kind === 274 /* SourceFile */) { // emitting single module file // For modules or multiple emit files the mapRoot will have directory structure like the sources // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); @@ -73677,7 +73993,7 @@ var ts; * @param pos The position. */ function emitPos(pos) { - if (disabled || ts.positionIsSynthesized(pos)) { + if (disabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(currentSource)) { return; } if (extendedDiagnostics) { @@ -73726,12 +74042,12 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithSourceMap(hint, node, emitCallback) { - if (disabled) { + if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0 /* None */; var range = emitNode && emitNode.sourceMapRange; var _a = range || node, pos = _a.pos, end = _a.end; var source = range && range.source; @@ -73740,7 +74056,7 @@ var ts; source = undefined; if (source) setSourceFile(source); - if (node.kind !== 299 /* NotEmittedStatement */ + if (node.kind !== 300 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -73757,7 +74073,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 299 /* NotEmittedStatement */ + if (node.kind !== 300 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -73775,11 +74091,11 @@ var ts; * @param emitCallback The callback used to emit the token. */ function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { - if (disabled) { + if (disabled || ts.isInJsonFile(node)) { return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0 /* None */; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; tokenPos = skipSourceTrivia(range ? range.pos : tokenPos); if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { @@ -73793,6 +74109,9 @@ var ts; } return tokenPos; } + function isJsonSourceMapSource(sourceFile) { + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + } /** * Set the current source file. * @@ -73804,6 +74123,9 @@ var ts; } currentSource = sourceFile; currentSourceText = currentSource.text; + if (isJsonSourceMapSource(sourceFile)) { + return; + } // Add the file to tsFilePaths // If sourceroot option: Use the relative path corresponding to the common directory path // otherwise source locations relative to map file location @@ -73825,8 +74147,8 @@ var ts; * Gets the text for the source map. */ function getText() { - if (disabled) { - return; + if (disabled || isJsonSourceMapSource(currentSource)) { + return undefined; // TODO: GH#18217 } encodeLastRecordedSourceMapSpan(); return JSON.stringify({ @@ -73843,8 +74165,8 @@ var ts; * Gets the SourceMappingURL for the source map. */ function getSourceMappingURL() { - if (disabled) { - return; + if (disabled || isJsonSourceMapSource(currentSource)) { + return undefined; // TODO: GH#18217 } if (compilerOptions.inlineSourceMap) { // Encode the sourceMap into the sourceMap url @@ -73905,7 +74227,7 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = printerOptions.removeComments; + var disabled = !!printerOptions.removeComments; return { reset: reset, setWriter: setWriter, @@ -73923,7 +74245,7 @@ var ts; if (node) { hasWrittenComment = false; var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0; var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; if ((pos < 0 && end < 0) || (pos === end)) { // Both pos and end are synthesized, so just emit the node without comments. @@ -73933,7 +74255,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 299 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 300 /* 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 === 10 /* JsxText */; @@ -73954,7 +74276,7 @@ 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 === 232 /* VariableDeclarationList */) { + if (node.kind === 233 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -74211,11 +74533,11 @@ var ts; detachedCommentsInfo = undefined; } function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; } function forEachLeadingCommentWithoutDetachedComments(cb) { // get the leading comments from detachedPos - var pos = ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos; + var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); } @@ -74270,6 +74592,7 @@ var ts; * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { @@ -74295,17 +74618,17 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 274 /* Bundle */) { + if (sourceFile.kind === 275 /* Bundle */) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var bundleInfoPath = options.references && jsFilePath && (ts.removeFileExtension(jsFilePath) + infoExtension); + var bundleInfoPath = options.references && jsFilePath ? (ts.removeFileExtension(jsFilePath) + infoExtension) : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: bundleInfoPath }; } else { var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var sourceMapFilePath = ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error var isJs = ts.isSourceFileJavaScript(sourceFile); var declarationFilePath = ((forceDtsPaths || options.declaration) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; @@ -74371,7 +74694,7 @@ var ts; emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), emittedFiles: emittedFilesList, - sourceMaps: sourceMapDataList + sourceMaps: sourceMapDataList, }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, bundleInfoPath = _a.bundleInfoPath; @@ -74458,8 +74781,8 @@ var ts; declarationTransform.dispose(); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 274 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 273 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 275 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 274 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -74478,7 +74801,7 @@ var ts; ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, mapRecorder.getText(), /*writeByteOrderMark*/ false, sourceFiles); } // Write the output file - ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); + ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); // Write bundled offset information if applicable if (bundleInfoPath) { bundleInfo.totalLength = writer.getTextPos(); @@ -74559,9 +74882,9 @@ var ts; break; } switch (node.kind) { - case 273 /* SourceFile */: return printFile(node); - case 274 /* Bundle */: return printBundle(node); - case 275 /* UnparsedSource */: return printUnparsedSource(node); + case 274 /* SourceFile */: return printFile(node); + case 275 /* Bundle */: return printBundle(node); + case 276 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -74662,7 +74985,7 @@ var ts; } } function setWriter(output) { - writer = output; + writer = output; // TODO: GH#18217 comments.setWriter(output); } function reset() { @@ -74720,8 +75043,7 @@ var ts; return getPipelinePhase(currentPhase + 1, hint); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assertDefined(onEmitNode); - onEmitNode(hint, node, getNextPipelinePhase(0 /* Notification */, hint)); + ts.Debug.assertDefined(onEmitNode)(hint, node, getNextPipelinePhase(0 /* Notification */, hint)); } function pipelineEmitWithComments(hint, node) { ts.Debug.assertDefined(emitNodeWithComments); @@ -74733,9 +75055,8 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assertDefined(onEmitSourceMapOfNode); ts.Debug.assert(hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */); - onEmitSourceMapOfNode(hint, node, pipelineEmitWithHint); + ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { if (hint === 0 /* SourceFile */) @@ -74753,235 +75074,235 @@ var ts; case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: return emitLiteral(node); - case 275 /* UnparsedSource */: + case 276 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers case 71 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return emitQualifiedName(node); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return emitTypeParameter(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return emitParameter(node); - case 149 /* Decorator */: + case 150 /* Decorator */: return emitDecorator(node); // Type members - case 150 /* PropertySignature */: + case 151 /* PropertySignature */: return emitPropertySignature(node); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 152 /* MethodSignature */: + case 153 /* MethodSignature */: return emitMethodSignature(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return emitConstructor(node); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return emitAccessorDeclaration(node); - case 157 /* CallSignature */: + case 158 /* CallSignature */: return emitCallSignature(node); - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: return emitConstructSignature(node); - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: return emitIndexSignature(node); // Types - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return emitTypePredicate(node); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return emitTypeReference(node); - case 162 /* FunctionType */: + case 163 /* FunctionType */: return emitFunctionType(node); - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 163 /* ConstructorType */: + case 164 /* ConstructorType */: return emitConstructorType(node); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return emitTypeQuery(node); - case 165 /* TypeLiteral */: + case 166 /* TypeLiteral */: return emitTypeLiteral(node); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return emitArrayType(node); - case 167 /* TupleType */: + case 168 /* TupleType */: return emitTupleType(node); - case 168 /* UnionType */: + case 169 /* UnionType */: return emitUnionType(node); - case 169 /* IntersectionType */: + case 170 /* IntersectionType */: return emitIntersectionType(node); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return emitConditionalType(node); - case 171 /* InferType */: + case 172 /* InferType */: return emitInferType(node); - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return emitParenthesizedType(node); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 173 /* ThisType */: + case 174 /* ThisType */: return emitThisType(); - case 174 /* TypeOperator */: + case 175 /* TypeOperator */: return emitTypeOperator(node); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 176 /* MappedType */: + case 177 /* MappedType */: return emitMappedType(node); - case 177 /* LiteralType */: + case 178 /* LiteralType */: return emitLiteralType(node); - case 178 /* ImportType */: + case 179 /* ImportType */: return emitImportTypeNode(node); - case 278 /* JSDocAllType */: + case 279 /* JSDocAllType */: write("*"); return; - case 279 /* JSDocUnknownType */: + case 280 /* JSDocUnknownType */: write("?"); return; - case 280 /* JSDocNullableType */: + case 281 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 281 /* JSDocNonNullableType */: + case 282 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 282 /* JSDocOptionalType */: + case 283 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: return emitJSDocVariadicType(node); // Binding patterns - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return emitBindingElement(node); // Misc - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return emitTemplateSpan(node); - case 211 /* SemicolonClassElement */: + case 212 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 212 /* Block */: + case 213 /* Block */: return emitBlock(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return emitVariableStatement(node); - case 214 /* EmptyStatement */: + case 215 /* EmptyStatement */: return emitEmptyStatement(); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return emitExpressionStatement(node); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return emitIfStatement(node); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return emitDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return emitWhileStatement(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return emitForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return emitForInStatement(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return emitForOfStatement(node); - case 222 /* ContinueStatement */: + case 223 /* ContinueStatement */: return emitContinueStatement(node); - case 223 /* BreakStatement */: + case 224 /* BreakStatement */: return emitBreakStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return emitReturnStatement(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return emitWithStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return emitSwitchStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return emitLabeledStatement(node); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return emitThrowStatement(node); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return emitTryStatement(node); - case 230 /* DebuggerStatement */: + case 231 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return emitClassDeclaration(node); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return emitModuleBlock(node); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return emitCaseBlock(node); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return emitImportDeclaration(node); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return emitImportClause(node); - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return emitNamespaceImport(node); - case 246 /* NamedImports */: + case 247 /* NamedImports */: return emitNamedImports(node); - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: return emitImportSpecifier(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return emitExportAssignment(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return emitExportDeclaration(node); - case 250 /* NamedExports */: + case 251 /* NamedExports */: return emitNamedExports(node); - case 251 /* ExportSpecifier */: + case 252 /* ExportSpecifier */: return emitExportSpecifier(node); - case 252 /* MissingDeclaration */: + case 253 /* MissingDeclaration */: return; // Module references - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 256 /* JsxOpeningElement */: - case 259 /* JsxOpeningFragment */: + case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 257 /* JsxClosingElement */: - case 260 /* JsxClosingFragment */: + case 258 /* JsxClosingElement */: + case 261 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return emitJsxAttribute(node); - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return emitJsxAttributes(node); - case 263 /* JsxSpreadAttribute */: + case 264 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 265 /* CaseClause */: + case 266 /* CaseClause */: return emitCaseClause(node); - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: return emitDefaultClause(node); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: return emitHeritageClause(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 272 /* EnumMember */: + case 273 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (ignored) // Transformation nodes (ignored) @@ -75016,71 +75337,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return emitCallExpression(node); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return emitNewExpression(node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return emitFunctionExpression(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return emitArrowFunction(node); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return emitDeleteExpression(node); - case 194 /* TypeOfExpression */: + case 195 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return emitVoidExpression(node); - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return emitAwaitExpression(node); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return emitBinaryExpression(node); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return emitConditionalExpression(node); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return emitTemplateExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return emitYieldExpression(node); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return emitSpreadExpression(node); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return emitClassExpression(node); - case 205 /* OmittedExpression */: + case 206 /* OmittedExpression */: return; - case 207 /* AsExpression */: + case 208 /* AsExpression */: return emitAsExpression(node); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: return emitNonNullExpression(node); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 254 /* JsxElement */: + case 255 /* JsxElement */: return emitJsxElement(node); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: return emitCommaList(node); } } @@ -75097,7 +75418,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 274 /* Bundle */ ? node : undefined; + var bundle = node.kind === 275 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -75223,7 +75544,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 283 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 284 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -75285,7 +75606,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 155 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 156 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -75542,7 +75863,7 @@ var ts; increaseIndent(); } var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ ? 32 /* AllowTrailingComma */ : 0 /* None */; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 32 /* AllowTrailingComma */ : 0 /* None */; emitList(node, node.properties, 263122 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); @@ -75682,7 +76003,7 @@ 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 === 197 /* PrefixUnaryExpression */ + return operand.kind === 198 /* PrefixUnaryExpression */ && ((node.operator === 37 /* PlusToken */ && (operand.operator === 37 /* PlusToken */ || operand.operator === 43 /* PlusPlusToken */)) || (node.operator === 38 /* MinusToken */ && (operand.operator === 38 /* MinusToken */ || operand.operator === 44 /* MinusMinusToken */))); } @@ -75802,7 +76123,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 216 /* IfStatement */) { + if (node.elseStatement.kind === 217 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -75865,7 +76186,7 @@ var ts; emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(144 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(145 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -75873,7 +76194,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 232 /* VariableDeclarationList */) { + if (node.kind === 233 /* VariableDeclarationList */) { emit(node); } else { @@ -75988,7 +76309,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); + emitIdentifierName(node.name); // TODO: GH#18217 emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -76168,7 +76489,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 238 /* ModuleDeclaration */) { + while (body.kind === 239 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -76213,7 +76534,7 @@ var ts; if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(142 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(143 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -76265,7 +76586,7 @@ var ts; if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(142 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(143 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -76357,7 +76678,7 @@ var ts; } function emitJsxAttribute(node) { emit(node.name); - emitNodeWithPrefix("=", writePunctuation, node.initializer, emit); + emitNodeWithPrefix("=", writePunctuation, node.initializer, emit); // TODO: GH#18217 } function emitJsxSpreadAttribute(node) { writePunctuation("{..."); @@ -76491,7 +76812,7 @@ var ts; emitSourceFileWorker(node); } function emitSyntheticTripleSlashReferencesIfNeeded(node) { - emitTripleSlashDirectives(node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || []); + emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || []); } function emitTripleSlashDirectivesIfNeeded(node) { if (node.isDeclarationFile) @@ -76719,7 +77040,7 @@ var ts; emitNodeList(emit, parentNode, children, format, start, count); } function emitExpressionList(parentNode, children, format, start, count) { - emitNodeList(emitExpression, parentNode, children, format, start, count); + emitNodeList(emitExpression, parentNode, children, format, start, count); // TODO: GH#18217 } function writeDelimiter(format) { switch (format & 28 /* DelimitersMask */) { @@ -76745,7 +77066,7 @@ var ts; if (isUndefined && format & 8192 /* OptionalIfUndefined */) { return; } - var isEmpty = isUndefined || start >= children.length || count === 0; + var isEmpty = children === undefined || start >= children.length || count === 0; if (isEmpty && format & 16384 /* OptionalIfEmpty */) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); @@ -76758,6 +77079,7 @@ var ts; if (format & 7680 /* BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && !isUndefined) { + // TODO: GH#18217 emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists } } @@ -76777,7 +77099,7 @@ var ts; // Write the opening line terminator or leading whitespace. var mayEmitInterveningComments = (format & 131072 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; - if (shouldWriteLeadingLineTerminator(parentNode, children, format)) { + if (shouldWriteLeadingLineTerminator(parentNode, children, format)) { // TODO: GH#18217 writeLine(); shouldEmitInterveningComments = false; } @@ -76790,7 +77112,7 @@ var ts; } // Emit each child. var previousSibling = void 0; - var shouldDecreaseIndentAfterEmit = void 0; + var shouldDecreaseIndentAfterEmit = false; for (var i = 0; i < count; i++) { var child = children[start + i]; // Write the delimiter if this is not the first node. @@ -76868,6 +77190,7 @@ var ts; } if (format & 7680 /* BracketsMask */) { if (isEmpty && !isUndefined) { + // TODO: GH#18217 emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } writePunctuation(getClosingBracket(format)); @@ -77091,7 +77414,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 190 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 191 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -77156,81 +77479,81 @@ var ts; if (!node) return; switch (node.kind) { - case 212 /* Block */: + case 213 /* Block */: ts.forEach(node.statements, generateNames); break; - case 227 /* LabeledStatement */: - case 225 /* WithStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 228 /* LabeledStatement */: + case 226 /* WithStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: generateNames(node.statement); break; - case 216 /* IfStatement */: + case 217 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 219 /* ForStatement */: - case 221 /* ForOfStatement */: - case 220 /* ForInStatement */: + case 220 /* ForStatement */: + case 222 /* ForOfStatement */: + case 221 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 229 /* TryStatement */: + case 230 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 268 /* CatchClause */: + case 269 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: generateNames(node.declarationList); break; - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: - case 181 /* BindingElement */: - case 234 /* ClassDeclaration */: + case 232 /* VariableDeclaration */: + case 149 /* Parameter */: + case 182 /* BindingElement */: + case 235 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: generateNames(node.importClause); break; - case 244 /* ImportClause */: + case 245 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 246 /* NamedImports */: + case 247 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -77239,12 +77562,12 @@ var ts; if (!node) return; switch (node.kind) { - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -77396,7 +77719,7 @@ var ts; * Generates a unique name for an ImportDeclaration or ExportDeclaration. */ function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); + var expr = ts.getExternalModuleName(node); // TODO: GH#18217 var baseName = ts.isStringLiteral(expr) ? ts.makeIdentifierFromModuleName(expr.text) : "module"; return makeUniqueName(baseName); @@ -77426,21 +77749,21 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - case 248 /* ExportAssignment */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 249 /* ExportAssignment */: return generateNameForExportDefault(); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return generateNameForClassExpression(); - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); @@ -77458,7 +77781,7 @@ var ts; case 3 /* Unique */: return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* Optimistic */), !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); } - ts.Debug.fail("Unsupported GeneratedIdentifierKind."); + return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } /** * Gets the node from which a name should be generated. @@ -77921,8 +78244,8 @@ var ts; if (!outputFingerprints) { outputFingerprints = ts.createMap(); } - var hash = ts.sys.createHash(data); - var mtimeBefore = ts.sys.getModifiedTime(fileName); + var hash = ts.sys.createHash(data); // TODO: GH#18217 + var mtimeBefore = ts.sys.getModifiedTime(fileName); // TODO: GH#18217 if (mtimeBefore) { var fingerprint = outputFingerprints.get(fileName); // If output has not been changed, and the file has no external modification @@ -77934,7 +78257,7 @@ var ts; } } ts.sys.writeFile(fileName, data, writeByteOrderMark); - var mtimeAfter = ts.sys.getModifiedTime(fileName); + var mtimeAfter = ts.sys.getModifiedTime(fileName); // TODO: GH#18217 outputFingerprints.set(fileName, { hash: hash, byteOrderMark: writeByteOrderMark, @@ -78005,7 +78328,7 @@ var ts; function formatDiagnostic(diagnostic, host) { var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); if (diagnostic.file) { - var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; + var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; // TODO: GH#18217 var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; @@ -78052,7 +78375,7 @@ var ts; var context_2 = ""; if (diagnostic.file) { var start = diagnostic.start, length_4 = diagnostic.length, file_9 = diagnostic.file; - var _a = ts.getLineAndCharacterOfPosition(file_9, start), firstLine = _a.line, firstLineChar = _a.character; + var _a = ts.getLineAndCharacterOfPosition(file_9, start), firstLine = _a.line, firstLineChar = _a.character; // TODO: GH#18217 var _b = ts.getLineAndCharacterOfPosition(file_9, start + length_4), lastLine = _b.line, lastLineChar = _b.character; var lastLineInFile = ts.getLineAndCharacterOfPosition(file_9, file_9.text.length).line; var relativeFileName = host ? ts.convertToRelativePath(file_9.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file_9.fileName; @@ -78196,8 +78519,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? - configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -78228,9 +78550,9 @@ var ts; }; } function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) { - var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; + var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; - var host = createProgramOptions.host, oldProgram = createProgramOptions.oldProgram; + var oldProgram = createProgramOptions.oldProgram; var program; var files = []; var commonSourceDirectory; @@ -78257,7 +78579,7 @@ var ts; // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. var sourceFilesFoundSearchingNodeModules = ts.createMap(); ts.performance.mark("beforeProgram"); - host = host || createCompilerHost(options); + var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHost(host); var skipDefaultLib = options.noLib; var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); }); @@ -78285,7 +78607,7 @@ var ts; } else { moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; // TODO: GH#18217 resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -78293,7 +78615,7 @@ var ts; resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile); }; } else { - var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; + var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; // TODO: GH#18217 resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, loader_2); }; } // Map from a stringified PackageId to the source file with that id. @@ -78384,6 +78706,7 @@ var ts; getOptionsDiagnostics: getOptionsDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getSemanticDiagnostics: getSemanticDiagnostics, + getSuggestionDiagnostics: getSuggestionDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, getTypeChecker: getTypeChecker, getClassifiableNames: getClassifiableNames, @@ -78427,7 +78750,7 @@ var ts; } else if (options.composite) { // Project compilations never infer their root from the input source paths - commonSourceDirectory = ts.getDirectoryPath(ts.normalizeSlashes(options.configFilePath)); + commonSourceDirectory = ts.getDirectoryPath(ts.normalizeSlashes(options.configFilePath)); // TODO: GH#18217 checkSourceFilesBelongToPath(emittedFiles, commonSourceDirectory); } else { @@ -78548,7 +78871,7 @@ var ts; // `result[i]` is either a `ResolvedModuleFull` or a marker. // If it is the former, we can leave it as is. if (result[i] === predictedToResolveToAmbientModuleMarker) { - result[i] = undefined; + result[i] = undefined; // TODO: GH#18217 } } else { @@ -78561,7 +78884,7 @@ var ts; // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) { - var resolutionToFile = ts.getResolvedModule(oldProgramState.oldSourceFile, moduleName); + var resolutionToFile = ts.getResolvedModule(oldProgramState.oldSourceFile, moduleName); // TODO: GH#18217 var resolvedFile = resolutionToFile && oldProgramState.program && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) { // In the old program, we resolved to an ambient module that was in the same @@ -78657,7 +78980,7 @@ var ts; var oldSourceFile = oldSourceFiles_2[_i]; var newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.path, options.target, /*onError*/ undefined, shouldCreateNewSourceFile) - : host.getSourceFile(oldSourceFile.fileName, options.target, /*onError*/ undefined, shouldCreateNewSourceFile); + : host.getSourceFile(oldSourceFile.fileName, options.target, /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 if (!newSourceFile) { return oldProgram.structureIsReused = 0 /* Not */; } @@ -78843,7 +79166,7 @@ var ts; return nodes; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules.get(file.path); + return !!sourceFilesFoundSearchingNodeModules.get(file.path); } function isSourceFileDefaultLibrary(file) { if (file.hasNoDefaultLib) { @@ -78859,7 +79182,7 @@ var ts; return equalityComparer(file.fileName, getDefaultLibraryFileName()); } else { - return ts.forEach(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); }); + return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); }); } } function getDiagnosticsProducingTypeChecker() { @@ -78912,7 +79235,8 @@ var ts; var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(options, customTransformers); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, // TODO: GH#18217 + emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -79003,11 +79327,24 @@ var ts; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); - if (isCheckJs) { - diagnostics = ts.concatenate(diagnostics, sourceFile.jsDocDiagnostics); + var diagnostics; + for (var _i = 0, _a = [bindDiagnostics, checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile, isCheckJs ? sourceFile.jsDocDiagnostics : undefined]; _i < _a.length; _i++) { + var diags = _a[_i]; + if (diags) { + for (var _b = 0, diags_1 = diags; _b < diags_1.length; _b++) { + var diag = diags_1[_b]; + if (shouldReportDiagnostic(diag)) { + diagnostics = ts.append(diagnostics, diag); + } + } + } } - return ts.filter(diagnostics, shouldReportDiagnostic); + return diagnostics; + }); + } + function getSuggestionDiagnostics(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken); }); } /** @@ -79017,7 +79354,7 @@ var ts; var file = diagnostic.file, start = diagnostic.start; if (file) { var lineStarts = ts.getLineStarts(file); - var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line; + var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line; // TODO: GH#18217 while (line > 0) { var previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]); var result = ignoreDiagnosticCommentRegEx.exec(previousLineText); @@ -79044,22 +79381,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 148 /* Parameter */: - case 151 /* PropertyDeclaration */: + case 149 /* Parameter */: + case 152 /* PropertyDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: - case 231 /* VariableDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: + case 232 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -79067,41 +79404,41 @@ var ts; } } switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 108 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 207 /* AsExpression */: + case 208 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -79114,28 +79451,28 @@ 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_to_remove_this_warning)); } switch (parent.kind) { - case 234 /* ClassDeclaration */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: + case 235 /* ClassDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 213 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 214 /* VariableStatement */); } break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -79147,18 +79484,18 @@ var ts; return; } break; - case 148 /* Parameter */: + case 149 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 206 /* ExpressionWithTypeArguments */: - case 255 /* JsxSelfClosingElement */: - case 256 /* JsxOpeningElement */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 207 /* ExpressionWithTypeArguments */: + case 256 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -79224,7 +79561,7 @@ var ts; if (cachedResult) { return cachedResult; } - var result = getDiagnostics(sourceFile, cancellationToken) || ts.emptyArray; + var result = getDiagnostics(sourceFile, cancellationToken) || ts.emptyArray; // TODO: GH#18217 if (sourceFile) { if (!cache.perFile) { cache.perFile = ts.createMap(); @@ -79404,7 +79741,8 @@ var ts; } /** This has side effects through `findSourceFile`. */ function processSourceFile(fileName, isDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId); }, function (diagnostic) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; @@ -79496,7 +79834,7 @@ var ts; if (fileFromPackageId) { // Some other SourceFile already exists with this package name and version. // Instead of creating a duplicate, just redirect to the existing one. - var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path); + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path); // TODO: GH#18217 redirectTargetsSet.set(fileFromPackageId.path, true); filesByName.set(path, dupFile); sourceFileToPackageName.set(path, packageId.name); @@ -79591,7 +79929,7 @@ var ts; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -79601,7 +79939,8 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 + ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -79614,7 +79953,7 @@ var ts; } } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); + fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -79718,7 +80057,7 @@ var ts; } function parseProjectReferenceConfigFile(ref) { // The actual filename (i.e. add "/tsconfig.json" if necessary) - var refPath = resolveProjectReferencePath(host, ref); + var refPath = resolveProjectReferencePath(host, ref); // TODO: GH#18217 // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); var sourceFile = host.getSourceFile(refPath, 100 /* JSON */); @@ -79729,13 +80068,13 @@ var ts; return { commandLine: commandLine, sourceFile: sourceFile }; } function addProjectReferenceRedirects(referencedProject, target) { - var rootDir = ts.normalizePath(referencedProject.options.rootDir || ts.getDirectoryPath(referencedProject.options.configFilePath)); + var rootDir = ts.normalizePath(referencedProject.options.rootDir || ts.getDirectoryPath(referencedProject.options.configFilePath)); // TODO: GH#18217 target.set(rootDir, getDeclarationOutputDirectory(referencedProject)); } function getDeclarationOutputDirectory(proj) { return proj.options.declarationDir || proj.options.outDir || - ts.getDirectoryPath(proj.options.configFilePath); + ts.getDirectoryPath(proj.options.configFilePath); // TODO: GH#18217 } function verifyCompilerOptions() { if (options.strictPropertyInitialization && !options.strictNullChecks) { @@ -79990,9 +80329,9 @@ var ts; if (ts.isObjectLiteralExpression(pathProp.initializer)) { for (var _a = 0, _b = ts.getPropertyAssignment(pathProp.initializer, key); _a < _b.length; _a++) { var keyProps = _b[_a]; - if (ts.isArrayLiteralExpression(keyProps.initializer) && - keyProps.initializer.elements.length > valueIndex) { - programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, keyProps.initializer.elements[valueIndex], message, arg0, arg1, arg2)); + var initializer = keyProps.initializer; + if (ts.isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) { + programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, arg0, arg1, arg2)); needCompilerDiagnostic = false; } } @@ -80053,7 +80392,7 @@ var ts; if (_referencesArrayLiteralSyntax === undefined) { _referencesArrayLiteralSyntax = null; // tslint:disable-line:no-null-keyword if (options.configFile) { - var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); + var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); // TODO: GH#18217 for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "references"); _i < _a.length; _i++) { var prop = _a[_i]; if (ts.isArrayLiteralExpression(prop.initializer)) { @@ -80095,6 +80434,7 @@ var ts; return false; } programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, arrayLiteral.elements[index], message, arg0, arg1, arg2)); + return false; // TODO: GH#18217 This function always returns `false`!` } function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(toPath(emitFileName), true); @@ -80114,6 +80454,10 @@ var ts; if (out) { return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Dts */); } + // If declarationDir is specified, return if its a file in that directory + if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { + return true; + } // If --outDir, check if file is in that directory if (options.outDir) { return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); @@ -80121,8 +80465,8 @@ var ts; if (ts.fileExtensionIsOneOf(filePath, ts.supportedJavascriptExtensions) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) { // Otherwise just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath(ts.combinePaths(filePathWithoutExtension, ".ts" /* Ts */)) || - !!getSourceFileByPath(ts.combinePaths(filePathWithoutExtension, ".tsx" /* Tsx */)); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Tsx */)); } return false; } @@ -80247,7 +80591,7 @@ var ts; if (!resolvedTypeReferenceDirective) { return; } - var fileName = resolvedTypeReferenceDirective.resolvedFileName; + var fileName = resolvedTypeReferenceDirective.resolvedFileName; // TODO: GH#18217 var typeFilePath = ts.toPath(fileName, sourceFileDirectory, getCanonicalFileName); addReferencedFile(typeFilePath); }); @@ -80279,7 +80623,7 @@ var ts; for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var version_1 = sourceFile.version; - var oldInfo = useOldState && oldState.fileInfos.get(sourceFile.path); + var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.path) : undefined; if (referencedMap) { var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName); if (newReferences) { @@ -80342,7 +80686,8 @@ var ts; return false; } var info = state.fileInfos.get(sourceFile.path); - ts.Debug.assert(!!info); + if (!info) + return ts.Debug.fail(); var prevSignature = info.signature; var latestSignature; if (sourceFile.isDeclarationFile) { @@ -80354,7 +80699,7 @@ var ts; latestSignature = computeHash(emitOutput.outputFiles[0].text); } else { - latestSignature = prevSignature; + latestSignature = prevSignature; // TODO: GH#18217 } } cacheToUpdateSignature.set(sourceFile.path, latestSignature); @@ -80489,8 +80834,9 @@ var ts; if (!seenFileNamesMap.has(currentPath)) { var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath); seenFileNamesMap.set(currentPath, currentSourceFile); - if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash)) { - queue.push.apply(queue, getReferencedByPaths(state, currentPath)); + if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash)) { // TODO: GH#18217 + queue.push.apply(// TODO: GH#18217 + queue, getReferencedByPaths(state, currentPath)); } } } @@ -80505,7 +80851,7 @@ var ts; (function (ts) { function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps - return map1 === map2 || map1 && map2 && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); + return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); } /** * Create the state so that we can iterate on changedFiles/affected files @@ -80533,7 +80879,7 @@ var ts; } // Update changed files and copy semantic diagnostics if we can var referencedMap = state.referencedMap; - var oldReferencedMap = useOldState && oldState.referencedMap; + var oldReferencedMap = useOldState ? oldState.referencedMap : undefined; state.fileInfos.forEach(function (info, sourceFilePath) { var oldInfo; var newReferences; @@ -80577,7 +80923,7 @@ var ts; var affectedFiles = state.affectedFiles; if (affectedFiles) { var seenAffectedFiles = state.seenAffectedFiles, semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile; - var affectedFilesIndex = state.affectedFilesIndex; + var affectedFilesIndex = state.affectedFilesIndex; // TODO: GH#18217 while (affectedFilesIndex < affectedFiles.length) { var affectedFile = affectedFiles[affectedFilesIndex]; if (!seenAffectedFiles.has(affectedFile.path)) { @@ -80690,7 +81036,7 @@ var ts; // Return same program if underlying program doesnt change var oldState = oldProgram && oldProgram.getState(); if (oldState && newProgram === oldState.program && configFileParsingDiagnostics === newProgram.getConfigFileParsingDiagnostics()) { - newProgram = undefined; + newProgram = undefined; // TODO: GH#18217 oldState = undefined; return oldProgram; } @@ -80704,7 +81050,7 @@ var ts; var computeHash = host.createHash || ts.identity; var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); // To ensure that we arent storing any references to old program or new program without state - newProgram = undefined; + newProgram = undefined; // TODO: GH#18217 oldProgram = undefined; oldState = undefined; var result = { @@ -80765,7 +81111,7 @@ var ts; if (!targetSourceFile) { // Emit and report any errors we ran into. var sourceMaps = []; - var emitSkipped = void 0; + var emitSkipped = false; var diagnostics = void 0; var emittedFiles = []; var affectedEmitResult = void 0; @@ -80885,7 +81231,7 @@ var ts; var filesWithInvalidatedResolutions; var filesWithInvalidatedNonRelativeUnresolvedImports; var allFilesHaveInvalidatedResolution = false; - var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); + 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. // The key in the map is source file's path. @@ -80906,7 +81252,7 @@ var ts; var customFailedLookupPaths = ts.createMap(); var directoryWatchesOfFailedLookups = ts.createMap(); var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory())); - var rootPath = rootDir && resolutionHost.toPath(rootDir); + var rootPath = (rootDir && resolutionHost.toPath(rootDir)); // TODO: GH#18217 // TypeRoot watches for the types that get added as part of getAutomaticTypeDirectiveNames var typeRootsWatches = ts.createMap(); return { @@ -80964,7 +81310,7 @@ var ts; } // Invalidated if file has unresolved imports var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path); - return value && !!value.length; + return !!value && !!value.length; } function createHasInvalidatedResolution(forceAllFilesAsInvalidated) { if (allFilesHaveInvalidatedResolution || forceAllFilesAsInvalidated) { @@ -80974,7 +81320,7 @@ var ts; } var collected = filesWithInvalidatedResolutions; filesWithInvalidatedResolutions = undefined; - return function (path) { return (collected && collected.has(path)) || + return function (path) { return (!!collected && collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } function clearPerDirectoryResolutions() { @@ -81055,7 +81401,7 @@ var ts; } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); - resolvedModules.push(getResolutionWithResolvedFileName(resolution)); + resolvedModules.push(getResolutionWithResolvedFileName(resolution)); // TODO: GH#18217 } // Stop watching and remove the unused name resolutionsInFile.forEach(function (resolution, name) { @@ -81126,7 +81472,7 @@ var ts; } function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) { if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { - return { dir: rootDir, dirPath: rootPath }; + return { dir: rootDir, dirPath: rootPath }; // TODO: GH#18217 } return getDirectoryToWatchFromFailedLookupLocationDirectory(ts.getDirectoryPath(ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())), ts.getDirectoryPath(failedLookupLocationPath)); } @@ -81141,19 +81487,20 @@ var ts; return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath }, ts.getDirectoryPath(dirPath)); } // Use some ancestor of the root directory - var subDirectory; + var subDirectoryPath, subDirectory; if (rootPath !== undefined) { while (!isInDirectoryPath(dirPath, rootPath)) { var parentPath = ts.getDirectoryPath(dirPath); if (parentPath === dirPath) { break; } - subDirectory = dirPath.slice(parentPath.length + ts.directorySeparator.length); + subDirectoryPath = dirPath; + subDirectory = dir; dirPath = parentPath; dir = ts.getDirectoryPath(dir); } } - return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath, subDirectory: subDirectory }, dirPath); + return filterFSRootDirectoriesToWatch({ dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath }, dirPath); } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -81173,7 +81520,7 @@ var ts; for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) { var failedLookupLocation = failedLookupLocations_1[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, ignore = _a.ignore, subDirectory = _a.subDirectory; + var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, ignore = _a.ignore; if (!ignore) { // If the failed lookup location path is not one of the supported extensions, // store it in the custom path @@ -81185,27 +81532,21 @@ var ts; setAtRoot = true; } else { - setDirectoryWatcher(dir, dirPath, subDirectory); + setDirectoryWatcher(dir, dirPath); } } } if (setAtRoot) { - setDirectoryWatcher(rootDir, rootPath); + setDirectoryWatcher(rootDir, rootPath); // TODO: GH#18217 } } - function setDirectoryWatcher(dir, dirPath, subDirectory) { + function setDirectoryWatcher(dir, dirPath) { var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); if (dirWatcher) { dirWatcher.refCount++; } else { - dirWatcher = { watcher: createDirectoryWatcher(dir, dirPath), refCount: 1 }; - directoryWatchesOfFailedLookups.set(dirPath, dirWatcher); - } - if (subDirectory) { - var subDirectoryMap = dirWatcher.subDirectoryMap || (dirWatcher.subDirectoryMap = ts.createMap()); - var existing = subDirectoryMap.get(subDirectory) || 0; - subDirectoryMap.set(subDirectory, existing + 1); + directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath), refCount: 1 }); } } function stopWatchFailedLookupLocationOfResolution(resolution) { @@ -81221,7 +81562,7 @@ var ts; for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) { var failedLookupLocation = failedLookupLocations_2[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore, subDirectory = _a.subDirectory; + var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore; if (!ignore) { var refCount = customFailedLookupPaths.get(failedLookupLocationPath); if (refCount) { @@ -81237,7 +81578,7 @@ var ts; removeAtRoot = true; } else { - removeDirectoryWatcher(dirPath, subDirectory); + removeDirectoryWatcher(dirPath); } } } @@ -81245,29 +81586,11 @@ var ts; removeDirectoryWatcher(rootPath); } } - function removeDirectoryWatcher(dirPath, subDirectory) { + function removeDirectoryWatcher(dirPath) { var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); - if (subDirectory) { - var existing = dirWatcher.subDirectoryMap.get(subDirectory); - if (existing === 1) { - dirWatcher.subDirectoryMap.delete(subDirectory); - } - else { - dirWatcher.subDirectoryMap.set(subDirectory, existing - 1); - } - } // Do not close the watcher yet since it might be needed by other failed lookup locations. dirWatcher.refCount--; } - function inWatchedSubdirectory(dirPath, fileOrDirectoryPath) { - var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); - if (!dirWatcher || !dirWatcher.subDirectoryMap) - return false; - return ts.forEachKey(dirWatcher.subDirectoryMap, function (subDirectory) { - var fullSubDirectory = dirPath + "/" + subDirectory; - return fullSubDirectory === fileOrDirectoryPath || isInDirectoryPath(fullSubDirectory, fileOrDirectoryPath); - }); - } function createDirectoryWatcher(directory, dirPath) { return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) { var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory); @@ -81275,13 +81598,8 @@ var ts; // Since the file existence changed, update the sourceFiles cache cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } - // If the files are added to project root or node_modules directory, always run through the invalidation process - // Otherwise run through invalidation only if adding to the immediate directory - if (!allFilesHaveInvalidatedResolution && - (dirPath === rootPath || isNodeModulesDirectory(dirPath) || ts.getDirectoryPath(fileOrDirectoryPath) === dirPath || inWatchedSubdirectory(dirPath, fileOrDirectoryPath))) { - if (invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) { - resolutionHost.onInvalidatedResolution(); - } + if (!allFilesHaveInvalidatedResolution && invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) { + resolutionHost.onInvalidatedResolution(); } }, 1 /* Recursive */); } @@ -81339,7 +81657,7 @@ var ts; // Resolution is invalidated if the resulting file name is same as the deleted file path function (resolution, getResolutionWithResolvedFileName) { var result = getResolutionWithResolvedFileName(resolution); - return result && resolutionHost.toPath(result.resolvedFileName) === filePath; + return !!result && resolutionHost.toPath(result.resolvedFileName) === filePath; // TODO: GH#18217 }); } function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) { @@ -81395,7 +81713,7 @@ var ts; return rootPath; } var _a = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath), dirPath = _a.dirPath, ignore = _a.ignore; - return !ignore && directoryWatchesOfFailedLookups.has(dirPath) && dirPath; + return !ignore && directoryWatchesOfFailedLookups.has(dirPath) ? dirPath : undefined; } function createTypeRootsWatch(typeRootPath, typeRoot) { // Create new watch and recursive info @@ -81462,7 +81780,7 @@ var ts; getCurrentDirectory: function () { return ts.sys.getCurrentDirectory(); }, getNewLine: function () { return ts.sys.newLine; }, getCanonicalFileName: ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames) - } : undefined; + } : undefined; // TODO: GH#18217 /** * Create a function that reports error by writing to the system and handles the formating of the diagnostic */ @@ -81479,7 +81797,7 @@ var ts; return function (diagnostic) { diagnostics[0] = diagnostic; system.write(ts.formatDiagnosticsWithColorAndContext(diagnostics, host) + host.getNewLine()); - diagnostics[0] = undefined; + diagnostics[0] = undefined; // TODO: GH#18217 }; } ts.createDiagnosticReporter = createDiagnosticReporter; @@ -81539,7 +81857,7 @@ var ts; var host = system; host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(ts.sys, reportDiagnostic, diagnostic); }; var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host); - host.onUnRecoverableConfigFileDiagnostic = undefined; + host.onUnRecoverableConfigFileDiagnostic = undefined; // TODO: GH#18217 return result; } ts.parseConfigFileWithSystem = parseConfigFileWithSystem; @@ -81669,9 +81987,9 @@ var ts; * Creates the watch compiler host from system for config file in watch mode */ function createWatchCompilerHostOfConfigFile(configFileName, optionsToExtend, system, createProgram, reportDiagnostic, reportWatchStatus) { - reportDiagnostic = reportDiagnostic || createDiagnosticReporter(system); - var host = createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus); - host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; + var diagnosticReporter = reportDiagnostic || createDiagnosticReporter(system); + var host = createWatchCompilerHost(system, createProgram, diagnosticReporter, reportWatchStatus); + host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, diagnosticReporter, diagnostic); }; host.configFileName = configFileName; host.optionsToExtend = optionsToExtend; return host; @@ -81691,7 +82009,7 @@ var ts; (function (ts) { function createWatchCompilerHost(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus) { if (ts.isArray(rootFilesOrConfigFileName)) { - return ts.createWatchCompilerHostOfFilesAndCompilerOptions(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus); + return ts.createWatchCompilerHostOfFilesAndCompilerOptions(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus); // TODO: GH#18217 } else { return ts.createWatchCompilerHostOfConfigFile(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus); @@ -81718,7 +82036,7 @@ var ts; var configFileSpecs; var configFileParsingDiagnostics; var hasChangedConfigFileParsingErrors = false; - var cachedDirectoryStructureHost = configFileName && ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames); + var cachedDirectoryStructureHost = configFileName === undefined ? undefined : ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames); if (cachedDirectoryStructureHost && host.onCachedDirectoryStructureHostCreate) { host.onCachedDirectoryStructureHostCreate(cachedDirectoryStructureHost); } @@ -81748,7 +82066,7 @@ var ts; var trace = host.trace && (function (s) { host.trace(s + newLine); }); var watchLogLevel = trace ? compilerOptions.extendedDiagnostics ? ts.WatchLogLevel.Verbose : compilerOptions.diagnostis ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; - var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? trace : ts.noop; + var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? trace : ts.noop; // TODO: GH#18217 var _b = ts.getWatchFactory(watchLogLevel, writeLog), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); @@ -81770,7 +82088,7 @@ var ts; readFile: readFile, trace: trace, directoryExists: directoryStructureHost.directoryExists && (function (path) { return directoryStructureHost.directoryExists(path); }), - getDirectories: directoryStructureHost.getDirectories && (function (path) { return directoryStructureHost.getDirectories(path); }), + getDirectories: (directoryStructureHost.getDirectories && (function (path) { return directoryStructureHost.getDirectories(path); })), realpath: host.realpath && (function (s) { return host.realpath(s); }), getEnvironmentVariable: host.getEnvironmentVariable ? (function (name) { return host.getEnvironmentVariable(name); }) : (function () { return ""; }), onReleaseOldSourceFile: onReleaseOldSourceFile, @@ -82059,12 +82377,12 @@ var ts; watchConfigFileWildCardDirectories(); } function parseConfigFile() { - setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost)); + setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost)); // TODO: GH#18217 } function setConfigFileParsingResult(configFileParseResult) { rootFileNames = configFileParseResult.fileNames; compilerOptions = configFileParseResult.options; - configFileSpecs = configFileParseResult.configFileSpecs; + configFileSpecs = configFileParseResult.configFileSpecs; // TODO: GH#18217 configFileParsingDiagnostics = ts.getConfigFileParsingDiagnostics(configFileParseResult); hasChangedConfigFileParsingErrors = true; } @@ -82303,6 +82621,7 @@ var ts; "es2018.promise": "lib.es2018.promise.d.ts", "es2018.regexp": "lib.es2018.regexp.d.ts", "esnext.array": "lib.esnext.array.d.ts", + "esnext.symbol": "lib.esnext.symbol.d.ts", "esnext.asynciterable": "lib.esnext.asynciterable.d.ts", }), }, @@ -82948,7 +83267,7 @@ var ts; case "string": return ts.map(values, function (v) { return v || ""; }); default: - return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + return ts.mapDefined(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }); } } ts.parseListTypeOption = parseListTypeOption; @@ -83061,6 +83380,7 @@ var ts; } } ts.parseCommandLine = parseCommandLine; + /** @internal */ function getOptionFromName(optionName, allowShort) { if (allowShort === void 0) { allowShort = false; } optionName = optionName.toLowerCase(); @@ -83074,6 +83394,7 @@ var ts; } return optionNameMap.get(optionName); } + ts.getOptionFromName = getOptionFromName; /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ @@ -83233,7 +83554,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 269 /* PropertyAssignment */) { + if (element.kind !== 270 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -83310,13 +83631,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: if (valueExpression.operator !== 38 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -83333,7 +83654,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -83371,6 +83692,7 @@ var ts; var expectedType = ts.isString(option.type) ? option.type : "string"; return typeof value === expectedType; } + return false; } /** * Generate tsconfig configuration when running command line "--init" @@ -83423,7 +83745,7 @@ var ts; } else { if (optionDefinition.type === "list") { - result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); + result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); // TODO: GH#18217 } else { // There is a typeMap associated with this command-line option so use it to map value back to its name @@ -83850,13 +84172,10 @@ var ts; } function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { - return undefined; + return false; } var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption.compileOnSave, basePath, errors); - if (typeof result === "boolean" && result) { - return result; - } - return false; + return typeof result === "boolean" && result; } function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var errors = []; @@ -83885,7 +84204,7 @@ var ts; return options; } function getDefaultTypeAcquisition(configFileName) { - return { enable: configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; + return { enable: !!configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; } function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) { var options = getDefaultTypeAcquisition(configFileName); @@ -84282,7 +84601,7 @@ var ts; if (optionEnumValue === value) { return optionStringValue; } - }); + }); // TODO: GH#18217 } } })(ts || (ts = {})); @@ -84550,36 +84869,36 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 148 /* Parameter */: - case 231 /* VariableDeclaration */: - case 181 /* BindingElement */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 268 /* CatchClause */: - case 261 /* JsxAttribute */: + case 149 /* Parameter */: + case 232 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 269 /* CatchClause */: + case 262 /* JsxAttribute */: return 1 /* Value */; - case 147 /* TypeParameter */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 165 /* TypeLiteral */: + case 148 /* TypeParameter */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 166 /* TypeLiteral */: return 2 /* Type */; - case 296 /* JSDocTypedefTag */: + case 297 /* 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 272 /* EnumMember */: - case 234 /* ClassDeclaration */: + case 273 /* EnumMember */: + case 235 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -84589,26 +84908,26 @@ var ts; else { return 4 /* Namespace */; } - case 237 /* EnumDeclaration */: - case 246 /* NamedImports */: - case 247 /* ImportSpecifier */: - case 242 /* ImportEqualsDeclaration */: - case 243 /* ImportDeclaration */: - case 248 /* ExportAssignment */: - case 249 /* ExportDeclaration */: + case 238 /* EnumDeclaration */: + case 247 /* NamedImports */: + case 248 /* ImportSpecifier */: + case 243 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: + case 249 /* ExportAssignment */: + case 250 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 273 /* SourceFile */: + case 274 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 248 /* ExportAssignment */) { + else if (node.parent.kind === 249 /* ExportAssignment */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -84640,11 +84959,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 145 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 242 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 146 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 243 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 145 /* QualifiedName */) { + while (node.parent.kind === 146 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -84656,27 +84975,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 145 /* QualifiedName */) { - while (root.parent && root.parent.kind === 145 /* QualifiedName */) { + if (root.parent.kind === 146 /* QualifiedName */) { + while (root.parent && root.parent.kind === 146 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 161 /* TypeReference */ && !isLastClause; + return root.parent.kind === 162 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 184 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 184 /* PropertyAccessExpression */) { + if (root.parent.kind === 185 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 185 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 206 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 267 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 207 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 268 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 234 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || - (decl.kind === 235 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); + return (decl.kind === 235 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || + (decl.kind === 236 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); } return false; } @@ -84687,30 +85006,30 @@ var ts; switch (node.kind) { case 99 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 173 /* ThisType */: + case 174 /* ThisType */: return true; } switch (node.parent.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return true; - case 178 /* ImportType */: + case 179 /* ImportType */: return !node.parent.isTypeOf; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 186 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 187 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 187 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 188 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { var target = climbPastPropertyAccess(node); - return target && target.parent && target.parent.kind === kind && target.parent.expression === target; + return !!target && !!target.parent && target.parent.kind === kind && target.parent.expression === target; } function climbPastPropertyAccess(node) { return isRightSideOfPropertyAccess(node) ? node.parent : node; @@ -84718,7 +85037,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 227 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 228 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -84739,15 +85058,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 145 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 238 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 239 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -84757,22 +85076,24 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 269 /* PropertyAssignment */: - case 272 /* EnumMember */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 238 /* ModuleDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 270 /* PropertyAssignment */: + case 273 /* EnumMember */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 239 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return true; - case 177 /* LiteralType */: - return node.parent.parent.kind === 175 /* IndexedAccessType */; + case 178 /* LiteralType */: + return node.parent.parent.kind === 176 /* IndexedAccessType */; + default: + return false; } } ts.isLiteralNameOfPropertyDeclarationOrIndexAccess = isLiteralNameOfPropertyDeclarationOrIndexAccess; @@ -84794,17 +85115,17 @@ var ts; return undefined; } switch (node.kind) { - case 273 /* SourceFile */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 238 /* ModuleDeclaration */: + case 274 /* SourceFile */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 239 /* ModuleDeclaration */: return node; } } @@ -84812,49 +85133,49 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: return "class" /* classElement */; - case 235 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 236 /* TypeAliasDeclaration */: - case 291 /* JSDocCallbackTag */: - case 296 /* JSDocTypedefTag */: + case 236 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 237 /* TypeAliasDeclaration */: + case 292 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 237 /* EnumDeclaration */: return "enum" /* enumElement */; - case 231 /* VariableDeclaration */: + case 238 /* EnumDeclaration */: return "enum" /* enumElement */; + case 232 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 192 /* ArrowFunction */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: return "function" /* functionElement */; - case 155 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 156 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 156 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 157 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return "property" /* memberVariableElement */; - case 159 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 158 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 157 /* CallSignature */: return "call" /* callSignatureElement */; - case 154 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 147 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 272 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 148 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 242 /* ImportEqualsDeclaration */: - case 247 /* ImportSpecifier */: - case 244 /* ImportClause */: - case 251 /* ExportSpecifier */: - case 245 /* NamespaceImport */: + case 160 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 159 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 158 /* CallSignature */: return "call" /* callSignatureElement */; + case 155 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 148 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 273 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 149 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 243 /* ImportEqualsDeclaration */: + case 248 /* ImportSpecifier */: + case 245 /* ImportClause */: + case 252 /* ExportSpecifier */: + case 246 /* NamespaceImport */: return "alias" /* alias */; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var kind = ts.getSpecialPropertyAssignmentKind(node); var right = node.right; switch (kind) { @@ -84897,7 +85218,7 @@ var ts; return true; case 71 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 148 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 149 /* Parameter */; default: return false; } @@ -84919,6 +85240,10 @@ var ts; return r.pos <= pos && pos <= r.end; } ts.rangeContainsPosition = rangeContainsPosition; + function rangeContainsPositionExclusive(r, pos) { + return r.pos < pos && pos < r.end; + } + ts.rangeContainsPositionExclusive = rangeContainsPositionExclusive; function startEndContainsRange(start, end, range) { return start <= range.pos && end >= range.end; } @@ -84946,46 +85271,46 @@ var ts; } ts.positionBelongsToNode = positionBelongsToNode; function isCompletedNode(n, sourceFile) { - if (ts.nodeIsMissing(n)) { + if (n === undefined || ts.nodeIsMissing(n)) { return false; } switch (n.kind) { - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 183 /* ObjectLiteralExpression */: - case 179 /* ObjectBindingPattern */: - case 165 /* TypeLiteral */: - case 212 /* Block */: - case 239 /* ModuleBlock */: - case 240 /* CaseBlock */: - case 246 /* NamedImports */: - case 250 /* NamedExports */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 184 /* ObjectLiteralExpression */: + case 180 /* ObjectBindingPattern */: + case 166 /* TypeLiteral */: + case 213 /* Block */: + case 240 /* ModuleBlock */: + case 241 /* CaseBlock */: + case 247 /* NamedImports */: + case 251 /* NamedExports */: return nodeEndsWith(n, 18 /* CloseBraceToken */, sourceFile); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 187 /* NewExpression */: + case 188 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 186 /* CallExpression */: - case 190 /* ParenthesizedExpression */: - case 172 /* ParenthesizedType */: + case 187 /* CallExpression */: + case 191 /* ParenthesizedExpression */: + case 173 /* ParenthesizedType */: return nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile); - case 162 /* FunctionType */: - case 163 /* ConstructorType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 158 /* ConstructSignature */: - case 157 /* CallSignature */: - case 192 /* ArrowFunction */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 159 /* ConstructSignature */: + case 158 /* CallSignature */: + case 193 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -84995,65 +85320,65 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 20 /* CloseParenToken */, sourceFile); - case 238 /* ModuleDeclaration */: - return n.body && isCompletedNode(n.body, sourceFile); - case 216 /* IfStatement */: + case 239 /* ModuleDeclaration */: + return !!n.body && isCompletedNode(n.body, sourceFile); + case 217 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 25 /* SemicolonToken */, sourceFile); - case 182 /* ArrayLiteralExpression */: - case 180 /* ArrayBindingPattern */: - case 185 /* ElementAccessExpression */: - case 146 /* ComputedPropertyName */: - case 167 /* TupleType */: + case 183 /* ArrayLiteralExpression */: + case 181 /* ArrayBindingPattern */: + case 186 /* ElementAccessExpression */: + case 147 /* ComputedPropertyName */: + case 168 /* TupleType */: return nodeEndsWith(n, 22 /* CloseBracketToken */, sourceFile); - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 218 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 219 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 217 /* DoStatement */: + case 218 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; return hasChildOfKind(n, 106 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 194 /* TypeOfExpression */: - case 193 /* DeleteExpression */: - case 195 /* VoidExpression */: - case 202 /* YieldExpression */: - case 203 /* SpreadElement */: + case 195 /* TypeOfExpression */: + case 194 /* DeleteExpression */: + case 196 /* VoidExpression */: + case 203 /* YieldExpression */: + case 204 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 249 /* ExportDeclaration */: - case 243 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -85066,11 +85391,11 @@ var ts; function nodeEndsWith(n, expectedLastToken, sourceFile) { var children = n.getChildren(sourceFile); if (children.length) { - var last_2 = ts.lastOrUndefined(children); - if (last_2.kind === expectedLastToken) { + var lastChild = ts.last(children); + if (lastChild.kind === expectedLastToken) { return true; } - else if (last_2.kind === 25 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 25 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -85130,6 +85455,7 @@ var ts; ts.getTouchingToken = getTouchingToken; /** Returns a token if position is in [start-of-leading-trivia, end) */ function getTokenAtPosition(sourceFile, position, includeJsDocComment, includeEndPosition) { + if (includeEndPosition === void 0) { includeEndPosition = false; } return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includePrecedingTokenAtEndPosition*/ undefined, includeEndPosition, includeJsDocComment); } ts.getTokenAtPosition = getTokenAtPosition; @@ -85244,7 +85570,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 273 /* SourceFile */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 274 /* SourceFile */ || 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. @@ -85284,7 +85610,7 @@ var ts; function isInString(sourceFile, position, previousToken) { if (previousToken === void 0) { previousToken = findPrecedingToken(position, sourceFile); } if (previousToken && ts.isStringTextContainingNode(previousToken)) { - var start = previousToken.getStart(); + var start = previousToken.getStart(sourceFile); var end = previousToken.getEnd(); // To be "in" one of these literals, the position has to be: // 1. entirely within the token text. @@ -85316,17 +85642,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 264 /* JsxExpression */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 265 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 264 /* JsxExpression */) { + if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 265 /* JsxExpression */) { return true; } //
|
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 257 /* JsxClosingElement */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 258 /* JsxClosingElement */) { return true; } return false; @@ -85344,10 +85670,11 @@ var ts; var tokenKind = token.kind; var remainingMatchingTokens = 0; while (true) { - token = findPrecedingToken(token.getFullStart(), sourceFile); - if (!token) { + var preceding = findPrecedingToken(token.getFullStart(), sourceFile); + if (!preceding) { return undefined; } + token = preceding; if (token.kind === matchingTokenKind) { if (remainingMatchingTokens === 0) { return token; @@ -85360,21 +85687,24 @@ var ts; } } ts.findPrecedingMatchingToken = findPrecedingMatchingToken; - function isPossiblyTypeArgumentPosition(token, sourceFile) { + function isPossiblyTypeArgumentPosition(tokenIn, sourceFile) { + var token = tokenIn; // This function determines if the node could be type argument position // Since during editing, when type argument list is not complete, // the tree could be of any shape depending on the tokens parsed before current node, // scanning of the previous identifier followed by "<" before current node would give us better result // Note that we also balance out the already provided type arguments, arrays, object literals while doing so var remainingLessThanTokens = 0; + var nTypeArguments = 0; while (token) { switch (token.kind) { case 27 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); - var tokenIsIdentifier = token && ts.isIdentifier(token); - if (!remainingLessThanTokens || !tokenIsIdentifier) { - return tokenIsIdentifier; + if (!token || !ts.isIdentifier(token)) + return undefined; + if (!remainingLessThanTokens) { + return { called: token, nTypeArguments: nTypeArguments }; } remainingLessThanTokens--; break; @@ -85392,24 +85722,26 @@ var ts; // Skip until the matching open brace token token = findPrecedingMatchingToken(token, 17 /* OpenBraceToken */, sourceFile); if (!token) - return false; + return undefined; break; case 20 /* CloseParenToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token token = findPrecedingMatchingToken(token, 19 /* OpenParenToken */, sourceFile); if (!token) - return false; + return undefined; break; case 22 /* CloseBracketToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token token = findPrecedingMatchingToken(token, 21 /* OpenBracketToken */, sourceFile); if (!token) - return false; + return undefined; break; // Valid tokens in a type name. Skip. case 26 /* CommaToken */: + nTypeArguments++; + break; case 36 /* EqualsGreaterThanToken */: case 71 /* Identifier */: case 9 /* StringLiteral */: @@ -85429,11 +85761,11 @@ var ts; break; } // Invalid token in type - return false; + return undefined; } token = findPrecedingToken(token.getFullStart(), sourceFile); } - return false; + return undefined; } ts.isPossiblyTypeArgumentPosition = isPossiblyTypeArgumentPosition; /** @@ -85483,10 +85815,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 161 /* TypeReference */ || node.kind === 186 /* CallExpression */) { + if (node.kind === 162 /* TypeReference */ || node.kind === 187 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 234 /* ClassDeclaration */ || node.kind === 235 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 235 /* ClassDeclaration */ || node.kind === 236 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -85509,9 +85841,9 @@ var ts; return 17 /* FirstPunctuation */ <= kind && kind <= 70 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; - function isInsideTemplateLiteral(node, position) { + function isInsideTemplateLiteral(node, position, sourceFile) { return ts.isTemplateLiteralKind(node.kind) - && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); + && (node.getStart(sourceFile) < position && position < node.end) || (!!node.isUnterminated && position === node.end); } ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { @@ -85531,18 +85863,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 182 /* ArrayLiteralExpression */ || - node.kind === 183 /* ObjectLiteralExpression */) { + if (node.kind === 183 /* ArrayLiteralExpression */ || + node.kind === 184 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 199 /* BinaryExpression */ && + if (node.parent.kind === 200 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 58 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 221 /* ForOfStatement */ && + if (node.parent.kind === 222 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -85550,7 +85882,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 269 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 270 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -85604,6 +85936,7 @@ var ts; 105 /* VoidKeyword */, 140 /* UndefinedKeyword */, 141 /* UniqueKeyword */, + 142 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -85636,11 +85969,11 @@ var ts; } ts.repeatString = repeatString; function skipConstraint(type) { - return type.isTypeParameter() ? type.getConstraint() : type; + return type.isTypeParameter() ? type.getConstraint() : type; // TODO: GH#18217 } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 146 /* ComputedPropertyName */ + return name.kind === 147 /* ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteral(name.expression) ? name.expression.text : undefined : ts.getTextOfIdentifierOrLiteral(name); @@ -85662,16 +85995,16 @@ var ts; return ts.createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host)); } ts.hostGetCanonicalFileName = hostGetCanonicalFileName; - function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier) { - return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier) : undefined; + function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, preferences) { + return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, preferences) : undefined; } ts.makeImportIfNecessary = makeImportIfNecessary; - function makeImport(defaultImport, namedImports, moduleSpecifier) { + function makeImport(defaultImport, namedImports, moduleSpecifier, preferences) { return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, defaultImport || namedImports ? ts.createImportClause(defaultImport, namedImports && namedImports.length ? ts.createNamedImports(namedImports) : undefined) - : undefined, typeof moduleSpecifier === "string" ? ts.createLiteral(moduleSpecifier) : moduleSpecifier); + : undefined, typeof moduleSpecifier === "string" ? ts.createLiteral(moduleSpecifier, preferences.quotePreference === "single") : moduleSpecifier); } ts.makeImport = makeImport; function symbolNameNoDefault(symbol) { @@ -85700,6 +86033,37 @@ var ts; return propSymbol; } ts.getPropertySymbolFromBindingElement = getPropertySymbolFromBindingElement; + /** + * Find symbol of the given property-name and add the symbol to the given result array + * @param symbol a symbol to start searching for the given propertyName + * @param propertyName a name of property to search for + * @param result an array of symbol of found property symbols + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. + * The value of previousIterationSymbol is undefined when the function is first called. + */ + function getPropertySymbolsFromBaseTypes(symbol, propertyName, checker, cb) { + var seen = ts.createMap(); + return recur(symbol); + function recur(symbol) { + // Use `addToSeen` to ensure we don't infinitely recurse in this situation: + // interface C extends C { + // /*findRef*/propName: string; + // } + if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) + return; + return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { + var type = checker.getTypeAtLocation(typeReference); + var propertySymbol = type && type.symbol && checker.getPropertyOfType(type, propertyName); + // Visit the typeReference as well to see if it directly or indirectly uses that property + return type && propertySymbol && (ts.firstDefined(checker.getRootSymbols(propertySymbol), cb) || recur(type.symbol)); + }); }); + } + } + ts.getPropertySymbolsFromBaseTypes = getPropertySymbolsFromBaseTypes; + function isMemberSymbolInBaseType(memberSymbol, checker) { + return getPropertySymbolsFromBaseTypes(memberSymbol.parent, memberSymbol.name, checker, function (_) { return true; }) || false; + } + ts.isMemberSymbolInBaseType = isMemberSymbolInBaseType; var NodeSet = /** @class */ (function () { function NodeSet() { this.map = ts.createMap(); @@ -85719,12 +86083,27 @@ var ts; return NodeSet; }()); ts.NodeSet = NodeSet; + function getParentNodeInSpan(node, file, span) { + if (!node) + return undefined; + while (node.parent) { + if (ts.isSourceFile(node.parent) || !spanContainsNode(span, node.parent, file)) { + return node; + } + node = node.parent; + } + } + ts.getParentNodeInSpan = getParentNodeInSpan; + function spanContainsNode(span, node, file) { + return ts.textSpanContainsPosition(span, node.getStart(file)) && + node.getEnd() <= ts.textSpanEnd(span); + } })(ts || (ts = {})); // Display-part writer helpers /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 148 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 149 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -85897,18 +86276,21 @@ var ts; } ts.mapToDisplayParts = mapToDisplayParts; function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { + if (flags === void 0) { flags = 0 /* None */; } return mapToDisplayParts(function (writer) { - typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, writer); + typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.typeToDisplayParts = typeToDisplayParts; function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { + if (flags === void 0) { flags = 0 /* None */; } return mapToDisplayParts(function (writer) { typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + if (flags === void 0) { flags = 0 /* None */; } flags |= 16384 /* UseAliasDefinedOutsideCurrentScope */ | 1024 /* MultilineObjectLiterals */ | 32 /* WriteTypeArgumentsOfSignature */ | 8192 /* OmitParameterModifiers */; return mapToDisplayParts(function (writer) { typechecker.writeSignature(signature, enclosingDeclaration, flags, /*signatureKind*/ undefined, writer); @@ -85916,8 +86298,8 @@ var ts; } ts.signatureToDisplayParts = signatureToDisplayParts; function isImportOrExportSpecifierName(location) { - return location.parent && - (location.parent.kind === 247 /* ImportSpecifier */ || location.parent.kind === 251 /* ExportSpecifier */) && + return !!location.parent && + (location.parent.kind === 248 /* ImportSpecifier */ || location.parent.kind === 252 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -85944,7 +86326,7 @@ var ts; scriptKinds[_i - 2] = arguments[_i]; } var scriptKind = getScriptKind(fileName, host); - return ts.forEach(scriptKinds, function (k) { return k === scriptKind; }); + return ts.some(scriptKinds, function (k) { return k === scriptKind; }); } ts.scriptKindIs = scriptKindIs; function getScriptKind(fileName, host) { @@ -86037,9 +86419,9 @@ var ts; return node.forEachChild(function (child) { return child; }); } /* @internal */ - function getUniqueName(baseName, fileText) { + function getUniqueName(baseName, sourceFile) { var nameText = baseName; - for (var i = 1; ts.stringContains(fileText, nameText); i++) { + for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { nameText = baseName + "_" + i; } return nameText; @@ -86060,7 +86442,7 @@ var ts; for (var _b = 0, textChanges_1 = textChanges_2; _b < textChanges_1.length; _b++) { var change = textChanges_1[_b]; var span = change.span, newText = change.newText; - var index = newText.indexOf(name); + var index = indexInTextChange(newText, name); if (index !== -1) { lastPos = span.start + delta + index; // If the reference comes first, return immediately. @@ -86077,6 +86459,17 @@ var ts; return lastPos; } ts.getRenameLocation = getRenameLocation; + function indexInTextChange(change, name) { + if (ts.startsWith(change, name)) + return 0; + // Add a " " to avoid references inside words + var idx = change.indexOf(" " + name); + if (idx === -1) + idx = change.indexOf("." + name); + if (idx === -1) + idx = change.indexOf('"' + name); + return idx === -1 ? -1 : idx + 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -86356,6 +86749,8 @@ var ts; case 9 /* text */: case 17 /* parameterName */: return ts.TokenClass.Identifier; + default: + return undefined; // TODO: GH#18217 Debug.assertNever(type); } } /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ @@ -86506,10 +86901,10 @@ 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 238 /* ModuleDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 233 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 234 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -86603,6 +86998,7 @@ var ts; case 22 /* jsxAttribute */: return "jsx attribute" /* jsxAttribute */; case 23 /* jsxText */: return "jsx text" /* jsxText */; case 24 /* jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* jsxAttributeStringLiteralValue */; + default: return undefined; // TODO: GH#18217 throw Debug.assertNever(type); } } function convertClassificationsToSpans(classifications) { @@ -86720,18 +87116,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 292 /* JSDocParameterTag */: + case 293 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 295 /* JSDocTemplateTag */: + case 296 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 294 /* JSDocTypeTag */: + case 295 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 293 /* JSDocReturnTag */: + case 294 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -86818,22 +87214,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 256 /* JsxOpeningElement */: + case 257 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -86859,19 +87255,20 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { + var parent = token.parent; if (tokenKind === 58 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 231 /* VariableDeclaration */ || - token.parent.kind === 151 /* PropertyDeclaration */ || - token.parent.kind === 148 /* Parameter */ || - token.parent.kind === 261 /* JsxAttribute */) { + if (parent.kind === 232 /* VariableDeclaration */ || + parent.kind === 152 /* PropertyDeclaration */ || + parent.kind === 149 /* Parameter */ || + parent.kind === 262 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 199 /* BinaryExpression */ || - token.parent.kind === 197 /* PrefixUnaryExpression */ || - token.parent.kind === 198 /* PostfixUnaryExpression */ || - token.parent.kind === 200 /* ConditionalExpression */) { + if (parent.kind === 200 /* BinaryExpression */ || + parent.kind === 198 /* PrefixUnaryExpression */ || + parent.kind === 199 /* PostfixUnaryExpression */ || + parent.kind === 201 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -86881,7 +87278,8 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 261 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + // TODO: GH#18217 + return token.parent.kind === 262 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 12 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -86897,32 +87295,32 @@ var ts; else if (tokenKind === 71 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 148 /* Parameter */: + case 149 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -87006,7 +87404,7 @@ var ts; // Determine the path to the directory containing the script relative to the root directory it is contained within var relativeDirectory = ts.firstDefined(rootDirs, function (rootDirectory) { return ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase) ? scriptPath.substr(rootDirectory.length) : undefined; - }); + }); // TODO: GH#18217 // Now find a path for each potential directory that is to be merged with the one containing the script return ts.deduplicate(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } @@ -87210,8 +87608,8 @@ var ts; // after the last '/' that appears in the fragment because that's where the replacement span // starts if (fragmentDirectory !== undefined) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(fragmentDirectory); - return nonRelativeModuleNames.map(function (nonRelativeModuleName) { return ts.removePrefix(nonRelativeModuleName, moduleNameWithSeperator_1); }); + var moduleNameWithSeparator_1 = ts.ensureTrailingDirectorySeparator(fragmentDirectory); + return nonRelativeModuleNames.map(function (nonRelativeModuleName) { return ts.removePrefix(nonRelativeModuleName, moduleNameWithSeparator_1); }); } return nonRelativeModuleNames; } @@ -87321,7 +87719,7 @@ var ts; } return result; } - // Replace everything after the last directory seperator that appears + // Replace everything after the last directory separator that appears function getDirectoryFragmentTextSpan(text, textStart) { var index = Math.max(text.lastIndexOf(ts.directorySeparator), text.lastIndexOf("\\")); var offset = index !== -1 ? index + 1 : 0; @@ -87366,7 +87764,7 @@ var ts; return ts.directoryProbablyExists(path, host); } catch ( /*ignore*/_a) { /*ignore*/ } - return undefined; + return false; } function tryIOAndConsumeErrors(host, toApply) { var args = []; @@ -87414,7 +87812,7 @@ var ts; } var contextToken = ts.findPrecedingToken(position, sourceFile); if (triggerCharacter && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) - return undefined; + return undefined; // TODO: GH#18217 if (ts.isInString(sourceFile, position, contextToken)) { return !contextToken || !ts.isStringLiteralLike(contextToken) ? undefined @@ -87424,7 +87822,7 @@ var ts; && (contextToken.kind === 72 /* BreakKeyword */ || contextToken.kind === 77 /* ContinueKeyword */ || contextToken.kind === 71 /* Identifier */)) { return getLabelCompletionAtPosition(contextToken.parent); } - var completionData = getCompletionData(program, log, sourceFile, position, preferences, /*detailsEntryId*/ undefined); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined); if (!completionData) { return undefined; } @@ -87494,9 +87892,9 @@ var ts; }] }; } var entries = []; - if (ts.isSourceFileJavaScript(sourceFile)) { + if (isUncheckedFile(sourceFile, compilerOptions)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap); - getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); + getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217 } else { if ((!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { @@ -87514,6 +87912,9 @@ var ts; } return { isGlobalCompletion: isInSnippetScope, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; } + function isUncheckedFile(sourceFile, compilerOptions) { + return ts.isSourceFileJavaScript(sourceFile) && !ts.isCheckJsEnabledForFile(sourceFile, compilerOptions); + } function isMemberCompletionKind(kind) { switch (kind) { case 0 /* ObjectPropertyDeclaration */: @@ -87632,7 +88033,7 @@ var ts; continue; } // Latter case tests whether this is a global variable. - if (!origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }))) { + if (!origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }))) { // TODO: GH#18217 uniques.set(name, true); } entries.push(entry); @@ -87678,11 +88079,11 @@ var ts; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { switch (node.parent.kind) { - case 177 /* LiteralType */: + case 178 /* LiteralType */: switch (node.parent.parent.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(node.parent), typeChecker), isNewIdentifier: false }; - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -87690,12 +88091,12 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(node.parent.parent.objectType)); - case 178 /* ImportType */: + case 179 /* ImportType */: return { kind: 0 /* Paths */, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; default: return undefined; } - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(node.parent.parent) && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -87712,7 +88113,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(node.parent.parent)); } return fromContextualType(); - case 185 /* ElementAccessExpression */: { + case 186 /* ElementAccessExpression */: { var _a = node.parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -87725,19 +88126,19 @@ var ts; } return undefined; } - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: if (!ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(node.parent)) { - var argumentInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: - case 253 /* ExternalModuleReference */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: + case 254 /* 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*/"); @@ -87763,7 +88164,7 @@ var ts; if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) return; var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); - isNewIdentifier = isNewIdentifier || !!(type.flags & 2 /* String */); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); return getStringLiteralTypes(type, checker, uniques); }); return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; @@ -87778,12 +88179,13 @@ var ts; type = ts.skipConstraint(type); return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, typeChecker, uniques); }) - : type.isStringLiteral() && !(type.flags & 256 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) + : type.isStringLiteral() && !(type.flags & 512 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { - var completionData = getCompletionData(program, log, sourceFile, position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); + var compilerOptions = program.getCompilerOptions(); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); if (!completionData) { return { type: "none" }; } @@ -87797,7 +88199,7 @@ var ts; // completion entry. return ts.firstDefined(symbols, function (symbol) { var origin = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; - var info = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, origin, completionKind); + var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target, origin, completionKind); return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source ? { type: "symbol", symbol: symbol, location: location, symbolToOriginInfoMap: symbolToOriginInfoMap, previousToken: previousToken, isJsxInitializer: isJsxInitializer } : undefined; @@ -87819,7 +88221,7 @@ var ts; var stringLiteralCompletions = !contextToken || !ts.isStringLiteralLike(contextToken) ? undefined : getStringLiteralCompletionEntries(sourceFile, contextToken, position, typeChecker, compilerOptions, host); - return stringLiteralCompletions && stringLiteralCompletionDetails(name, contextToken, stringLiteralCompletions, sourceFile, typeChecker, cancellationToken); + return stringLiteralCompletions && stringLiteralCompletionDetails(name, contextToken, stringLiteralCompletions, sourceFile, typeChecker, cancellationToken); // TODO: GH#18217 } // Compute all the completion symbols again. var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); @@ -87840,7 +88242,7 @@ var ts; 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, previousToken, formatContext, getCanonicalFileName, program.getSourceFiles(), preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; - return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); + return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "none": // Didn't find a symbol with this name. See if we can find a keyword instead. @@ -87879,7 +88281,7 @@ var ts; return { codeActions: undefined, sourceDisplay: undefined }; } var moduleSymbol = symbolOriginInfo.moduleSymbol; - var exportedSymbol = ts.skipAlias(symbol.exportSymbol || symbol, checker); + var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, checker, compilerOptions, allSourceFiles, formatContext, getCanonicalFileName, previousToken, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } @@ -87905,12 +88307,15 @@ var ts; CompletionKind[CompletionKind["None"] = 5] = "None"; })(CompletionKind || (CompletionKind = {})); function getRecommendedCompletion(currentToken, position, sourceFile, checker) { - var ty = getContextualType(currentToken, position, sourceFile, checker); - var symbol = ty && ty.symbol; - // Don't include make a recommended completion for an abstract class - return symbol && (symbol.flags & 384 /* Enum */ || symbol.flags & 32 /* Class */ && !ts.isAbstractConstructorSymbol(symbol)) - ? getFirstSymbolInChain(symbol, currentToken, checker) - : undefined; + var contextualType = getContextualType(currentToken, position, sourceFile, checker); + // For a union, return the first one with a recommended completion. + return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { + var symbol = type && type.symbol; + // Don't include make a recommended completion for an abstract class + return symbol && (symbol.flags & (8 /* EnumMember */ | 384 /* Enum */ | 32 /* Class */) && !ts.isAbstractConstructorSymbol(symbol)) + ? getFirstSymbolInChain(symbol, currentToken, checker) + : undefined; + }); } function getContextualType(currentToken, position, sourceFile, checker) { var parent = currentToken.parent; @@ -87919,11 +88324,11 @@ var ts; return getContextualTypeFromParent(currentToken, checker); case 58 /* EqualsToken */: switch (parent.kind) { - case 231 /* VariableDeclaration */: - return checker.getContextualType(parent.initializer); - case 199 /* BinaryExpression */: + case 232 /* VariableDeclaration */: + return checker.getContextualType(parent.initializer); // TODO: GH#18217 + case 200 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -87933,9 +88338,9 @@ var ts; case 73 /* CaseKeyword */: return getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 17 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 254 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 255 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: - var argInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(currentToken, position, sourceFile); + var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(currentToken, position, sourceFile); return argInfo // At `,`, treat this as the next argument after the comma. ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (currentToken.kind === 26 /* CommaToken */ ? 1 : 0)) @@ -87948,15 +88353,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 187 /* NewExpression */: + case 188 /* NewExpression */: return checker.getContextualType(parent); - case 199 /* BinaryExpression */: { + case 200 /* 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 265 /* CaseClause */: + case 266 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -87972,9 +88377,9 @@ 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 === 273 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 274 /* SourceFile */; }); } - function getCompletionData(program, log, sourceFile, position, preferences, detailsEntryId) { + function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); // TODO: GH#15853 @@ -88024,11 +88429,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 277 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 278 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 297 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 298 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -88046,7 +88451,7 @@ var ts; } } start = ts.timestamp(); - var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); + var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 log("getCompletionData: Get previous token 1: " + (ts.timestamp() - start)); // The decision to provide completion depends on the contextToken, which is determined through the previousToken. // Note: 'previousToken' (and thus 'contextToken') can be undefined if we are the beginning of the file @@ -88055,7 +88460,7 @@ var ts; // Skip this partial identifier and adjust the contextToken to the token that precedes it. if (contextToken && position <= contextToken.end && (ts.isIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) { var start_4 = ts.timestamp(); - contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_4)); } // Find the node where completion is requested on. @@ -88078,14 +88483,15 @@ var ts; if (contextToken.kind === 23 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; break; - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: node = parent.left; break; - case 178 /* ImportType */: + case 179 /* ImportType */: + case 210 /* MetaProperty */: node = parent; break; default: @@ -88098,7 +88504,7 @@ var ts; // // 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 === 184 /* PropertyAccessExpression */) { + if (parent && parent.kind === 185 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -88106,39 +88512,39 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 29 /* GreaterThanToken */: - if (currentToken.parent.kind === 254 /* JsxElement */ || currentToken.parent.kind === 256 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 255 /* JsxElement */ || currentToken.parent.kind === 257 /* JsxOpeningElement */) { location = currentToken; } break; case 41 /* SlashToken */: - if (currentToken.parent.kind === 255 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 256 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: if (contextToken.kind === 41 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (!(parent.left.flags & 32768 /* ThisNodeHasError */)) { // It has a left-hand side, so we're not in an opening JSX tag. break; } // falls through - case 255 /* JsxSelfClosingElement */: - case 254 /* JsxElement */: - case 256 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: + case 255 /* JsxElement */: + case 257 /* JsxOpeningElement */: if (contextToken.kind === 27 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: switch (previousToken.kind) { case 58 /* EqualsToken */: isJsxInitializer = true; @@ -88189,12 +88595,14 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 292 /* JSDocParameterTag */: - case 297 /* JSDocPropertyTag */: - case 293 /* JSDocReturnTag */: - case 294 /* JSDocTypeTag */: - case 296 /* JSDocTypedefTag */: + case 293 /* JSDocParameterTag */: + case 298 /* JSDocPropertyTag */: + case 294 /* JSDocReturnTag */: + case 295 /* JSDocTypeTag */: + case 297 /* JSDocTypedefTag */: return true; + default: + return false; } } function getTypeScriptMemberSymbols() { @@ -88225,20 +88633,25 @@ 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.some(function (d) { return d.kind !== 273 /* SourceFile */ && d.kind !== 238 /* ModuleDeclaration */ && d.kind !== 237 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 274 /* SourceFile */ && d.kind !== 239 /* ModuleDeclaration */ && d.kind !== 238 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; } } } + if (ts.isMetaProperty(node) && (node.keywordToken === 94 /* NewKeyword */ || node.keywordToken === 91 /* ImportKeyword */)) { + var completion = (node.keywordToken === 94 /* NewKeyword */) ? "target" : "meta"; + symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); + return; + } if (!isTypeLocation) { addTypeProperties(typeChecker.getTypeAtLocation(node)); } } function addTypeProperties(type) { isNewIdentifierLocation = hasIndexSignature(type); - if (ts.isSourceFileJavaScript(sourceFile)) { + 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 // each individual type has. This is because we're going to add all identifiers @@ -88249,7 +88662,7 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 178 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 179 /* ImportType */ ? node : node.parent, type, symbol)) { addPropertySymbol(symbol); } } @@ -88259,7 +88672,7 @@ var ts; // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. var symbolSymbol = ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - var leftName = name.kind === 146 /* ComputedPropertyName */ ? getLeftMostName(name.expression) : undefined; + var leftName = name.kind === 147 /* ComputedPropertyName */ ? getLeftMostName(name.expression) : undefined; return leftName && typeChecker.getSymbolAtLocation(leftName); }); if (symbolSymbol) { @@ -88348,7 +88761,7 @@ var ts; var symbolMeanings = 67901928 /* Type */ | 67216319 /* Value */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 273 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 274 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker, /*isForAccess*/ true); _i < _a.length; _i++) { @@ -88377,17 +88790,17 @@ var ts; if (ts.programContainsEs6Modules(program)) return true; // For JS, stay on the safe side. - if (ts.isSourceFileJavaScript(sourceFile)) + if (isUncheckedFile) return false; // If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK. return ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions()); } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 273 /* SourceFile */: - case 201 /* TemplateExpression */: - case 264 /* JsxExpression */: - case 212 /* Block */: + case 274 /* SourceFile */: + case 202 /* TemplateExpression */: + case 265 /* JsxExpression */: + case 213 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -88424,22 +88837,22 @@ var ts; function isContextTokenValueLocation(contextToken) { return contextToken && contextToken.kind === 103 /* TypeOfKeyword */ && - (contextToken.parent.kind === 164 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + (contextToken.parent.kind === 165 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 56 /* ColonToken */: - return parentKind === 151 /* PropertyDeclaration */ || - parentKind === 150 /* PropertySignature */ || - parentKind === 148 /* Parameter */ || - parentKind === 231 /* VariableDeclaration */ || + return parentKind === 152 /* PropertyDeclaration */ || + parentKind === 151 /* PropertySignature */ || + parentKind === 149 /* Parameter */ || + parentKind === 232 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 58 /* EqualsToken */: - return parentKind === 236 /* TypeAliasDeclaration */; + return parentKind === 237 /* TypeAliasDeclaration */; case 118 /* AsKeyword */: - return parentKind === 207 /* AsExpression */; + return parentKind === 208 /* AsExpression */; } } return false; @@ -88457,14 +88870,21 @@ var ts; // symbol can be referenced at locations where type is allowed return exportedSymbols.some(symbolCanBeReferencedAtTypeLocation); } + return false; } function getSymbolsFromOtherSourceFileExports(symbols, tokenText, target) { var tokenTextLowerCase = tokenText.toLowerCase(); + var seenResolvedModules = ts.createMap(); ts.codefix.forEachExternalModuleToImportFrom(typeChecker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { // Perf -- ignore other modules if this is a request for details if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { return; } + 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))) { + return; + } for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) { var symbol = _a[_i]; // Don't add a completion for a re-export, only for the original. @@ -88473,7 +88893,7 @@ var ts; // // If `symbol.parent !== ...`, this comes from an `export * from "foo"` re-export. Those don't create new symbols. // If `some(...)`, this comes from an `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). - if (typeChecker.getMergedSymbol(symbol.parent) !== typeChecker.resolveExternalModuleSymbol(moduleSymbol) + if (typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.parent.parent.moduleSpecifier; })) { continue; } @@ -88535,11 +88955,11 @@ var ts; return true; } if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 256 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 257 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 257 /* JsxClosingElement */ || contextToken.parent.kind === 255 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 254 /* JsxElement */; + if (contextToken.parent.kind === 258 /* JsxClosingElement */ || contextToken.parent.kind === 256 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 255 /* JsxElement */; } } return false; @@ -88549,40 +88969,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 186 /* CallExpression */ // func( a, | - || containingNodeKind === 154 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 187 /* NewExpression */ // new C(a, | - || containingNodeKind === 182 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 199 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 162 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 187 /* CallExpression */ // func( a, | + || containingNodeKind === 155 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 188 /* NewExpression */ // new C(a, | + || containingNodeKind === 183 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 200 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 163 /* FunctionType */; // var x: (s: string, list| case 19 /* OpenParenToken */: - return containingNodeKind === 186 /* CallExpression */ // func( | - || containingNodeKind === 154 /* Constructor */ // constructor( | - || containingNodeKind === 187 /* NewExpression */ // new C(a| - || containingNodeKind === 190 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 172 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 187 /* CallExpression */ // func( | + || containingNodeKind === 155 /* Constructor */ // constructor( | + || containingNodeKind === 188 /* NewExpression */ // new C(a| + || containingNodeKind === 191 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 173 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 21 /* OpenBracketToken */: - return containingNodeKind === 182 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 159 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 146 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 183 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 160 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 147 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 129 /* ModuleKeyword */: // module | case 130 /* NamespaceKeyword */: // namespace | return true; case 23 /* DotToken */: - return containingNodeKind === 238 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 239 /* ModuleDeclaration */; // module A.| case 17 /* OpenBraceToken */: - return containingNodeKind === 234 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 235 /* ClassDeclaration */; // class A{ | case 58 /* EqualsToken */: - return containingNodeKind === 231 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 199 /* BinaryExpression */; // x = a| + return containingNodeKind === 232 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 200 /* BinaryExpression */; // x = a| case 14 /* TemplateHead */: - return containingNodeKind === 201 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 202 /* TemplateExpression */; // `aa ${| case 15 /* TemplateMiddle */: - return containingNodeKind === 210 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 211 /* TemplateSpan */; // `aa ${10} dd ${| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: - return containingNodeKind === 151 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 152 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { @@ -88595,24 +89015,12 @@ var ts; return false; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 12 /* RegularExpressionLiteral */ - || ts.isTemplateLiteralKind(contextToken.kind)) { - var start_5 = contextToken.getStart(); - var end = contextToken.getEnd(); - // To be "in" one of these literals, the position has to be: - // 1. entirely within the token text. - // 2. at the end position of an unterminated token. - // 3. at the end of a regular expression (due to trailing flags like '/foo/g'). - if (start_5 < position && position < end) { - return true; - } - if (position === end) { - return !!contextToken.isUnterminated - || contextToken.kind === 12 /* RegularExpressionLiteral */; - } - } - return false; + // To be "in" one of these literals, the position has to be: + // 1. entirely within the token text. + // 2. at the end position of an unterminated token. + // 3. at the end of a regular expression (due to trailing flags like '/foo/g'). + return (ts.isRegularExpressionLiteral(contextToken) || ts.isStringTextContainingNode(contextToken)) && (ts.rangeContainsPositionExclusive(ts.createTextRangeFromSpan(ts.createTextSpanFromNode(contextToken)), position) || + position === contextToken.end && (!!contextToken.isUnterminated || ts.isRegularExpressionLiteral(contextToken))); } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. @@ -88628,7 +89036,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 183 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 184 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; @@ -88637,7 +89045,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 179 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 180 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -88648,12 +89056,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 === 221 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 148 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 222 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 149 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 153 /* MethodDeclaration */ || rootDeclaration.parent.kind === 156 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 154 /* MethodDeclaration */ || rootDeclaration.parent.kind === 157 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -88695,8 +89103,8 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 246 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); + var moduleSpecifier = (namedImportsOrExports.kind === 247 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; completionKind = 3 /* MemberLike */; @@ -88723,7 +89131,7 @@ var ts; if (!ts.isClassLike(decl)) return 1 /* Success */; var classElement = contextToken.parent; - var classElementModifierFlags = ts.isClassElement(classElement) && ts.getModifierFlags(classElement); + var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(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 === 71 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { @@ -88739,7 +89147,7 @@ var ts; 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 type = typeChecker.getTypeAtLocation(baseTypeNode); + var type = typeChecker.getTypeAtLocation(baseTypeNode); // TODO: GH#18217 return typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); }); symbols = filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags); @@ -88774,13 +89182,14 @@ var ts; */ function tryGetConstructorLikeCompletionContainer(contextToken) { if (contextToken) { + var parent = contextToken.parent; switch (contextToken.kind) { case 19 /* OpenParenToken */: case 26 /* CommaToken */: - return ts.isConstructorDeclaration(contextToken.parent) && contextToken.parent; + return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { - return contextToken.parent.parent; + return parent.parent; } } } @@ -88797,6 +89206,7 @@ var ts; return true; } prev_1 = node; + return false; }); return container && container; } @@ -88808,14 +89218,14 @@ var ts; case 28 /* LessThanSlashToken */: case 41 /* SlashToken */: case 71 /* Identifier */: - case 184 /* PropertyAccessExpression */: - case 262 /* JsxAttributes */: - case 261 /* JsxAttribute */: - case 263 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 255 /* JsxSelfClosingElement */ || parent.kind === 256 /* JsxOpeningElement */)) { + case 185 /* PropertyAccessExpression */: + case 263 /* JsxAttributes */: + case 262 /* JsxAttribute */: + case 264 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 256 /* JsxSelfClosingElement */ || parent.kind === 257 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 261 /* JsxAttribute */) { + else if (parent.kind === 262 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -88827,7 +89237,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent && ((parent.kind === 261 /* JsxAttribute */) || (parent.kind === 263 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 262 /* JsxAttribute */) || (parent.kind === 264 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -88837,8 +89247,8 @@ var ts; break; case 18 /* CloseBraceToken */: if (parent && - parent.kind === 264 /* JsxExpression */ && - parent.parent && parent.parent.kind === 261 /* JsxAttribute */) { + parent.kind === 265 /* JsxExpression */ && + parent.parent && parent.parent.kind === 262 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -88846,7 +89256,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 263 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 264 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -88862,53 +89272,53 @@ var ts; * @returns true if we are certain that the currently edited location must define a new location; false otherwise. */ function isSolelyIdentifierDefinitionLocation(contextToken) { - var containingNodeKind = contextToken.parent.kind; + var parent = contextToken.parent; + var containingNodeKind = parent.kind; switch (contextToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 231 /* VariableDeclaration */ || - containingNodeKind === 232 /* VariableDeclarationList */ || - containingNodeKind === 213 /* VariableStatement */ || - containingNodeKind === 237 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 232 /* VariableDeclaration */ || + containingNodeKind === 233 /* VariableDeclarationList */ || + containingNodeKind === 214 /* VariableStatement */ || + containingNodeKind === 238 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 235 /* InterfaceDeclaration */ || // interface A= contextToken.pos); + (ts.isClassLike(parent) && + !!parent.typeParameters && + parent.typeParameters.end >= contextToken.pos); case 23 /* DotToken */: - return containingNodeKind === 180 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 181 /* ArrayBindingPattern */; // var [.| case 56 /* ColonToken */: - return containingNodeKind === 181 /* BindingElement */; // var {x :html| + return containingNodeKind === 182 /* BindingElement */; // var {x :html| case 21 /* OpenBracketToken */: - return containingNodeKind === 180 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 181 /* ArrayBindingPattern */; // var [x| case 19 /* OpenParenToken */: - return containingNodeKind === 268 /* CatchClause */ || + return containingNodeKind === 269 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 17 /* OpenBraceToken */: - return containingNodeKind === 237 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 238 /* EnumDeclaration */; // enum a { | case 27 /* LessThanToken */: - return containingNodeKind === 234 /* ClassDeclaration */ || // class A< | - containingNodeKind === 204 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 235 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 236 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 235 /* ClassDeclaration */ || // class A< | + containingNodeKind === 205 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 237 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 115 /* StaticKeyword */: - return containingNodeKind === 151 /* PropertyDeclaration */ && !ts.isClassLike(contextToken.parent.parent); + return containingNodeKind === 152 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 24 /* DotDotDotToken */: - return containingNodeKind === 148 /* Parameter */ || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 180 /* ArrayBindingPattern */); // var [...z| + return containingNodeKind === 149 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 181 /* ArrayBindingPattern */); // var [...z| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: - return containingNodeKind === 148 /* Parameter */ && !ts.isConstructorDeclaration(contextToken.parent.parent); + return containingNodeKind === 149 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 118 /* AsKeyword */: - return containingNodeKind === 247 /* ImportSpecifier */ || - containingNodeKind === 251 /* ExportSpecifier */ || - containingNodeKind === 245 /* NamespaceImport */; + return containingNodeKind === 248 /* ImportSpecifier */ || + containingNodeKind === 252 /* ExportSpecifier */ || + containingNodeKind === 246 /* NamespaceImport */; case 125 /* GetKeyword */: case 136 /* SetKeyword */: if (isFromObjectTypeDeclaration(contextToken)) { @@ -88969,7 +89379,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 154 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 155 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -88992,12 +89402,12 @@ 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 !== 269 /* PropertyAssignment */ && - m.kind !== 270 /* ShorthandPropertyAssignment */ && - m.kind !== 181 /* BindingElement */ && - m.kind !== 153 /* MethodDeclaration */ && - m.kind !== 155 /* GetAccessor */ && - m.kind !== 156 /* SetAccessor */) { + if (m.kind !== 270 /* PropertyAssignment */ && + m.kind !== 271 /* ShorthandPropertyAssignment */ && + m.kind !== 182 /* BindingElement */ && + m.kind !== 154 /* MethodDeclaration */ && + m.kind !== 156 /* GetAccessor */ && + m.kind !== 157 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -89005,7 +89415,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 181 /* BindingElement */ && m.propertyName) { + if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 71 /* Identifier */) { existingName = m.propertyName.escapedText; @@ -89018,7 +89428,7 @@ var ts; var name = ts.getNameOfDeclaration(m); existingName = ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } - existingMemberNames.set(existingName, true); + existingMemberNames.set(existingName, true); // TODO: GH#18217 } return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); } @@ -89032,10 +89442,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 !== 151 /* PropertyDeclaration */ && - m.kind !== 153 /* MethodDeclaration */ && - m.kind !== 155 /* GetAccessor */ && - m.kind !== 156 /* SetAccessor */) { + if (m.kind !== 152 /* PropertyDeclaration */ && + m.kind !== 154 /* MethodDeclaration */ && + m.kind !== 156 /* GetAccessor */ && + m.kind !== 157 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -89075,7 +89485,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 261 /* JsxAttribute */) { + if (attr.kind === 262 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } } @@ -89119,7 +89529,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 72 /* FirstKeyword */; i <= 144 /* LastKeyword */; i++) { + for (var i = 72 /* FirstKeyword */; i <= 145 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -89220,7 +89630,7 @@ var ts; } // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. var filteredTypes = isForAccess ? type.types : type.types.filter(function (memberType) { - return !(memberType.flags & 16382 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker)); + return !(memberType.flags & 32764 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker)); }); return ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(filteredTypes), "getAllPossiblePropertiesOfTypes() should all be defined"); } @@ -89231,7 +89641,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 298 /* SyntaxList */: + case 299 /* 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); @@ -89255,7 +89665,7 @@ var ts; if (!isFromObjectTypeDeclaration(contextToken)) return undefined; var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) + return (isValidKeyword(contextToken.kind) || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -89278,7 +89688,7 @@ var ts; return isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return contextToken.kind === 27 /* LessThanToken */ && contextToken.parent.kind !== 199 /* BinaryExpression */; + return contextToken.kind === 27 /* LessThanToken */ && contextToken.parent.kind !== 200 /* BinaryExpression */; case "/": return ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) @@ -89291,8 +89701,8 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 201 /* TemplateExpression */: - case 188 /* TaggedTemplateExpression */: + case 202 /* TemplateExpression */: + case 189 /* TaggedTemplateExpression */: return true; default: return false; @@ -89337,7 +89747,7 @@ var ts; if (!sourceFilesSet.has(fileName)) { ts.Debug.assert(program.redirectTargetsSet.has(fileName)); var redirectTarget_1 = program.getSourceFile(fileName); - var redirect = ts.find(sourceFilesToSearch, function (f) { return f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget_1; }); + var redirect = ts.find(sourceFilesToSearch, function (f) { return !!f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget_1; }); fileName = redirect.fileName; ts.Debug.assert(sourceFilesSet.has(fileName)); } @@ -89383,6 +89793,8 @@ var ts; return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); case 120 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); + case 116 /* YieldKeyword */: + return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) ? highlightSpans(getModifierOccurrences(node.kind, node.parent)) @@ -89410,7 +89822,7 @@ var ts; } else if (ts.isTryStatement(node)) { // Exceptions thrown within a try block lacking a catch clause are "owned" in the current context. - return ts.concatenate(node.catchClause ? aggregateOwnedThrowStatements(node.catchClause) : node.tryBlock && aggregateOwnedThrowStatements(node.tryBlock), aggregateOwnedThrowStatements(node.finallyBlock)); + return ts.concatenate(node.catchClause ? aggregateOwnedThrowStatements(node.catchClause) : node.tryBlock && aggregateOwnedThrowStatements(node.tryBlock), node.finallyBlock && aggregateOwnedThrowStatements(node.finallyBlock)); } // Do not cross function boundaries. return ts.isFunctionLike(node) ? undefined : flatMapChildren(node, aggregateOwnedThrowStatements); @@ -89424,7 +89836,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 273 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 274 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -89451,26 +89863,26 @@ var ts; } function ownsBreakOrContinueStatement(owner, statement) { var actualOwner = getBreakOrContinueOwner(statement); - return actualOwner && actualOwner === owner; + return !!actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 226 /* SwitchStatement */: - if (statement.kind === 222 /* ContinueStatement */) { + case 227 /* SwitchStatement */: + if (statement.kind === 223 /* ContinueStatement */) { return false; } // falls through - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 218 /* WhileStatement */: - case 217 /* DoStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 219 /* WhileStatement */: + case 218 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. // TODO: GH#20090 - return (ts.isFunctionLike(node) && "quit"); + return ts.isFunctionLike(node) && "quit"; } }); } @@ -89488,11 +89900,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 239 /* ModuleBlock */: - case 273 /* SourceFile */: - case 212 /* Block */: - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 240 /* ModuleBlock */: + case 274 /* SourceFile */: + case 213 /* Block */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return declaration.members.concat([declaration]); @@ -89500,13 +89912,12 @@ var ts; else { return container.statements; } - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 233 /* FunctionDeclaration */: { + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 234 /* FunctionDeclaration */: return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - } - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: 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. @@ -89539,7 +89950,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 88 /* ForKeyword */, 106 /* WhileKeyword */, 81 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 217 /* DoStatement */) { + if (loopNode.kind === 218 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { @@ -89559,13 +89970,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -89641,16 +90052,35 @@ var ts; pushKeywordIf(keywords, modifier, 120 /* AsyncKeyword */); }); } - ts.forEachChild(func, aggregate); + ts.forEachChild(func, function (child) { + traverseWithoutCrossingFunction(child, function (node) { + if (ts.isAwaitExpression(node)) { + pushKeywordIf(keywords, node.getFirstToken(), 121 /* AwaitKeyword */); + } + }); + }); return keywords; - function aggregate(node) { - if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 121 /* AwaitKeyword */); - } - // Do not cross function boundaries. - if (!ts.isFunctionLike(node) && !ts.isClassLike(node) && !ts.isInterfaceDeclaration(node) && !ts.isModuleDeclaration(node) && !ts.isTypeAliasDeclaration(node) && !ts.isTypeNode(node)) { - ts.forEachChild(node, aggregate); - } + } + function getYieldOccurrences(node) { + var func = ts.getContainingFunction(node); + if (!func) { + return undefined; + } + var keywords = []; + ts.forEachChild(func, function (child) { + traverseWithoutCrossingFunction(child, function (node) { + if (ts.isYieldExpression(node)) { + pushKeywordIf(keywords, node.getFirstToken(), 116 /* YieldKeyword */); + } + }); + }); + return keywords; + } + // Do not cross function/class/interface/module/type boundaries. + function traverseWithoutCrossingFunction(node, cb) { + cb(node); + if (!ts.isFunctionLike(node) && !ts.isClassLike(node) && !ts.isInterfaceDeclaration(node) && !ts.isModuleDeclaration(node) && !ts.isTypeAliasDeclaration(node) && !ts.isTypeNode(node)) { + ts.forEachChild(node, function (child) { return traverseWithoutCrossingFunction(child, cb); }); } } function getIfElseOccurrences(ifStatement, sourceFile) { @@ -89720,6 +90150,11 @@ var ts; var ts; (function (ts) { function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { + return createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory); + } + ts.createDocumentRegistry = createDocumentRegistry; + /*@internal*/ + function createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory, externalCache) { if (currentDirectory === void 0) { currentDirectory = ""; } // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. @@ -89733,7 +90168,7 @@ var ts; if (!bucket && createIfMissing) { buckets.set(key, bucket = ts.createMap()); } - return bucket; + return bucket; // TODO: GH#18217 } function reportStats() { var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { @@ -89742,8 +90177,7 @@ var ts; entries.forEach(function (entry, name) { sourceFiles.push({ name: name, - refCount: entry.languageServiceRefCount, - references: entry.owners.slice(0) + refCount: entry.languageServiceRefCount }); }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); @@ -89774,13 +90208,26 @@ var ts; var bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ true); var entry = bucket.get(path); var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings.target; + if (!entry && externalCache) { + var sourceFile = externalCache.getDocument(key, path); + if (sourceFile) { + ts.Debug.assert(acquiring); + entry = { + sourceFile: sourceFile, + languageServiceRefCount: 0 + }; + bucket.set(path, entry); + } + } if (!entry) { // Have never seen this file with these settings. Create a new source file for it. - var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, /*setNodeParents*/ false, scriptKind); + var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, /*setNodeParents*/ false, scriptKind); // TODO: GH#18217 + if (externalCache) { + externalCache.setDocument(key, path, sourceFile); + } entry = { sourceFile: sourceFile, languageServiceRefCount: 1, - owners: [] }; bucket.set(path, entry); } @@ -89789,7 +90236,10 @@ var ts; // the script snapshot. If so, update it appropriately. Otherwise, we can just // return it as is. if (entry.sourceFile.version !== version) { - entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); + entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); // TODO: GH#18217 + if (externalCache) { + externalCache.setDocument(key, path, entry.sourceFile); + } } // If we're acquiring, then this is the first time this LS is asking for this document. // Increase our ref count so we know there's another LS using the document. If we're @@ -89800,6 +90250,7 @@ var ts; entry.languageServiceRefCount++; } } + ts.Debug.assert(entry.languageServiceRefCount !== 0); return entry.sourceFile; } function releaseDocument(fileName, compilationSettings) { @@ -89817,6 +90268,13 @@ var ts; bucket.delete(path); } } + function getLanguageServiceRefCounts(path) { + return ts.arrayFrom(buckets.entries(), function (_a) { + var key = _a[0], bucket = _a[1]; + var entry = bucket.get(path); + return [key, entry && entry.languageServiceRefCount]; + }); + } return { acquireDocument: acquireDocument, acquireDocumentWithKey: acquireDocumentWithKey, @@ -89824,11 +90282,12 @@ var ts; updateDocumentWithKey: updateDocumentWithKey, releaseDocument: releaseDocument, releaseDocumentWithKey: releaseDocumentWithKey, + getLanguageServiceRefCounts: getLanguageServiceRefCounts, reportStats: reportStats, getKeyForCompilationSettings: getKeyForCompilationSettings }; } - ts.createDocumentRegistry = createDocumentRegistry; + ts.createDocumentRegistryInternal = createDocumentRegistryInternal; })(ts || (ts = {})); /* Code for finding imports of an exported symbol. Used only by FindAllReferences. */ /* @internal */ @@ -89891,10 +90350,10 @@ var ts; } cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 231 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 232 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 71 /* Identifier */) { directImports.push(name); @@ -89907,12 +90366,12 @@ var ts; break; case 71 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */)); break; - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 245 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 246 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name); } else if (ts.isDefaultImport(direct)) { @@ -89926,7 +90385,7 @@ var ts; directImports.push(direct); } break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -89936,7 +90395,7 @@ var ts; directImports.push(direct); } break; - case 178 /* ImportType */: + case 179 /* ImportType */: directImports.push(direct); break; default: @@ -89952,7 +90411,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 273 /* SourceFile */ || sourceFileLike.kind === 238 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 274 /* SourceFile */ || sourceFileLike.kind === 239 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -89965,7 +90424,7 @@ var ts; ts.Debug.assert(!isAvailableThroughGlobal); var isNew = markSeenIndirectUser(sourceFileLike); if (isNew) { - indirectUserDeclarations.push(sourceFileLike); + indirectUserDeclarations.push(sourceFileLike); // TODO: GH#18217 } return isNew; } @@ -90007,7 +90466,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 242 /* ImportEqualsDeclaration */) { + if (decl.kind === 243 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -90017,7 +90476,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 178 /* ImportType */) { + if (decl.kind === 179 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -90032,7 +90491,7 @@ var ts; if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { return; } - if (decl.kind === 249 /* ExportDeclaration */) { + if (decl.kind === 250 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } @@ -90041,12 +90500,12 @@ var ts; return; } var namedBindings = importClause.namedBindings; - if (namedBindings && namedBindings.kind === 245 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 246 /* NamespaceImport */) { handleNamespaceImportLike(namedBindings.name); return; } if (exportKind === 0 /* Named */) { - searchForNamedImport(namedBindings); + searchForNamedImport(namedBindings); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) } else { // `export =` might be imported by a default import if `--allowSyntheticDefaultImports` is on, so this handles both ExportKind.Default and ExportKind.ExportEquals @@ -90095,7 +90554,7 @@ var ts; } } else { - var localSymbol = element.kind === 251 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 252 /* 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); @@ -90110,7 +90569,7 @@ var ts; /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ function findNamespaceReExports(sourceFileLike, name, checker) { var namespaceImportSymbol = checker.getSymbolAtLocation(name); - return forEachPossibleImportOrExportStatement(sourceFileLike, function (statement) { + return !!forEachPossibleImportOrExportStatement(sourceFileLike, function (statement) { if (!ts.isExportDeclaration(statement)) return; var exportClause = statement.exportClause, moduleSpecifier = statement.moduleSpecifier; @@ -90124,7 +90583,7 @@ var ts; for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { var referencingFile = sourceFiles_5[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 273 /* SourceFile */) { + if (searchSourceFile.kind === 274 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -90171,7 +90630,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 === 273 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 274 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -90186,15 +90645,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 249 /* ExportDeclaration */: - case 243 /* ImportDeclaration */: { + case 250 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 242 /* ImportEqualsDeclaration */: { + case 243 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -90216,12 +90675,13 @@ var ts; return comingFromExport ? getExport() : getExport() || getImport(); function getExport() { var parent = node.parent; + var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 184 /* PropertyAccessExpression */) { + if (parent.kind === 185 /* 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(parent.parent) - ? getSpecialPropertyExport(parent.parent, /*useLhsSymbol*/ false) + return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) + ? getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ false) : undefined; } else { @@ -90248,15 +90708,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(parent.parent)) { - return getExportAssignmentExport(parent.parent); + 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(parent.parent)) { - return getSpecialPropertyExport(parent.parent, /*useLhsSymbol*/ true); + else if (ts.isBinaryExpression(grandParent)) { + return getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { return exportInfo(symbol, 0 /* Named */); @@ -90331,15 +90791,18 @@ var ts; else if (ts.isBinaryExpression(decl)) { // `module.exports = class {}` return ts.Debug.assertDefined(decl.right.symbol); } + else if (ts.isSourceFile(decl)) { // json module + return ts.Debug.assertDefined(decl.symbol); + } return ts.Debug.fail(); } // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent, node) { - if (parent.kind === 231 /* VariableDeclaration */) { + if (parent.kind === 232 /* VariableDeclaration */) { var p = parent; return p.name !== node ? undefined : - p.parent.kind === 268 /* CatchClause */ ? undefined : p.parent.parent.kind === 213 /* VariableStatement */ ? p.parent.parent : undefined; + p.parent.kind === 269 /* CatchClause */ ? undefined : p.parent.parent.kind === 214 /* VariableStatement */ ? p.parent.parent : undefined; } else { return parent; @@ -90348,15 +90811,15 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent) ? { isNamedImport: false } : undefined; - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return parent.propertyName ? undefined : { isNamedImport: true }; - case 244 /* ImportClause */: - case 245 /* NamespaceImport */: + case 245 /* ImportClause */: + case 246 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return { isNamedImport: false }; default: @@ -90389,21 +90852,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 186 /* CallExpression */) { + if (node.kind === 187 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 273 /* SourceFile */) { + if (parent.kind === 274 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 239 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 240 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 238 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + return node.kind === 239 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 253 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; + return eq.moduleReference.kind === 254 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -90413,7 +90876,7 @@ var ts; var FindAllReferences; (function (FindAllReferences) { function nodeEntry(node, isInString) { - return { type: "node", node: node, isInString: isInString }; + return { type: "node", node: node.name || node, isInString: isInString }; } FindAllReferences.nodeEntry = nodeEntry; function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position) { @@ -90439,13 +90902,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* 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 === 270 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 271 /* ShorthandPropertyAssignment */) { var result_5 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_5.push(nodeEntry(node)); }); return result_5; @@ -90549,13 +91012,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 183 /* ObjectLiteralExpression */) { + else if (node.kind === 184 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] }; } - else if (node.kind === 204 /* ClassExpression */) { + else if (node.kind === 205 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] @@ -90626,6 +91089,7 @@ var ts; } var moduleReferences = ts.emptyArray; var moduleSourceFile = isModuleSymbol(symbol); + var referencedNode = node; if (moduleSourceFile) { var exportEquals = symbol.exports.get("export=" /* ExportEquals */); // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. @@ -90634,13 +91098,13 @@ var ts; return moduleReferences; // Continue to get references to 'export ='. symbol = ts.skipAlias(exportEquals, checker); - node = undefined; + referencedNode = undefined; } - return ts.concatenate(moduleReferences, getReferencedSymbolsForSymbol(symbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options)); + return ts.concatenate(moduleReferences, getReferencedSymbolsForSymbol(symbol, referencedNode, sourceFiles, sourceFilesSet, checker, cancellationToken, options)); } Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; function isModuleSymbol(symbol) { - return symbol.flags & 1536 /* Module */ && ts.find(symbol.declarations, ts.isSourceFile); + return symbol.flags & 1536 /* Module */ ? ts.find(symbol.declarations, ts.isSourceFile) : undefined; } function getReferencedSymbolsForModule(program, symbol, excludeImportTypeOfExportEquals, sourceFiles, sourceFilesSet) { ts.Debug.assert(!!symbol.valueDeclaration); @@ -90667,10 +91131,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 273 /* SourceFile */: + case 274 /* 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 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push({ type: "node", node: decl.name }); } @@ -90718,7 +91182,7 @@ var ts; searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); } else { - var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.implementations) : [symbol] }); + var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, !!options.implementations) : [symbol] }); // Try to get the smallest valid scope that we can limit our search to; // otherwise we'll need to search globally (i.e. include each file). var scope = getSymbolScope(symbol); @@ -90826,7 +91290,7 @@ var ts; State.prototype.getImportSearches = function (exportSymbol, exportInfo) { if (!this.importTracker) this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); - return this.importTracker(exportSymbol, exportInfo, this.options.isForRename); + return this.importTracker(exportSymbol, exportInfo, !!this.options.isForRename); }; /** @param allSearchSymbols set of additinal symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { @@ -90837,7 +91301,7 @@ var ts; // here appears to be intentional). var _a = searchOptions.text, text = _a === void 0 ? ts.stripQuotes(ts.unescapeLeadingUnderscores((ts.getLocalSymbolForExportDefault(symbol) || symbol).escapedName)) : _a, _b = searchOptions.allSearchSymbols, allSearchSymbols = _b === void 0 ? [symbol] : _b; var escapedText = ts.escapeLeadingUnderscores(text); - var parents = this.options.implementations && location && getParentSymbolsOfPropertyAccess(location, symbol, this.checker); + var parents = this.options.implementations && location ? getParentSymbolsOfPropertyAccess(location, symbol, this.checker) : undefined; return { symbol: symbol, comingFrom: comingFrom, text: text, escapedText: escapedText, parents: parents, allSearchSymbols: allSearchSymbols, includes: function (sym) { return ts.contains(allSearchSymbols, sym); } }; }; /** @@ -90938,13 +91402,14 @@ var ts; } } function getPropertySymbolOfDestructuringAssignment(location, checker) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - checker.getPropertySymbolOfDestructuringAssignment(location); + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) + ? checker.getPropertySymbolOfDestructuringAssignment(location) + : undefined; } function getObjectBindingElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 181 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 182 /* BindingElement */); if (bindingElement && - bindingElement.parent.kind === 179 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 180 /* ObjectBindingPattern */ && ts.isIdentifier(bindingElement.name) && !bindingElement.propertyName) { return bindingElement; @@ -90966,7 +91431,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 === 191 /* FunctionExpression */ || valueDeclaration.kind === 204 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 192 /* FunctionExpression */ || valueDeclaration.kind === 205 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -90976,7 +91441,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 234 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 235 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -90998,14 +91463,14 @@ var ts; return undefined; } var scope; - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; var container = ts.getContainerNode(declaration); if (scope && scope !== container) { // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 273 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 274 /* 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; @@ -91018,23 +91483,32 @@ var ts; // declare module "a" { export type T = number; } // declare module "b" { import { T } from "a"; export const x: T; } // So we must search the whole source file. (Because we will mark the source file as seen, we we won't return to it when searching for imports.) - return exposedByParent ? scope.getSourceFile() : scope; + return exposedByParent ? scope.getSourceFile() : scope; // TODO: GH#18217 } /** Used as a quick check for whether a symbol is used at all in a file (besides its definition). */ function isSymbolReferencedInFile(definition, checker, sourceFile) { - var symbol = checker.getSymbolAtLocation(definition); - if (!symbol) - return true; // Be lenient with invalid code. - return getPossibleSymbolReferenceNodes(sourceFile, symbol.name).some(function (token) { - if (!ts.isIdentifier(token) || token === definition || token.escapedText !== definition.escapedText) - return false; - var referenceSymbol = checker.getSymbolAtLocation(token); - return referenceSymbol === symbol - || checker.getShorthandAssignmentValueSymbol(token.parent) === symbol - || ts.isExportSpecifier(token.parent) && getLocalSymbolForExportSpecifier(token, referenceSymbol, token.parent, checker) === symbol; - }); + return eachSymbolReferenceInFile(definition, checker, sourceFile, function () { return true; }) || false; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; + function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { + var symbol = checker.getSymbolAtLocation(definition); + if (!symbol) + return undefined; + for (var _i = 0, _a = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _i < _a.length; _i++) { + var token = _a[_i]; + if (!ts.isIdentifier(token) || token === definition || token.escapedText !== definition.escapedText) + continue; + var referenceSymbol = checker.getSymbolAtLocation(token); // See GH#19955 for why the type annotation is necessary + if (referenceSymbol === symbol + || checker.getShorthandAssignmentValueSymbol(token.parent) === symbol + || ts.isExportSpecifier(token.parent) && getLocalSymbolForExportSpecifier(token, referenceSymbol, token.parent, checker) === symbol) { + var res = cb(token); + if (res) + return res; + } + } + } + Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile; function getPossibleSymbolReferenceNodes(sourceFile, symbolName, container) { if (container === void 0) { container = sourceFile; } return getPossibleSymbolReferencePositions(sourceFile, symbolName, container).map(function (pos) { return ts.getTouchingPropertyName(sourceFile, pos, /*includeJsDocComment*/ true); }); @@ -91210,7 +91684,8 @@ var ts; if (!(referenceLocation === propertyName && state.options.isForRename)) { var exportKind = referenceLocation.originalKeywordKind === 79 /* DefaultKeyword */ ? 1 /* Default */ : 0 /* Named */; var exportInfo = FindAllReferences.getExportInfo(referenceSymbol, exportKind, state.checker); - ts.Debug.assert(!!exportInfo); + if (!exportInfo) + return ts.Debug.fail(); searchForImportsOfExport(referenceLocation, referenceSymbol, exportInfo, state); } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. @@ -91327,12 +91802,12 @@ var ts; for (var _i = 0, _a = classSymbol.members.get("__constructor" /* Constructor */).declarations; _i < _a.length; _i++) { var decl = _a[_i]; var ctrKeyword = ts.findChildOfKind(decl, 123 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 154 /* Constructor */ && !!ctrKeyword); + ts.Debug.assert(decl.kind === 155 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 153 /* MethodDeclaration */) { + if (decl && decl.kind === 154 /* MethodDeclaration */) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 99 /* ThisKeyword */, function (thisKeyword) { @@ -91346,14 +91821,13 @@ var ts; } /** Find references to `super` in the constructor of an extending class. */ function findSuperConstructorAccesses(cls, addNode) { - var symbol = cls.symbol; - var ctr = symbol.members.get("__constructor" /* Constructor */); + var ctr = cls.symbol.members.get("__constructor" /* Constructor */); if (!ctr) { return; } for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 154 /* Constructor */); + ts.Debug.assert(decl.kind === 155 /* Constructor */); var body = decl.body; if (body) { forEachDescendantOfKind(body, 97 /* SuperKeyword */, function (node) { @@ -91367,13 +91841,13 @@ var ts; function addImplementationReferences(refNode, addReference, state) { // Check if we found a function/propertyAssignment/method with an implementation or initializer if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - addReference(refNode.parent); + addReference(refNode); return; } if (refNode.kind !== 71 /* Identifier */) { return; } - if (refNode.parent.kind === 270 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 271 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -91393,7 +91867,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 212 /* Block */) { + if (body.kind === 213 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -91421,13 +91895,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 192 /* ArrowFunction */: - case 191 /* FunctionExpression */: - case 183 /* ObjectLiteralExpression */: - case 204 /* ClassExpression */: - case 182 /* ArrayLiteralExpression */: + case 193 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 184 /* ObjectLiteralExpression */: + case 205 /* ClassExpression */: + case 183 /* ArrayLiteralExpression */: return true; default: return false; @@ -91480,13 +91954,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -91511,34 +91985,34 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // falls through - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 192 /* 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 === 273 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 274 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -91546,19 +92020,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 204 /* ClassExpression */: - case 234 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 235 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 273 /* SourceFile */: - return container.kind === 273 /* SourceFile */ && !ts.isExternalModule(container); + case 274 /* SourceFile */: + return container.kind === 274 /* SourceFile */ && !ts.isExternalModule(container); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -91643,37 +92117,11 @@ var ts; return cbSymbol(sym, rootSymbol) // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */) && allowBaseTypes(rootSymbol) - ? getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base); }) + ? ts.getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base); }) : undefined); }); } } - /** - * Find symbol of the given property-name and add the symbol to the given result array - * @param symbol a symbol to start searching for the given propertyName - * @param propertyName a name of property to search for - * @param result an array of symbol of found property symbols - * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. - * The value of previousIterationSymbol is undefined when the function is first called. - */ - function getPropertySymbolsFromBaseTypes(symbol, propertyName, checker, cb) { - var seen = ts.createMap(); - return recur(symbol); - function recur(symbol) { - // Use `addToSeen` to ensure we don't infinitely recurse in this situation: - // interface C extends C { - // /*findRef*/propName: string; - // } - if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) - return; - return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { - var type = checker.getTypeAtLocation(typeReference); - var propertySymbol = type && type.symbol && checker.getPropertyOfType(type, propertyName); - // Visit the typeReference as well to see if it directly or indirectly uses that property - return propertySymbol && (ts.firstDefined(checker.getRootSymbols(propertySymbol), cb) || recur(type.symbol)); - }); }); - } - } function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { var checker = state.checker; return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, function (sym, rootSymbol, baseSymbol) { return search.includes(baseSymbol || rootSymbol || sym) @@ -91690,7 +92138,7 @@ var ts; var name = ts.getNameFromPropertyName(node.name); var symbol = contextualType && name && contextualType.getProperty(name); return symbol ? [symbol] : - contextualType && contextualType.isUnion() ? ts.mapDefined(contextualType.types, function (t) { return t.getProperty(name); }) : ts.emptyArray; + contextualType && contextualType.isUnion() ? ts.mapDefined(contextualType.types, function (t) { return t.getProperty(name); }) : ts.emptyArray; // TODO: GH#18217 } /** * Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations @@ -91712,8 +92160,8 @@ var ts; // To achieve that we will keep iterating until the result stabilizes. // Remember the last meaning lastIterationMeaning = meaning; - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var declaration = declarations_10[_i]; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; var declarationMeaning = ts.getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -91774,6 +92222,184 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, preferences) { + var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); + var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + var oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName); + var newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName); + return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { + updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); + updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences); + }); + } + ts.getEditsForFileRename = getEditsForFileRename; + function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName) { + var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); + return function (path) { + var canonicalPath = getCanonicalFileName(path); + if (canonicalPath === canonicalOldPath) + return newFileOrDirPath; + var suffix = ts.tryRemoveDirectoryPrefix(canonicalPath, canonicalOldPath); + return suffix === undefined ? undefined : newFileOrDirPath + "/" + suffix; + }; + } + function updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { + var configFile = program.getCompilerOptions().configFile; + if (!configFile) + return; + var configDir = ts.getDirectoryPath(configFile.fileName); + var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(configFile); + if (!jsonObjectLiteral) + return; + forEachProperty(jsonObjectLiteral, function (property, propertyName) { + switch (propertyName) { + case "files": + case "include": + case "exclude": { + var foundExactMatch = updatePaths(property); + if (!foundExactMatch && propertyName === "include" && ts.isArrayLiteralExpression(property.initializer)) { + var includes = ts.mapDefined(property.initializer.elements, function (e) { return ts.isStringLiteral(e) ? e.text : undefined; }); + var matchers = ts.getFileMatcherPatterns(configDir, /*excludes*/ [], includes, useCaseSensitiveFileNames, currentDirectory); + // If there isn't some include for this, add a new one. + if (!ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { + changeTracker.insertNodeAfter(configFile, ts.last(property.initializer.elements), ts.createStringLiteral(relativePath(newFileOrDirPath))); + } + } + break; + } + case "compilerOptions": + forEachProperty(property.initializer, function (property, propertyName) { + var option = ts.getOptionFromName(propertyName); + if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) { + updatePaths(property); + } + else if (propertyName === "paths") { + forEachProperty(property.initializer, function (pathsProperty) { + if (!ts.isArrayLiteralExpression(pathsProperty.initializer)) + return; + for (var _i = 0, _a = pathsProperty.initializer.elements; _i < _a.length; _i++) { + var e = _a[_i]; + tryUpdateString(e); + } + }); + } + }); + break; + } + }); + function updatePaths(property) { + // Type annotation needed due to #7294 + var elements = ts.isArrayLiteralExpression(property.initializer) ? property.initializer.elements : [property.initializer]; + var foundExactMatch = false; + for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) { + var element = elements_5[_i]; + foundExactMatch = tryUpdateString(element) || foundExactMatch; + } + return foundExactMatch; + } + function tryUpdateString(element) { + if (!ts.isStringLiteral(element)) + return false; + var elementFileName = combinePathsSafe(configDir, element.text); + var updated = oldToNew(elementFileName); + if (updated !== undefined) { + changeTracker.replaceRangeWithText(configFile, createStringRange(element, configFile), relativePath(updated)); + return true; + } + return false; + } + function relativePath(path) { + return ts.getRelativePathFromDirectory(configDir, path, /*ignoreCase*/ !useCaseSensitiveFileNames); + } + } + function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences) { + var _loop_14 = function (sourceFile) { + var newImportFromPath = oldToNew(sourceFile.fileName) || sourceFile.fileName; + var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); + var oldFromNew = newToOld(sourceFile.fileName); + var oldImportFromPath = oldFromNew || sourceFile.fileName; + var oldImportFromDirectory = ts.getDirectoryPath(oldImportFromPath); + updateImportsWorker(sourceFile, changeTracker, function (referenceText) { + if (!ts.pathIsRelative(referenceText)) + return undefined; + var oldAbsolute = combinePathsSafe(oldImportFromDirectory, referenceText); + var newAbsolute = oldToNew(oldAbsolute); + return newAbsolute === undefined ? undefined : ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(newImportFromDirectory, newAbsolute, getCanonicalFileName)); + }, function (importLiteral) { + 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. + // TODO:GH#18217 + ? getSourceFileToImportFromResolved(ts.resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host), oldToNew, program) + : getSourceFileToImport(importLiteral, sourceFile, program, host, oldToNew); + return toImport === undefined ? undefined : ts.moduleSpecifiers.getModuleSpecifier(program, sourceFile, newImportFromPath, toImport, host, preferences); + }); + }; + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + _loop_14(sourceFile); + } + } + function combineNormal(pathA, pathB) { + return ts.normalizePath(ts.combinePaths(pathA, pathB)); + } + function combinePathsSafe(pathA, pathB) { + return ts.ensurePathIsNonModuleName(combineNormal(pathA, pathB)); + } + function getSourceFileToImport(importLiteral, importingSourceFile, program, host, oldToNew) { + var symbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); + if (symbol) { + if (symbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + return undefined; // No need to update if it's an ambient module + var oldFileName = ts.find(symbol.declarations, ts.isSourceFile).fileName; + return oldToNew(oldFileName) || oldFileName; + } + else { + var resolved = host.resolveModuleNames + ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName) + : program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName); + return getSourceFileToImportFromResolved(resolved, oldToNew, program); + } + } + function getSourceFileToImportFromResolved(resolved, oldToNew, program) { + return resolved && ((resolved.resolvedModule && getIfInProgram(resolved.resolvedModule.resolvedFileName)) || ts.firstDefined(resolved.failedLookupLocations, getIfInProgram)); + function getIfInProgram(oldLocation) { + var newLocation = oldToNew(oldLocation); + return program.getSourceFile(oldLocation) || newLocation !== undefined && program.getSourceFile(newLocation) + ? newLocation || oldLocation + : undefined; + } + } + function updateImportsWorker(sourceFile, changeTracker, updateRef, updateImport) { + for (var _i = 0, _a = sourceFile.referencedFiles; _i < _a.length; _i++) { + var ref = _a[_i]; + var updated = updateRef(ref.fileName); + if (updated !== undefined && updated !== sourceFile.text.slice(ref.pos, ref.end)) + changeTracker.replaceRangeWithText(sourceFile, ref, updated); + } + for (var _b = 0, _c = sourceFile.imports; _b < _c.length; _b++) { + var importStringLiteral = _c[_b]; + var updated = updateImport(importStringLiteral); + if (updated !== undefined && updated !== importStringLiteral.text) + changeTracker.replaceRangeWithText(sourceFile, createStringRange(importStringLiteral, sourceFile), updated); + } + } + function createStringRange(node, sourceFile) { + return ts.createTextRange(node.getStart(sourceFile) + 1, node.end - 1); + } + function forEachProperty(objectLiteral, cb) { + if (!ts.isObjectLiteralExpression(objectLiteral)) + return; + for (var _i = 0, _a = objectLiteral.properties; _i < _a.length; _i++) { + var property = _a[_i]; + if (ts.isPropertyAssignment(property) && ts.isStringLiteral(property.name)) { + cb(property, property.name.text); + } + } + } +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var GoToDefinition; (function (GoToDefinition) { @@ -91786,10 +92412,11 @@ var ts; if (node === sourceFile) { return undefined; } + var parent = node.parent; // Labels if (ts.isJumpStatementTarget(node)) { var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 } var typeChecker = program.getTypeChecker(); var symbol = getSymbol(node, typeChecker); @@ -91805,7 +92432,7 @@ var ts; // If this is the original constructor definition, parent is the class. return typeChecker.getRootSymbols(symbol).some(function (s) { return calledDeclaration.symbol === s || calledDeclaration.symbol.parent === s; }) || // TODO: GH#23742 Following check shouldn't be necessary if 'require' is an alias - symbol.declarations.some(function (d) { return ts.isVariableDeclaration(d) && d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ false); }) + symbol.declarations.some(function (d) { return ts.isVariableDeclaration(d) && !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ false); }) ? [sigInfo] : [sigInfo].concat(getDefinitionFromSymbol(typeChecker, symbol, node)); } @@ -91814,7 +92441,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 270 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 271 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -91829,9 +92456,9 @@ var ts; // pr/*destination*/op1: number // } // bar(({pr/*goto*/op1})=>{}); - if (ts.isPropertyName(node) && ts.isBindingElement(node.parent) && ts.isObjectBindingPattern(node.parent.parent) && - (node === (node.parent.propertyName || node.parent.name))) { - var type = typeChecker.getTypeAtLocation(node.parent.parent); + if (ts.isPropertyName(node) && ts.isBindingElement(parent) && ts.isObjectBindingPattern(parent.parent) && + (node === (parent.propertyName || parent.name))) { + var type = typeChecker.getTypeAtLocation(parent.parent); if (type) { var propSymbols = ts.getPropertySymbolsFromType(type, node); if (propSymbols) { @@ -91866,7 +92493,7 @@ var ts; var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); - var file_17 = reference && program.getSourceFile(reference.resolvedFileName); + var file_17 = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217 return file_17 && { fileName: typeReferenceDirective.fileName, file: file_17 }; } return undefined; @@ -91883,7 +92510,7 @@ var ts; if (!type) { return undefined; } - if (type.isUnion() && !(type.flags & 16 /* Enum */)) { + if (type.isUnion() && !(type.flags & 32 /* Enum */)) { return ts.flatMap(type.types, function (t) { return t.symbol && getDefinitionFromSymbol(typeChecker, t.symbol, node); }); } return type.symbol && getDefinitionFromSymbol(typeChecker, type.symbol, node); @@ -91941,11 +92568,11 @@ var ts; return true; } switch (declaration.kind) { - case 244 /* ImportClause */: - case 242 /* ImportEqualsDeclaration */: + case 245 /* ImportClause */: + case 243 /* ImportEqualsDeclaration */: return true; - case 247 /* ImportSpecifier */: - return declaration.parent.kind === 246 /* NamedImports */; + case 248 /* ImportSpecifier */: + return declaration.parent.kind === 247 /* NamedImports */; default: return false; } @@ -92009,14 +92636,14 @@ var ts; kind: "script" /* scriptElement */, name: name, containerName: undefined, - containerKind: undefined + containerKind: undefined, }; } /** Returns a CallLikeExpression where `node` is the target being invoked. */ function getAncestorCallLikeExpression(node) { var target = climbPastManyPropertyAccesses(node); var callLike = target.parent; - return callLike && ts.isCallLikeExpression(callLike) && ts.getInvokedExpression(callLike) === target && callLike; + return callLike && ts.isCallLikeExpression(callLike) && ts.getInvokedExpression(callLike) === target ? callLike : undefined; } function climbPastManyPropertyAccesses(node) { return ts.isRightSideOfPropertyAccess(node) ? climbPastManyPropertyAccesses(node.parent) : node; @@ -92104,11 +92731,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 292 /* JSDocParameterTag */: - case 297 /* JSDocPropertyTag */: + case 293 /* JSDocParameterTag */: + case 298 /* JSDocPropertyTag */: return [declaration]; - case 291 /* JSDocCallbackTag */: - case 296 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -92129,16 +92756,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 289 /* JSDocAugmentsTag */: + case 290 /* JSDocAugmentsTag */: return withNode(tag.class); - case 295 /* JSDocTemplateTag */: + case 296 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 294 /* JSDocTypeTag */: + case 295 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: - case 297 /* JSDocPropertyTag */: - case 292 /* JSDocParameterTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 298 /* JSDocPropertyTag */: + case 293 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -92220,7 +92847,7 @@ var ts; if (!ts.isIdentifier(param.name)) return undefined; var name = param.name.text; - if (jsdoc.tags.some(function (t) { return t !== tag && ts.isJSDocParameterTag(t) && ts.isIdentifier(t.name) && t.name.escapedText === name; }) + if (jsdoc.tags.some(function (t) { return t !== tag && ts.isJSDocParameterTag(t) && ts.isIdentifier(t.name) && t.name.escapedText === name; }) // TODO: GH#18217 || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } @@ -92269,7 +92896,7 @@ var ts; return undefined; } var tokenAtPos = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); - var tokenStart = tokenAtPos.getStart(); + var tokenStart = tokenAtPos.getStart(sourceFile); if (!tokenAtPos || tokenStart < position) { return undefined; } @@ -92278,7 +92905,7 @@ var ts; return undefined; } var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters; - if (commentOwner.getStart() < position) { + if (commentOwner.getStart(sourceFile) < position) { return undefined; } if (!parameters || parameters.length === 0) { @@ -92290,18 +92917,6 @@ var ts; var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; // replace non-whitespace characters in prefix with spaces. var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); - var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); - var docParams = ""; - for (var i = 0; i < parameters.length; i++) { - var currentName = parameters[i].name; - var paramName = currentName.kind === 71 /* Identifier */ ? currentName.escapedText : "param" + i; - if (isJavaScriptFile) { - docParams += indentationStr + " * @param {any} " + paramName + newLine; - } - else { - docParams += indentationStr + " * @param " + paramName + newLine; - } - } // A doc comment consists of the following // * The opening comment line // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) @@ -92312,29 +92927,37 @@ var ts; var preamble = "/**" + newLine + indentationStr + " * "; var result = preamble + newLine + - docParams + + parameterDocComments(parameters, ts.hasJavaScriptFileExtension(sourceFile.fileName), indentationStr, newLine) + indentationStr + " */" + (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; + function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { + return parameters.map(function (_a, i) { + var name = _a.name, dotDotDotToken = _a.dotDotDotToken; + var paramName = name.kind === 71 /* Identifier */ ? name.text : "param" + i; + var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; + return indentationStr + " * @param " + type + paramName + newLine; + }).join(""); + } function getCommentOwnerInfo(tokenAtPos) { for (var commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: - case 152 /* MethodSignature */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: + case 153 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 150 /* PropertySignature */: - case 237 /* EnumDeclaration */: - case 272 /* EnumMember */: - case 236 /* TypeAliasDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 151 /* PropertySignature */: + case 238 /* EnumDeclaration */: + case 273 /* EnumMember */: + case 237 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 213 /* VariableStatement */: { + case 214 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -92342,14 +92965,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 273 /* SourceFile */: + case 274 /* SourceFile */: return undefined; - case 238 /* ModuleDeclaration */: + case 239 /* 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 === 238 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 199 /* BinaryExpression */: { + return commentOwner.parent.kind === 239 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 200 /* BinaryExpression */: { var be = commentOwner; if (ts.getSpecialPropertyAssignmentKind(be) === 0 /* None */) { return undefined; @@ -92369,16 +92992,16 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 190 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 191 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return rightHandSide.parameters; - case 204 /* ClassExpression */: { + case 205 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); - return ctr && ctr.parameters; + return ctr ? ctr.parameters : ts.emptyArray; } } return ts.emptyArray; @@ -92562,7 +93185,8 @@ var ts; } // Add the cached typing locations for inferred typings that are already installed packageNameToTypingLocation.forEach(function (typing, name) { - if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && isTypingUpToDate(typing, typesRegistry.get(name))) { + var registryEntry = typesRegistry.get(name); + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && registryEntry !== undefined && isTypingUpToDate(typing, registryEntry)) { inferredTypings.set(name, typing.typingLocation); } }); @@ -92589,7 +93213,7 @@ var ts; return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { - inferredTypings.set(typingName, undefined); + inferredTypings.set(typingName, undefined); // TODO: GH#18217 } } function addInferredTypings(typingNames, message) { @@ -92740,7 +93364,7 @@ var ts; case 0 /* Ok */: return ts.Debug.fail(); // Shouldn't have called this. default: - ts.Debug.assertNever(result); + throw ts.Debug.assertNever(result); } } JsTyping.renderPackageNameValidationFailure = renderPackageNameValidationFailure; @@ -92756,7 +93380,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_14 = function (sourceFile) { + var _loop_15 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */)) { return "continue"; @@ -92768,7 +93392,7 @@ var ts; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { var sourceFile = sourceFiles_7[_i]; - _loop_14(sourceFile); + _loop_15(sourceFile); } rawItems.sort(compareNavigateToItems); if (maxResultCount !== undefined) { @@ -92784,12 +93408,12 @@ var ts; if (!match) { return; // continue to next named declarations } - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_i]; if (!shouldKeepItem(declaration, checker)) continue; if (patternMatcher.patternContainsDots) { - var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); + var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); // TODO: GH#18217 if (fullMatch) { rawItems.push({ name: name, fileName: fileName, matchKind: fullMatch.kind, isCaseSensitive: fullMatch.isCaseSensitive, declaration: declaration }); } @@ -92802,9 +93426,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 244 /* ImportClause */: - case 247 /* ImportSpecifier */: - case 242 /* ImportEqualsDeclaration */: + case 245 /* ImportClause */: + case 248 /* ImportSpecifier */: + case 243 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -92818,7 +93442,7 @@ var ts; containers.unshift(ts.getTextOfIdentifierOrLiteral(name)); return true; } - else if (name && name.kind === 146 /* ComputedPropertyName */) { + else if (name && name.kind === 147 /* ComputedPropertyName */) { return tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ true); } else { @@ -92850,16 +93474,16 @@ 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.kind === 146 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { + if (name.kind === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } // Now, walk up our containers, adding all their names to the container array. - declaration = ts.getContainerNode(declaration); - while (declaration) { - if (!tryAddSingleDeclarationName(declaration, containers)) { + var container = ts.getContainerNode(declaration); + while (container) { + if (!tryAddSingleDeclarationName(container, containers)) { return undefined; } - declaration = ts.getContainerNode(declaration); + container = ts.getContainerNode(container); } return containers; } @@ -92882,7 +93506,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ + containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ // TODO: GH#18217 Just use `container ? ...` }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -93016,7 +93640,7 @@ var ts; return; } switch (node.kind) { - case 154 /* Constructor */: + case 155 /* 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); @@ -93028,21 +93652,21 @@ var ts; } } break; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 153 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 244 /* ImportClause */: + case 245 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -93054,7 +93678,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 245 /* NamespaceImport */) { + if (namedBindings.kind === 246 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -93065,8 +93689,8 @@ var ts; } } break; - case 181 /* BindingElement */: - case 231 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 232 /* VariableDeclaration */: var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -93087,12 +93711,12 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; - case 192 /* ArrowFunction */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -93102,9 +93726,9 @@ var ts; } endNode(); break; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -93112,18 +93736,18 @@ var ts; } endNode(); break; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 251 /* ExportSpecifier */: - case 242 /* ImportEqualsDeclaration */: - case 159 /* IndexSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 236 /* TypeAliasDeclaration */: + case 252 /* ExportSpecifier */: + case 243 /* ImportEqualsDeclaration */: + case 160 /* IndexSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 237 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 199 /* BinaryExpression */: { + case 200 /* BinaryExpression */: { var special = ts.getSpecialPropertyAssignmentKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -93202,12 +93826,12 @@ var ts; return false; } switch (a.kind) { - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -93216,7 +93840,8 @@ 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) { - return a.body.kind === b.body.kind && (a.body.kind !== 238 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + // TODO: GH#18217 + return a.body.kind === b.body.kind && (a.body.kind !== 239 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -93237,7 +93862,7 @@ var ts; children.sort(compareChildren); } function compareChildren(child1, child2) { - return ts.compareStringsCaseSensitiveUI(tryGetName(child1.node), tryGetName(child2.node)) + return ts.compareStringsCaseSensitiveUI(tryGetName(child1.node), tryGetName(child2.node)) // TODO: GH#18217 || ts.compareValues(navigationBarNodeKind(child1), navigationBarNodeKind(child2)); } /** @@ -93246,24 +93871,24 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 238 /* ModuleDeclaration */) { + if (node.kind === 239 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); if (declName) { - return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); + return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 204 /* ClassExpression */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 205 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 238 /* ModuleDeclaration */) { + if (node.kind === 239 /* ModuleDeclaration */) { return getModuleName(node); } var name = ts.getNameOfDeclaration(node); @@ -93274,16 +93899,16 @@ var ts; } } switch (node.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 192 /* ArrowFunction */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 193 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -93291,13 +93916,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return "constructor"; - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: return "new()"; - case 157 /* CallSignature */: + case 158 /* CallSignature */: return "()"; - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: return "[]"; default: return ""; @@ -93321,25 +93946,25 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 237 /* EnumDeclaration */: - case 235 /* InterfaceDeclaration */: - case 238 /* ModuleDeclaration */: - case 273 /* SourceFile */: - case 236 /* TypeAliasDeclaration */: - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 238 /* EnumDeclaration */: + case 236 /* InterfaceDeclaration */: + case 239 /* ModuleDeclaration */: + case 274 /* SourceFile */: + case 237 /* TypeAliasDeclaration */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: return true; - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 231 /* VariableDeclaration */: + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 232 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 192 /* ArrowFunction */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -93349,19 +93974,19 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 239 /* ModuleBlock */: - case 273 /* SourceFile */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: + case 240 /* ModuleBlock */: + case 274 /* SourceFile */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: return true; default: return hasSomeImportantChild(item); } } function hasSomeImportantChild(item) { - return ts.forEach(item.children, function (child) { + return ts.some(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 231 /* VariableDeclaration */ && childKind !== 181 /* BindingElement */; + return childKind !== 232 /* VariableDeclaration */ && childKind !== 182 /* BindingElement */; }); } } @@ -93417,7 +94042,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 238 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -93428,16 +94053,16 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 238 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 239 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 } function isComputedProperty(member) { - return !member.name || member.name.kind === 146 /* ComputedPropertyName */; + return !member.name || member.name.kind === 147 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 273 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 274 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 231 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 232 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -93447,16 +94072,16 @@ var ts; return ts.declarationNameToString(node.name); } // See if it is a var initializer. If so, use the var name. - else if (node.parent.kind === 231 /* VariableDeclaration */) { + else if (node.parent.kind === 232 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (node.parent.kind === 199 /* BinaryExpression */ && + else if (node.parent.kind === 200 /* BinaryExpression */ && node.parent.operatorToken.kind === 58 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name - else if (node.parent.kind === 269 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 270 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } // Default exports are named "default" @@ -93469,9 +94094,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 192 /* ArrowFunction */: - case 191 /* FunctionExpression */: - case 204 /* ClassExpression */: + case 193 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 205 /* ClassExpression */: return true; default: return false; @@ -93501,7 +94126,7 @@ var ts; organizeImportsWorker(topLevelExportDecls, coalesceExports); for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) { var ambientModule = _a[_i]; - var ambientModuleBody = getModuleBlock(ambientModule); + var ambientModuleBody = getModuleBlock(ambientModule); // TODO: GH#18217 var ambientModuleImportDecls = ambientModuleBody.statements.filter(ts.isImportDeclaration); organizeImportsWorker(ambientModuleImportDecls, coalesceAndOrganizeImports); var ambientModuleExportDecls = ambientModuleBody.statements.filter(ts.isExportDeclaration); @@ -93549,12 +94174,12 @@ var ts; OrganizeImports.organizeImports = organizeImports; function getModuleBlock(moduleDecl) { var body = moduleDecl.body; - return body && !ts.isIdentifier(body) && (ts.isModuleBlock(body) ? body : getModuleBlock(body)); + return body && !ts.isIdentifier(body) ? (ts.isModuleBlock(body) ? body : getModuleBlock(body)) : undefined; } function removeUnusedImports(oldImports, sourceFile, program) { var typeChecker = program.getTypeChecker(); var jsxNamespace = typeChecker.getJsxNamespace(); - var jsxContext = sourceFile.languageVariant === 1 /* JSX */ && program.getCompilerOptions().jsx; + var jsxElementsPresent = !!(sourceFile.transformFlags & 4 /* ContainsJsx */); var usedImports = []; for (var _i = 0, oldImports_1 = oldImports; _i < oldImports_1.length; _i++) { var importDecl = oldImports_1[_i]; @@ -93592,8 +94217,8 @@ var ts; } return usedImports; function isDeclarationUsed(identifier) { - // The JSX factory symbol is always used. - return jsxContext && (identifier.text === jsxNamespace) || ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile); + // The JSX factory symbol is always used if JSX elements are present - even if they are not allowed. + return jsxElementsPresent && (identifier.text === jsxNamespace) || ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile); } } function getExternalModuleName(specifier) { @@ -93619,16 +94244,16 @@ var ts; if (defaultImports.length === 1 && namespaceImports.length === 1 && namedImports.length === 0) { // Add the namespace import to the existing default ImportDeclaration. var defaultImport = defaultImports[0]; - coalescedImports.push(updateImportDeclarationAndClause(defaultImport, defaultImport.importClause.name, namespaceImports[0].importClause.namedBindings)); + coalescedImports.push(updateImportDeclarationAndClause(defaultImport, defaultImport.importClause.name, namespaceImports[0].importClause.namedBindings)); // TODO: GH#18217 return coalescedImports; } var sortedNamespaceImports = ts.stableSort(namespaceImports, function (i1, i2) { return compareIdentifiers(i1.importClause.namedBindings.name, i2.importClause.namedBindings.name); - }); + }); // TODO: GH#18217 for (var _i = 0, sortedNamespaceImports_1 = sortedNamespaceImports; _i < sortedNamespaceImports_1.length; _i++) { var namespaceImport = sortedNamespaceImports_1[_i]; // Drop the name, if any - coalescedImports.push(updateImportDeclarationAndClause(namespaceImport, /*name*/ undefined, namespaceImport.importClause.namedBindings)); + coalescedImports.push(updateImportDeclarationAndClause(namespaceImport, /*name*/ undefined, namespaceImport.importClause.namedBindings)); // TODO: GH#18217 } if (defaultImports.length === 0 && namedImports.length === 0) { return coalescedImports; @@ -93641,10 +94266,10 @@ var ts; else { for (var _b = 0, defaultImports_1 = defaultImports; _b < defaultImports_1.length; _b++) { var defaultImport = defaultImports_1[_b]; - newImportSpecifiers.push(ts.createImportSpecifier(ts.createIdentifier("default"), defaultImport.importClause.name)); + newImportSpecifiers.push(ts.createImportSpecifier(ts.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217 } } - newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); + newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217 var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers); var importDecl = defaultImports.length > 0 ? defaultImports[0] @@ -93655,7 +94280,7 @@ var ts; : ts.createNamedImports(ts.emptyArray) : namedImports.length === 0 ? ts.createNamedImports(sortedImportSpecifiers) - : ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); + : ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); // TODO: GH#18217 coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, newNamedImports)); return coalescedImports; /* @@ -93749,7 +94374,8 @@ var ts; } OrganizeImports.coalesceExports = coalesceExports; function updateImportDeclarationAndClause(importDeclaration, name, namedBindings) { - return ts.updateImportDeclaration(importDeclaration, importDeclaration.decorators, importDeclaration.modifiers, ts.updateImportClause(importDeclaration.importClause, name, namedBindings), importDeclaration.moduleSpecifier); + return ts.updateImportDeclaration(importDeclaration, importDeclaration.decorators, importDeclaration.modifiers, ts.updateImportClause(importDeclaration.importClause, name, namedBindings), // TODO: GH#18217 + importDeclaration.moduleSpecifier); } function sortSpecifiers(specifiers) { return ts.stableSort(specifiers, function (s1, s2) { @@ -93773,73 +94399,6 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; -(function (ts) { - function getEditsForFileRename(program, oldFilePath, newFilePath, host, formatContext) { - var pathUpdater = getPathUpdater(oldFilePath, newFilePath, host); - return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { - updateTsconfigFiles(program, changeTracker, oldFilePath, newFilePath); - for (var _i = 0, _a = getImportsToUpdate(program, oldFilePath, host); _i < _a.length; _i++) { - var _b = _a[_i], sourceFile = _b.sourceFile, toUpdate = _b.toUpdate; - var newPath = pathUpdater(isRef(toUpdate) ? toUpdate.fileName : toUpdate.text); - if (newPath !== undefined) { - var range = isRef(toUpdate) ? toUpdate : createStringRange(toUpdate, sourceFile); - changeTracker.replaceRangeWithText(sourceFile, range, isRef(toUpdate) ? newPath : ts.removeFileExtension(newPath)); - } - } - }); - } - ts.getEditsForFileRename = getEditsForFileRename; - function updateTsconfigFiles(program, changeTracker, oldFilePath, newFilePath) { - var configFile = program.getCompilerOptions().configFile; - var oldFile = ts.getTsConfigPropArrayElementValue(configFile, "files", oldFilePath); - if (oldFile) { - changeTracker.replaceRangeWithText(configFile, createStringRange(oldFile, configFile), newFilePath); - } - } - function isRef(toUpdate) { - return "fileName" in toUpdate; - } - function getImportsToUpdate(program, oldFilePath, host) { - var checker = program.getTypeChecker(); - var result = []; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { - var ref = _c[_b]; - if (!program.getSourceFileFromReference(sourceFile, ref) && ts.resolveTripleslashReference(ref.fileName, sourceFile.fileName) === oldFilePath) { - result.push({ sourceFile: sourceFile, toUpdate: ref }); - } - } - for (var _d = 0, _e = sourceFile.imports; _d < _e.length; _d++) { - var importStringLiteral = _e[_d]; - // If it resolved to something already, ignore. - if (checker.getSymbolAtLocation(importStringLiteral)) - continue; - var resolved = host.resolveModuleNames - ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importStringLiteral.text, sourceFile.fileName) - : program.getResolvedModuleWithFailedLookupLocationsFromCache(importStringLiteral.text, sourceFile.fileName); - if (resolved && ts.contains(resolved.failedLookupLocations, oldFilePath)) { - result.push({ sourceFile: sourceFile, toUpdate: importStringLiteral }); - } - } - } - return result; - } - function getPathUpdater(oldFilePath, newFilePath, host) { - // Get the relative path from old to new location, and append it on to the end of imports and normalize. - var rel = ts.getRelativePathFromFile(oldFilePath, newFilePath, ts.createGetCanonicalFileName(ts.hostUsesCaseSensitiveFileNames(host))); - return function (oldPath) { - if (!ts.pathIsRelative(oldPath)) - return; - return ts.ensurePathIsNonModuleName(ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(oldPath), rel))); - }; - } - function createStringRange(node, sourceFile) { - return ts.createTextRange(node.getStart(sourceFile) + 1, node.end - 1); - } -})(ts || (ts = {})); -/* @internal */ -var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { @@ -93964,24 +94523,24 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 212 /* Block */: + case 213 /* Block */: if (ts.isFunctionBlock(n)) { - return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 192 /* ArrowFunction */); + return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 193 /* ArrowFunction */); } // Check if the block is standalone, or 'attached' to some parent statement. // 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 217 /* DoStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 219 /* ForStatement */: - case 216 /* IfStatement */: - case 218 /* WhileStatement */: - case 225 /* WithStatement */: - case 268 /* CatchClause */: + case 218 /* DoStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 220 /* ForStatement */: + case 217 /* IfStatement */: + case 219 /* WhileStatement */: + case 226 /* WithStatement */: + case 269 /* CatchClause */: return spanForNode(n.parent); - case 229 /* TryStatement */: + case 230 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -93996,16 +94555,16 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return spanForNode(n.parent); - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 240 /* CaseBlock */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 241 /* CaseBlock */: return spanForNode(n); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 21 /* OpenBracketToken */); } function spanForObjectOrArrayLiteral(node, open) { @@ -94075,7 +94634,7 @@ var ts; // First, check that the last part of the dot separated pattern matches the name of the // candidate. If not, then there's no point in proceeding and doing the more // expensive work. - var candidateMatch = matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments), stringToWordSpans); + var candidateMatch = matchSegment(candidate, ts.last(dotSeparatedSegments), stringToWordSpans); if (!candidateMatch) { return undefined; } @@ -94316,13 +94875,13 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_15 = function (start) { + var _loop_16 = 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_4 = _loop_15(start); + var state_4 = _loop_16(start); if (typeof state_4 === "object") return state_4.value; } @@ -94595,7 +95154,7 @@ var ts; else { if (token === 71 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -94626,7 +95185,7 @@ var ts; } if (token === 18 /* CloseBraceToken */) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -94642,7 +95201,7 @@ var ts; token = nextToken(); if (token === 71 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -94672,7 +95231,7 @@ var ts; } if (token === 18 /* CloseBraceToken */) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -94684,7 +95243,7 @@ var ts; } else if (token === 39 /* AsteriskToken */) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -94808,7 +95367,7 @@ var ts; importedFiles.push(decl.ref); } } - return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: pragmaContext.hasNoDefaultLib, ambientExternalModules: undefined }; + return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: !!pragmaContext.hasNoDefaultLib, ambientExternalModules: undefined }; } else { // for global scripts ambient modules still can have augmentations - look for ambient modules with depth > 0 @@ -94827,7 +95386,7 @@ var ts; } } } - return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: pragmaContext.hasNoDefaultLib, ambientExternalModules: ambientModuleNames }; + return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: !!pragmaContext.hasNoDefaultLib, ambientExternalModules: ambientModuleNames }; } } ts.preProcessFile = preProcessFile; @@ -94856,36 +95415,30 @@ var ts; Rename.getRenameInfo = getRenameInfo; function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) + return; // Only allow a symbol to be renamed if it actually has at least one declaration. - if (symbol) { - var declarations = symbol.declarations; - if (declarations && declarations.length > 0) { - // Disallow rename for elements that are defined in the standard TypeScript library. - if (declarations.some(isDefinedInLibraryFile)) { - 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 === 79 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { - return undefined; - } - // Can't rename a module name. - if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) - return undefined; - var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteral(node) && node.parent.kind === 146 /* 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(symbol), node, sourceFile); - } + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) + return; + // Disallow rename for elements that are defined in the standard TypeScript library. + if (declarations.some(isDefinedInLibraryFile)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } - else if (ts.isStringLiteral(node)) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); - } - return getRenameInfoSuccess(node.text, node.text, "var" /* variableElement */, "" /* none */, node, sourceFile); + // Cannot rename `default` as in `import { default as foo } from "./someModule"; + if (ts.isIdentifier(node) && node.originalKeywordKind === 79 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + return undefined; } + // Can't rename a module name. + if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) + return undefined; + var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteral(node) && node.parent.kind === 147 /* 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(symbol), node, sourceFile); } function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { return { @@ -94899,6 +95452,7 @@ var ts; }; } function getRenameInfoError(diagnostic) { + // TODO: GH#18217 return { canRename: false, localizedErrorMessage: ts.getLocaleSpecificMessage(diagnostic), @@ -94944,7 +95498,12 @@ var ts; ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; ArgumentListKind[ArgumentListKind["JSXAttributesArguments"] = 3] = "JSXAttributesArguments"; - })(ArgumentListKind = SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); + })(ArgumentListKind || (ArgumentListKind = {})); + var InvocationKind; + (function (InvocationKind) { + InvocationKind[InvocationKind["Call"] = 0] = "Call"; + InvocationKind[InvocationKind["TypeArgs"] = 1] = "TypeArgs"; + })(InvocationKind || (InvocationKind = {})); function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); // Decide whether to show signature help @@ -94958,11 +95517,9 @@ var ts; return undefined; cancellationToken.throwIfCancellationRequested(); // Semantic filtering of signature help - var call = argumentInfo.invocation; - var candidates = []; - var resolvedSignature = typeChecker.getResolvedSignature(call, candidates, argumentInfo.argumentCount); + var candidateInfo = getCandidateInfo(argumentInfo, typeChecker); cancellationToken.throwIfCancellationRequested(); - if (!candidates.length) { + if (!candidateInfo) { // We didn't have any sig help items produced by the TS compiler. If this is a JS // file, then see if we can figure out anything better. if (ts.isSourceFileJavaScript(sourceFile)) { @@ -94970,54 +95527,76 @@ var ts; } return undefined; } - return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo, typeChecker); }); + return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker); }); } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; - function createJavaScriptSignatureHelpItems(argumentInfo, program, cancellationToken) { - if (argumentInfo.invocation.kind !== 186 /* CallExpression */) { - return undefined; + function getCandidateInfo(argumentInfo, checker) { + var invocation = argumentInfo.invocation; + if (invocation.kind === 0 /* Call */) { + var candidates = []; + var resolvedSignature = checker.getResolvedSignature(invocation.node, candidates, argumentInfo.argumentCount); // TODO: GH#18217 + return candidates.length === 0 ? undefined : { candidates: candidates, resolvedSignature: resolvedSignature }; } + else { + var type = checker.getTypeAtLocation(invocation.called); // TODO: GH#18217 + var signatures = ts.isNewExpression(invocation.called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); + var candidates = signatures.filter(function (candidate) { return !!candidate.typeParameters && candidate.typeParameters.length >= argumentInfo.argumentCount; }); + return candidates.length === 0 ? undefined : { candidates: candidates, resolvedSignature: ts.first(candidates) }; + } + } + function createJavaScriptSignatureHelpItems(argumentInfo, program, cancellationToken) { // See if we can find some symbol with the call expression name that has call signatures. - var callExpression = argumentInfo.invocation; - var expression = callExpression.expression; + var expression = getExpressionFromInvocation(argumentInfo.invocation); var name = ts.isIdentifier(expression) ? expression : ts.isPropertyAccessExpression(expression) ? expression.name : undefined; if (!name || !name.escapedText) { return undefined; } var typeChecker = program.getTypeChecker(); - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; + var _loop_17 = function (sourceFile) { var nameToDeclarations = sourceFile.getNamedDeclarations(); var declarations = nameToDeclarations.get(name.text); if (declarations) { - var _loop_16 = function (declaration) { + var _loop_18 = function (declaration) { var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); if (type) { var callSignatures_1 = type.getCallSignatures(); if (callSignatures_1 && callSignatures_1.length) { - return { value: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(callSignatures_1, callSignatures_1[0], argumentInfo, typeChecker); }) }; + return { value: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(callSignatures_1, callSignatures_1[0], argumentInfo, sourceFile, typeChecker); }) }; } } } }; - for (var _b = 0, declarations_12 = declarations; _b < declarations_12.length; _b++) { - var declaration = declarations_12[_b]; - var state_5 = _loop_16(declaration); - if (typeof state_5 === "object") - return state_5.value; + for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { + var declaration = declarations_13[_i]; + var state_6 = _loop_18(declaration); + if (typeof state_6 === "object") + return state_6; } } + }; + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + var state_5 = _loop_17(sourceFile); + if (typeof state_5 === "object") + return state_5.value; } } + function getArgumentInfoForCompletions(node, position, sourceFile) { + var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile); + return !info || info.kind === 0 /* TypeArguments */ || info.invocation.kind === 1 /* TypeArgs */ ? undefined + : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex }; + } + SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions; /** * Returns relevant information for the argument list and the current argument if we are * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (ts.isCallOrNewExpression(node.parent)) { - var invocation = node.parent; + var parent = node.parent; + if (ts.isCallOrNewExpression(parent)) { + var invocation = parent; var list = void 0; var argumentIndex = void 0; // There are 3 cases to handle: @@ -95037,7 +95616,7 @@ var ts; if (node.kind === 27 /* LessThanToken */ || node.kind === 19 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. - list = getChildListThatStartsWithOpenerToken(invocation, node, sourceFile); + list = getChildListThatStartsWithOpenerToken(parent, node, sourceFile); ts.Debug.assert(list !== undefined); argumentIndex = 0; } @@ -95053,60 +95632,66 @@ var ts; return undefined; argumentIndex = getArgumentIndex(list, node); } - var kind = invocation.typeArguments && invocation.typeArguments.pos === list.pos ? 0 /* TypeArguments */ : 1 /* CallArguments */; + var kind = parent.typeArguments && parent.typeArguments.pos === list.pos ? 0 /* TypeArguments */ : 1 /* CallArguments */; var argumentCount = getArgumentCount(list); if (argumentIndex !== 0) { ts.Debug.assertLessThan(argumentIndex, argumentCount); } var argumentsSpan = getApplicableSpanForArguments(list, sourceFile); - return { kind: kind, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; + return { kind: kind, invocation: { kind: 0 /* Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } - else if (node.kind === 13 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 188 /* TaggedTemplateExpression */) { + else if (ts.isNoSubstitutionTemplateLiteral(node) && ts.isTaggedTemplateExpression(parent)) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. - if (ts.isInsideTemplateLiteral(node, position)) { - return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0, sourceFile); + if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { + return getArgumentListInfoForTemplate(parent, /*argumentIndex*/ 0, sourceFile); } } - else if (node.kind === 14 /* TemplateHead */ && node.parent.parent.kind === 188 /* TaggedTemplateExpression */) { - var templateExpression = node.parent; + else if (ts.isTemplateHead(node) && parent.parent.kind === 189 /* TaggedTemplateExpression */) { + var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 201 /* TemplateExpression */); - var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; + ts.Debug.assert(templateExpression.kind === 202 /* TemplateExpression */); + var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 210 /* TemplateSpan */ && node.parent.parent.parent.kind === 188 /* TaggedTemplateExpression */) { - var templateSpan = node.parent; - var templateExpression = templateSpan.parent; - var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 201 /* TemplateExpression */); + else if (ts.isTemplateSpan(parent) && ts.isTaggedTemplateExpression(parent.parent.parent)) { + var templateSpan = parent; + var tagExpression = parent.parent.parent; // If we're just after a template tail, don't show signature help. - if (node.kind === 16 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (ts.isTemplateTail(node) && !ts.isInsideTemplateLiteral(node, position, sourceFile)) { return undefined; } - var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); - var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); + var spanIndex = templateSpan.parent.templateSpans.indexOf(templateSpan); + var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position, sourceFile); return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent && ts.isJsxOpeningLikeElement(node.parent)) { + else if (ts.isJsxOpeningLikeElement(parent)) { // Provide a signature help for JSX opening element or JSX self-closing element. // This is not guarantee that JSX tag-name is resolved into stateless function component. (that is done in "getSignatureHelpItems") // i.e // export function MainButton(props: ButtonProps, context: any): JSX.Element { ... } // 0 && ts.lastOrUndefined(listChildren).kind === 26 /* CommaToken */) { + if (listChildren.length > 0 && ts.last(listChildren).kind === 26 /* CommaToken */) { argumentCount++; } return argumentCount; } // spanIndex is either the index for a given template span. // This does not give appropriate results for a NoSubstitutionTemplateLiteral - function getArgumentIndexForTemplatePiece(spanIndex, node, position) { + function getArgumentIndexForTemplatePiece(spanIndex, node, position, sourceFile) { // Because the TemplateStringsArray is the first argument, we have to offset each substitution expression by 1. // There are three cases we can encounter: // 1. We are precisely in the template literal (argIndex = 0). @@ -95167,8 +95752,8 @@ var ts; // Case: 1 1 3 2 1 3 2 2 1 // tslint:enable no-double-space ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); - if (ts.isTemplateLiteralKind(node.kind)) { - if (ts.isInsideTemplateLiteral(node, position)) { + if (ts.isTemplateLiteralToken(node)) { + if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { return 0; } return spanIndex + 2; @@ -95183,7 +95768,7 @@ var ts; } return { kind: 2 /* TaggedTemplateArguments */, - invocation: tagExpression, + invocation: { kind: 0 /* Call */, node: tagExpression }, argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile), argumentIndex: argumentIndex, argumentCount: argumentCount @@ -95214,8 +95799,8 @@ 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 === 201 /* TemplateExpression */) { - var lastSpan = ts.lastOrUndefined(template.templateSpans); + if (template.kind === 202 /* TemplateExpression */) { + var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); } @@ -95223,39 +95808,40 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 273 /* SourceFile */; n = n.parent) { - if (ts.isFunctionBlock(n)) { - return undefined; - } + var _loop_19 = 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. - if (n.pos < n.parent.pos || n.end > n.parent.end) { - ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); - } + ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.showSyntaxKind(n) + ", parent: " + ts.Debug.showSyntaxKind(n.parent); }); var argumentInfo = getImmediatelyContainingArgumentInfo(n, position, sourceFile); if (argumentInfo) { - return argumentInfo; + return { value: argumentInfo }; } - // TODO: Handle generic call with incomplete syntax + }; + for (var n = node; !ts.isBlock(n) && !ts.isSourceFile(n); n = n.parent) { + var state_7 = _loop_19(n); + if (typeof state_7 === "object") + return state_7.value; } return undefined; } - SignatureHelp.getContainingArgumentInfo = getContainingArgumentInfo; function getChildListThatStartsWithOpenerToken(parent, openerToken, sourceFile) { var children = parent.getChildren(sourceFile); var indexOfOpenerToken = children.indexOf(openerToken); ts.Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1); return children[indexOfOpenerToken + 1]; } + function getExpressionFromInvocation(invocation) { + return invocation.kind === 0 /* Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; + } var signatureHelpNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 3112960 /* IgnoreErrors */; - function createSignatureHelpItems(candidates, resolvedSignature, argumentListInfo, typeChecker) { + function createSignatureHelpItems(candidates, resolvedSignature, argumentListInfo, sourceFile, typeChecker) { var argumentCount = argumentListInfo.argumentCount, applicableSpan = argumentListInfo.argumentsSpan, invocation = argumentListInfo.invocation, argumentIndex = argumentListInfo.argumentIndex; var isTypeParameterList = argumentListInfo.kind === 0 /* TypeArguments */; - var callTarget = ts.getInvokedExpression(invocation); - var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); + var enclosingDeclaration = invocation.kind === 0 /* Call */ ? invocation.node : invocation.called; + var callTargetSymbol = typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)); var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); var printer = ts.createPrinter({ removeComments: true }); - var items = ts.map(candidates, function (candidateSignature) { + var items = candidates.map(function (candidateSignature) { var signatureHelpParameters; var prefixDisplayParts = []; var suffixDisplayParts = []; @@ -95270,9 +95856,9 @@ var ts; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : ts.emptyArray; suffixDisplayParts.push(ts.punctuationPart(29 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { - var thisParameter = candidateSignature.thisParameter ? [typeChecker.symbolToParameterDeclaration(candidateSignature.thisParameter, invocation, signatureHelpNodeBuilderFlags)] : []; - var params = ts.createNodeArray(thisParameter.concat(ts.map(candidateSignature.parameters, function (param) { return typeChecker.symbolToParameterDeclaration(param, invocation, signatureHelpNodeBuilderFlags); }))); - printer.writeList(1296 /* CallExpressionArguments */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var thisParameter = candidateSignature.thisParameter ? [typeChecker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; + var params = ts.createNodeArray(thisParameter.concat(candidateSignature.parameters.map(function (param) { return typeChecker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); + printer.writeList(1296 /* CallExpressionArguments */, params, sourceFile, writer); }); ts.addRange(suffixDisplayParts, parameterParts); } @@ -95280,8 +95866,8 @@ var ts; isVariadic = candidateSignature.hasRestParameter; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { - var args = ts.createNodeArray(ts.map(candidateSignature.typeParameters, function (p) { return typeChecker.typeParameterToDeclaration(p, invocation); })); - printer.writeList(26896 /* TypeParameters */, args, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var args = ts.createNodeArray(candidateSignature.typeParameters.map(function (p) { return typeChecker.typeParameterToDeclaration(p, enclosingDeclaration); })); + printer.writeList(26896 /* TypeParameters */, args, sourceFile, writer); } }); ts.addRange(prefixDisplayParts, typeParameterParts); @@ -95294,10 +95880,10 @@ var ts; writer.writeSpace(" "); var predicate = typeChecker.getTypePredicateOfSignature(candidateSignature); if (predicate) { - typeChecker.writeTypePredicate(predicate, invocation, /*flags*/ undefined, writer); + typeChecker.writeTypePredicate(predicate, enclosingDeclaration, /*flags*/ undefined, writer); } else { - typeChecker.writeType(typeChecker.getReturnTypeOfSignature(candidateSignature), invocation, /*flags*/ undefined, writer); + typeChecker.writeType(typeChecker.getReturnTypeOfSignature(candidateSignature), enclosingDeclaration, /*flags*/ undefined, writer); } }); ts.addRange(suffixDisplayParts, returnTypeParts); @@ -95319,8 +95905,8 @@ var ts; return { items: items, applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; function createSignatureHelpParameterForParameter(parameter) { var displayParts = ts.mapToDisplayParts(function (writer) { - var param = typeChecker.symbolToParameterDeclaration(parameter, invocation, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var param = typeChecker.symbolToParameterDeclaration(parameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); + printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); }); return { name: parameter.name, @@ -95331,8 +95917,8 @@ var ts; } function createSignatureHelpParameterForTypeParameter(typeParameter) { var displayParts = ts.mapToDisplayParts(function (writer) { - var param = typeChecker.typeParameterToDeclaration(typeParameter, invocation); - printer.writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var param = typeChecker.typeParameterToDeclaration(typeParameter, enclosingDeclaration); + printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); }); return { name: typeParameter.symbol.name, @@ -95347,9 +95933,8 @@ var ts; /* @internal */ var ts; (function (ts) { - function computeSuggestionDiagnostics(sourceFile, program) { - program.getSemanticDiagnostics(sourceFile); - var checker = program.getDiagnosticsProducingTypeChecker(); + function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) { + program.getSemanticDiagnostics(sourceFile, cancellationToken); var diags = []; if (sourceFile.commonJsModuleIndicator && (ts.programContainsEs6Modules(program) || ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) && @@ -95357,40 +95942,10 @@ var ts; diags.push(ts.createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module)); } var isJsFile = ts.isSourceFileJavaScript(sourceFile); - function check(node) { - switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - if (isJsFile) { - var symbol = node.symbol; - if (symbol.members && (symbol.members.size > 0)) { - diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); - } - } - break; - } - if (!isJsFile && ts.codefix.parameterShouldGetTypeFromJSDoc(node)) { - diags.push(ts.createDiagnosticForNode(node.name || node, ts.Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types)); - } - node.forEachChild(check); - } check(sourceFile); - if (!isJsFile) { - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (ts.isVariableStatement(statement) && - statement.declarationList.flags & 2 /* Const */ && - statement.declarationList.declarations.length === 1) { - var init = statement.declarationList.declarations[0].initializer; - if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) { - diags.push(ts.createDiagnosticForNode(init, ts.Diagnostics.require_call_may_be_converted_to_an_import)); - } - } - } - } if (ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())) { - for (var _b = 0, _c = sourceFile.imports; _b < _c.length; _b++) { - var moduleSpecifier = _c[_b]; + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var moduleSpecifier = _a[_i]; var importNode = ts.importFromModuleSpecifier(moduleSpecifier); var name = importNameForConvertToDefaultImport(importNode); if (!name) @@ -95402,18 +95957,57 @@ var ts; } } } - return diags.concat(checker.getSuggestionDiagnostics(sourceFile)).sort(function (d1, d2) { return d1.start - d2.start; }); + ts.addRange(diags, sourceFile.bindSuggestionDiagnostics); + ts.addRange(diags, program.getSuggestionDiagnostics(sourceFile, cancellationToken)); + return diags.sort(function (d1, d2) { return d1.start - d2.start; }); + function check(node) { + if (isJsFile) { + switch (node.kind) { + case 192 /* FunctionExpression */: + var decl = ts.getDeclarationOfJSInitializer(node); + if (decl) { + var symbol_3 = decl.symbol; + if (symbol_3 && (symbol_3.exports && symbol_3.exports.size || symbol_3.members && symbol_3.members.size)) { + diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); + break; + } + } + // falls through if no diagnostic was created + case 234 /* FunctionDeclaration */: + var symbol = node.symbol; + if (symbol.members && (symbol.members.size > 0)) { + diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); + } + break; + } + } + else { + if (ts.isVariableStatement(node) && + node.parent === sourceFile && + node.declarationList.flags & 2 /* Const */ && + node.declarationList.declarations.length === 1) { + var init = node.declarationList.declarations[0].initializer; + if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) { + diags.push(ts.createDiagnosticForNode(init, ts.Diagnostics.require_call_may_be_converted_to_an_import)); + } + } + if (ts.codefix.parameterShouldGetTypeFromJSDoc(node)) { + diags.push(ts.createDiagnosticForNode(node.name || node, ts.Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types)); + } + } + node.forEachChild(check); + } } ts.computeSuggestionDiagnostics = computeSuggestionDiagnostics; // convertToEs6Module only works on top-level, so don't trigger it if commonjs code only appears in nested scopes. function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); - }); - case 215 /* ExpressionStatement */: { + }); // TODO: GH#18217 + case 216 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -95430,12 +96024,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings.kind === 245 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 246 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -95458,7 +96052,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 204 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -95546,11 +96140,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 256 /* JsxOpeningElement */: - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: return location.kind === 71 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -95576,7 +96170,7 @@ var ts; var tags; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - var hasAddedSymbolInfo; + var hasAddedSymbolInfo = false; var isThisExpression = location.kind === 99 /* ThisKeyword */ && ts.isExpression(location); var type; var printer; @@ -95590,7 +96184,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 184 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 185 /* 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)) { @@ -95610,8 +96204,8 @@ var ts; } if (callExpressionLike) { var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); - var useConstructSignatures = callExpressionLike.kind === 187 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); // TODO: GH#18217 + var useConstructSignatures = callExpressionLike.kind === 188 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -95666,7 +96260,7 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 154 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 155 /* 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 @@ -95674,21 +96268,21 @@ var ts; return declaration === (location.kind === 123 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 154 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 155 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { - signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); + signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 154 /* Constructor */) { + if (functionDeclaration_1.kind === 155 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 157 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 158 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -95698,7 +96292,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 204 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 205 /* 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 @@ -95742,7 +96336,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 238 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 239 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 130 /* NamespaceKeyword */ : 129 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -95763,23 +96357,24 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 147 /* TypeParameter */); - ts.Debug.assert(decl !== undefined); + var decl = ts.getDeclarationOfKind(symbol, 148 /* TypeParameter */); + if (decl === undefined) + return ts.Debug.fail(); var declaration = decl.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); - var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 158 /* ConstructSignature */) { + var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 + if (declaration.kind === 159 /* ConstructSignature */) { displayParts.push(ts.keywordPart(94 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 157 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 158 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 236 /* TypeAliasDeclaration */) { + else if (declaration.kind === 237 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -95796,7 +96391,7 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 272 /* EnumMember */) { + if (declaration.kind === 273 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -95826,17 +96421,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(130 /* NamespaceKeyword */)); break; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 58 /* EqualsToken */ : 79 /* DefaultKeyword */)); break; - case 251 /* ExportSpecifier */: + case 252 /* ExportSpecifier */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); break; default: @@ -95845,7 +96440,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 242 /* ImportEqualsDeclaration */) { + if (declaration.kind === 243 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -95923,10 +96518,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 === 273 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 274 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 199 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 200 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -96009,6 +96604,7 @@ var ts; } } function addSignatureDisplayParts(signature, allSignatures, flags) { + if (flags === void 0) { flags = 0 /* None */; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); @@ -96037,16 +96633,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 191 /* FunctionExpression */) { + if (declaration.kind === 192 /* FunctionExpression */) { return true; } - if (declaration.kind !== 231 /* VariableDeclaration */ && declaration.kind !== 233 /* FunctionDeclaration */) { + if (declaration.kind !== 232 /* VariableDeclaration */ && declaration.kind !== 234 /* 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 === 273 /* SourceFile */ || parent.kind === 239 /* ModuleBlock */) { + if (parent.kind === 274 /* SourceFile */ || parent.kind === 240 /* ModuleBlock */) { return false; } } @@ -96094,7 +96690,7 @@ var ts; options.noResolve = true; // if jsx is specified then treat file as .tsx var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); - var sourceFile = ts.createSourceFile(inputFileName, input, options.target); + var sourceFile = ts.createSourceFile(inputFileName, input, options.target); // TODO: GH#18217 if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; } @@ -96135,7 +96731,8 @@ var ts; } // Emit program.emit(/*targetSourceFile*/ undefined, /*writeFile*/ undefined, /*cancellationToken*/ undefined, /*emitOnlyDtsFiles*/ undefined, transpileOptions.transformers); - ts.Debug.assert(outputText !== undefined, "Output generation failed"); + if (outputText === undefined) + return ts.Debug.fail("Output generation failed"); return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; } ts.transpileModule = transpileModule; @@ -96158,7 +96755,7 @@ var ts; return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.cloneCompilerOptions(options); - var _loop_17 = function (opt) { + var _loop_20 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -96177,7 +96774,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_17(opt); + _loop_20(opt); } return options; } @@ -96314,7 +96911,7 @@ var ts; lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - wasNewLine = trailingTrivia && ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */; + wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* NewLineTrivia */; } else { scanner.scan(); @@ -96354,10 +96951,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 261 /* JsxAttribute */: - case 256 /* JsxOpeningElement */: - case 257 /* JsxClosingElement */: - case 255 /* JsxSelfClosingElement */: + case 262 /* JsxAttribute */: + case 257 /* JsxOpeningElement */: + case 258 /* JsxClosingElement */: + case 256 /* 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 === 71 /* Identifier */; } @@ -96534,7 +97131,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 144 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 145 /* LastToken */; token++) { allTokens.push(token); } function anyTokenExcept() { @@ -96546,9 +97143,9 @@ var ts; } var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(72 /* FirstKeyword */, 144 /* LastKeyword */); + var keywords = tokenRangeFromRange(72 /* FirstKeyword */, 145 /* LastKeyword */); var binaryOperators = tokenRangeFromRange(27 /* FirstBinaryOperator */, 70 /* LastBinaryOperator */); - var binaryKeywordOperators = [92 /* InKeyword */, 93 /* InstanceOfKeyword */, 144 /* OfKeyword */, 118 /* AsKeyword */, 127 /* IsKeyword */]; + var binaryKeywordOperators = [92 /* InKeyword */, 93 /* InstanceOfKeyword */, 145 /* OfKeyword */, 118 /* AsKeyword */, 127 /* IsKeyword */]; var unaryPrefixOperators = [43 /* PlusPlusToken */, 44 /* MinusMinusToken */, 52 /* TildeToken */, 51 /* ExclamationToken */]; var unaryPrefixExpressions = [ 8 /* NumericLiteral */, 71 /* Identifier */, 19 /* OpenParenToken */, 21 /* OpenBracketToken */, @@ -96669,11 +97266,11 @@ var ts; 136 /* SetKeyword */, 115 /* StaticKeyword */, 139 /* TypeKeyword */, - 142 /* FromKeyword */, + 143 /* FromKeyword */, 128 /* KeyOfKeyword */, 126 /* InferKeyword */, ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [85 /* ExtendsKeyword */, 108 /* ImplementsKeyword */, 142 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [85 /* ExtendsKeyword */, 108 /* ImplementsKeyword */, 143 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), // 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", 9 /* StringLiteral */, 17 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), // Lambda expressions @@ -96838,45 +97435,45 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 219 /* ForStatement */; + return context.contextNode.kind === 220 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 199 /* BinaryExpression */: - case 200 /* ConditionalExpression */: - case 170 /* ConditionalType */: - case 207 /* AsExpression */: - case 251 /* ExportSpecifier */: - case 247 /* ImportSpecifier */: - case 160 /* TypePredicate */: - case 168 /* UnionType */: - case 169 /* IntersectionType */: + case 200 /* BinaryExpression */: + case 201 /* ConditionalExpression */: + case 171 /* ConditionalType */: + case 208 /* AsExpression */: + case 252 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 161 /* TypePredicate */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 181 /* BindingElement */: + case 182 /* BindingElement */: // equals in type X = ... - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: // equal in p = 0; - case 148 /* Parameter */: - case 272 /* EnumMember */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 149 /* Parameter */: + case 273 /* EnumMember */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return context.currentTokenSpan.kind === 58 /* EqualsToken */ || context.nextTokenSpan.kind === 58 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return context.currentTokenSpan.kind === 92 /* InKeyword */ || context.nextTokenSpan.kind === 92 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 221 /* ForOfStatement */: - return context.currentTokenSpan.kind === 144 /* OfKeyword */ || context.nextTokenSpan.kind === 144 /* OfKeyword */; + case 222 /* ForOfStatement */: + return context.currentTokenSpan.kind === 145 /* OfKeyword */ || context.nextTokenSpan.kind === 145 /* OfKeyword */; } return false; } @@ -96888,22 +97485,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 151 /* PropertyDeclaration */ || - contextKind === 150 /* PropertySignature */ || - contextKind === 148 /* Parameter */ || - contextKind === 231 /* VariableDeclaration */ || + return contextKind === 152 /* PropertyDeclaration */ || + contextKind === 151 /* PropertySignature */ || + contextKind === 149 /* Parameter */ || + contextKind === 232 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 200 /* ConditionalExpression */ || - context.contextNode.kind === 170 /* ConditionalType */; + return context.contextNode.kind === 201 /* ConditionalExpression */ || + context.contextNode.kind === 171 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 179 /* ObjectBindingPattern */ || - context.contextNode.kind === 176 /* MappedType */ || + return context.contextNode.kind === 180 /* ObjectBindingPattern */ || + context.contextNode.kind === 177 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -96929,31 +97526,31 @@ var ts; return true; } switch (node.kind) { - case 212 /* Block */: - case 240 /* CaseBlock */: - case 183 /* ObjectLiteralExpression */: - case 239 /* ModuleBlock */: + case 213 /* Block */: + case 241 /* CaseBlock */: + case 184 /* ObjectLiteralExpression */: + case 240 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 157 /* CallSignature */: - case 191 /* FunctionExpression */: - case 154 /* Constructor */: - case 192 /* ArrowFunction */: + case 158 /* CallSignature */: + case 192 /* FunctionExpression */: + case 155 /* Constructor */: + case 193 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 235 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 236 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -96962,40 +97559,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 233 /* FunctionDeclaration */ || context.contextNode.kind === 191 /* FunctionExpression */; + return context.contextNode.kind === 234 /* FunctionDeclaration */ || context.contextNode.kind === 192 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 165 /* TypeLiteral */: - case 238 /* ModuleDeclaration */: - case 249 /* ExportDeclaration */: - case 250 /* NamedExports */: - case 243 /* ImportDeclaration */: - case 246 /* NamedImports */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 166 /* TypeLiteral */: + case 239 /* ModuleDeclaration */: + case 250 /* ExportDeclaration */: + case 251 /* NamedExports */: + case 244 /* ImportDeclaration */: + case 247 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 234 /* ClassDeclaration */: - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 268 /* CatchClause */: - case 239 /* ModuleBlock */: - case 226 /* SwitchStatement */: + case 235 /* ClassDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 269 /* CatchClause */: + case 240 /* ModuleBlock */: + case 227 /* SwitchStatement */: return true; - case 212 /* Block */: { + case 213 /* 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 !== 192 /* ArrowFunction */ && blockParent.kind !== 191 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 193 /* ArrowFunction */ && blockParent.kind !== 192 /* FunctionExpression */) { return true; } } @@ -97004,31 +97601,31 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 216 /* IfStatement */: - case 226 /* SwitchStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 218 /* WhileStatement */: - case 229 /* TryStatement */: - case 217 /* DoStatement */: - case 225 /* WithStatement */: + case 217 /* IfStatement */: + case 227 /* SwitchStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 219 /* WhileStatement */: + case 230 /* TryStatement */: + case 218 /* DoStatement */: + case 226 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 268 /* CatchClause */: + case 269 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 183 /* ObjectLiteralExpression */; + return context.contextNode.kind === 184 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 186 /* CallExpression */; + return context.contextNode.kind === 187 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 187 /* NewExpression */; + return context.contextNode.kind === 188 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -97040,35 +97637,35 @@ var ts; return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 192 /* ArrowFunction */; + return context.contextNode.kind === 193 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 178 /* ImportType */; + return context.contextNode.kind === 179 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 254 /* JsxElement */ && context.contextNode.kind !== 258 /* JsxFragment */; + return context.contextNode.kind !== 255 /* JsxElement */ && context.contextNode.kind !== 259 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 264 /* JsxExpression */ || context.contextNode.kind === 263 /* JsxSpreadAttribute */; + return context.contextNode.kind === 265 /* JsxExpression */ || context.contextNode.kind === 264 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 261 /* JsxAttribute */; + return context.nextTokenParent.kind === 262 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 261 /* JsxAttribute */; + return context.contextNode.kind === 262 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 255 /* JsxSelfClosingElement */; + return context.contextNode.kind === 256 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); } function isEndOfDecoratorContextOnSameLine(context) { return context.TokensAreOnSameLine() && - context.contextNode.decorators && + !!context.contextNode.decorators && nodeIsInDecoratorContext(context.currentTokenParent) && !nodeIsInDecoratorContext(context.nextTokenParent); } @@ -97076,45 +97673,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 149 /* Decorator */; + return node.kind === 150 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 232 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 233 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 238 /* ModuleDeclaration */; + return context.contextNode.kind === 239 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 165 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 166 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 158 /* ConstructSignature */; + return context.contextNode.kind === 159 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 27 /* LessThanToken */ && token.kind !== 29 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 161 /* TypeReference */: - case 189 /* TypeAssertionExpression */: - case 236 /* TypeAliasDeclaration */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 206 /* ExpressionWithTypeArguments */: + case 162 /* TypeReference */: + case 190 /* TypeAssertionExpression */: + case 237 /* TypeAliasDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 207 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -97125,16 +97722,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 189 /* TypeAssertionExpression */; + return context.contextNode.kind === 190 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 195 /* VoidExpression */; + return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 196 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 202 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 203 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 208 /* NonNullExpression */; + return context.contextNode.kind === 209 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -97185,12 +97782,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 144 /* LastKeyword */ && column <= 144 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 145 /* LastKeyword */ && column <= 145 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 144 /* LastToken */ + 1; + var mapRowLength = 145 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; @@ -97368,17 +97965,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 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 239 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 273 /* SourceFile */: - case 212 /* Block */: - case 239 /* ModuleBlock */: + return !!body && body.kind === 240 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 274 /* SourceFile */: + case 213 /* Block */: + case 240 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -97407,7 +98004,7 @@ var ts; } // pick only errors that fall in range var sorted = errors - .filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }) + .filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }) // TODO: GH#18217 .sort(function (e1, e2) { return e1.start - e2.start; }); if (!sorted.length) { return rangeHasNoErrors; @@ -97535,7 +98132,7 @@ var ts; if (!formattingScanner.isOnToken()) { var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { - processTrivia(leadingTrivia, enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); + processTrivia(leadingTrivia, enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); // TODO: GH#18217 trimTrailingWhitespacesForRemainingRange(); } } @@ -97601,19 +98198,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 234 /* ClassDeclaration */: return 75 /* ClassKeyword */; - case 235 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; - case 233 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; - case 237 /* EnumDeclaration */: return 237 /* EnumDeclaration */; - case 155 /* GetAccessor */: return 125 /* GetKeyword */; - case 156 /* SetAccessor */: return 136 /* SetKeyword */; - case 153 /* MethodDeclaration */: + case 235 /* ClassDeclaration */: return 75 /* ClassKeyword */; + case 236 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; + case 234 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; + case 238 /* EnumDeclaration */: return 238 /* EnumDeclaration */; + case 156 /* GetAccessor */: return 125 /* GetKeyword */; + case 157 /* SetAccessor */: return 136 /* SetKeyword */; + case 154 /* MethodDeclaration */: if (node.asteriskToken) { return 39 /* AsteriskToken */; } // falls through - case 151 /* PropertyDeclaration */: - case 148 /* Parameter */: + case 152 /* PropertyDeclaration */: + case 149 /* Parameter */: return ts.getNameOfDeclaration(node).kind; } } @@ -97658,15 +98255,15 @@ var ts; case 41 /* SlashToken */: case 29 /* GreaterThanToken */: switch (container.kind) { - case 256 /* JsxOpeningElement */: - case 257 /* JsxClosingElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 258 /* JsxClosingElement */: + case 256 /* JsxSelfClosingElement */: return false; } break; case 21 /* OpenBracketToken */: case 22 /* CloseBracketToken */: - if (container.kind !== 176 /* MappedType */) { + if (container.kind !== 177 /* MappedType */) { return false; } break; @@ -97758,7 +98355,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 149 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 150 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); if (child.kind === 10 /* JsxText */) { @@ -97766,7 +98363,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 182 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 183 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -97896,6 +98493,7 @@ var ts; } } } + // TODO: GH#18217 use an enum instead of `boolean | undefined` function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); var lineAction = 0 /* None */; @@ -98177,12 +98775,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 154 /* Constructor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 192 /* ArrowFunction */: + case 155 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 193 /* ArrowFunction */: if (node.typeParameters === list) { return 27 /* LessThanToken */; } @@ -98190,8 +98788,8 @@ var ts; return 19 /* OpenParenToken */; } break; - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: if (node.typeArguments === list) { return 27 /* LessThanToken */; } @@ -98199,7 +98797,7 @@ var ts; return 19 /* OpenParenToken */; } break; - case 161 /* TypeReference */: + case 162 /* TypeReference */: if (node.typeArguments === list) { return 27 /* LessThanToken */; } @@ -98316,7 +98914,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 199 /* BinaryExpression */) { + if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 200 /* 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 */) { @@ -98368,7 +98966,7 @@ var ts; // handle cases when codefix is about to be inserted before the close brace ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* CloseBrace */ ? options.indentSize : 0 : lineAtPosition !== currentStart.line ? options.indentSize : 0; - return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); + return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } // check if current node is a list item - if yes, take indentation from it var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); @@ -98377,7 +98975,7 @@ var ts; } actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + options.indentSize; + return actualIndentation + options.indentSize; // TODO: GH#18217 } previous = current; current = current.parent; @@ -98472,7 +99070,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 === 273 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 274 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -98520,7 +99118,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 216 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 217 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -98536,40 +99134,40 @@ var ts; if (node.parent) { var end = node.end; switch (node.parent.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), end); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return node.parent.properties; - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return node.parent.elements; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 154 /* Constructor */: - case 163 /* ConstructorType */: - case 158 /* ConstructSignature */: { + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 155 /* Constructor */: + case 164 /* ConstructorType */: + case 159 /* ConstructSignature */: { var start = node.getStart(sourceFile); return getListIfStartEndIsInListRange(node.parent.typeParameters, start, end) || getListIfStartEndIsInListRange(node.parent.parameters, start, end); } - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return getListIfStartEndIsInListRange(node.parent.typeParameters, node.getStart(sourceFile), end); - case 187 /* NewExpression */: - case 186 /* CallExpression */: { + case 188 /* NewExpression */: + case 187 /* CallExpression */: { var start = node.getStart(sourceFile); return getListIfStartEndIsInListRange(node.parent.typeArguments, start, end) || getListIfStartEndIsInListRange(node.parent.arguments, start, end); } - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), end); - case 246 /* NamedImports */: - case 250 /* NamedExports */: + case 247 /* NamedImports */: + case 251 /* NamedExports */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); } } @@ -98609,10 +99207,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: node = node.expression; break; default: @@ -98674,91 +99272,89 @@ var ts; return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; } SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; - function nodeContentIsAlwaysIndented(kind) { - switch (kind) { - case 215 /* ExpressionStatement */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 182 /* ArrayLiteralExpression */: - case 212 /* Block */: - case 239 /* ModuleBlock */: - case 183 /* ObjectLiteralExpression */: - case 165 /* TypeLiteral */: - case 176 /* MappedType */: - case 167 /* TupleType */: - case 240 /* CaseBlock */: - case 266 /* DefaultClause */: - case 265 /* CaseClause */: - case 190 /* ParenthesizedExpression */: - case 184 /* PropertyAccessExpression */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 213 /* VariableStatement */: - case 231 /* VariableDeclaration */: - case 248 /* ExportAssignment */: - case 224 /* ReturnStatement */: - case 200 /* ConditionalExpression */: - case 180 /* ArrayBindingPattern */: - case 179 /* ObjectBindingPattern */: - case 256 /* JsxOpeningElement */: - case 259 /* JsxOpeningFragment */: - case 255 /* JsxSelfClosingElement */: - case 264 /* JsxExpression */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 148 /* Parameter */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 172 /* ParenthesizedType */: - case 188 /* TaggedTemplateExpression */: - case 196 /* AwaitExpression */: - case 250 /* NamedExports */: - case 246 /* NamedImports */: - case 251 /* ExportSpecifier */: - case 247 /* ImportSpecifier */: - case 269 /* PropertyAssignment */: - case 151 /* PropertyDeclaration */: - return true; - } - return false; - } function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 231 /* VariableDeclaration */: - case 269 /* PropertyAssignment */: - case 183 /* ObjectLiteralExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 183 /* ObjectLiteralExpression */) { + case 216 /* ExpressionStatement */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 183 /* ArrayLiteralExpression */: + case 213 /* Block */: + case 240 /* ModuleBlock */: + case 184 /* ObjectLiteralExpression */: + case 166 /* TypeLiteral */: + case 177 /* MappedType */: + case 168 /* TupleType */: + case 241 /* CaseBlock */: + case 267 /* DefaultClause */: + case 266 /* CaseClause */: + case 191 /* ParenthesizedExpression */: + case 185 /* PropertyAccessExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 214 /* VariableStatement */: + case 249 /* ExportAssignment */: + case 225 /* ReturnStatement */: + case 201 /* ConditionalExpression */: + case 181 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningFragment */: + case 256 /* JsxSelfClosingElement */: + case 265 /* JsxExpression */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 149 /* Parameter */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 173 /* ParenthesizedType */: + case 189 /* TaggedTemplateExpression */: + case 197 /* AwaitExpression */: + case 251 /* NamedExports */: + case 247 /* NamedImports */: + case 252 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 152 /* PropertyDeclaration */: + return true; + case 232 /* VariableDeclaration */: + case 270 /* PropertyAssignment */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 184 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - break; - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 219 /* ForStatement */: - case 216 /* IfStatement */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 192 /* ArrowFunction */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - return childKind !== 212 /* Block */; - case 249 /* ExportDeclaration */: - return childKind !== 250 /* NamedExports */; - case 243 /* ImportDeclaration */: - return childKind !== 244 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 246 /* NamedImports */); - case 254 /* JsxElement */: - return childKind !== 257 /* JsxClosingElement */; - case 258 /* JsxFragment */: - return childKind !== 260 /* JsxClosingFragment */; + return true; + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 220 /* ForStatement */: + case 217 /* IfStatement */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 193 /* ArrowFunction */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + return childKind !== 213 /* Block */; + case 250 /* ExportDeclaration */: + return childKind !== 251 /* NamedExports */; + case 244 /* ImportDeclaration */: + return childKind !== 245 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 247 /* NamedImports */); + case 255 /* JsxElement */: + return childKind !== 258 /* JsxClosingElement */; + case 259 /* JsxFragment */: + return childKind !== 261 /* JsxClosingFragment */; + case 170 /* IntersectionType */: + case 169 /* UnionType */: + if (childKind === 166 /* TypeLiteral */) { + return false; + } + // falls through } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -98766,17 +99362,17 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 224 /* ReturnStatement */: - case 228 /* ThrowStatement */: { - if (parent.kind !== 212 /* Block */) { + case 225 /* ReturnStatement */: + case 229 /* ThrowStatement */: { + if (parent.kind !== 213 /* Block */) { return true; } var grandParent = parent.parent; // In a function, we may want to write inner functions after this. - return !(grandParent && grandParent.kind === 191 /* FunctionExpression */ || grandParent.kind === 233 /* FunctionDeclaration */); + return !(grandParent && grandParent.kind === 192 /* FunctionExpression */ || grandParent.kind === 234 /* FunctionDeclaration */); } - case 222 /* ContinueStatement */: - case 223 /* BreakStatement */: + case 223 /* ContinueStatement */: + case 224 /* BreakStatement */: return true; default: return false; @@ -98788,7 +99384,7 @@ var ts; */ function shouldIndentChildNode(settings, parent, child, sourceFile, isNextChild) { if (isNextChild === void 0) { isNextChild = false; } - return (nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(settings, parent, child, sourceFile, /*indentByDefault*/ false)) + return nodeWillIndentChild(settings, parent, child, sourceFile, /*indentByDefault*/ false) && !(isNextChild && child && isControlFlowEndingStatement(child.kind, parent)); } SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; @@ -98905,7 +99501,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 === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 183 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 184 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -98951,6 +99547,12 @@ var ts; this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); return this; }; + ChangeTracker.prototype.deleteNodeRangeExcludingEnd = function (sourceFile, startNode, afterEndNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); + var endPosition = afterEndNode === undefined ? sourceFile.text.length : getAdjustedStartPosition(sourceFile, afterEndNode, options, Position.FullStart); + this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + }; ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { var containingList = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); if (!containingList) { @@ -99064,7 +99666,7 @@ var ts; } } else { - endNode = node.kind !== 231 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 232 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -99168,7 +99770,7 @@ var ts; else if (ts.isStatement(node) || ts.isClassOrTypeElement(node)) { return { suffix: this.newLineCharacter }; } - else if (ts.isVariableDeclaration(node)) { + else if (ts.isVariableDeclaration(node) || ts.isStringLiteral(node)) { return { prefix: ", " }; } else if (ts.isPropertyAssignment(node)) { @@ -99181,7 +99783,7 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 192 /* ArrowFunction */) { + if (node.kind === 193 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 36 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 19 /* OpenParenToken */, sourceFile); if (lparen) { @@ -99195,14 +99797,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(20 /* CloseParenToken */)); } - if (node.body.kind !== 212 /* Block */) { + if (node.body.kind !== 213 /* Block */) { // `() => 0` => `function f() { return 0; }` this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(17 /* OpenBraceToken */), ts.createToken(96 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(25 /* SemicolonToken */), ts.createToken(18 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 191 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 192 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -99358,7 +99960,7 @@ var ts; var changes = changesToText.getTextChangesFromChanges(this.changes, this.newLineCharacter, this.formatContext, validate); for (var _i = 0, _a = this.newFiles; _i < _a.length; _i++) { var _b = _a[_i], oldFile = _b.oldFile, fileName = _b.fileName, statements = _b.statements; - changes.push(changesToText.newFileChanges(oldFile, fileName, statements, this.newLineCharacter)); + changes.push(changesToText.newFileChanges(oldFile, fileName, statements, this.newLineCharacter, this.formatContext)); } return changes; }; @@ -99383,14 +99985,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_18 = function (i) { + var _loop_21 = 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_18(i); + _loop_21(i); } var textChanges = normalized.map(function (c) { return ts.createTextChange(ts.createTextSpanFromRange(c.range), computeNewText(c, sourceFile, newLineCharacter, formatContext, validate)); @@ -99399,8 +100001,12 @@ var ts; }); } changesToText.getTextChangesFromChanges = getTextChangesFromChanges; - function newFileChanges(oldFile, fileName, statements, newLineCharacter) { - var text = statements.map(function (s) { return getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + function newFileChanges(oldFile, fileName, statements, newLineCharacter, formatContext) { + // TODO: this emits the file, parses it back, then formats it that -- may be a less roundabout way to do this + var nonFormattedText = statements.map(function (s) { return getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + var sourceFile = ts.createSourceFile(fileName, nonFormattedText, 6 /* ESNext */); + var changes = ts.formatting.formatDocument(sourceFile, formatContext); + var text = applyChanges(nonFormattedText, changes); return { fileName: fileName, textChanges: [ts.createTextChange(ts.createTextSpan(0, 0), text)], isNewFile: true }; } changesToText.newFileChanges = newFileChanges; @@ -99414,7 +100020,7 @@ var ts; var _a = change.options, options = _a === void 0 ? {} : _a, pos = change.range.pos; var format = function (n) { return getFormattedTextOfNode(n, sourceFile, pos, options, newLineCharacter, formatContext, validate); }; var text = change.kind === ChangeKind.ReplaceWithMultipleNodes - ? change.nodes.map(function (n) { return ts.removeSuffix(format(n), newLineCharacter); }).join(change.options.joiner || newLineCharacter) + ? change.nodes.map(function (n) { return ts.removeSuffix(format(n), newLineCharacter); }).join(change.options.joiner || newLineCharacter) // TODO: GH#18217 : format(change.node); // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, ""); @@ -99457,7 +100063,7 @@ var ts; return ts.skipTrivia(s, 0) === s.length; } function assignPositionsToNode(node) { - var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); + var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // TODO: GH#18217 // create proxy node for non synthesized nodes var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited); newNode.pos = getPos(node); @@ -99647,7 +100253,7 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 146 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 147 /* ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } })(textChanges = ts.textChanges || (ts.textChanges = {})); @@ -99718,8 +100324,8 @@ var ts; } codefix.codeFixAll = codeFixAll; function eachDiagnostic(_a, errorCodes, cb) { - var program = _a.program, sourceFile = _a.sourceFile; - for (var _i = 0, _b = program.getSemanticDiagnostics(sourceFile).concat(ts.computeSuggestionDiagnostics(sourceFile, program)); _i < _b.length; _i++) { + var program = _a.program, sourceFile = _a.sourceFile, cancellationToken = _a.cancellationToken; + for (var _i = 0, _b = program.getSemanticDiagnostics(sourceFile, cancellationToken).concat(ts.computeSuggestionDiagnostics(sourceFile, program, cancellationToken)); _i < _b.length; _i++) { var diag = _b[_i]; if (ts.contains(errorCodes, diag.code)) { cb(diag); @@ -99855,29 +100461,29 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 231 /* VariableDeclaration */ || - node.kind === 150 /* PropertySignature */ || - node.kind === 151 /* PropertyDeclaration */; + node.kind === 232 /* VariableDeclaration */ || + node.kind === 151 /* PropertySignature */ || + node.kind === 152 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 278 /* JSDocAllType */: - case 279 /* JSDocUnknownType */: + case 279 /* JSDocAllType */: + case 280 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 282 /* JSDocOptionalType */: + case 283 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 281 /* JSDocNonNullableType */: + case 282 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 280 /* JSDocNullableType */: + case 281 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return transformJSDocTypeReference(node); default: - var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); + var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 ts.setEmitFlags(visited, 1 /* SingleLine */); return visited; } @@ -99896,7 +100502,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 284 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; + var isRest = node.type.kind === 285 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(24 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -99972,16 +100578,16 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: precedingNode = ctorDeclaration; deleteNode(ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { - copyComments(precedingNode, newClassDeclaration, sourceFile); + copyComments(precedingNode, newClassDeclaration, sourceFile); // TODO: GH#18217 deleteNode(precedingNode); } else { @@ -100048,7 +100654,7 @@ var ts; return; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 215 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 216 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; deleteNode(nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -100056,7 +100662,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 191 /* FunctionExpression */: { + case 192 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 120 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, @@ -100064,12 +100670,12 @@ var ts; copyComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 192 /* ArrowFunction */: { + case 193 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 212 /* Block */) { + if (arrowFunctionBody.kind === 213 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -100097,13 +100703,13 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 191 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 192 /* FunctionExpression */) { return undefined; } if (node.name.kind !== 71 /* Identifier */) { return undefined; } - var memberElements = createClassElementsFromSymbol(initializer.symbol); + var memberElements = createClassElementsFromSymbol(node.symbol); if (initializer.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } @@ -100153,13 +100759,13 @@ var ts; codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module.code], getCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program; + var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { - var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, program.getCompilerOptions().target); + var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, program.getCompilerOptions().target, preferences); if (moduleExportsChangedToDefault) { for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var importingFile = _a[_i]; - fixImportOfModuleExports(importingFile, sourceFile, changes); + fixImportOfModuleExports(importingFile, sourceFile, changes, preferences); } } }); @@ -100167,7 +100773,7 @@ var ts; return [codefix.createCodeFixActionNoFixId("convertToEs6Module", changes, ts.Diagnostics.Convert_to_ES6_module)]; }, }); - function fixImportOfModuleExports(importingFile, exportingFile, changes) { + function fixImportOfModuleExports(importingFile, exportingFile, changes, preferences) { for (var _i = 0, _a = importingFile.imports; _i < _a.length; _i++) { var moduleSpecifier = _a[_i]; var imported = ts.getResolvedModule(importingFile, moduleSpecifier.text); @@ -100176,10 +100782,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 242 /* ImportEqualsDeclaration */: - changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier)); + case 243 /* ImportEqualsDeclaration */: + changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, preferences)); break; - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -100188,14 +100794,14 @@ var ts; } } /** @returns Whether we converted a `module.exports =` to a default export. */ - function convertFileToEs6Module(sourceFile, checker, changes, target) { + function convertFileToEs6Module(sourceFile, checker, changes, target, preferences) { var identifiers = { original: collectFreeIdentifiers(sourceFile), additional: ts.createMap() }; var exports = collectExportRenames(sourceFile, checker, identifiers); convertExportsAccesses(sourceFile, exports, changes); var moduleExportsChangedToDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - var moduleExportsChanged = convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports); + var moduleExportsChanged = convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, preferences); moduleExportsChangedToDefault = moduleExportsChangedToDefault || moduleExportsChanged; } return moduleExportsChangedToDefault; @@ -100230,22 +100836,22 @@ var ts; node.forEachChild(recur); }); } - function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports) { + function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, preferences) { switch (statement.kind) { - case 213 /* VariableStatement */: - convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target); + case 214 /* VariableStatement */: + convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, preferences); return false; - case 215 /* ExpressionStatement */: { + case 216 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 186 /* CallExpression */: { + case 187 /* 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])); + changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], preferences)); } return false; } - case 199 /* BinaryExpression */: { + case 200 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 58 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } @@ -100256,7 +100862,7 @@ var ts; return false; } } - function convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target) { + function convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, preferences) { var declarationList = statement.declarationList; var foundImport = false; var newNodes = ts.flatMap(declarationList.declarations, function (decl) { @@ -100269,11 +100875,11 @@ var ts; } else if (ts.isRequireCall(initializer, /*checkArgumentIsStringLiteralLike*/ true)) { foundImport = true; - return convertSingleImport(sourceFile, name, initializer.arguments[0], changes, checker, identifiers, target); + return convertSingleImport(sourceFile, name, initializer.arguments[0], changes, checker, identifiers, target, preferences); } else if (ts.isPropertyAccessExpression(initializer) && ts.isRequireCall(initializer.expression, /*checkArgumentIsStringLiteralLike*/ true)) { foundImport = true; - return convertPropertyAccessImport(name, initializer.name.text, initializer.expression.arguments[0], identifiers); + return convertPropertyAccessImport(name, initializer.name.text, initializer.expression.arguments[0], identifiers, preferences); } } // Move it out to its own variable statement. (This will not be used if `!foundImport`) @@ -100285,22 +100891,22 @@ var ts; } } /** Converts `const name = require("moduleSpecifier").propertyName` */ - function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers) { + function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, preferences) { switch (name.kind) { - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: { + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ - makeSingleImport(tmp, propertyName, moduleSpecifier), + makeSingleImport(tmp, propertyName, moduleSpecifier, preferences), makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } case 71 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; - return [makeSingleImport(name.text, propertyName, moduleSpecifier)]; + return [makeSingleImport(name.text, propertyName, moduleSpecifier, preferences)]; default: - ts.Debug.assertNever(name); + return ts.Debug.assertNever(name); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -100339,15 +100945,15 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 270 /* ShorthandPropertyAssignment */: - case 271 /* SpreadAssignment */: + case 271 /* ShorthandPropertyAssignment */: + case 272 /* SpreadAssignment */: return undefined; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(84 /* ExportKeyword */)], prop); default: ts.Debug.assertNever(prop); @@ -100413,7 +101019,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported) { var modifiers = [ts.createToken(84 /* ExportKeyword */)]; switch (exported.kind) { - case 191 /* FunctionExpression */: { + case 192 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -100421,10 +101027,10 @@ var ts; } } // falls through - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -100432,7 +101038,7 @@ var ts; } function exportConst() { // `exports.x = 0;` --> `export const x = 0;` - return makeConst(modifiers, ts.createIdentifier(name), exported); + return makeConst(modifiers, ts.createIdentifier(name), exported); // TODO: GH#18217 } } /** @@ -100440,41 +101046,41 @@ var ts; * Returns nodes that will replace the variable declaration for the commonjs import. * May also make use `changes` to remove qualifiers at the use sites of imports, to change `mod.x` to `x`. */ - function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target) { + function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, preferences) { switch (name.kind) { - case 179 /* ObjectBindingPattern */: { + case 180 /* 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 : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); + }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) if (importSpecifiers) { - return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier)]; + return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, preferences)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 180 /* ArrayBindingPattern */: { + case 181 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; */ var tmp = makeUniqueName(codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, target), identifiers); return [ - ts.makeImport(ts.createIdentifier(tmp), /*namedImports*/ undefined, moduleSpecifier), + ts.makeImport(ts.createIdentifier(tmp), /*namedImports*/ undefined, moduleSpecifier, preferences), makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } case 71 /* Identifier */: - return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers); + return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, preferences); default: - ts.Debug.assertNever(name); + return ts.Debug.assertNever(name); } } /** * Convert `import x = require("x").` * Also converts uses like `x.y()` to `y()` and uses a named import. */ - function convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers) { + function convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, preferences) { var nameSymbol = checker.getSymbolAtLocation(name); // Maps from module property name to name actually used. (The same if there isn't shadowing.) var namedBindingsNames = ts.createMap(); @@ -100509,7 +101115,7 @@ var ts; // If it was unused, ensure that we at least import *something*. needDefaultImport = true; } - return [ts.makeImport(needDefaultImport ? ts.getSynthesizedDeepClone(name) : undefined, namedBindings, moduleSpecifier)]; + return [ts.makeImport(needDefaultImport ? ts.getSynthesizedDeepClone(name) : undefined, namedBindings, moduleSpecifier, preferences)]; } // Identifiers helpers function makeUniqueName(name, identifiers) { @@ -100521,20 +101127,26 @@ var ts; } function collectFreeIdentifiers(file) { var map = ts.createMultiMap(); - file.forEachChild(function recur(node) { - if (ts.isIdentifier(node) && isFreeIdentifier(node)) { - map.add(node.text, node); - } - node.forEachChild(recur); - }); + forEachFreeIdentifier(file, function (id) { return map.add(id.text, id); }); return map; } + /** + * A free identifier is an identifier that can be accessed through name lookup as a local variable. + * In the expression `x.y`, `x` is a free identifier, but `y` is not. + */ + function forEachFreeIdentifier(node, cb) { + if (ts.isIdentifier(node) && isFreeIdentifier(node)) + cb(node); + node.forEachChild(function (child) { return forEachFreeIdentifier(child, cb); }); + } function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return parent.name !== node; - case 181 /* BindingElement */: + case 182 /* BindingElement */: + return parent.propertyName !== node; + case 248 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -100549,10 +101161,10 @@ var ts; return ts.createClassDeclaration(ts.getSynthesizedDeepClones(cls.decorators), // TODO: GH#19915 Don't think this is even legal. ts.concatenate(additionalModifiers, ts.getSynthesizedDeepClones(cls.modifiers)), name, ts.getSynthesizedDeepClones(cls.typeParameters), ts.getSynthesizedDeepClones(cls.heritageClauses), ts.getSynthesizedDeepClones(cls.members)); } - function makeSingleImport(localName, propertyName, moduleSpecifier) { + function makeSingleImport(localName, propertyName, moduleSpecifier, preferences) { return propertyName === "default" - ? ts.makeImport(ts.createIdentifier(localName), /*namedImports*/ undefined, moduleSpecifier) - : ts.makeImport(/*name*/ undefined, [makeImportSpecifier(propertyName, localName)], moduleSpecifier); + ? ts.makeImport(ts.createIdentifier(localName), /*namedImports*/ undefined, moduleSpecifier, preferences) + : ts.makeImport(/*name*/ undefined, [makeImportSpecifier(propertyName, localName)], moduleSpecifier, preferences); } function makeImportSpecifier(propertyName, name) { return ts.createImportSpecifier(propertyName !== undefined && propertyName !== name ? ts.createIdentifier(propertyName) : undefined, ts.createIdentifier(name)); @@ -100640,12 +101252,16 @@ var ts; function getClass(sourceFile, pos) { return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false))); } + function symbolPointsToNonPrivateMember(symbol) { + return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); + } function addMissingDeclarations(checker, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) { + var maybeHeritageClauseSymbol = getHeritageClauseSymbolTable(classDeclaration, checker); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. var implementedType = checker.getTypeAtLocation(implementedTypeNode); var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); - var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); }); + var nonPrivateAndNotExistedInHeritageClauseMembers = implementedTypeSymbols.filter(ts.and(symbolPointsToNonPrivateMember, function (symbol) { return !maybeHeritageClauseSymbol.has(symbol.escapedName); })); var classType = checker.getTypeAtLocation(classDeclaration); if (!classType.getNumberIndexType()) { createMissingIndexSignatureDeclaration(implementedType, 1 /* Number */); @@ -100653,7 +101269,7 @@ var ts; if (!classType.getStringIndexType()) { createMissingIndexSignatureDeclaration(implementedType, 0 /* String */); } - codefix.createMissingMemberNodes(classDeclaration, nonPrivateMembers, checker, preferences, function (member) { return changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member); }); + codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, checker, preferences, function (member) { return changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member); }); function createMissingIndexSignatureDeclaration(type, kind) { var indexInfoOfKind = checker.getIndexInfoOfType(type, kind); if (indexInfoOfKind) { @@ -100661,6 +101277,14 @@ var ts; } } } + function getHeritageClauseSymbolTable(classDeclaration, checker) { + var heritageClauseNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + if (!heritageClauseNode) + return ts.createSymbolTable(); + var heritageClauseType = checker.getTypeAtLocation(heritageClauseNode); + var heritageClauseTypeSymbols = checker.getPropertiesOfType(heritageClauseType); + return ts.createSymbolTable(heritageClauseTypeSymbols.filter(symbolPointsToNonPrivateMember)); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -100677,7 +101301,9 @@ var ts; ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code, ], - getCodeActions: getImportCodeActions, + getCodeActions: function (context) { return context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ? getActionsForUMDImport(context) + : getActionsForNonUMDImport(context); }, // TODO: GH#20315 fixIds: [], getAllCodeActions: ts.notImplemented, @@ -100696,7 +101322,6 @@ var ts; program: program, checker: checker, compilerOptions: program.getCompilerOptions(), - cachedImportDeclarations: [], getCanonicalFileName: ts.createGetCanonicalFileName(ts.hostUsesCaseSensitiveFileNames(context.host)), symbolName: symbolName, symbolToken: symbolToken, @@ -100742,9 +101367,17 @@ var ts; return result; } function getCodeActionsForImport_separateExistingAndNew(exportInfos, context, useExisting, addNew) { - var existingImports = ts.flatMap(exportInfos, function (info) { - return getImportDeclarations(info, context.checker, context.sourceFile, context.cachedImportDeclarations); - }); + var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, context.checker, context.sourceFile); }); + ts.append(useExisting, tryUseExistingNamespaceImport(existingImports, context, context.symbolToken, context.checker)); + var addToExisting = tryAddToExistingImport(existingImports, context); + if (addToExisting) { + useExisting.push(addToExisting); + } + else { // Don't bother providing an action to add a new import if we can add to an existing one. + getCodeActionsForAddImport(exportInfos, context, existingImports, addNew); + } + } + function tryUseExistingNamespaceImport(existingImports, context, symbolToken, checker) { // It is possible that multiple import statements with the same specifier exist in the file. // e.g. // @@ -100757,44 +101390,46 @@ var ts; // 1. change "member3" to "ns.member3" // 2. add "member3" to the second import statement's import list // and it is up to the user to decide which one fits best. - if (context.symbolToken && ts.isIdentifier(context.symbolToken)) { - for (var _i = 0, existingImports_1 = existingImports; _i < existingImports_1.length; _i++) { - var declaration = existingImports_1[_i].declaration; - var namespace_2 = getNamespaceImportName(declaration); - if (namespace_2) { - var moduleSymbol = context.checker.getAliasedSymbol(context.checker.getSymbolAtLocation(namespace_2)); - if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(context.symbolName))) { - useExisting.push(getCodeActionForUseExistingNamespaceImport(namespace_2.text, context, context.symbolToken)); - } + return !symbolToken || !ts.isIdentifier(symbolToken) ? undefined : ts.firstDefined(existingImports, function (_a) { + var declaration = _a.declaration; + var namespace = getNamespaceImportName(declaration); + if (namespace) { + var moduleSymbol = namespace && checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)); + if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(context.symbolName))) { + return getCodeActionForUseExistingNamespaceImport(namespace.text, context, symbolToken); } } - } - getCodeActionsForAddImport(exportInfos, context, existingImports, useExisting, addNew); + }); + } + function tryAddToExistingImport(existingImports, context) { + return ts.firstDefined(existingImports, function (_a) { + var declaration = _a.declaration, importKind = _a.importKind; + if (declaration.kind === 244 /* ImportDeclaration */ && declaration.importClause) { + var changes = tryUpdateExistingImport(context, declaration.importClause, importKind); + if (changes) { + var moduleSpecifierWithoutQuotes = ts.stripQuotes(declaration.moduleSpecifier.getText()); + return createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [context.symbolName, moduleSpecifierWithoutQuotes], changes); + } + } + }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 243 /* ImportDeclaration */) { + if (declaration.kind === 244 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 245 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 246 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; } } - // TODO(anhans): This doesn't seem important to cache... just use an iterator instead of creating a new array? - function getImportDeclarations(_a, checker, _b, cachedImportDeclarations) { + function getExistingImportDeclarations(_a, checker, _b) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind; var imports = _b.imports; - if (cachedImportDeclarations === void 0) { cachedImportDeclarations = []; } - var moduleSymbolId = ts.getUniqueSymbolId(moduleSymbol, checker); - var cached = cachedImportDeclarations[moduleSymbolId]; - if (!cached) { - cached = cachedImportDeclarations[moduleSymbolId] = ts.mapDefined(imports, function (moduleSpecifier) { - var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 243 /* ImportDeclaration */ || i.kind === 242 /* ImportEqualsDeclaration */) - && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; - }); - } - return cached; + return ts.mapDefined(imports, function (moduleSpecifier) { + var i = ts.importFromModuleSpecifier(moduleSpecifier); + return (i.kind === 244 /* ImportDeclaration */ || i.kind === 243 /* ImportEqualsDeclaration */) + && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; + }); } function getCodeActionForNewImport(context, _a) { var moduleSpecifier = _a.moduleSpecifier, importKind = _a.importKind; @@ -100819,7 +101454,7 @@ var ts; }); // if this file doesn't have any import statements, insert an import statement and then insert a new line // between the only import statement and user code. Otherwise just insert the statement because chances - // are there are already a new line seperating code and import statements. + // are there are already a new line separating code and import statements. return createCodeAction(ts.Diagnostics.Import_0_from_module_1, [symbolName, moduleSpecifierWithoutQuotes], changes); } function shouldUseSingleQuote(sourceFile, preferences) { @@ -100853,21 +101488,7 @@ var ts; // Sort to keep the shortest paths first, but keep [relativePath, importRelativeToBaseUrl] groups together return ts.flatten(choicesForEachExportingModule.sort(function (a, b) { return ts.first(a).moduleSpecifier.length - ts.first(b).moduleSpecifier.length; })); } - function getCodeActionsForAddImport(exportInfos, ctx, existingImports, useExisting, addNew) { - var fromExistingImport = ts.firstDefined(existingImports, function (_a) { - var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 243 /* ImportDeclaration */ && declaration.importClause) { - var changes = tryUpdateExistingImport(ctx, ts.isImportClause(declaration.importClause) && declaration.importClause || undefined, importKind); - if (changes) { - var moduleSpecifierWithoutQuotes = ts.stripQuotes(declaration.moduleSpecifier.getText()); - return createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [ctx.symbolName, moduleSpecifierWithoutQuotes], changes); - } - } - }); - if (fromExistingImport) { - useExisting.push(fromExistingImport); - return; - } + function getCodeActionsForAddImport(exportInfos, ctx, existingImports, addNew) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); var newImportInfos = existingDeclaration ? [existingDeclaration] @@ -100879,9 +101500,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 243 /* ImportDeclaration */ + var expression = declaration.kind === 244 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 253 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 254 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -100889,7 +101510,7 @@ var ts; function tryUpdateExistingImport(context, importClause, importKind) { var symbolName = context.symbolName, sourceFile = context.sourceFile; var name = importClause.name; - var namedBindings = (importClause.kind !== 242 /* ImportEqualsDeclaration */ && importClause).namedBindings; + var namedBindings = (importClause.kind !== 243 /* ImportEqualsDeclaration */ && importClause).namedBindings; // TODO: GH#18217 switch (importKind) { case 1 /* Default */: return name ? undefined : ChangeTracker.with(context, function (t) { @@ -100897,11 +101518,11 @@ var ts; }); case 0 /* Named */: { var newImportSpecifier_1 = ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(symbolName)); - if (namedBindings && namedBindings.kind === 246 /* NamedImports */ && namedBindings.elements.length !== 0) { + if (namedBindings && namedBindings.kind === 247 /* NamedImports */ && namedBindings.elements.length !== 0) { // There are already named imports; add another. return ChangeTracker.with(context, function (t) { return t.insertNodeInListAfter(sourceFile, namedBindings.elements[namedBindings.elements.length - 1], newImportSpecifier_1); }); } - if (!namedBindings || namedBindings.kind === 246 /* NamedImports */ && namedBindings.elements.length === 0) { + if (!namedBindings || namedBindings.kind === 247 /* NamedImports */ && namedBindings.elements.length === 0) { return ChangeTracker.with(context, function (t) { return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamedImports([newImportSpecifier_1]))); }); @@ -100935,11 +101556,6 @@ var ts; }); return createCodeAction(ts.Diagnostics.Change_0_to_1, [symbolName, namespacePrefix + "." + symbolName], changes); } - function getImportCodeActions(context) { - return context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code - ? getActionsForUMDImport(context) - : getActionsForNonUMDImport(context); - } function getActionsForUMDImport(context) { var token = ts.getTokenAtPosition(context.sourceFile, context.span.start, /*includeJsDocComment*/ false); var checker = context.program.getTypeChecker(); @@ -100952,7 +101568,7 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(parent); - if ((ts.isJsxOpeningLikeElement && parent.tagName === token) || parent.kind === 259 /* JsxOpeningFragment */) { + if ((ts.isJsxOpeningLikeElement && parent.tagName === token) || parent.kind === 260 /* JsxOpeningFragment */) { umdSymbol = checker.resolveName(checker.getJsxNamespace(parent), isNodeOpeningLikeElement ? parent.tagName : parent, 67216319 /* Value */, /*excludeGlobals*/ false); } } @@ -101001,7 +101617,14 @@ var ts; return undefined; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here ts.Debug.assert(symbolName !== "default"); - var currentTokenMeaning = ts.getMeaningFromLocation(symbolToken); + var addToExistingDeclaration = []; + var addNewDeclaration = []; + getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).forEach(function (exportInfos) { + getCodeActionsForImport_separateExistingAndNew(exportInfos, convertToImportCodeFixContext(context, symbolToken, symbolName), addToExistingDeclaration, addNewDeclaration); + }); + return addToExistingDeclaration.concat(addNewDeclaration); + } + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { // 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(); @@ -101026,7 +101649,7 @@ var ts; addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */); } function getEscapedNameForExportDefault(symbol) { - return ts.firstDefined(symbol.declarations, function (declaration) { + return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { if (ts.isExportAssignment(declaration)) { if (ts.isIdentifier(declaration.expression)) { return declaration.expression.escapedText; @@ -101034,19 +101657,12 @@ var ts; } else if (ts.isExportSpecifier(declaration)) { ts.Debug.assert(declaration.name.escapedText === "default" /* Default */); - if (declaration.propertyName) { - return declaration.propertyName.escapedText; - } + return declaration.propertyName && declaration.propertyName.escapedText; } }); } }); - var addToExistingDeclaration = []; - var addNewDeclaration = []; - originalSymbolToExportInfos.forEach(function (exportInfos) { - getCodeActionsForImport_separateExistingAndNew(exportInfos, convertToImportCodeFixContext(context, symbolToken, symbolName), addToExistingDeclaration, addNewDeclaration); - }); - return addToExistingDeclaration.concat(addNewDeclaration); + return originalSymbolToExportInfos; } function checkSymbolHasMeaning(_a, meaning) { var declarations = _a.declarations; @@ -101068,7 +101684,7 @@ var ts; for (var _b = 0, allSourceFiles_1 = allSourceFiles; _b < allSourceFiles_1.length; _b++) { var sourceFile = allSourceFiles_1[_b]; if (ts.isExternalOrCommonJsModule(sourceFile)) { - cb(sourceFile.symbol, sourceFile); + cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile); } } } @@ -101285,7 +101901,7 @@ var ts; } function addMissingMemberInJs(changeTracker, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 204 /* ClassExpression */) { + if (classDeclaration.kind === 205 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -101311,10 +101927,10 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 199 /* BinaryExpression */) { + if (token.parent.parent.kind === 200 /* 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))); + var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); // TODO: GH#18217 typeNode = checker.typeToTypeNode(widenedType, classDeclaration); } return typeNode || ts.createKeywordTypeNode(119 /* AnyKeyword */); @@ -101370,7 +101986,13 @@ var ts; } function addMethodDeclaration(changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(callExpression, token.text, inJs, makeStatic, preferences); - changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); + var containingMethodDeclaration = ts.getAncestor(callExpression, 154 /* MethodDeclaration */); + if (containingMethodDeclaration && containingMethodDeclaration.parent === classDeclaration) { + changeTracker.insertNodeAfter(classDeclarationSourceFile, containingMethodDeclaration, methodDeclaration); + } + else { + changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); + } } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -101409,7 +102031,7 @@ var ts; var packageName = ts.getPackageName(moduleName).packageName; return diagCode === errorCodeCannotFindModule ? (ts.JsTyping.nodeCoreModules.has(packageName) ? "@types/node" : undefined) - : (host.isKnownTypesPackageName(packageName) ? ts.getTypesPackageName(packageName) : undefined); + : (host.isKnownTypesPackageName(packageName) ? ts.getTypesPackageName(packageName) : undefined); // TODO: GH#18217 } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -101628,7 +102250,9 @@ var ts; }, fixIds: [fixId], getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - doChange(changes, context.sourceFile, getInfo(diag.file, diag.start, diag.code)); + var info = getInfo(diag.file, diag.start, diag.code); + if (info) + doChange(changes, context.sourceFile, info); }); }, }); function getInfo(sourceFile, pos, diagCode) { @@ -101659,23 +102283,30 @@ var ts; ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code, ts.Diagnostics.All_imports_in_import_declaration_are_unused.code, ts.Diagnostics.All_destructured_elements_are_unused.code, + ts.Diagnostics.All_variables_are_unused.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var errorCode = context.errorCode, sourceFile = context.sourceFile; - var importDecl = tryGetFullImport(sourceFile, context.span.start); + var errorCode = context.errorCode, sourceFile = context.sourceFile, program = context.program; + var checker = program.getTypeChecker(); + var startToken = ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); + var importDecl = tryGetFullImport(startToken); if (importDecl) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.deleteNode(sourceFile, importDecl); }); return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Remove_import_from_0, ts.showModuleSpecifier(importDecl)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } - var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, context.span.start, /*deleted*/ undefined); }); + var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, startToken, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); if (delDestructure.length) { return [codefix.createCodeFixAction(fixName, delDestructure, ts.Diagnostics.Remove_destructuring, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } + var delVar = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullVariableStatement(t, sourceFile, startToken, /*deleted*/ undefined); }); + if (delVar.length) { + return [codefix.createCodeFixAction(fixName, delVar, ts.Diagnostics.Remove_variable_statement, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; + } var token = getToken(sourceFile, ts.textSpanEnd(context.span)); var result = []; - var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, /*deleted*/ undefined); }); + var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); if (deletion.length) { result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, token.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)); } @@ -101688,9 +102319,11 @@ var ts; fixIds: [fixIdPrefix, fixIdDelete], getAllCodeActions: function (context) { // Track a set of deleted nodes that may be ancestors of other marked for deletion -- only delete the ancestors. - var deleted = new NodeSet(); + var deleted = new ts.NodeSet(); + var sourceFile = context.sourceFile, program = context.program; + var checker = program.getTypeChecker(); return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var sourceFile = context.sourceFile; + var startToken = ts.getTokenAtPosition(sourceFile, diag.start, /*includeJsDocComment*/ false); var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file); switch (context.fixId) { case fixIdPrefix: @@ -101702,14 +102335,13 @@ var ts; // Ignore if this range was already deleted. if (deleted.some(function (d) { return ts.rangeContainsPosition(d, diag.start); })) break; - var importDecl = tryGetFullImport(diag.file, diag.start); + var importDecl = tryGetFullImport(startToken); if (importDecl) { changes.deleteNode(sourceFile, importDecl); } - else { - if (!tryDeleteFullDestructure(changes, sourceFile, diag.start, deleted)) { - tryDeleteDeclaration(changes, sourceFile, token, deleted); - } + else if (!tryDeleteFullDestructure(changes, sourceFile, startToken, deleted, checker, /*isFixAll*/ true) && + !tryDeleteFullVariableStatement(changes, sourceFile, startToken, deleted)) { + tryDeleteDeclaration(changes, sourceFile, token, deleted, checker, /*isFixAll*/ true); } break; default: @@ -101719,25 +102351,25 @@ var ts; }, }); // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. - function tryGetFullImport(sourceFile, pos) { - var startToken = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + function tryGetFullImport(startToken) { return startToken.kind === 91 /* ImportKeyword */ ? ts.tryCast(startToken.parent, ts.isImportDeclaration) : undefined; } - function tryDeleteFullDestructure(changes, sourceFile, pos, deletedAncestors) { - var startToken = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + function tryDeleteFullDestructure(changes, sourceFile, startToken, deletedAncestors, checker, isFixAll) { if (startToken.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(startToken.parent)) return false; - var decl = startToken.parent.parent; + var decl = ts.cast(startToken.parent, ts.isObjectBindingPattern).parent; switch (decl.kind) { - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors); break; - case 148 /* Parameter */: + case 149 /* Parameter */: + if (!mayDeleteParameter(decl, checker, isFixAll)) + break; if (deletedAncestors) deletedAncestors.add(decl); changes.deleteNodeInList(sourceFile, decl); break; - case 181 /* BindingElement */: + case 182 /* BindingElement */: if (deletedAncestors) deletedAncestors.add(decl); changes.deleteNode(sourceFile, decl); @@ -101747,6 +102379,16 @@ var ts; } return true; } + function tryDeleteFullVariableStatement(changes, sourceFile, startToken, deletedAncestors) { + var declarationList = ts.tryCast(startToken.parent, ts.isVariableDeclarationList); + if (declarationList && declarationList.getChildren(sourceFile)[0] === startToken) { + if (deletedAncestors) + deletedAncestors.add(declarationList); + changes.deleteNode(sourceFile, declarationList.parent.kind === 214 /* VariableStatement */ ? declarationList.parent : declarationList); + return true; + } + return false; + } function getToken(sourceFile, pos) { var token = ts.findPrecedingToken(pos, sourceFile, /*startNode*/ undefined, /*includeJsDoc*/ true); // this handles var ["computed"] = 12; @@ -101760,26 +102402,26 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 148 /* Parameter */: + case 149 /* Parameter */: return true; - case 231 /* VariableDeclaration */: { + case 232 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 221 /* ForOfStatement */: - case 220 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 221 /* ForInStatement */: return true; } } } return false; } - function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors) { + function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { switch (token.kind) { case 71 /* Identifier */: - tryDeleteIdentifier(changes, sourceFile, token, deletedAncestors); + tryDeleteIdentifier(changes, sourceFile, token, deletedAncestors, checker, isFixAll); break; - case 151 /* PropertyDeclaration */: - case 245 /* NamespaceImport */: + case 152 /* PropertyDeclaration */: + case 246 /* NamespaceImport */: if (deletedAncestors) deletedAncestors.add(token.parent); changes.deleteNode(sourceFile, token.parent); @@ -101800,13 +102442,13 @@ var ts; changes.deleteNode(sourceFile, token.parent.parent); } } - function tryDeleteIdentifier(changes, sourceFile, identifier, deletedAncestors) { + function tryDeleteIdentifier(changes, sourceFile, identifier, deletedAncestors, checker, isFixAll) { var parent = identifier.parent; switch (parent.kind) { - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors); break; - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: var typeParameters = ts.getEffectiveTypeParameterDeclarations(parent.parent); if (typeParameters.length === 1) { var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end; @@ -101820,18 +102462,17 @@ var ts; changes.deleteNodeInList(sourceFile, parent); } break; - case 148 /* Parameter */: - var oldFunction = parent.parent; - if (ts.isSetAccessor(oldFunction)) { - // Setter must have a parameter + case 149 /* Parameter */: + if (!mayDeleteParameter(parent, checker, isFixAll)) break; - } + var oldFunction = parent.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) { // Lambdas with exactly one parameter are special because, after removal, there // must be an empty parameter list (i.e. `()`) and this won't necessarily be the // case if the parameter is simply removed (e.g. in `x => 1`). var newFunction = ts.updateArrowFunction(oldFunction, oldFunction.modifiers, oldFunction.typeParameters, - /*parameters*/ undefined, oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); + /*parameters*/ undefined, // TODO: GH#18217 + oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); // Drop leading and trailing trivia of the new function because we're only going // to replace the span (vs the full span) of the old function - the old leading // and trailing trivia will remain. @@ -101842,13 +102483,13 @@ var ts; changes.deleteNodeInList(sourceFile, parent); } break; - case 181 /* BindingElement */: { + case 182 /* BindingElement */: { var pattern = parent.parent; switch (pattern.kind) { - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: changes.deleteNode(sourceFile, parent); // Don't delete ',' break; - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: changes.deleteNodeInList(sourceFile, parent); break; default: @@ -101857,11 +102498,11 @@ var ts; break; } // handle case where 'import a = A;' - case 242 /* ImportEqualsDeclaration */: - var importEquals = ts.getAncestor(identifier, 242 /* ImportEqualsDeclaration */); + case 243 /* ImportEqualsDeclaration */: + var importEquals = ts.getAncestor(identifier, 243 /* ImportEqualsDeclaration */); changes.deleteNode(sourceFile, importEquals); break; - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: var namedImports = parent.parent; if (namedImports.elements.length === 1) { tryDeleteNamedImportBinding(changes, sourceFile, namedImports); @@ -101871,10 +102512,10 @@ var ts; changes.deleteNodeInList(sourceFile, parent); } break; - case 244 /* ImportClause */: // this covers both 'import |d|' and 'import |d,| *' + case 245 /* ImportClause */: // this covers both 'import |d|' and 'import |d,| *' var importClause = parent; if (!importClause.namedBindings) { // |import d from './file'| - changes.deleteNode(sourceFile, ts.getAncestor(importClause, 243 /* ImportDeclaration */)); + changes.deleteNode(sourceFile, ts.getAncestor(importClause, 244 /* ImportDeclaration */)); } else { // import |d,| * as ns from './file' @@ -101890,7 +102531,7 @@ var ts; } } break; - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: tryDeleteNamedImportBinding(changes, sourceFile, parent); break; default: @@ -101912,14 +102553,14 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(namedBindings, 243 /* ImportDeclaration */); + var importDecl = ts.getAncestor(namedBindings, 244 /* ImportDeclaration */); changes.deleteNode(sourceFile, importDecl); } } // token.parent is a variableDeclaration function tryDeleteVariableDeclaration(changes, sourceFile, varDecl, deletedAncestors) { switch (varDecl.parent.parent.kind) { - case 219 /* ForStatement */: { + case 220 /* ForStatement */: { var forStatement = varDecl.parent.parent; var forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { @@ -101934,16 +102575,16 @@ var ts; } break; } - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: var forOfStatement = varDecl.parent.parent; - ts.Debug.assert(forOfStatement.initializer.kind === 232 /* VariableDeclarationList */); + ts.Debug.assert(forOfStatement.initializer.kind === 233 /* VariableDeclarationList */); var forOfInitializer = forOfStatement.initializer; if (deletedAncestors) deletedAncestors.add(forOfInitializer.declarations[0]); changes.replaceNode(sourceFile, forOfInitializer.declarations[0], ts.createObjectLiteral()); break; - case 220 /* ForInStatement */: - case 229 /* TryStatement */: + case 221 /* ForInStatement */: + case 230 /* TryStatement */: break; default: var variableStatement = varDecl.parent.parent; @@ -101959,18 +102600,34 @@ var ts; } } } - var NodeSet = /** @class */ (function () { - function NodeSet() { - this.map = ts.createMap(); + function mayDeleteParameter(p, checker, isFixAll) { + var parent = p.parent; + switch (parent.kind) { + case 154 /* MethodDeclaration */: + // Don't remove a parameter if this overrides something + var symbol = checker.getSymbolAtLocation(parent.name); + if (ts.isMemberSymbolInBaseType(symbol, checker)) + return false; + // falls through + case 155 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: { + // Can't remove a non-last parameter. Can remove a parameter in code-fix-all if future parameters are also unused. + var parameters = parent.parameters; + var index = parameters.indexOf(p); + ts.Debug.assert(index !== -1); + return isFixAll + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 71 /* Identifier */ && !p.symbol.isReferenced; }) + : index === parameters.length - 1; + } + case 157 /* SetAccessor */: + // Setter must have a parameter + return false; + default: + return ts.Debug.failBadSyntaxKind(parent); } - NodeSet.prototype.add = function (node) { - this.map.set(String(ts.getNodeId(node)), node); - }; - NodeSet.prototype.some = function (pred) { - return ts.forEachEntry(this.map, pred) || false; - }; - return NodeSet; - }()); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -101995,7 +102652,7 @@ var ts; ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; switch (container.kind) { - case 216 /* IfStatement */: + case 217 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { changes.deleteNodeRange(sourceFile, ts.first(statement.parent.statements), ts.last(statement.parent.statements)); @@ -102006,8 +102663,8 @@ var ts; break; } // falls through - case 218 /* WhileStatement */: - case 219 /* ForStatement */: + case 219 /* WhileStatement */: + case 220 /* ForStatement */: changes.deleteNode(sourceFile, container); break; default: @@ -102027,13 +102684,15 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: return true; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return ts.getModuleInstanceState(s) !== 1 /* Instantiated */; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); + default: + return false; } } function sliceAfter(arr, value) { @@ -102094,10 +102753,10 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 280 /* JSDocNullableType */) { + if (typeNode.kind === 281 /* 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, 4096 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 8192 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -102114,13 +102773,13 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 280 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 4096 /* Undefined */) : type; + var fixedType = typeNode.kind === 281 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } }); function doChange(changes, sourceFile, oldTypeNode, newType, checker) { - changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(newType, /*enclosingDeclaration*/ oldTypeNode)); + changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(newType, /*enclosingDeclaration*/ oldTypeNode)); // TODO: GH#18217 } function getInfo(sourceFile, pos, checker) { var decl = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false), isTypeContainer); @@ -102131,22 +102790,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 207 /* AsExpression */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 233 /* FunctionDeclaration */: - case 155 /* GetAccessor */: - case 159 /* IndexSignature */: - case 176 /* MappedType */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 148 /* Parameter */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 156 /* SetAccessor */: - case 236 /* TypeAliasDeclaration */: - case 189 /* TypeAssertionExpression */: - case 231 /* VariableDeclaration */: + case 208 /* AsExpression */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 234 /* FunctionDeclaration */: + case 156 /* GetAccessor */: + case 160 /* IndexSignature */: + case 177 /* MappedType */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 149 /* Parameter */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 157 /* SetAccessor */: + case 237 /* TypeAliasDeclaration */: + case 190 /* TypeAssertionExpression */: + case 232 /* VariableDeclaration */: return true; default: return false; @@ -102200,20 +102859,20 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 89 /* FunctionKeyword */, sourceFile); break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 19 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: return; } - return { + return insertBefore && { insertBefore: insertBefore, returnType: getReturnType(containingFunction) }; @@ -102316,17 +102975,17 @@ var ts; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); switch (declaration.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 150 /* PropertySignature */: - case 151 /* PropertyDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 151 /* PropertySignature */: + case 152 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration); out(ts.createProperty( /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 152 /* MethodSignature */: - case 153 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 154 /* 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 @@ -102366,7 +103025,7 @@ var ts; } } function signatureToMethodDeclaration(checker, signature, enclosingDeclaration, modifiers, name, optional, body) { - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 153 /* MethodDeclaration */, enclosingDeclaration, 256 /* SuppressAnyReturnType */); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 154 /* MethodDeclaration */, enclosingDeclaration, 256 /* SuppressAnyReturnType */); if (!signatureDeclaration) { return undefined; } @@ -102508,7 +103167,7 @@ var ts; function getDiagnostic(errorCode, token) { switch (errorCode) { case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: - return ts.isSetAccessor(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; + return ts.isSetAccessor(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217 case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: return ts.Diagnostics.Infer_parameter_types_from_usage; default: @@ -102583,11 +103242,11 @@ var ts; } function isApplicableFunctionForInference(declaration) { switch (declaration.kind) { - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: return true; - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return !!declaration.name; } return false; @@ -102626,6 +103285,7 @@ var ts; var notAccessible = function () { typeIsAccessible = false; }; var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { trackSymbol: function (symbol, declaration, meaning) { + // TODO: GH#18217 typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; }, reportInaccessibleThisError: notAccessible, @@ -102645,11 +103305,11 @@ var ts; } function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { switch (containingFunction.kind) { - case 154 /* Constructor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - var isConstructor = containingFunction.kind === 154 /* Constructor */; + case 155 /* Constructor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + var isConstructor = containingFunction.kind === 155 /* Constructor */; var searchToken = isConstructor ? ts.findChildOfKind(containingFunction, 123 /* ConstructorKeyword */, sourceFile) : containingFunction.name; @@ -102683,7 +103343,7 @@ var ts; cancellationToken.throwIfCancellationRequested(); inferTypeFromContext(reference, checker, usageContext); } - var isConstructor = declaration.kind === 154 /* Constructor */; + var isConstructor = declaration.kind === 155 /* Constructor */; var callContexts = isConstructor ? usageContext.constructContexts : usageContext.callContexts; return callContexts && declaration.parameters.map(function (parameter, parameterIndex) { var types = []; @@ -102715,21 +103375,21 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: usageContext.isNumber = true; break; - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); break; - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); break; - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpressionContext(node.parent, checker, usageContext); } @@ -102737,13 +103397,13 @@ var ts; inferTypeFromContextualType(node, checker, usageContext); } break; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); break; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); break; - case 231 /* VariableDeclaration */: { + case 232 /* 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. @@ -102813,7 +103473,7 @@ var ts; case 29 /* GreaterThanToken */: case 31 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 272 /* EnumLike */) { + if (operandType.flags & 544 /* EnumLike */) { addCandidateType(usageContext, operandType); } else { @@ -102823,13 +103483,13 @@ var ts; case 59 /* PlusEqualsToken */: case 37 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 272 /* EnumLike */) { + if (otherOperandType.flags & 544 /* EnumLike */) { addCandidateType(usageContext, otherOperandType); } - else if (otherOperandType.flags & 84 /* NumberLike */) { + else if (otherOperandType.flags & 168 /* NumberLike */) { usageContext.isNumber = true; } - else if (otherOperandType.flags & 34 /* StringLike */) { + else if (otherOperandType.flags & 68 /* StringLike */) { usageContext.isString = true; } else { @@ -102852,7 +103512,7 @@ var ts; // LogicalOperator case 54 /* BarBarToken */: if (node === parent.left && - (node.parent.parent.kind === 231 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 232 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); @@ -102880,7 +103540,7 @@ var ts; } } inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 186 /* CallExpression */) { + if (parent.kind === 187 /* CallExpression */) { (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); } else { @@ -102905,7 +103565,7 @@ var ts; var indexType = checker.getTypeAtLocation(parent); var indexUsageContext = {}; inferTypeFromContext(parent, checker, indexUsageContext); - if (indexType.flags & 84 /* NumberLike */) { + if (indexType.flags & 168 /* NumberLike */) { usageContext.numberIndexContext = indexUsageContext; } else { @@ -102927,7 +103587,7 @@ var ts; return checker.getWidenedType(checker.getUnionType(usageContext.candidateTypes.map(function (t) { return checker.getBaseTypeOfLiteralType(t); }), 2 /* Subtype */)); } else if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); + var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 var types = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); return checker.createPromiseType(types.length ? checker.getUnionType(types, 2 /* Subtype */) : checker.getAnyType()); } @@ -102960,12 +103620,12 @@ var ts; } } if (usageContext.numberIndexContext) { - numberIndexInfo = checker.createIndexInfo(getTypeFromUsageContext(usageContext.numberIndexContext, checker), /*isReadonly*/ false); + numberIndexInfo = checker.createIndexInfo(getTypeFromUsageContext(usageContext.numberIndexContext, checker), /*isReadonly*/ false); // TODO: GH#18217 } if (usageContext.stringIndexContext) { stringIndexInfo = checker.createIndexInfo(getTypeFromUsageContext(usageContext.stringIndexContext, checker), /*isReadonly*/ false); } - return checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + return checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); // TODO: GH#18217 } else { return undefined; @@ -103000,15 +103660,16 @@ var ts; parameters.push(symbol); } var returnType = getTypeFromUsageContext(callContext.returnType, checker) || checker.getVoidType(); + // TODO: GH#18217 return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); } function addCandidateType(context, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 16384 /* Never */)) { + if (type && !(type.flags & 1 /* Any */) && !(type.flags & 32768 /* Never */)) { (context.candidateTypes || (context.candidateTypes = [])).push(type); } } function hasCallContext(usageContext) { - return usageContext && usageContext.callContexts; + return !!usageContext && !!usageContext.callContexts; } })(InferFromReference || (InferFromReference = {})); })(codefix = ts.codefix || (ts.codefix = {})); @@ -103041,7 +103702,7 @@ var ts; var opts = context.program.getCompilerOptions(); var variations = []; // import Bluebird from "bluebird"; - variations.push(createAction(context, sourceFile, node, ts.makeImport(namespace.name, /*namedImports*/ undefined, node.moduleSpecifier))); + variations.push(createAction(context, sourceFile, node, ts.makeImport(namespace.name, /*namedImports*/ undefined, node.moduleSpecifier, context.preferences))); if (ts.getEmitModuleKind(opts) === ts.ModuleKind.CommonJS) { // import Bluebird = require("bluebird"); variations.push(createAction(context, sourceFile, node, ts.createImportEqualsDeclaration( @@ -103063,18 +103724,18 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 186 /* CallExpression */ : 187 /* NewExpression */; + var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 187 /* CallExpression */ : 188 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } var expr = node.expression; - var type = context.program.getTypeChecker().getTypeAtLocation(expr); + var type = context.program.getTypeChecker().getTypeAtLocation(expr); // TODO: GH#18217 if (!(type.symbol && type.symbol.originatingImport)) { return []; } var fixes = []; - var relatedImport = type.symbol.originatingImport; + var relatedImport = type.symbol.originatingImport; // TODO: GH#18217 if (!ts.isImportCall(relatedImport)) { ts.addRange(fixes, getCodeFixesForImportDeclaration(context, relatedImport)); } @@ -103151,8 +103812,9 @@ var ts; } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { var undefinedTypeNode = ts.createKeywordTypeNode(140 /* UndefinedKeyword */); - var types = ts.isUnionTypeNode(propertyDeclaration.type) ? propertyDeclaration.type.types.concat(undefinedTypeNode) : [propertyDeclaration.type, undefinedTypeNode]; - changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration.type, ts.createUnionTypeNode(types)); + var type = propertyDeclaration.type; // TODO: GH#18217 + var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; + changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.createUnionTypeNode(types)); } function getActionForAddMissingInitializer(context, propertyDeclaration) { var checker = context.program.getTypeChecker(); @@ -103167,16 +103829,16 @@ var ts; changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getInitializer(checker, propertyDeclaration) { - return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); + return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 2 /* String */) { + if (type.flags & 4 /* String */) { return ts.createLiteral(""); } - else if (type.flags & 4 /* Number */) { + else if (type.flags & 8 /* Number */) { return ts.createNumericLiteral("0"); } - else if (type.flags & 8 /* Boolean */) { + else if (type.flags & 16 /* Boolean */) { return ts.createFalse(); } else if (type.isLiteral()) { @@ -103204,78 +103866,99 @@ var ts; (function (ts) { var moduleSpecifiers; (function (moduleSpecifiers) { + // Note: fromSourceFile is just for usesJsExtensionOnImports + function getModuleSpecifier(program, fromSourceFile, fromSourceFileName, toFileName, host, preferences) { + var info = getInfo(program.getCompilerOptions(), fromSourceFile, fromSourceFileName, host); + var compilerOptions = program.getCompilerOptions(); + return getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || + ts.first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); + } + moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; // For each symlink/original for a module, returns a list of ways to import that file. function getModuleSpecifiers(moduleSymbol, program, importingSourceFile, host, preferences) { + var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); + if (ambient) + return [[ambient]]; var compilerOptions = program.getCompilerOptions(); - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); - var addJsExtension = usesJsExtensionOnImports(importingSourceFile); - var getCanonicalFileName = ts.hostGetCanonicalFileName(host); - var sourceDirectory = ts.getDirectoryPath(importingSourceFile.fileName); - return getAllModulePaths(program, moduleSymbol.valueDeclaration.getSourceFile()).map(function (moduleFileName) { - var global = tryGetModuleNameFromAmbientModule(moduleSymbol) - || tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) - || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) - || rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); - if (global) { - return [global]; - } - var relativePath = removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); - if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { - return [relativePath]; - } - var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName); - if (!relativeToBaseUrl) { - return [relativePath]; - } - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, moduleResolutionKind, addJsExtension); - if (paths) { - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - if (fromPaths) { - return [fromPaths]; - } - } - if (preferences.importModuleSpecifierPreference === "non-relative") { - return [importRelativeToBaseUrl]; - } - if (preferences.importModuleSpecifierPreference !== undefined) - ts.Debug.assertNever(preferences.importModuleSpecifierPreference); - if (isPathRelativeToParent(relativeToBaseUrl)) { - return [relativePath]; - } - /* - Prefer a relative import over a baseUrl import if it doesn't traverse up to baseUrl. - - Suppose we have: - baseUrl = /base - sourceDirectory = /base/a/b - moduleFileName = /base/foo/bar - Then: - relativePath = ../../foo/bar - getRelativePathNParents(relativePath) = 2 - pathFromSourceToBaseUrl = ../../ - getRelativePathNParents(pathFromSourceToBaseUrl) = 2 - 2 < 2 = false - In this case we should prefer using the baseUrl path "/a/b" instead of the relative path "../../foo/bar". - - Suppose we have: - baseUrl = /base - sourceDirectory = /base/foo/a - moduleFileName = /base/foo/bar - Then: - relativePath = ../a - getRelativePathNParents(relativePath) = 1 - pathFromSourceToBaseUrl = ../../ - getRelativePathNParents(pathFromSourceToBaseUrl) = 2 - 1 < 2 = true - In this case we should prefer using the relative path "../a" instead of the baseUrl path "foo/a". - */ - var pathFromSourceToBaseUrl = ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, baseUrl, getCanonicalFileName)); - var relativeFirst = getRelativePathNParents(relativePath) < getRelativePathNParents(pathFromSourceToBaseUrl); - return relativeFirst ? [relativePath, importRelativeToBaseUrl] : [importRelativeToBaseUrl, relativePath]; + var info = getInfo(compilerOptions, importingSourceFile, importingSourceFile.fileName, host); + var modulePaths = getAllModulePaths(program, moduleSymbol.valueDeclaration.getSourceFile()); + var global = ts.mapDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }); + return global.length ? global.map(function (g) { return [g]; }) : modulePaths.map(function (moduleFileName) { + return getLocalModuleSpecifiers(moduleFileName, info, compilerOptions, preferences); }); } moduleSpecifiers.getModuleSpecifiers = getModuleSpecifiers; + // importingSourceFileName is separate because getEditsForFileRename may need to specify an updated path + function getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host) { + var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); + var addJsExtension = usesJsExtensionOnImports(importingSourceFile); + var getCanonicalFileName = ts.hostGetCanonicalFileName(host); + var sourceDirectory = ts.getDirectoryPath(importingSourceFileName); + return { moduleResolutionKind: moduleResolutionKind, addJsExtension: addJsExtension, getCanonicalFileName: getCanonicalFileName, sourceDirectory: sourceDirectory }; + } + function getGlobalModuleSpecifier(moduleFileName, _a, host, compilerOptions) { + var addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; + return tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) + || compilerOptions.rootDirs && tryGetModuleNameFromRootDirs(compilerOptions.rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); + } + function getLocalModuleSpecifiers(moduleFileName, _a, compilerOptions, preferences) { + var moduleResolutionKind = _a.moduleResolutionKind, addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var relativePath = removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); + if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { + return [relativePath]; + } + var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName); + if (!relativeToBaseUrl) { + return [relativePath]; + } + var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, moduleResolutionKind, addJsExtension); + if (paths) { + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); + if (fromPaths) { + return [fromPaths]; + } + } + if (preferences.importModuleSpecifierPreference === "non-relative") { + return [importRelativeToBaseUrl]; + } + if (preferences.importModuleSpecifierPreference !== undefined) + ts.Debug.assertNever(preferences.importModuleSpecifierPreference); + if (isPathRelativeToParent(relativeToBaseUrl)) { + return [relativePath]; + } + /* + Prefer a relative import over a baseUrl import if it doesn't traverse up to baseUrl. + + Suppose we have: + baseUrl = /base + sourceDirectory = /base/a/b + moduleFileName = /base/foo/bar + Then: + relativePath = ../../foo/bar + getRelativePathNParents(relativePath) = 2 + pathFromSourceToBaseUrl = ../../ + getRelativePathNParents(pathFromSourceToBaseUrl) = 2 + 2 < 2 = false + In this case we should prefer using the baseUrl path "/a/b" instead of the relative path "../../foo/bar". + + Suppose we have: + baseUrl = /base + sourceDirectory = /base/foo/a + moduleFileName = /base/foo/bar + Then: + relativePath = ../a + getRelativePathNParents(relativePath) = 1 + pathFromSourceToBaseUrl = ../../ + getRelativePathNParents(pathFromSourceToBaseUrl) = 2 + 1 < 2 = true + In this case we should prefer using the relative path "../a" instead of the baseUrl path "foo/a". + */ + var pathFromSourceToBaseUrl = ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, baseUrl, getCanonicalFileName)); + var relativeFirst = getRelativePathNParents(relativePath) < getRelativePathNParents(pathFromSourceToBaseUrl); + return relativeFirst ? [relativePath, importRelativeToBaseUrl] : [importRelativeToBaseUrl, relativePath]; + } function usesJsExtensionOnImports(_a) { var imports = _a.imports; return ts.firstDefined(imports, function (_a) { @@ -103369,14 +104052,16 @@ var ts; // If the module could be imported by a directory name, use that directory's name var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path - moduleSpecifier = getNodeResolvablePath(moduleSpecifier); + // if node_modules folder is in this folder or any of its parent folders, no need to keep it. + if (!ts.startsWith(sourceDirectory, moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex))) + return undefined; // If the module was found in @types, get the actual Node package name - return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier); + return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); function getDirectoryOrExtensionlessFileName(path) { // If the file is the main module, it can be imported by the package name var packageRootPath = path.substring(0, parts.packageRootIndex); var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - if (host.fileExists(packageJsonPath)) { + if (host.fileExists(packageJsonPath)) { // TODO: GH#18217 var packageJsonContent = JSON.parse(host.readFile(packageJsonPath)); if (packageJsonContent) { var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main; @@ -103396,16 +104081,6 @@ var ts; } return fullModulePathWithoutExtension; } - function getNodeResolvablePath(path) { - var basePath = path.substring(0, parts.topLevelNodeModulesIndex); - if (sourceDirectory.indexOf(basePath) === 0) { - // if node_modules folder is in this folder or any of its parent folders, no need to keep it. - return path.substring(parts.topLevelPackageNameIndex + 1); - } - else { - return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, path, getCanonicalFileName)); - } - } } function getNodeModulePathParts(fullPath) { // If fullPath can't be valid module file within node_modules, returns undefined. @@ -103461,7 +104136,7 @@ var ts; } function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) { return ts.firstDefined(rootDirs, function (rootDir) { - var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName); + var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName); // TODO: GH#18217 return isPathRelativeToParent(relativePath) ? undefined : relativePath; }); } @@ -103527,14 +104202,14 @@ var ts; var info = getInfo(sourceFile, start); if (!info) return undefined; - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info, context.preferences); }); return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_default_import, fixId, ts.Diagnostics.Convert_all_to_default_imports)]; }, fixIds: [fixId], getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { var info = getInfo(diag.file, diag.start); if (info) - doChange(changes, diag.file, info); + doChange(changes, diag.file, info, context.preferences); }); }, }); function getInfo(sourceFile, pos) { @@ -103550,8 +104225,8 @@ var ts; return { importNode: importNode, name: name, moduleSpecifier: importNode.moduleSpecifier }; } } - function doChange(changes, sourceFile, info) { - changes.replaceNode(sourceFile, info.importNode, ts.makeImport(info.name, /*namedImports*/ undefined, info.moduleSpecifier)); + function doChange(changes, sourceFile, info, preferences) { + changes.replaceNode(sourceFile, info.importNode, ts.makeImport(info.name, /*namedImports*/ undefined, info.moduleSpecifier, preferences)); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -103579,7 +104254,7 @@ var ts; function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); ts.Debug.assert(token.kind === 91 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 178 /* ImportType */); + ts.Debug.assert(token.parent.kind === 179 /* ImportType */); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -103590,6 +104265,187 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixIdAddMissingTypeof = "fixConvertToMappedObjectType"; + var fixId = fixIdAddMissingTypeof; + var errorCodes = [ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span; + var info = getInfo(sourceFile, span.start); + if (!info) + return undefined; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info); }); + var name = ts.idText(info.container.name); + return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Convert_0_to_mapped_object_type, name], fixId, [ts.Diagnostics.Convert_0_to_mapped_object_type, name])]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var info = getInfo(diag.file, diag.start); + if (info) + doChange(changes, diag.file, info); + }); } + }); + function getInfo(sourceFile, pos) { + var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var indexSignature = ts.cast(token.parent.parent, ts.isIndexSignatureDeclaration); + if (ts.isClassDeclaration(indexSignature.parent)) + return undefined; + var container = ts.isInterfaceDeclaration(indexSignature.parent) ? indexSignature.parent : ts.cast(indexSignature.parent.parent, ts.isTypeAliasDeclaration); + return { indexSignature: indexSignature, container: container }; + } + function createTypeAliasFromInterface(declaration, type) { + return ts.createTypeAliasDeclaration(declaration.decorators, declaration.modifiers, declaration.name, declaration.typeParameters, type); + } + function doChange(changes, sourceFile, _a) { + var indexSignature = _a.indexSignature, container = _a.container; + var members = ts.isInterfaceDeclaration(container) ? container.members : container.type.members; + var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); + var parameter = ts.first(indexSignature.parameters); + var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(132 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ + mappedIntersectionType + ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); + changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var refactor; + (function (refactor) { + var generateGetAccessorAndSetAccessor; + (function (generateGetAccessorAndSetAccessor) { + var refactorName = "Convert import"; + var actionNameNamespaceToNamed = "Convert namespace import to named imports"; + var actionNameNamedToNamespace = "Convert named imports to namespace import"; + refactor.registerRefactor(refactorName, { + getAvailableActions: function (context) { + var i = getImportToConvert(context); + if (!i) + return undefined; + var description = i.kind === 246 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 246 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; + }, + getEditsForAction: function (context, actionName) { + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + } + }); + // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`. + function getImportToConvert(context) { + var file = context.file; + var span = ts.getRefactorContextSpan(context); + var token = ts.getTokenAtPosition(file, span.start, /*includeJsDocComment*/ false); + var importDecl = ts.getParentNodeInSpan(token, file, span); + if (!importDecl || !ts.isImportDeclaration(importDecl)) + return undefined; + var importClause = importDecl.importClause; + return importClause && importClause.namedBindings; + } + function doChange(sourceFile, program, changes, toConvert) { + var checker = program.getTypeChecker(); + if (toConvert.kind === 246 /* NamespaceImport */) { + doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); + } + else { + doChangeNamedToNamespace(sourceFile, checker, changes, toConvert); + } + } + function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { + var usedAsNamespaceOrDefault = false; + var nodesToReplace = []; + var conflictingNames = ts.createMap(); + ts.FindAllReferences.Core.eachSymbolReferenceInFile(toConvert.name, checker, sourceFile, function (id) { + if (!ts.isPropertyAccessExpression(id.parent)) { + usedAsNamespaceOrDefault = true; + } + else { + var parent = ts.cast(id.parent, ts.isPropertyAccessExpression); + var exportName = parent.name.text; + if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { + conflictingNames.set(exportName, true); + } + ts.Debug.assert(parent.expression === id); + nodesToReplace.push(parent); + } + }); + // We may need to change `mod.x` to `_x` to avoid a name conflict. + var exportNameToImportName = ts.createMap(); + for (var _i = 0, nodesToReplace_1 = nodesToReplace; _i < nodesToReplace_1.length; _i++) { + var propertyAccess = nodesToReplace_1[_i]; + var exportName = propertyAccess.name.text; + var importName = exportNameToImportName.get(exportName); + if (importName === undefined) { + exportNameToImportName.set(exportName, importName = conflictingNames.has(exportName) ? ts.getUniqueName(exportName, sourceFile) : exportName); + } + changes.replaceNode(sourceFile, propertyAccess, ts.createIdentifier(importName)); + } + var importSpecifiers = []; + exportNameToImportName.forEach(function (name, propertyName) { + importSpecifiers.push(ts.createImportSpecifier(name === propertyName ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name))); + }); + var importDecl = toConvert.parent.parent; + if (usedAsNamespaceOrDefault && !allowSyntheticDefaultImports) { + // Need to leave the namespace import alone + changes.insertNodeAfter(sourceFile, importDecl, updateImport(importDecl, /*defaultImportName*/ undefined, importSpecifiers)); + } + else { + changes.replaceNode(sourceFile, importDecl, updateImport(importDecl, usedAsNamespaceOrDefault ? ts.createIdentifier(toConvert.name.text) : undefined, importSpecifiers)); + } + } + function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) { + var importDecl = toConvert.parent.parent; + var moduleSpecifier = importDecl.moduleSpecifier; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 6 /* ESNext */) : "module"; + var namespaceNameConflicts = toConvert.elements.some(function (element) { + return ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { + return !!checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + }) || false; + }); + var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; + var neededNamedImports = []; + var _loop_22 = function (element) { + var propertyName = (element.propertyName || element.name).text; + ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { + var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); + if (ts.isShorthandPropertyAssignment(id.parent)) { + changes.replaceNode(sourceFile, id.parent, ts.createPropertyAssignment(id.text, access)); + } + else if (ts.isExportSpecifier(id.parent) && !id.parent.propertyName) { + if (!neededNamedImports.some(function (n) { return n.name === element.name; })) { + neededNamedImports.push(ts.createImportSpecifier(element.propertyName && ts.createIdentifier(element.propertyName.text), ts.createIdentifier(element.name.text))); + } + } + else { + changes.replaceNode(sourceFile, id, access); + } + }); + }; + for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { + var element = _a[_i]; + _loop_22(element); + } + changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); + if (neededNamedImports.length) { + changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, neededNamedImports)); + } + } + function updateImport(old, defaultImportName, elements) { + return ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImportName, elements && elements.length ? ts.createNamedImports(elements) : undefined), old.moduleSpecifier); + } + })(generateGetAccessorAndSetAccessor = refactor.generateGetAccessorAndSetAccessor || (refactor.generateGetAccessorAndSetAccessor = {})); + })(refactor = ts.refactor || (ts.refactor = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -103672,7 +104528,7 @@ var ts; /* Exported for tests */ function getEditsForAction(context, actionName) { var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context)); - var targetRange = rangeToExtract.targetRange; + var targetRange = rangeToExtract.targetRange; // TODO:GH#18217 var parsedFunctionIndexMatch = /^function_scope_(\d+)$/.exec(actionName); if (parsedFunctionIndexMatch) { var index = +parsedFunctionIndexMatch[1]; @@ -103743,9 +104599,9 @@ var ts; } // 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 start = getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); + var start = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); // Do the same for the ending position - var end = getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); + var end = ts.getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); 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. @@ -103764,7 +104620,8 @@ var ts; return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } var statements = []; - for (var _i = 0, _a = start.parent.statements; _i < _a.length; _i++) { + var start2 = start; // TODO: GH#18217 Need to alias `start` to get this to compile. See https://github.com/Microsoft/TypeScript/issues/19955#issuecomment-344118248 + for (var _i = 0, _a = start2.parent.statements; _i < _a.length; _i++) { var statement = _a[_i]; if (statement === start || statements.length) { var errors_1 = checkNode(statement); @@ -103797,7 +104654,7 @@ var ts; if (errors) { return { errors: errors }; } - return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; + return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217 /** * Attempt to refine the extraction node (generally, by shrinking it) to produce better results. * @param node The unrefined extraction node. @@ -103839,20 +104696,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 151 /* PropertyDeclaration */) { + if (current.kind === 152 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 148 /* Parameter */) { + else if (current.kind === 149 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 154 /* Constructor */) { + if (ctorOrMethod.kind === 155 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 153 /* MethodDeclaration */) { + else if (current.kind === 154 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -103895,8 +104752,11 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 231 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 232 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(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`! + // Also TODO: GH#19956 (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; } @@ -103904,15 +104764,15 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; case 97 /* 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 === 186 /* CallExpression */) { + if (node.parent.kind === 187 /* CallExpression */) { // Super constructor call - var containingClass_1 = ts.getContainingClass(node); + var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractSuper)); return true; @@ -103923,10 +104783,10 @@ var ts; } break; } - if (!node || ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { + if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -103938,20 +104798,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 216 /* IfStatement */: + case 217 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 229 /* TryStatement */: + case 230 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 212 /* Block */: - if (node.parent && node.parent.kind === 229 /* TryStatement */ && node.parent.finallyBlock === node) { + case 213 /* Block */: + if (node.parent && node.parent.kind === 230 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 265 /* CaseClause */: + case 266 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -103963,11 +104823,11 @@ var ts; break; } switch (node.kind) { - case 173 /* ThisType */: + case 174 /* ThisType */: case 99 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); @@ -103975,8 +104835,8 @@ var ts; seenLabels.pop(); break; } - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: { var label = node.label; if (label) { @@ -103986,20 +104846,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 223 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 224 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -104053,7 +104913,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 === 148 /* Parameter */) { + if (current.kind === 149 /* 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; } @@ -104064,7 +104924,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 273 /* SourceFile */) { + if (current.kind === 274 /* SourceFile */) { return scopes; } } @@ -104073,7 +104933,7 @@ var ts; function getFunctionExtractionAtIndex(targetRange, context, requestedChangesIndex) { var _a = getPossibleExtractionsWorker(targetRange, context), scopes = _a.scopes, _b = _a.readsAndWrites, target = _b.target, usagesPerScope = _b.usagesPerScope, functionErrorsPerScope = _b.functionErrorsPerScope, exposedVariableDeclarations = _b.exposedVariableDeclarations; ts.Debug.assert(!functionErrorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?"); - context.cancellationToken.throwIfCancellationRequested(); + context.cancellationToken.throwIfCancellationRequested(); // TODO: GH#18217 return extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], exposedVariableDeclarations, targetRange, context); } function getConstantExtractionAtIndex(targetRange, context, requestedChangesIndex) { @@ -104154,32 +105014,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 154 /* Constructor */: + case 155 /* Constructor */: return "constructor"; - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return "arrow function"; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return "method '" + scope.name.getText(); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 234 /* ClassDeclaration */ + return scope.kind === 235 /* 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 === 239 /* ModuleBlock */ + return scope.kind === 240 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -104197,7 +105057,7 @@ var ts; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted function var file = scope.getSourceFile(); - var functionNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newMethod" : "newFunction", file.text); + var functionNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newMethod" : "newFunction", file); var isJS = ts.isInJavaScriptFile(scope); var functionName = ts.createIdentifier(functionNameText); var returnType; @@ -104238,7 +105098,7 @@ var ts; // to avoid problems when there are literal types present if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); - returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); + returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); // TODO: GH#18217 } var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; ts.suppressLeadingAndTrailingTrivia(body); @@ -104306,7 +105166,8 @@ var ts; /*propertyName*/ undefined, /*name*/ ts.getSynthesizedDeepClone(variableDeclaration.name))); // Being returned through an object literal will have widened the type. - var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NoTruncation */); + var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), // TODO: GH#18217 + scope, 1 /* NoTruncation */); typeElements.push(ts.createPropertySignature( /*modifiers*/ undefined, /*name*/ variableDeclaration.symbol.name, @@ -104413,11 +105274,11 @@ var ts; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable var file = scope.getSourceFile(); - var localNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file.text); + var localNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file); var isJS = ts.isInJavaScriptFile(scope); var variableType = isJS || !checker.isContextSensitive(node) ? undefined - : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); + : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); @@ -104433,7 +105294,7 @@ var ts; /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); var localReference = ts.createPropertyAccess(rangeFacts & RangeFacts.InStaticRegion - ? ts.createIdentifier(scope.name.getText()) + ? ts.createIdentifier(scope.name.getText()) // TODO: GH#18217 : ts.createThis(), ts.createIdentifier(localNameText)); // Declare var maxInsertionPos = node.pos; @@ -104457,7 +105318,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 215 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 216 /* 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.createVariableStatement( @@ -104476,7 +105337,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 215 /* ExpressionStatement */) { + if (node.parent.kind === 216 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.deleteNode(context.file, node.parent, ts.textChanges.useNonAdjustedPositions); } @@ -104527,7 +105388,7 @@ var ts; function getCalledExpression(scope, range, functionNameText) { var functionReference = ts.createIdentifier(functionNameText); if (ts.isClassLike(scope)) { - var lhs = range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.text) : ts.createThis(); + var lhs = range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.text) : ts.createThis(); // TODO: GH#18217 return ts.createPropertyAccess(lhs, functionReference); } else { @@ -104563,7 +105424,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 224 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 225 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -104599,7 +105460,7 @@ var ts; } function getStatementsOrClassElements(scope) { if (ts.isFunctionLikeDeclaration(scope)) { - var body = scope.body; + var body = scope.body; // TODO: GH#18217 if (ts.isBlock(body)) { return body.statements; } @@ -104644,7 +105505,8 @@ var ts; } prevMember = member; } - ts.Debug.assert(prevMember !== undefined); // If the loop didn't return, then it did set prevMember. + if (prevMember === undefined) + return ts.Debug.fail(); // If the loop didn't return, then it did set prevMember. return prevMember; } function getNodeToInsertConstantBefore(node, scope) { @@ -104671,18 +105533,15 @@ var ts; return curr.parent.parent; } // There must be at least one statement since we started in one. - ts.Debug.assert(prevStatement !== undefined); - return prevStatement; - } - if (curr === scope) { - ts.Debug.fail("Didn't encounter a block-like before encountering scope"); - break; + return ts.Debug.assertDefined(prevStatement); } + ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } } function getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes) { var variableAssignments = ts.map(exposedVariableDeclarations, function (v) { return ts.createShorthandPropertyAssignment(v.symbol.name); }); var writeAssignments = ts.map(writes, function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + // TODO: GH#18217 `variableAssignments` not possibly undefined! return variableAssignments === undefined ? writeAssignments : writeAssignments === undefined @@ -104735,7 +105594,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (2048 /* Void */ | 16384 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (4096 /* Void */ | 32768 /* Never */)) { // TODO: GH#18217 expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -104743,7 +105602,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 233 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 234 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -104768,7 +105627,7 @@ var ts; // will use the contextual type of an expression as the return type of the extracted // method (and will therefore "use" all the types involved). if (inGenericContext && !isReadonlyArray(targetRange.range)) { - var contextualType = checker.getContextualType(targetRange.range); + var contextualType = checker.getContextualType(targetRange.range); // TODO: GH#18217 recordTypeParameterUsages(contextualType); } if (allTypeParameterUsages.size > 0) { @@ -104806,7 +105665,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_19 = function (i) { + var _loop_23 = 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 @@ -104846,7 +105705,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_19(i); + _loop_23(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -104868,7 +105727,7 @@ var ts; function collectUsages(node, valueUsage) { if (valueUsage === void 0) { valueUsage = 1 /* Read */; } if (inGenericContext) { - var type = checker.getTypeAtLocation(node); + var type = checker.getTypeAtLocation(node); // TODO: GH#18217 recordTypeParameterUsages(type); } if (ts.isDeclaration(node) && node.symbol) { @@ -105049,20 +105908,6 @@ var ts; : ts.createPropertyAccess(prefix, symbol.name); } } - function getParentNodeInSpan(node, file, span) { - if (!node) - return undefined; - while (node.parent) { - if (ts.isSourceFile(node.parent) || !spanContainsNode(span, node.parent, file)) { - return node; - } - node = node.parent; - } - } - function spanContainsNode(span, node, file) { - return ts.textSpanContainsPosition(span, node.getStart(file)) && - node.getEnd() <= ts.textSpanEnd(span); - } /** * Computes whether or not a node represents an expression in a position where it could * be extracted. @@ -105071,31 +105916,32 @@ var ts; * in the sense of something that you could extract on */ function isExtractableExpression(node) { - switch (node.parent.kind) { - case 272 /* EnumMember */: + var parent = node.parent; + switch (parent.kind) { + case 273 /* EnumMember */: return false; } switch (node.kind) { case 9 /* StringLiteral */: - return node.parent.kind !== 243 /* ImportDeclaration */ && - node.parent.kind !== 247 /* ImportSpecifier */; - case 203 /* SpreadElement */: - case 179 /* ObjectBindingPattern */: - case 181 /* BindingElement */: + return parent.kind !== 244 /* ImportDeclaration */ && + parent.kind !== 248 /* ImportSpecifier */; + case 204 /* SpreadElement */: + case 180 /* ObjectBindingPattern */: + case 182 /* BindingElement */: return false; case 71 /* Identifier */: - return node.parent.kind !== 181 /* BindingElement */ && - node.parent.kind !== 247 /* ImportSpecifier */ && - node.parent.kind !== 251 /* ExportSpecifier */; + return parent.kind !== 182 /* BindingElement */ && + parent.kind !== 248 /* ImportSpecifier */ && + parent.kind !== 252 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 212 /* Block */: - case 273 /* SourceFile */: - case 239 /* ModuleBlock */: - case 265 /* CaseClause */: + case 213 /* Block */: + case 274 /* SourceFile */: + case 240 /* ModuleBlock */: + case 266 /* CaseClause */: return true; default: return false; @@ -105172,7 +106018,7 @@ var ts; var renameLocation = renameLocationOffset + ts.getRenameLocation(edits, renameFilename, nameNeedRename.text, /*preferLastLocation*/ ts.isParameter(declaration)); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; } - function isConvertableName(name) { + function isConvertibleName(name) { return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { @@ -105182,7 +106028,7 @@ var ts; return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); } function createAccessorAccessExpression(fieldName, isStatic, container) { - var leftHead = isStatic ? container.name : ts.createThis(); + var leftHead = isStatic ? container.name : ts.createThis(); // TODO: GH#18217 return ts.isIdentifier(fieldName) ? ts.createPropertyAccess(leftHead, fieldName) : ts.createElementAccess(leftHead, ts.createLiteral(fieldName)); } function getModifiers(isJS, isStatic, accessModifier) { @@ -105198,18 +106044,18 @@ var ts; var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; - if (!declaration || !ts.rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition) - || !isConvertableName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) + if (!declaration || !ts.rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition) // TODO: GH#18217 + || !isConvertibleName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) return undefined; var name = declaration.name.text; var startWithUnderscore = startsWithUnderscore(name); - var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file.text), declaration.name); - var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file.text) : name, declaration.name); + var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file), declaration.name); + var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file) : name, declaration.name); return { isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 148 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 149 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name, declaration: declaration, fieldName: fieldName, @@ -105220,7 +106066,8 @@ var ts; function generateGetAccessor(fieldName, accessorName, type, modifiers, isStatic, container) { return ts.createGetAccessor( /*decorators*/ undefined, modifiers, accessorName, - /*parameters*/ undefined, type, ts.createBlock([ + /*parameters*/ undefined, // TODO: GH#18217 + type, ts.createBlock([ ts.createReturn(createAccessorAccessExpression(fieldName, isStatic, container)) ], /*multiLine*/ true)); } @@ -105264,7 +106111,9 @@ var ts; if (!constructor.body) return; var file = context.file, program = context.program, cancellationToken = context.cancellationToken; - var referenceEntries = ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(originalName.parent.pos, originalName, program, [file], cancellationToken), function (entry) { return ((entry.type === "node" && ts.rangeContainsRange(constructor, entry.node) && ts.isIdentifier(entry.node) && ts.isWriteAccess(entry.node)) ? entry.node : undefined); }); + var referenceEntries = ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(originalName.parent.pos, originalName, program, [file], cancellationToken), function (entry) { + return (entry.type === "node" && ts.rangeContainsRange(constructor, entry.node) && ts.isIdentifier(entry.node) && ts.isWriteAccess(entry.node)) ? entry.node : undefined; + }); ts.forEach(referenceEntries, function (entry) { var parent = entry.parent; var accessorName = ts.createIdentifier(fieldName.text); @@ -105287,7 +106136,7 @@ var ts; var refactorName = "Move to a new file"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { - if (!context.preferences.allowTextChangesInNewFiles || getFirstAndLastStatementToMove(context) === undefined) + if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined) return undefined; var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Move_to_a_new_file); return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; @@ -105295,27 +106144,34 @@ var ts; getEditsForAction: function (context, actionName) { ts.Debug.assert(actionName === refactorName); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); - function getFirstAndLastStatementToMove(context) { + function getRangeToMove(context) { var file = context.file; var range = ts.createTextRangeFromSpan(ts.getRefactorContextSpan(context)); var statements = file.statements; var startNodeIndex = ts.findIndex(statements, function (s) { return s.end > range.pos; }); if (startNodeIndex === -1) return undefined; + var startStatement = statements[startNodeIndex]; + if (ts.isNamedDeclaration(startStatement) && startStatement.name && ts.rangeContainsRange(startStatement.name, range)) { + return { toMove: [statements[startNodeIndex]], afterLast: statements[startNodeIndex + 1] }; + } // Can't only partially include the start node or be partially into the next node - if (range.pos > statements[startNodeIndex].getStart(file)) + if (range.pos > startStatement.getStart(file)) return undefined; var afterEndNodeIndex = ts.findIndex(statements, function (s) { return s.end > range.end; }, startNodeIndex); // Can't be partially into the next node if (afterEndNodeIndex !== -1 && (afterEndNodeIndex === 0 || statements[afterEndNodeIndex].getStart(file) < range.end)) return undefined; - return { first: startNodeIndex, afterLast: afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex }; + return { + toMove: statements.slice(startNodeIndex, afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex), + afterLast: afterEndNodeIndex === -1 ? undefined : statements[afterEndNodeIndex], + }; } - function doChange(oldFile, program, toMove, changes, host) { + function doChange(oldFile, program, toMove, changes, host, preferences) { var checker = program.getTypeChecker(); var usage = getUsageInfo(oldFile, toMove.all, checker); var currentDirectory = ts.getDirectoryPath(oldFile.fileName); @@ -105323,31 +106179,32 @@ var ts; var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host); var newFileNameWithExtension = newModuleName + extension; // If previous file was global, this is easy. - changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatements(oldFile, usage, changes, toMove, program, newModuleName)); + changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences)); addNewFileToTsconfig(program, changes, oldFile.fileName, newFileNameWithExtension, ts.hostGetCanonicalFileName(host)); } // Filters imports out of the range of statements to move. Imports will be copied to the new file anyway, and may still be needed in the old file. function getStatementsToMove(context) { - var statements = context.file.statements; - var _a = getFirstAndLastStatementToMove(context), first = _a.first, afterLast = _a.afterLast; + var rangeToMove = getRangeToMove(context); + if (rangeToMove === undefined) + return undefined; var all = []; var ranges = []; - var rangeToMove = statements.slice(first, afterLast); - ts.getRangesWhere(rangeToMove, function (s) { return !isPureImport(s); }, function (start, afterEnd) { - for (var i = start; i < afterEnd; i++) - all.push(rangeToMove[i]); - ranges.push({ first: rangeToMove[start], last: rangeToMove[afterEnd - 1] }); + var toMove = rangeToMove.toMove, afterLast = rangeToMove.afterLast; + ts.getRangesWhere(toMove, function (s) { return !isPureImport(s); }, function (start, afterEndIndex) { + for (var i = start; i < afterEndIndex; i++) + all.push(toMove[i]); + ranges.push({ first: toMove[start], afterLast: afterLast }); }); - return { all: all, ranges: ranges }; + return all.length === 0 ? undefined : { all: all, ranges: ranges }; } function isPureImport(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return true; - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 213 /* VariableStatement */: - return node.declarationList.declarations.every(function (d) { return d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); + case 214 /* VariableStatement */: + return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; } @@ -105366,26 +106223,26 @@ var ts; changes.insertNodeInListAfter(cfg, ts.last(filesProp.initializer.elements), ts.createLiteral(newFilePath), filesProp.initializer.elements); } } - function getNewStatements(oldFile, usage, changes, toMove, program, newModuleName) { + function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences) { var checker = program.getTypeChecker(); if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) { deleteMovedStatements(oldFile, toMove.ranges, changes); return toMove.all; } var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator; - var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax); + var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax, preferences); if (importsFromNewFile) { changes.insertNodeBefore(oldFile, oldFile.statements[0], importsFromNewFile, /*blankLineBetween*/ true); } deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); deleteMovedStatements(oldFile, toMove.ranges, changes); updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName); - return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); + return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, preferences).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); } function deleteMovedStatements(sourceFile, moved, changes) { for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) { - var _a = moved_1[_i], first_1 = _a.first, last_3 = _a.last; - changes.deleteNodeRange(sourceFile, first_1, last_3); + var _a = moved_1[_i], first_1 = _a.first, afterLast = _a.afterLast; + changes.deleteNodeRangeExcludingEnd(sourceFile, first_1, afterLast); } } function deleteUnusedOldImports(oldFile, toMove, changes, toDelete, checker) { @@ -105398,15 +106255,17 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_20 = function (sourceFile) { + var _loop_24 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_21 = function (statement) { + var _loop_25 = function (statement) { forEachImportInStatement(statement, function (importNode) { + if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) + return; var shouldMove = function (name) { var symbol = ts.isBindingElement(name.parent) ? ts.getPropertySymbolFromBindingElement(checker, name.parent) - : ts.skipAlias(checker.getSymbolAtLocation(name), checker); + : ts.skipAlias(checker.getSymbolAtLocation(name), checker); // TODO: GH#18217 return !!symbol && movedSymbols.has(symbol); }; deleteUnusedImports(sourceFile, importNode, changes, shouldMove); // These will be changed to imports from the new file @@ -105414,21 +106273,73 @@ var ts; var newImportDeclaration = filterImport(importNode, ts.createLiteral(newModuleSpecifier), shouldMove); if (newImportDeclaration) changes.insertNodeAfter(sourceFile, statement, newImportDeclaration); + var ns = getNamespaceLikeImport(importNode); + if (ns) + updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, ns, importNode); }); }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_21(statement); + _loop_25(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_20(sourceFile); + _loop_24(sourceFile); + } + } + function getNamespaceLikeImport(node) { + switch (node.kind) { + case 244 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 246 /* NamespaceImport */ ? + node.importClause.namedBindings.name : undefined; + case 243 /* ImportEqualsDeclaration */: + return node.name; + case 232 /* VariableDeclaration */: + return ts.tryCast(node.name, ts.isIdentifier); + default: + return ts.Debug.assertNever(node); + } + } + function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { + var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 6 /* ESNext */); + var needUniqueName = false; + var toChange = []; + ts.FindAllReferences.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, function (ref) { + if (!ts.isPropertyAccessExpression(ref.parent)) + return; + needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* All */, /*excludeGlobals*/ true); + if (movedSymbols.has(checker.getSymbolAtLocation(ref.parent.name))) { + toChange.push(ref); + } + }); + if (toChange.length) { + var newNamespaceName = needUniqueName ? ts.getUniqueName(preferredNewNamespaceName, sourceFile) : preferredNewNamespaceName; + for (var _i = 0, toChange_1 = toChange; _i < toChange_1.length; _i++) { + var ref = toChange_1[_i]; + changes.replaceNode(sourceFile, ref, ts.createIdentifier(newNamespaceName)); + } + changes.insertNodeAfter(sourceFile, oldImportNode, updateNamespaceLikeImportNode(oldImportNode, newModuleName, newModuleSpecifier)); + } + } + function updateNamespaceLikeImportNode(node, newNamespaceName, newModuleSpecifier) { + var newNamespaceId = ts.createIdentifier(newNamespaceName); + var newModuleString = ts.createLiteral(newModuleSpecifier); + switch (node.kind) { + case 244 /* ImportDeclaration */: + return ts.createImportDeclaration( + /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); + case 243 /* ImportEqualsDeclaration */: + return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); + case 232 /* VariableDeclaration */: + return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); + default: + return ts.Debug.assertNever(node); } } function moduleSpecifierFromImport(i) { - return (i.kind === 243 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 242 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 244 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 243 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -105450,24 +106361,24 @@ var ts; } } } - function createOldFileImportsFromNewFile(newFileNeedExport, newFileNameWithExtension, useEs6Imports) { + function createOldFileImportsFromNewFile(newFileNeedExport, newFileNameWithExtension, useEs6Imports, preferences) { var defaultImport; var imports = []; newFileNeedExport.forEach(function (symbol) { if (symbol.escapedName === "default" /* Default */) { - defaultImport = ts.createIdentifier(ts.symbolNameNoDefault(symbol)); + defaultImport = ts.createIdentifier(ts.symbolNameNoDefault(symbol)); // TODO: GH#18217 } else { imports.push(symbol.name); } }); - return makeImportOrRequire(defaultImport, imports, newFileNameWithExtension, useEs6Imports); + return makeImportOrRequire(defaultImport, imports, newFileNameWithExtension, useEs6Imports, preferences); } - function makeImportOrRequire(defaultImport, imports, path, useEs6Imports) { + function makeImportOrRequire(defaultImport, imports, path, useEs6Imports, preferences) { path = ts.ensurePathIsNonModuleName(path); if (useEs6Imports) { var specifiers = imports.map(function (i) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(i)); }); - return ts.makeImportIfNecessary(defaultImport, specifiers, path); + return ts.makeImportIfNecessary(defaultImport, specifiers, path, preferences); } else { ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. @@ -105498,15 +106409,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.deleteNode(sourceFile, importDecl); } break; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -105519,7 +106430,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 245 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 246 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.deleteNode(sourceFile, importDecl); } @@ -105531,7 +106442,7 @@ var ts; if (namedBindingsUnused) { changes.deleteNode(sourceFile, namedBindings); } - else if (namedBindings.kind === 246 /* NamedImports */) { + else if (namedBindings.kind === 247 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -105549,9 +106460,9 @@ var ts; changes.deleteNode(sourceFile, name); } break; - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: break; - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.deleteNode(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -105566,7 +106477,7 @@ var ts; break; } } - function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax) { + function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, preferences) { var copiedOldImports = []; for (var _i = 0, _a = oldFile.statements; _i < _a.length; _i++) { var oldStatement = _a[_i]; @@ -105598,7 +106509,7 @@ var ts; } } }); - ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEs6ModuleSyntax)); + ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEs6ModuleSyntax, preferences)); return copiedOldImports; } function makeUniqueModuleName(moduleName, extension, inDirectory, host) { @@ -105606,7 +106517,7 @@ var ts; for (var i = 1;; i++) { var name = ts.combinePaths(inDirectory, newModuleName + extension); if (!host.fileExists(name)) - return newModuleName; + return newModuleName; // TODO: GH#18217 newModuleName = moduleName + "." + i; } } @@ -105633,7 +106544,7 @@ var ts; if (isInImport(decl)) { oldImportsNeededByNewFile.add(symbol); } - else if (isTopLevelDeclaration(decl) && !movedSymbols.has(symbol)) { + else if (isTopLevelDeclaration(decl) && sourceFileOfTopLevelDeclaration(decl) === oldFile && !movedSymbols.has(symbol)) { newFileImportsFromOldFile.add(symbol); } } @@ -105656,13 +106567,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 242 /* ImportEqualsDeclaration */: - case 247 /* ImportSpecifier */: - case 244 /* ImportClause */: + case 243 /* ImportEqualsDeclaration */: + case 248 /* ImportSpecifier */: + case 245 /* ImportClause */: return true; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -105674,7 +106585,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 243 /* ImportDeclaration */: { + case 244 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -105684,9 +106595,9 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 231 /* VariableDeclaration */: { + case 232 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -105695,7 +106606,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 245 /* NamespaceImport */) { + if (namedBindings.kind === 246 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -105707,9 +106618,9 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return keep(name) ? name : undefined; - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: return name; - case 179 /* ObjectBindingPattern */: { + case 180 /* 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.createObjectBindingPattern(newElements) : undefined; @@ -105755,7 +106666,10 @@ var ts; return SymbolSet; }()); function isTopLevelDeclaration(node) { - return isNonVariableTopLevelDeclaration(node) || ts.isVariableDeclaration(node) && ts.isSourceFile(node.parent.parent.parent); + return isNonVariableTopLevelDeclaration(node) && ts.isSourceFile(node.parent) || ts.isVariableDeclaration(node) && ts.isSourceFile(node.parent.parent.parent); + } + function sourceFileOfTopLevelDeclaration(node) { + return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { ts.Debug.assert(ts.isSourceFile(node.parent)); @@ -105763,13 +106677,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 235 /* InterfaceDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 243 /* ImportEqualsDeclaration */: return true; default: return false; @@ -105777,17 +106691,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 235 /* InterfaceDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 243 /* ImportEqualsDeclaration */: return cb(statement); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return ts.forEach(statement.declarationList.declarations, cb); - case 215 /* ExpressionStatement */: { + case 216 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getSpecialPropertyAssignmentKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -105796,7 +106710,7 @@ var ts; } } function nameOfTopLevelDeclaration(d) { - return d.kind === 215 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); + return d.kind === 216 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); } function getTopLevelDeclarationStatement(d) { return ts.isVariableDeclaration(d) ? d.parent.parent : d; @@ -105828,23 +106742,23 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.createModifier(84 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d); @@ -105855,21 +106769,21 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - return [decl.name.text]; - case 213 /* VariableStatement */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + return [decl.name.text]; // TODO: GH#18217 + case 214 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 235 /* InterfaceDeclaration */: - case 242 /* ImportEqualsDeclaration */: - return undefined; - case 215 /* ExpressionStatement */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 243 /* ImportEqualsDeclaration */: + return ts.emptyArray; + case 216 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - ts.Debug.assertNever(decl); + return ts.Debug.assertNever(decl); } } /** Creates `exports.x = x;` */ @@ -106089,7 +107003,7 @@ var ts; var value = 0; for (; moreDigits; state.decodingIndex++) { if (createErrorIfCondition(state.decodingIndex >= state.encodedText.length, "Error in decoding base64VLQFormatDecode, past the mapping string")) { - return; + return undefined; // TODO: GH#18217 } // 6 digit number var currentByte = base64FormatDecode(state.encodedText.charAt(state.decodingIndex)); @@ -106139,7 +107053,7 @@ var ts; this.pos = pos; this.end = end; this.flags = 0 /* None */; - this.transformFlags = undefined; + this.transformFlags = undefined; // TODO: GH#18217 this.parent = undefined; this.kind = kind; } @@ -106201,8 +107115,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 277 /* FirstJSDocNode */ || kid.kind > 297 /* LastJSDocNode */; }); - return child.kind < 145 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 278 /* FirstJSDocNode */ || kid.kind > 298 /* LastJSDocNode */; }); + return child.kind < 146 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -106213,7 +107127,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 145 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 146 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -106271,7 +107185,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(298 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(299 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -106325,7 +107239,7 @@ var ts; return 0; }; TokenOrIdentifierObject.prototype.getChildAt = function () { - return undefined; + return undefined; // TODO: GH#18217 }; TokenOrIdentifierObject.prototype.getChildren = function () { return ts.emptyArray; @@ -106449,25 +107363,25 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 131072 /* Union */); + return !!(this.flags & 262144 /* Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 262144 /* Intersection */); + return !!(this.flags & 524288 /* Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 393216 /* UnionOrIntersection */); + return !!(this.flags & 786432 /* UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 224 /* Literal */); + return !!(this.flags & 448 /* Literal */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 32 /* StringLiteral */); + return !!(this.flags & 64 /* StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 64 /* NumberLiteral */); + return !!(this.flags & 128 /* NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 32768 /* TypeParameter */); + return !!(this.flags & 65536 /* TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); @@ -106517,9 +107431,9 @@ var ts; return ts.emptyArray; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); if (doc.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { - var declaration = declarations_13[_i]; - var inheritedDocs = findInheritedJSDocComments(declaration, declaration.symbol.name, checker); + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; + var inheritedDocs = findInheritedJSDocComments(declaration, declaration.symbol.name, checker); // TODO: GH#18217 // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc); @@ -106604,10 +107518,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -106627,31 +107541,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 237 /* EnumDeclaration */: - case 238 /* ModuleDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 251 /* ExportSpecifier */: - case 247 /* ImportSpecifier */: - case 244 /* ImportClause */: - case 245 /* NamespaceImport */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 165 /* TypeLiteral */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 238 /* EnumDeclaration */: + case 239 /* ModuleDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 252 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 245 /* ImportClause */: + case 246 /* NamespaceImport */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 166 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 148 /* Parameter */: + case 149 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 231 /* VariableDeclaration */: - case 181 /* BindingElement */: { + case 232 /* VariableDeclaration */: + case 182 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -106662,19 +107576,19 @@ var ts; } } // falls through - case 272 /* EnumMember */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 273 /* EnumMember */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: addDeclaration(node); break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -106686,7 +107600,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 245 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -106695,7 +107609,7 @@ var ts; } } break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -106823,7 +107737,7 @@ var ts; }; HostCache.prototype.getOrCreateEntryByPath = function (fileName, path) { var info = this.getEntryByPath(path) || this.createEntry(fileName, path); - return ts.isString(info) ? undefined : info; + return ts.isString(info) ? undefined : info; // TODO: GH#18217 }; HostCache.prototype.getRootFileNames = function () { var names = []; @@ -106841,11 +107755,11 @@ var ts; }; HostCache.prototype.getVersion = function (path) { var file = this.getHostFileInformation(path); - return file && file.version; + return (file && file.version); // TODO: GH#18217 }; HostCache.prototype.getScriptSnapshot = function (path) { var file = this.getHostFileInformation(path); - return file && file.scriptSnapshot; + return (file && file.scriptSnapshot); // TODO: GH#18217 }; return HostCache; }()); @@ -106948,7 +107862,7 @@ var ts; this.cancellationToken = cancellationToken; } CancellationTokenObject.prototype.isCancellationRequested = function () { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + return !!this.cancellationToken && this.cancellationToken.isCancellationRequested(); }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { @@ -106998,7 +107912,7 @@ var ts; if (!host.fileExists || !host.readFile || !host.fileExists(path)) return; // And failing that, check the disk - var text = host.readFile(path); + var text = host.readFile(path); // TODO: GH#18217 var file = { text: text, lineMap: undefined, @@ -107056,7 +107970,7 @@ var ts; var typeRootsVersion = host.getTypeRootsVersion ? host.getTypeRootsVersion() : 0; if (lastTypesRootVersion !== typeRootsVersion) { log("TypeRoots version has changed; provide new program"); - program = undefined; + program = undefined; // TODO: GH#18217 lastTypesRootVersion = typeRootsVersion; } // Get a fresh cache of the host information @@ -107064,7 +107978,7 @@ var ts; var rootFileNames = hostCache.getRootFileNames(); var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; // If the program is already up-to-date, we can reuse it - if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (path) { return hostCache.getVersion(path); }, fileExists, hasInvalidatedResolution, host.hasChangedAutomaticTypeDirectiveNames)) { + if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (path) { return hostCache.getVersion(path); }, fileExists, hasInvalidatedResolution, !!host.hasChangedAutomaticTypeDirectiveNames)) { return; } // IMPORTANT - It is critical from this moment onward that we do not check @@ -107141,7 +108055,7 @@ var ts; var entry = hostCache.getEntryByPath(path); return entry ? !ts.isString(entry) : - (host.fileExists && host.fileExists(fileName)); + (!!host.fileExists && host.fileExists(fileName)); } // Release any files we have acquired in the old program but are // not part of the new program. @@ -107201,6 +108115,7 @@ var ts; return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } } + // TODO: GH#18217 frequently asserted as defined function getProgram() { if (syntaxOnly) { ts.Debug.assert(program === undefined); @@ -107210,14 +108125,14 @@ var ts; return program; } function cleanupSemanticCache() { - program = undefined; + program = undefined; // TODO: GH#18217 } function dispose() { if (program) { ts.forEach(program.getSourceFiles(), function (f) { return documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions()); }); - program = undefined; + program = undefined; // TODO: GH#18217 } host = undefined; } @@ -107245,7 +108160,7 @@ var ts; } function getSuggestionDiagnostics(fileName) { synchronizeHostData(); - return ts.computeSuggestionDiagnostics(getValidSourceFile(fileName), program); + return ts.computeSuggestionDiagnostics(getValidSourceFile(fileName), program, cancellationToken); } function getCompilerOptionsDiagnostics() { synchronizeHostData(); @@ -107261,7 +108176,8 @@ var ts; function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { if (preferences === void 0) { preferences = ts.defaultPreferences; } synchronizeHostData(); - return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, formattingOptions && ts.formatting.getFormatContext(formattingOptions), getCanonicalFileName, preferences, cancellationToken); + return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions)), // TODO: GH#18217 + getCanonicalFileName, preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); @@ -107286,10 +108202,10 @@ var ts; return undefined; } // falls through - case 184 /* PropertyAccessExpression */: - case 145 /* QualifiedName */: + case 185 /* PropertyAccessExpression */: + case 146 /* QualifiedName */: case 99 /* ThisKeyword */: - case 173 /* ThisType */: + case 174 /* ThisType */: case 97 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type_4 = typeChecker.getTypeAtLocation(node); @@ -107330,7 +108246,7 @@ var ts; } function toLineColumnOffset(fileName, position) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var file = program.getSourceFile(path) || sourcemappedFileCache.get(path); + var file = program.getSourceFile(path) || sourcemappedFileCache.get(path); // TODO: GH#18217 return file.getLineAndCharacterOfPosition(position); } // Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M]) @@ -107397,7 +108313,7 @@ var ts; var location = possibleMapLocations_1[_i]; var mapPath = ts.toPath(location, ts.getDirectoryPath(fileName), getCanonicalFileName); if (host.fileExists(mapPath)) { - return convertDocumentToSourceMapper(file, host.readFile(mapPath), mapPath); + return convertDocumentToSourceMapper(file, host.readFile(mapPath), mapPath); // TODO: GH#18217 } } return file.sourceMapper = ts.sourcemaps.identitySourceMapper; @@ -107509,18 +108425,9 @@ var ts; function getReferences(fileName, position, options) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. - var sourceFiles = []; - if (options && options.isForRename) { - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - if (!program.isSourceFileDefaultLibrary(sourceFile)) { - sourceFiles.push(sourceFile); - } - } - } - else { - sourceFiles = program.getSourceFiles().slice(); - } + var sourceFiles = options && options.isForRename + ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) + : program.getSourceFiles(); return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); } function findReferences(fileName, position) { @@ -107529,11 +108436,13 @@ var ts; } /// NavigateTo function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { + if (excludeDtsFiles === void 0) { excludeDtsFiles = false; } synchronizeHostData(); var sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); } function getEmitOutput(fileName, emitOnlyDtsFiles) { + if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); @@ -107552,31 +108461,28 @@ var ts; function getNonBoundSourceFile(fileName) { return syntaxTreeCache.getCurrentSourceFile(fileName); } - function getSourceFile(fileName) { - return getNonBoundSourceFile(fileName); - } function getNameOrDottedNameSpan(fileName, startPos, _endPos) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); // Get node at the location var node = ts.getTouchingPropertyName(sourceFile, startPos, /*includeJsDocComment*/ false); if (node === sourceFile) { - return; + return undefined; } switch (node.kind) { - case 184 /* PropertyAccessExpression */: - case 145 /* QualifiedName */: + case 185 /* PropertyAccessExpression */: + case 146 /* QualifiedName */: case 9 /* StringLiteral */: case 86 /* FalseKeyword */: case 101 /* TrueKeyword */: case 95 /* NullKeyword */: case 97 /* SuperKeyword */: case 99 /* ThisKeyword */: - case 173 /* ThisType */: + case 174 /* ThisType */: case 71 /* Identifier */: break; // Cant create the text span default: - return; + return undefined; } var nodeForStartPos = node; while (true) { @@ -107588,7 +108494,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 === 238 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 239 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -107725,8 +108631,9 @@ var ts; var formatContext = ts.formatting.getFormatContext(formatOptions); return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); } - function getEditsForFileRename(oldFilePath, newFilePath, formatOptions) { - return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions)); + function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { + if (preferences === void 0) { preferences = ts.defaultPreferences; } + return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions), preferences); } function applyCodeActionCommand(fileName, actionOrUndefined) { var action = typeof fileName === "string" ? actionOrUndefined : fileName; @@ -107739,7 +108646,7 @@ var ts; ? host.installPackage({ fileName: ts.toPath(action.file, currentDirectory, getCanonicalFileName), packageName: action.packageName }) : Promise.reject("Host does not implement `installPackage`"); default: - ts.Debug.fail(); + return ts.Debug.fail(); // TODO: Debug.assertNever(action); will only work if there is more than one type. } } @@ -107775,6 +108682,17 @@ var ts; } return true; } + function getJsxClosingTagAtPosition(fileName, position) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var token = ts.findPrecedingToken(position, sourceFile); + if (!token) + return undefined; + var element = token.kind === 29 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + : ts.isJsxText(token) ? token.parent : undefined; + if (element && !ts.tagNamesAreEquivalent(element.openingElement.tagName, element.closingElement.tagName)) { + return { newText: "" }; + } + } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); @@ -107830,7 +108748,8 @@ var ts; descriptor = descriptors[i]; } } - ts.Debug.assert(descriptor !== undefined); + if (descriptor === undefined) + return ts.Debug.fail(); // We don't want to match something like 'TODOBY', so we make sure a non // letter/digit follows the match. if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { @@ -107973,6 +108892,7 @@ var ts; getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, + getJsxClosingTagAtPosition: getJsxClosingTagAtPosition, getSpanOfEnclosingComment: getSpanOfEnclosingComment, getCodeFixesAtPosition: getCodeFixesAtPosition, getCombinedCodeFix: getCombinedCodeFix, @@ -107981,7 +108901,6 @@ var ts; getEditsForFileRename: getEditsForFileRename, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, - getSourceFile: getSourceFile, getProgram: getProgram, getApplicableRefactors: getApplicableRefactors, getEditsForRefactor: getEditsForRefactor, @@ -107995,7 +108914,7 @@ var ts; if (!sourceFile.nameTable) { initializeNameTable(sourceFile); } - return sourceFile.nameTable; + return sourceFile.nameTable; // TODO: GH#18217 } ts.getNameTable = getNameTable; function initializeNameTable(sourceFile) { @@ -108022,7 +108941,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 253 /* ExternalModuleReference */ || + node.parent.kind === 254 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -108034,13 +108953,13 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 146 /* ComputedPropertyName */) { + if (node.parent.kind === 147 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through case 71 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 183 /* ObjectLiteralExpression */ || node.parent.parent.kind === 262 /* JsxAttributes */) && + (node.parent.parent.kind === 184 /* ObjectLiteralExpression */ || node.parent.parent.kind === 263 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -108049,8 +108968,8 @@ var ts; /* @internal */ function getPropertySymbolsFromContextualType(typeChecker, node) { var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - return getPropertySymbolsFromType(contextualType, node.name); + var contextualType = typeChecker.getContextualType(objectLiteral); // TODO: GH#18217 + return getPropertySymbolsFromType(contextualType, node.name); // TODO: GH#18217 } ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; /* @internal */ @@ -108059,7 +108978,7 @@ var ts; if (name && type) { var result_7 = []; var symbol = type.getProperty(name); - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { ts.forEach(type.types, function (t) { var symbol = t.getProperty(name); if (symbol) { @@ -108079,7 +108998,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 185 /* ElementAccessExpression */ && + node.parent.kind === 186 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -108118,11 +109037,12 @@ var ts; // let y = 10; // token at position will return let keyword on second line as the token but we would like to use // token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line - tokenAtLocation = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); + var preceding = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); // It's a blank line - if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) { + if (!preceding || sourceFile.getLineAndCharacterOfPosition(preceding.getEnd()).line !== lineOfPosition) { return undefined; } + tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations if (tokenAtLocation.flags & 4194304 /* Ambient */) { @@ -108156,115 +109076,116 @@ var ts; } function spanInNode(node) { if (node) { + var parent = node.parent; switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 231 /* VariableDeclaration */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 232 /* VariableDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return spanInVariableDeclaration(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return spanInParameterDeclaration(node); - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 154 /* Constructor */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 155 /* Constructor */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 212 /* Block */: + case 213 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return spanInBlock(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return spanInBlock(node.block); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 217 /* DoStatement */: + case 218 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 230 /* DebuggerStatement */: + case 231 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 216 /* IfStatement */: + case 217 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return spanInForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 229 /* TryStatement */: + case 230 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: - case 272 /* EnumMember */: - case 181 /* BindingElement */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 273 /* EnumMember */: + case 182 /* BindingElement */: // span on complete node return textSpan(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 149 /* Decorator */: - return spanInNodeArray(node.parent.decorators); - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 150 /* Decorator */: + return spanInNodeArray(parent.decorators); + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: return undefined; // Tokens: case 25 /* SemicolonToken */: @@ -108294,7 +109215,7 @@ var ts; case 74 /* CatchKeyword */: case 87 /* FinallyKeyword */: return spanInNextNode(node); - case 144 /* OfKeyword */: + case 145 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -108307,13 +109228,13 @@ var ts; // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern if ((node.kind === 71 /* Identifier */ || - node.kind === 203 /* SpreadElement */ || - node.kind === 269 /* PropertyAssignment */ || - node.kind === 270 /* ShorthandPropertyAssignment */) && - ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + node.kind === 204 /* SpreadElement */ || + node.kind === 270 /* PropertyAssignment */ || + node.kind === 271 /* ShorthandPropertyAssignment */) && + ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 199 /* BinaryExpression */) { + if (node.kind === 200 /* 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 @@ -108334,23 +109255,23 @@ var ts; } } if (ts.isExpressionNode(node)) { - switch (node.parent.kind) { - case 217 /* DoStatement */: + switch (parent.kind) { + case 218 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 149 /* Decorator */: + case 150 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 219 /* ForStatement */: - case 221 /* ForOfStatement */: + case 220 /* ForStatement */: + case 222 /* ForOfStatement */: return textSpan(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (node.parent.operatorToken.kind === 26 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -108359,21 +109280,21 @@ var ts; } } switch (node.parent.kind) { - case 269 /* PropertyAssignment */: + case 270 /* 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 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: { + case 232 /* VariableDeclaration */: + case 149 /* 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)) { @@ -108381,7 +109302,7 @@ var ts; } break; } - case 199 /* BinaryExpression */: { + case 200 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -108411,9 +109332,10 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 220 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 221 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } + var parent = variableDeclaration.parent; // If this is a destructuring pattern, set breakpoint in binding pattern if (ts.isBindingPattern(variableDeclaration.name)) { return spanInBindingPattern(variableDeclaration.name); @@ -108422,7 +109344,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 221 /* ForOfStatement */) { + parent.parent.kind === 222 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -108463,7 +109385,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 234 /* ClassDeclaration */ && functionDeclaration.kind !== 154 /* Constructor */); + (functionDeclaration.parent.kind === 235 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -108486,26 +109408,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // falls through // Set on parent if on same line otherwise on first statement - case 218 /* WhileStatement */: - case 216 /* IfStatement */: - case 220 /* ForInStatement */: + case 219 /* WhileStatement */: + case 217 /* IfStatement */: + case 221 /* 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 219 /* ForStatement */: - case 221 /* ForOfStatement */: + case 220 /* ForStatement */: + case 222 /* 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 === 232 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 233 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -108530,21 +109452,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 205 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 181 /* BindingElement */) { + if (bindingPattern.parent.kind === 182 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 180 /* ArrayBindingPattern */ && node.kind !== 179 /* ObjectBindingPattern */); - var elements = node.kind === 182 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 205 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 181 /* ArrayBindingPattern */ && node.kind !== 180 /* ObjectBindingPattern */); + var elements = node.kind === 183 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -108552,18 +109474,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 === 199 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 200 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -108571,25 +109493,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 239 /* ModuleBlock */: + case 240 /* 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 237 /* EnumDeclaration */: - case 234 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 235 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 212 /* Block */: + case 213 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 268 /* CatchClause */: + case 269 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -108597,7 +109519,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 179 /* ObjectBindingPattern */: + case 180 /* 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); @@ -108613,7 +109535,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 180 /* ArrayBindingPattern */: + case 181 /* 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); @@ -108628,12 +109550,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 217 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 186 /* CallExpression */ || - node.parent.kind === 187 /* NewExpression */) { + if (node.parent.kind === 218 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 187 /* CallExpression */ || + node.parent.kind === 188 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 190 /* ParenthesizedExpression */) { + if (node.parent.kind === 191 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -108642,21 +109564,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 154 /* Constructor */: - case 218 /* WhileStatement */: - case 217 /* DoStatement */: - case 219 /* ForStatement */: - case 221 /* ForOfStatement */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 190 /* ParenthesizedExpression */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 155 /* Constructor */: + case 219 /* WhileStatement */: + case 218 /* DoStatement */: + case 220 /* ForStatement */: + case 222 /* ForOfStatement */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 191 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -108666,20 +109588,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 269 /* PropertyAssignment */ || - node.parent.kind === 148 /* Parameter */) { + node.parent.kind === 270 /* PropertyAssignment */ || + node.parent.kind === 149 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 189 /* TypeAssertionExpression */) { + if (node.parent.kind === 190 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 217 /* DoStatement */) { + if (node.parent.kind === 218 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -108687,7 +109609,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 221 /* ForOfStatement */) { + if (node.parent.kind === 222 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -108709,7 +109631,7 @@ var ts; */ function transform(source, transformers, compilerOptions) { var diagnostics = []; - compilerOptions = ts.fixupCompilerOptions(compilerOptions, diagnostics); + compilerOptions = ts.fixupCompilerOptions(compilerOptions, diagnostics); // TODO: GH#18217 var nodes = ts.isArray(source) ? source : [source]; var result = ts.transformNodes(/*resolver*/ undefined, /*emitHost*/ undefined, compilerOptions, nodes, transformers, /*allowDtsFiles*/ true); result.diagnostics = ts.concatenate(result.diagnostics, diagnostics); @@ -108758,16 +109680,16 @@ var ts; var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); if (encoded === null) { - return null; + return null; // TODO: GH#18217 } - var decoded = JSON.parse(encoded); + var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; ScriptSnapshotShimAdapter.prototype.dispose = function () { // if scriptSnapshotShim is a COM object then property check becomes method call with no arguments // 'in' does not have this effect if ("dispose" in this.scriptSnapshotShim) { - this.scriptSnapshotShim.dispose(); + this.scriptSnapshotShim.dispose(); // TODO: GH#18217 Can we just use `if (this.scriptSnapshotShim.dispose)`? } }; return ScriptSnapshotShimAdapter; @@ -108782,10 +109704,10 @@ var ts; // 'in' does not have this effect. if ("getModuleResolutionsForFile" in this.shimHost) { this.resolveModuleNames = function (moduleNames, containingFile) { - var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); // TODO: GH#18217 return ts.map(moduleNames, function (name) { var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; // TODO: GH#18217 }); }; } @@ -108794,8 +109716,8 @@ var ts; } if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); - return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); + var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); // TODO: GH#18217 + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); // TODO: GH#18217 }; } } @@ -108815,7 +109737,7 @@ var ts; LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { if (!this.shimHost.getProjectVersion) { // shimmed host does not support getProjectVersion - return undefined; + return undefined; // TODO: GH#18217 } return this.shimHost.getProjectVersion(); }; @@ -108848,7 +109770,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { if ("getScriptKind" in this.shimHost) { - return this.shimHost.getScriptKind(fileName); + return this.shimHost.getScriptKind(fileName); // TODO: GH#18217 } else { return 0 /* Unknown */; @@ -108884,7 +109806,7 @@ var ts; return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); }; LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); // TODO: GH#18217 return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); }; LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { @@ -108905,11 +109827,11 @@ var ts; this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; } if ("realpath" in this.shimHost) { - this.realpath = function (path) { return _this.shimHost.realpath(path); }; + this.realpath = function (path) { return _this.shimHost.realpath(path); }; // TODO: GH#18217 } } CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); // TODO: GH#18217 return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); }; CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { @@ -108981,7 +109903,8 @@ var ts; start: diagnostic.start, length: diagnostic.length, category: ts.diagnosticCategoryName(diagnostic), - code: diagnostic.code + code: diagnostic.code, + reportsUnnecessary: diagnostic.reportsUnnecessary, }; } var LanguageServiceShimObject = /** @class */ (function (_super) { @@ -109287,10 +110210,12 @@ var ts; } ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { var _this = this; + if (syntacticClassifierAbsent === void 0) { syntacticClassifierAbsent = false; } return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); }; /// COLORIZATION ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { + if (classifyKeywordsInGenerics === void 0) { classifyKeywordsInGenerics = false; } var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); var result = ""; for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index d237cc98eee..68ee36c20e0 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -204,169 +204,170 @@ declare namespace ts { TypeKeyword = 139, UndefinedKeyword = 140, UniqueKeyword = 141, - FromKeyword = 142, - GlobalKeyword = 143, - OfKeyword = 144, - QualifiedName = 145, - ComputedPropertyName = 146, - TypeParameter = 147, - Parameter = 148, - Decorator = 149, - PropertySignature = 150, - PropertyDeclaration = 151, - MethodSignature = 152, - MethodDeclaration = 153, - Constructor = 154, - GetAccessor = 155, - SetAccessor = 156, - CallSignature = 157, - ConstructSignature = 158, - IndexSignature = 159, - TypePredicate = 160, - TypeReference = 161, - FunctionType = 162, - ConstructorType = 163, - TypeQuery = 164, - TypeLiteral = 165, - ArrayType = 166, - TupleType = 167, - UnionType = 168, - IntersectionType = 169, - ConditionalType = 170, - InferType = 171, - ParenthesizedType = 172, - ThisType = 173, - TypeOperator = 174, - IndexedAccessType = 175, - MappedType = 176, - LiteralType = 177, - ImportType = 178, - ObjectBindingPattern = 179, - ArrayBindingPattern = 180, - BindingElement = 181, - ArrayLiteralExpression = 182, - ObjectLiteralExpression = 183, - PropertyAccessExpression = 184, - ElementAccessExpression = 185, - CallExpression = 186, - NewExpression = 187, - TaggedTemplateExpression = 188, - TypeAssertionExpression = 189, - ParenthesizedExpression = 190, - FunctionExpression = 191, - ArrowFunction = 192, - DeleteExpression = 193, - TypeOfExpression = 194, - VoidExpression = 195, - AwaitExpression = 196, - PrefixUnaryExpression = 197, - PostfixUnaryExpression = 198, - BinaryExpression = 199, - ConditionalExpression = 200, - TemplateExpression = 201, - YieldExpression = 202, - SpreadElement = 203, - ClassExpression = 204, - OmittedExpression = 205, - ExpressionWithTypeArguments = 206, - AsExpression = 207, - NonNullExpression = 208, - MetaProperty = 209, - TemplateSpan = 210, - SemicolonClassElement = 211, - Block = 212, - VariableStatement = 213, - EmptyStatement = 214, - ExpressionStatement = 215, - IfStatement = 216, - DoStatement = 217, - WhileStatement = 218, - ForStatement = 219, - ForInStatement = 220, - ForOfStatement = 221, - ContinueStatement = 222, - BreakStatement = 223, - ReturnStatement = 224, - WithStatement = 225, - SwitchStatement = 226, - LabeledStatement = 227, - ThrowStatement = 228, - TryStatement = 229, - DebuggerStatement = 230, - VariableDeclaration = 231, - VariableDeclarationList = 232, - FunctionDeclaration = 233, - ClassDeclaration = 234, - InterfaceDeclaration = 235, - TypeAliasDeclaration = 236, - EnumDeclaration = 237, - ModuleDeclaration = 238, - ModuleBlock = 239, - CaseBlock = 240, - NamespaceExportDeclaration = 241, - ImportEqualsDeclaration = 242, - ImportDeclaration = 243, - ImportClause = 244, - NamespaceImport = 245, - NamedImports = 246, - ImportSpecifier = 247, - ExportAssignment = 248, - ExportDeclaration = 249, - NamedExports = 250, - ExportSpecifier = 251, - MissingDeclaration = 252, - ExternalModuleReference = 253, - JsxElement = 254, - JsxSelfClosingElement = 255, - JsxOpeningElement = 256, - JsxClosingElement = 257, - JsxFragment = 258, - JsxOpeningFragment = 259, - JsxClosingFragment = 260, - JsxAttribute = 261, - JsxAttributes = 262, - JsxSpreadAttribute = 263, - JsxExpression = 264, - CaseClause = 265, - DefaultClause = 266, - HeritageClause = 267, - CatchClause = 268, - PropertyAssignment = 269, - ShorthandPropertyAssignment = 270, - SpreadAssignment = 271, - EnumMember = 272, - SourceFile = 273, - Bundle = 274, - UnparsedSource = 275, - InputFiles = 276, - JSDocTypeExpression = 277, - JSDocAllType = 278, - JSDocUnknownType = 279, - JSDocNullableType = 280, - JSDocNonNullableType = 281, - JSDocOptionalType = 282, - JSDocFunctionType = 283, - JSDocVariadicType = 284, - JSDocComment = 285, - JSDocTypeLiteral = 286, - JSDocSignature = 287, - JSDocTag = 288, - JSDocAugmentsTag = 289, - JSDocClassTag = 290, - JSDocCallbackTag = 291, - JSDocParameterTag = 292, - JSDocReturnTag = 293, - JSDocTypeTag = 294, - JSDocTemplateTag = 295, - JSDocTypedefTag = 296, - JSDocPropertyTag = 297, - SyntaxList = 298, - NotEmittedStatement = 299, - PartiallyEmittedExpression = 300, - CommaListExpression = 301, - MergeDeclarationMarker = 302, - EndOfDeclarationMarker = 303, - Count = 304, + UnknownKeyword = 142, + FromKeyword = 143, + GlobalKeyword = 144, + OfKeyword = 145, + QualifiedName = 146, + ComputedPropertyName = 147, + TypeParameter = 148, + Parameter = 149, + Decorator = 150, + PropertySignature = 151, + PropertyDeclaration = 152, + MethodSignature = 153, + MethodDeclaration = 154, + Constructor = 155, + GetAccessor = 156, + SetAccessor = 157, + CallSignature = 158, + ConstructSignature = 159, + IndexSignature = 160, + TypePredicate = 161, + TypeReference = 162, + FunctionType = 163, + ConstructorType = 164, + TypeQuery = 165, + TypeLiteral = 166, + ArrayType = 167, + TupleType = 168, + UnionType = 169, + IntersectionType = 170, + ConditionalType = 171, + InferType = 172, + ParenthesizedType = 173, + ThisType = 174, + TypeOperator = 175, + IndexedAccessType = 176, + MappedType = 177, + LiteralType = 178, + ImportType = 179, + ObjectBindingPattern = 180, + ArrayBindingPattern = 181, + BindingElement = 182, + ArrayLiteralExpression = 183, + ObjectLiteralExpression = 184, + PropertyAccessExpression = 185, + ElementAccessExpression = 186, + CallExpression = 187, + NewExpression = 188, + TaggedTemplateExpression = 189, + TypeAssertionExpression = 190, + ParenthesizedExpression = 191, + FunctionExpression = 192, + ArrowFunction = 193, + DeleteExpression = 194, + TypeOfExpression = 195, + VoidExpression = 196, + AwaitExpression = 197, + PrefixUnaryExpression = 198, + PostfixUnaryExpression = 199, + BinaryExpression = 200, + ConditionalExpression = 201, + TemplateExpression = 202, + YieldExpression = 203, + SpreadElement = 204, + ClassExpression = 205, + OmittedExpression = 206, + ExpressionWithTypeArguments = 207, + AsExpression = 208, + NonNullExpression = 209, + MetaProperty = 210, + TemplateSpan = 211, + SemicolonClassElement = 212, + Block = 213, + VariableStatement = 214, + EmptyStatement = 215, + ExpressionStatement = 216, + IfStatement = 217, + DoStatement = 218, + WhileStatement = 219, + ForStatement = 220, + ForInStatement = 221, + ForOfStatement = 222, + ContinueStatement = 223, + BreakStatement = 224, + ReturnStatement = 225, + WithStatement = 226, + SwitchStatement = 227, + LabeledStatement = 228, + ThrowStatement = 229, + TryStatement = 230, + DebuggerStatement = 231, + VariableDeclaration = 232, + VariableDeclarationList = 233, + FunctionDeclaration = 234, + ClassDeclaration = 235, + InterfaceDeclaration = 236, + TypeAliasDeclaration = 237, + EnumDeclaration = 238, + ModuleDeclaration = 239, + ModuleBlock = 240, + CaseBlock = 241, + NamespaceExportDeclaration = 242, + ImportEqualsDeclaration = 243, + ImportDeclaration = 244, + ImportClause = 245, + NamespaceImport = 246, + NamedImports = 247, + ImportSpecifier = 248, + ExportAssignment = 249, + ExportDeclaration = 250, + NamedExports = 251, + ExportSpecifier = 252, + MissingDeclaration = 253, + ExternalModuleReference = 254, + JsxElement = 255, + JsxSelfClosingElement = 256, + JsxOpeningElement = 257, + JsxClosingElement = 258, + JsxFragment = 259, + JsxOpeningFragment = 260, + JsxClosingFragment = 261, + JsxAttribute = 262, + JsxAttributes = 263, + JsxSpreadAttribute = 264, + JsxExpression = 265, + CaseClause = 266, + DefaultClause = 267, + HeritageClause = 268, + CatchClause = 269, + PropertyAssignment = 270, + ShorthandPropertyAssignment = 271, + SpreadAssignment = 272, + EnumMember = 273, + SourceFile = 274, + Bundle = 275, + UnparsedSource = 276, + InputFiles = 277, + JSDocTypeExpression = 278, + JSDocAllType = 279, + JSDocUnknownType = 280, + JSDocNullableType = 281, + JSDocNonNullableType = 282, + JSDocOptionalType = 283, + JSDocFunctionType = 284, + JSDocVariadicType = 285, + JSDocComment = 286, + JSDocTypeLiteral = 287, + JSDocSignature = 288, + JSDocTag = 289, + JSDocAugmentsTag = 290, + JSDocClassTag = 291, + JSDocCallbackTag = 292, + JSDocParameterTag = 293, + JSDocReturnTag = 294, + JSDocTypeTag = 295, + JSDocTemplateTag = 296, + JSDocTypedefTag = 297, + JSDocPropertyTag = 298, + SyntaxList = 299, + NotEmittedStatement = 300, + PartiallyEmittedExpression = 301, + CommaListExpression = 302, + MergeDeclarationMarker = 303, + EndOfDeclarationMarker = 304, + Count = 305, FirstAssignment = 58, LastAssignment = 70, FirstCompoundAssignment = 59, @@ -374,15 +375,15 @@ declare namespace ts { FirstReservedWord = 72, LastReservedWord = 107, FirstKeyword = 72, - LastKeyword = 144, + LastKeyword = 145, FirstFutureReservedWord = 108, LastFutureReservedWord = 116, - FirstTypeNode = 160, - LastTypeNode = 178, + FirstTypeNode = 161, + LastTypeNode = 179, FirstPunctuation = 17, LastPunctuation = 70, FirstToken = 0, - LastToken = 144, + LastToken = 145, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, @@ -391,11 +392,11 @@ declare namespace ts { LastTemplateToken = 16, FirstBinaryOperator = 27, LastBinaryOperator = 70, - FirstNode = 145, - FirstJSDocNode = 277, - LastJSDocNode = 297, - FirstJSDocTagNode = 288, - LastJSDocTagNode = 297 + FirstNode = 146, + FirstJSDocNode = 278, + LastJSDocNode = 298, + FirstJSDocTagNode = 289, + LastJSDocTagNode = 298 } enum NodeFlags { None = 0, @@ -460,7 +461,7 @@ declare namespace ts { flags: NodeFlags; decorators?: NodeArray; modifiers?: ModifiersArray; - parent?: Node; + parent: Node; } interface JSDocContainer { } @@ -525,12 +526,12 @@ declare namespace ts { } interface Decorator extends Node { kind: SyntaxKind.Decorator; - parent?: NamedDeclaration; + parent: NamedDeclaration; expression: LeftHandSideExpression; } interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; - parent?: DeclarationWithTypeParameters | InferTypeNode; + parent: DeclarationWithTypeParameters | InferTypeNode; name: Identifier; constraint?: TypeNode; default?: TypeNode; @@ -541,7 +542,7 @@ declare namespace ts { name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; - type: TypeNode | undefined; + type?: TypeNode; } type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { @@ -553,7 +554,7 @@ declare namespace ts { type BindingName = Identifier | BindingPattern; interface VariableDeclaration extends NamedDeclaration { kind: SyntaxKind.VariableDeclaration; - parent?: VariableDeclarationList | CatchClause; + parent: VariableDeclarationList | CatchClause; name: BindingName; exclamationToken?: ExclamationToken; type?: TypeNode; @@ -561,12 +562,12 @@ declare namespace ts { } interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; - parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement; + parent: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; - parent?: SignatureDeclaration; + parent: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; name: BindingName; questionToken?: QuestionToken; @@ -575,7 +576,7 @@ declare namespace ts { } interface BindingElement extends NamedDeclaration { kind: SyntaxKind.BindingElement; - parent?: BindingPattern; + parent: BindingPattern; propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; name: BindingName; @@ -628,12 +629,12 @@ declare namespace ts { } interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; - parent?: VariableDeclaration | ParameterDeclaration | BindingElement; + parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; - parent?: VariableDeclaration | ParameterDeclaration | BindingElement; + parent: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; @@ -662,47 +663,47 @@ declare namespace ts { } interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; - parent?: ObjectTypeDeclaration; + parent: ObjectTypeDeclaration; name: PropertyName; } interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; - parent?: ClassLikeDeclaration | ObjectLiteralExpression; + parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; - parent?: ClassLikeDeclaration; + parent: ClassLikeDeclaration; body?: FunctionBody; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; - parent?: ClassLikeDeclaration; + parent: ClassLikeDeclaration; } interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; - parent?: ClassLikeDeclaration | ObjectLiteralExpression; + parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; - parent?: ClassLikeDeclaration | ObjectLiteralExpression; + parent: ClassLikeDeclaration | ObjectLiteralExpression; name: PropertyName; body?: FunctionBody; } type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; - parent?: ObjectTypeDeclaration; + parent: ObjectTypeDeclaration; } interface TypeNode extends Node { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } interface ImportTypeNode extends NodeWithTypeArguments { kind: SyntaxKind.ImportType; @@ -730,7 +731,7 @@ declare namespace ts { } interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; - parent?: SignatureDeclaration; + parent: SignatureDeclaration; parameterName: Identifier | ThisTypeNode; type: TypeNode; } @@ -959,15 +960,15 @@ declare namespace ts { } interface TemplateHead extends LiteralLikeNode { kind: SyntaxKind.TemplateHead; - parent?: TemplateExpression; + parent: TemplateExpression; } interface TemplateMiddle extends LiteralLikeNode { kind: SyntaxKind.TemplateMiddle; - parent?: TemplateSpan; + parent: TemplateSpan; } interface TemplateTail extends LiteralLikeNode { kind: SyntaxKind.TemplateTail; - parent?: TemplateSpan; + parent: TemplateSpan; } type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; interface TemplateExpression extends PrimaryExpression { @@ -977,7 +978,7 @@ declare namespace ts { } interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; - parent?: TemplateExpression; + parent: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } @@ -991,7 +992,7 @@ declare namespace ts { } interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; - parent?: ArrayLiteralExpression | CallExpression | NewExpression; + parent: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; } /** @@ -1044,7 +1045,7 @@ declare namespace ts { } interface ExpressionWithTypeArguments extends NodeWithTypeArguments { kind: SyntaxKind.ExpressionWithTypeArguments; - parent?: HeritageClause; + parent: HeritageClause; expression: LeftHandSideExpression; } interface NewExpression extends PrimaryExpression, Declaration { @@ -1090,11 +1091,11 @@ declare namespace ts { type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; interface JsxAttributes extends ObjectLiteralExpressionBase { - parent?: JsxOpeningLikeElement; + parent: JsxOpeningLikeElement; } interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; - parent?: JsxElement; + parent: JsxElement; tagName: JsxTagNameExpression; typeArguments?: NodeArray; attributes: JsxAttributes; @@ -1113,38 +1114,38 @@ declare namespace ts { } interface JsxOpeningFragment extends Expression { kind: SyntaxKind.JsxOpeningFragment; - parent?: JsxFragment; + parent: JsxFragment; } interface JsxClosingFragment extends Expression { kind: SyntaxKind.JsxClosingFragment; - parent?: JsxFragment; + parent: JsxFragment; } interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; - parent?: JsxAttributes; + parent: JsxAttributes; name: Identifier; initializer?: StringLiteral | JsxExpression; } interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; - parent?: JsxAttributes; + parent: JsxAttributes; expression: Expression; } interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; - parent?: JsxElement; + parent: JsxElement; tagName: JsxTagNameExpression; } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; - parent?: JsxElement | JsxAttributeLike; + parent: JsxElement | JsxAttributeLike; dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { kind: SyntaxKind.JsxText; containsOnlyWhiteSpaces: boolean; - parent?: JsxElement; + parent: JsxElement; } type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement | JsxFragment; interface Statement extends Node { @@ -1245,18 +1246,18 @@ declare namespace ts { } interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; - parent?: SwitchStatement; + parent: SwitchStatement; clauses: NodeArray; } interface CaseClause extends Node { kind: SyntaxKind.CaseClause; - parent?: CaseBlock; + parent: CaseBlock; expression: Expression; statements: NodeArray; } interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; - parent?: CaseBlock; + parent: CaseBlock; statements: NodeArray; } type CaseOrDefaultClause = CaseClause | DefaultClause; @@ -1267,7 +1268,7 @@ declare namespace ts { } interface ThrowStatement extends Statement { kind: SyntaxKind.ThrowStatement; - expression: Expression; + expression?: Expression; } interface TryStatement extends Statement { kind: SyntaxKind.TryStatement; @@ -1277,7 +1278,7 @@ declare namespace ts { } interface CatchClause extends Node { kind: SyntaxKind.CatchClause; - parent?: TryStatement; + parent: TryStatement; variableDeclaration?: VariableDeclaration; block: Block; } @@ -1317,7 +1318,7 @@ declare namespace ts { } interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; - parent?: InterfaceDeclaration | ClassLikeDeclaration; + parent: InterfaceDeclaration | ClassLikeDeclaration; token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; types: NodeArray; } @@ -1329,7 +1330,7 @@ declare namespace ts { } interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; - parent?: EnumDeclaration; + parent: EnumDeclaration; name: PropertyName; initializer?: Expression; } @@ -1342,7 +1343,7 @@ declare namespace ts { type ModuleBody = NamespaceBody | JSDocNamespaceBody; interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; - parent?: ModuleBody | SourceFile; + parent: ModuleBody | SourceFile; name: ModuleName; body?: ModuleBody | JSDocNamespaceDeclaration; } @@ -1354,11 +1355,11 @@ declare namespace ts { type JSDocNamespaceBody = Identifier | JSDocNamespaceDeclaration; interface JSDocNamespaceDeclaration extends ModuleDeclaration { name: Identifier; - body: JSDocNamespaceBody; + body?: JSDocNamespaceBody; } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; - parent?: ModuleDeclaration; + parent: ModuleDeclaration; statements: NodeArray; } type ModuleReference = EntityName | ExternalModuleReference; @@ -1369,18 +1370,18 @@ declare namespace ts { */ interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; - parent?: SourceFile | ModuleBlock; + parent: SourceFile | ModuleBlock; name: Identifier; moduleReference: ModuleReference; } interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; - parent?: ImportEqualsDeclaration; - expression?: Expression; + parent: ImportEqualsDeclaration; + expression: Expression; } interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; - parent?: SourceFile | ModuleBlock; + parent: SourceFile | ModuleBlock; importClause?: ImportClause; /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier: Expression; @@ -1388,13 +1389,13 @@ declare namespace ts { type NamedImportBindings = NamespaceImport | NamedImports; interface ImportClause extends NamedDeclaration { kind: SyntaxKind.ImportClause; - parent?: ImportDeclaration; + parent: ImportDeclaration; name?: Identifier; namedBindings?: NamedImportBindings; } interface NamespaceImport extends NamedDeclaration { kind: SyntaxKind.NamespaceImport; - parent?: ImportClause; + parent: ImportClause; name: Identifier; } interface NamespaceExportDeclaration extends DeclarationStatement { @@ -1403,7 +1404,7 @@ declare namespace ts { } interface ExportDeclaration extends DeclarationStatement { kind: SyntaxKind.ExportDeclaration; - parent?: SourceFile | ModuleBlock; + parent: SourceFile | ModuleBlock; /** Will not be assigned in the case of `export * from "foo";` */ exportClause?: NamedExports; /** If this is not a StringLiteral it will be a grammar error. */ @@ -1411,24 +1412,24 @@ declare namespace ts { } interface NamedImports extends Node { kind: SyntaxKind.NamedImports; - parent?: ImportClause; + parent: ImportClause; elements: NodeArray; } interface NamedExports extends Node { kind: SyntaxKind.NamedExports; - parent?: ExportDeclaration; + parent: ExportDeclaration; elements: NodeArray; } type NamedImportsOrExports = NamedImports | NamedExports; interface ImportSpecifier extends NamedDeclaration { kind: SyntaxKind.ImportSpecifier; - parent?: NamedImports; + parent: NamedImports; propertyName?: Identifier; name: Identifier; } interface ExportSpecifier extends NamedDeclaration { kind: SyntaxKind.ExportSpecifier; - parent?: NamedExports; + parent: NamedExports; propertyName?: Identifier; name: Identifier; } @@ -1439,7 +1440,7 @@ declare namespace ts { */ interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; - parent?: SourceFile; + parent: SourceFile; isExportEquals?: boolean; expression: Expression; } @@ -1494,15 +1495,15 @@ declare namespace ts { type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; interface JSDoc extends Node { kind: SyntaxKind.JSDocComment; - parent?: HasJSDoc; - tags: NodeArray | undefined; - comment: string | undefined; + parent: HasJSDoc; + tags?: NodeArray; + comment?: string; } interface JSDocTag extends Node { parent: JSDoc | JSDocTypeLiteral; atToken: AtToken; tagName: Identifier; - comment: string | undefined; + comment?: string; } interface JSDocUnknownTag extends JSDocTag { kind: SyntaxKind.JSDocTag; @@ -1526,11 +1527,11 @@ declare namespace ts { } interface JSDocReturnTag extends JSDocTag { kind: SyntaxKind.JSDocReturnTag; - typeExpression: JSDocTypeExpression; + typeExpression?: JSDocTypeExpression; } interface JSDocTypeTag extends JSDocTag { kind: SyntaxKind.JSDocTypeTag; - typeExpression: JSDocTypeExpression; + typeExpression?: JSDocTypeExpression; } interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { parent: JSDoc; @@ -1608,7 +1609,7 @@ declare namespace ts { container?: FunctionExpression | ArrowFunction | MethodDeclaration; } interface FlowLabel extends FlowNodeBase { - antecedents: FlowNode[]; + antecedents: FlowNode[] | undefined; } interface FlowAssignment extends FlowNodeBase { node: Expression | VariableDeclaration | BindingElement; @@ -1635,7 +1636,7 @@ declare namespace ts { } interface AmdDependency { path: string; - name: string; + name?: string; } interface SourceFile extends Declaration { kind: SyntaxKind.SourceFile; @@ -1644,7 +1645,7 @@ declare namespace ts { fileName: string; text: string; amdDependencies: ReadonlyArray; - moduleName: string; + moduleName?: string; referencedFiles: ReadonlyArray; typeReferenceDirectives: ReadonlyArray; languageVariant: LanguageVariant; @@ -1704,7 +1705,7 @@ declare namespace ts { fileExists(path: string): boolean; readFile(path: string): string | undefined; } - type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray) => void; + type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles?: ReadonlyArray) => void; class OperationCanceledException { } interface CancellationToken { @@ -1734,9 +1735,10 @@ declare namespace ts { emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + /** The first time this is called, it will return global diagnostics (no location). */ getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; getConfigFileParsingDiagnostics(): ReadonlyArray; /** * Gets a type checker that can be used to semantically analyze source files in the program. @@ -1793,7 +1795,7 @@ declare namespace ts { emitSkipped: boolean; /** Contains declaration emit diagnostics */ diagnostics: ReadonlyArray; - emittedFiles: string[]; + emittedFiles?: string[]; } interface TypeChecker { getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type; @@ -1810,7 +1812,7 @@ declare namespace ts { getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; /** Note that the resulting nodes cannot be checked. */ - typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode; + typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): (SignatureDeclaration & { typeArguments?: NodeArray; @@ -1846,7 +1848,7 @@ declare namespace ts { */ getExportSymbolOfSymbol(symbol: Symbol): Symbol; getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined; - getTypeAtLocation(node: Node): Type; + getTypeAtLocation(node: Node): Type | undefined; getTypeFromTypeNode(node: TypeNode): Type; signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; @@ -1863,9 +1865,10 @@ declare namespace ts { getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. + * returns undefined if the node is not valid. * @param argumentCount Apparent number of arguments, passed in case of a possibly incomplete call. This should come from an ArgumentListInfo. See `signatureHelp.ts`. */ - getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature; + getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[], argumentCount?: number): Signature | undefined; getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined; isImplementationOfOverload(node: SignatureDeclaration): boolean | undefined; isUndefinedSymbol(symbol: Symbol): boolean; @@ -2069,8 +2072,8 @@ declare namespace ts { interface Symbol { flags: SymbolFlags; escapedName: __String; - declarations?: Declaration[]; - valueDeclaration?: Declaration; + declarations: Declaration[]; + valueDeclaration: Declaration; members?: SymbolTable; exports?: SymbolTable; globalExports?: SymbolTable; @@ -2126,61 +2129,62 @@ declare namespace ts { type SymbolTable = UnderscoreEscapedMap; enum TypeFlags { Any = 1, - String = 2, - Number = 4, - Boolean = 8, - Enum = 16, - StringLiteral = 32, - NumberLiteral = 64, - BooleanLiteral = 128, - EnumLiteral = 256, - ESSymbol = 512, - UniqueESSymbol = 1024, - Void = 2048, - Undefined = 4096, - Null = 8192, - Never = 16384, - TypeParameter = 32768, - Object = 65536, - Union = 131072, - Intersection = 262144, - Index = 524288, - IndexedAccess = 1048576, - Conditional = 2097152, - Substitution = 4194304, - NonPrimitive = 134217728, - Literal = 224, - Unit = 13536, - StringOrNumberLiteral = 96, - PossiblyFalsy = 14574, - StringLike = 34, - NumberLike = 84, - BooleanLike = 136, - EnumLike = 272, - ESSymbolLike = 1536, - VoidLike = 6144, - UnionOrIntersection = 393216, - StructuredType = 458752, - TypeVariable = 1081344, - InstantiableNonPrimitive = 7372800, - InstantiablePrimitive = 524288, - Instantiable = 7897088, - StructuredOrInstantiable = 8355840, - Narrowable = 142575359, - NotUnionOrUnit = 134283777 + Unknown = 2, + String = 4, + Number = 8, + Boolean = 16, + Enum = 32, + StringLiteral = 64, + NumberLiteral = 128, + BooleanLiteral = 256, + EnumLiteral = 512, + ESSymbol = 1024, + UniqueESSymbol = 2048, + Void = 4096, + Undefined = 8192, + Null = 16384, + Never = 32768, + TypeParameter = 65536, + Object = 131072, + Union = 262144, + Intersection = 524288, + Index = 1048576, + IndexedAccess = 2097152, + Conditional = 4194304, + Substitution = 8388608, + NonPrimitive = 16777216, + Literal = 448, + Unit = 27072, + StringOrNumberLiteral = 192, + PossiblyFalsy = 29148, + StringLike = 68, + NumberLike = 168, + BooleanLike = 272, + EnumLike = 544, + ESSymbolLike = 3072, + VoidLike = 12288, + UnionOrIntersection = 786432, + StructuredType = 917504, + TypeVariable = 2162688, + InstantiableNonPrimitive = 14745600, + InstantiablePrimitive = 1048576, + Instantiable = 15794176, + StructuredOrInstantiable = 16711680, + Narrowable = 33492479, + NotUnionOrUnit = 16909315 } type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; interface Type { flags: TypeFlags; - symbol?: Symbol; + symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; aliasTypeArguments?: Type[]; } interface LiteralType extends Type { value: string | number; - freshType?: LiteralType; - regularType?: LiteralType; + freshType: LiteralType; + regularType: LiteralType; } interface UniqueESSymbolType extends Type { symbol: Symbol; @@ -2215,18 +2219,18 @@ declare namespace ts { } /** Class and interface types (ObjectFlags.Class and ObjectFlags.Interface). */ interface InterfaceType extends ObjectType { - typeParameters: TypeParameter[]; - outerTypeParameters: TypeParameter[]; - localTypeParameters: TypeParameter[]; - thisType: TypeParameter; + typeParameters: TypeParameter[] | undefined; + outerTypeParameters: TypeParameter[] | undefined; + localTypeParameters: TypeParameter[] | undefined; + thisType: TypeParameter | undefined; } type BaseType = ObjectType | IntersectionType; interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; declaredConstructSignatures: Signature[]; - declaredStringIndexInfo: IndexInfo; - declaredNumberIndexInfo: IndexInfo; + declaredStringIndexInfo?: IndexInfo; + declaredNumberIndexInfo?: IndexInfo; } /** * Type references (ObjectFlags.Reference). When a class or interface has type parameters or @@ -2277,11 +2281,11 @@ declare namespace ts { trueType: Type; falseType: Type; isDistributive: boolean; - inferTypeParameters: TypeParameter[]; + inferTypeParameters?: TypeParameter[]; outerTypeParameters?: TypeParameter[]; instantiations?: Map; - aliasSymbol: Symbol; - aliasTypeArguments: Type[]; + aliasSymbol?: Symbol; + aliasTypeArguments?: Type[]; } interface ConditionalType extends InstantiableType { root: ConditionalRoot; @@ -2359,6 +2363,11 @@ declare namespace ts { code: number; source?: string; } + interface DiagnosticWithLocation extends Diagnostic { + file: SourceFile; + start: number; + length: number; + } enum DiagnosticCategory { Warning = 0, Error = 1, @@ -2624,7 +2633,7 @@ declare namespace ts { packageId?: PackageId; } interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { - readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective; + readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; readonly failedLookupLocations: ReadonlyArray; } interface CompilerHost extends ModuleResolutionHost { @@ -2644,8 +2653,8 @@ declare namespace ts { /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): (ResolvedTypeReferenceDirective | undefined)[]; - getEnvironmentVariable?(name: string): string; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; + getEnvironmentVariable?(name: string): string | undefined; createHash?(data: string): string; } interface SourceMapRange extends TextRange { @@ -2657,6 +2666,7 @@ declare namespace ts { skipTrivia?: (pos: number) => number; } enum EmitFlags { + None = 0, SingleLine = 1, AdviseOnEmitNode = 2, NoSubstitution = 4, @@ -2710,7 +2720,7 @@ declare namespace ts { /** Resumes a suspended lexical environment, usually before visiting a function body. */ resumeLexicalEnvironment(): void; /** Ends a lexical environment, returning any declarations. */ - endLexicalEnvironment(): Statement[]; + endLexicalEnvironment(): Statement[] | undefined; /** Hoists a function declaration to the containing scope. */ hoistFunctionDeclaration(node: FunctionDeclaration): void; /** Hoists a variable declaration to the containing scope. */ @@ -2754,7 +2764,7 @@ declare namespace ts { /** Gets the transformed source files. */ transformed: T[]; /** Gets diagnostics for the transformation. */ - diagnostics?: Diagnostic[]; + diagnostics?: DiagnosticWithLocation[]; /** * Gets a substitute for a node, if one is available; otherwise, returns the original node. * @@ -2841,7 +2851,7 @@ declare namespace ts { * }); * ``` */ - onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + onEmitNode?(hint: EmitHint, node: Node | undefined, emitCallback: (hint: EmitHint, node: Node | undefined) => void): void; /** * 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, @@ -2954,13 +2964,13 @@ declare namespace ts { } } declare namespace ts { - const versionMajorMinor = "2.9"; + const versionMajorMinor = "3.0"; /** The version of the TypeScript compiler release */ const version: string; } declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): Diagnostic[]; + function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): T[]; } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; @@ -3014,7 +3024,7 @@ declare namespace ts { interface FileWatcher { close(): void; } - function getNodeMajorVersion(): number; + function getNodeMajorVersion(): number | undefined; let sys: System; } declare namespace ts { @@ -3041,8 +3051,8 @@ declare namespace ts { scanJSDocToken(): JsDocSyntaxKind; scan(): SyntaxKind; getText(): string; - setText(text: string, start?: number, length?: number): void; - setOnError(onError: ErrorCallback): void; + setText(text: string | undefined, start?: number, length?: number): void; + setOnError(onError: ErrorCallback | undefined): void; setScriptTarget(scriptTarget: ScriptTarget): void; setLanguageVariant(variant: LanguageVariant): void; setTextPos(textPos: number): void; @@ -3062,15 +3072,15 @@ declare namespace ts { function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean) => U): U | undefined; function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state: T): U | undefined; - function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; - function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; + function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined; + function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U | undefined; function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; /** Optionally, get the shebang */ function getShebang(text: string): string | undefined; - function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean; - function isIdentifierPart(ch: number, languageVersion: ScriptTarget): boolean; - function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, text?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; + function isIdentifierStart(ch: number, languageVersion: ScriptTarget | undefined): boolean; + function isIdentifierPart(ch: number, languageVersion: ScriptTarget | undefined): boolean; + function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean, languageVariant?: LanguageVariant, textInitial?: string, onError?: ErrorCallback, start?: number, length?: number): Scanner; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3079,12 +3089,12 @@ declare namespace ts { function textSpanContainsPosition(span: TextSpan, position: number): boolean; function textSpanContainsTextSpan(span: TextSpan, other: TextSpan): boolean; function textSpanOverlapsWith(span: TextSpan, other: TextSpan): boolean; - function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan; + function textSpanOverlap(span1: TextSpan, span2: TextSpan): TextSpan | undefined; function textSpanIntersectsWithTextSpan(span: TextSpan, other: TextSpan): boolean; function textSpanIntersectsWith(span: TextSpan, start: number, length: number): boolean; function decodedTextSpanIntersectsWith(start1: number, length1: number, start2: number, length2: number): boolean; function textSpanIntersectsWithPosition(span: TextSpan, position: number): boolean; - function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan; + function textSpanIntersection(span1: TextSpan, span2: TextSpan): TextSpan | undefined; function createTextSpan(start: number, length: number): TextSpan; function createTextSpanFromBounds(start: number, end: number): TextSpan; function textChangeRangeNewSpan(range: TextChangeRange): TextSpan; @@ -3100,7 +3110,7 @@ declare namespace ts { * Vn. */ function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; - function getTypeParameterOwner(d: Declaration): Declaration; + function getTypeParameterOwner(d: Declaration): Declaration | undefined; type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration; name: Identifier; @@ -3122,6 +3132,8 @@ declare namespace ts { }, errors?: Push): void; function getOriginalNode(node: Node): Node; function getOriginalNode(node: Node, nodeTest: (node: Node) => node is T): T; + function getOriginalNode(node: Node | undefined): Node | undefined; + function getOriginalNode(node: Node | undefined, nodeTest: (node: Node | undefined) => node is T): T | undefined; /** * Gets a value indicating whether a node originated in the parse tree. * @@ -3142,7 +3154,7 @@ declare namespace ts { * @param nodeTest A callback used to ensure the correct type of parse tree node is returned. * @returns The original parse tree node if found; otherwise, undefined. */ - function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; + function getParseTreeNode(node: Node | undefined, nodeTest?: (node: Node) => node is T): T | undefined; /** * Remove extra underscore from escaped identifier text content. * @@ -3160,7 +3172,7 @@ declare namespace ts { */ function unescapeIdentifier(id: string): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined; - function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; + function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName; /** * Gets the JSDoc parameter tags for the node if present. * @@ -3389,8 +3401,10 @@ declare namespace ts { */ function isToken(n: Node): boolean; function isLiteralExpression(node: Node): node is LiteralExpression; + type TemplateLiteralToken = NoSubstitutionTemplateLiteral | TemplateHead | TemplateMiddle | TemplateTail; + function isTemplateLiteralToken(node: Node): node is TemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node: Node): node is TemplateMiddle | TemplateTail; - function isStringTextContainingNode(node: Node): boolean; + function isStringTextContainingNode(node: Node): node is StringLiteral | TemplateLiteralToken; function isModifier(node: Node): node is Modifier; function isEntityName(node: Node): node is EntityName; function isPropertyName(node: Node): node is PropertyName; @@ -3442,7 +3456,7 @@ declare namespace ts { */ function forEachChild(node: Node, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray) => T | undefined): T | undefined; function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile; - function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName; + function parseIsolatedEntityName(text: string, languageVersion: ScriptTarget): EntityName | undefined; /** * Parse json text into SyntaxTree and return node and parse errors if any * @param fileName @@ -3488,7 +3502,7 @@ declare namespace ts { getOrCreateCacheForModuleName(nonRelativeModuleName: string): PerModuleNameCache; } interface PerModuleNameCache { - get(directory: string): ResolvedModuleWithFailedLookupLocations; + get(directory: string): ResolvedModuleWithFailedLookupLocations | undefined; set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): ModuleResolutionCache; @@ -3570,7 +3584,7 @@ declare namespace ts { function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; function createTypeQueryNode(exprName: EntityName): TypeQueryNode; function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; - function createTypeLiteralNode(members: ReadonlyArray): TypeLiteralNode; + function createTypeLiteralNode(members: ReadonlyArray | undefined): TypeLiteralNode; function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; @@ -3609,23 +3623,23 @@ declare namespace ts { function updateArrayLiteral(node: ArrayLiteralExpression, elements: ReadonlyArray): ArrayLiteralExpression; function createObjectLiteral(properties?: ReadonlyArray, multiLine?: boolean): ObjectLiteralExpression; function updateObjectLiteral(node: ObjectLiteralExpression, properties: ReadonlyArray): ObjectLiteralExpression; - function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; + function createPropertyAccess(expression: Expression, name: string | Identifier | undefined): PropertyAccessExpression; function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; + function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): CallExpression; function updateCall(node: CallExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; function createNew(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; function updateNew(node: NewExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray, template: TemplateLiteral): TaggedTemplateExpression; + function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; + function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; @@ -3655,15 +3669,15 @@ declare namespace ts { function createTemplateTail(text: string): TemplateTail; function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral; function createYield(expression?: Expression): YieldExpression; - function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; + function createYield(asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray, members: ReadonlyArray): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray, members: ReadonlyArray): ClassExpression; + function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; function createOmittedExpression(): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: ReadonlyArray, expression: Expression): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray, expression: Expression): ExpressionWithTypeArguments; + function createExpressionWithTypeArguments(typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; function createAsExpression(expression: Expression, type: TypeNode): AsExpression; function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; function createNonNullExpression(expression: Expression): NonNullExpression; @@ -3690,8 +3704,8 @@ declare namespace ts { function updateFor(node: ForStatement, initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement): ForStatement; function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; - function createForOf(awaitModifier: AwaitKeywordToken, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; - function updateForOf(node: ForOfStatement, awaitModifier: AwaitKeywordToken, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function createForOf(awaitModifier: AwaitKeywordToken | undefined, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function updateForOf(node: ForOfStatement, awaitModifier: AwaitKeywordToken | undefined, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; function createContinue(label?: string | Identifier): ContinueStatement; function updateContinue(node: ContinueStatement, label: Identifier | undefined): ContinueStatement; function createBreak(label?: string | Identifier): BreakStatement; @@ -3715,8 +3729,8 @@ declare namespace ts { function updateVariableDeclarationList(node: VariableDeclarationList, declarations: ReadonlyArray): VariableDeclarationList; function createFunctionDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; function updateFunctionDeclaration(node: FunctionDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray, members: ReadonlyArray): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray, members: ReadonlyArray): ClassDeclaration; + function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; function createInterfaceDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; function createTypeAliasDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; @@ -3734,7 +3748,7 @@ declare namespace ts { function createImportEqualsDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; function createImportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression | undefined): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; function createImportClause(name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function updateImportClause(node: ImportClause, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; @@ -3743,7 +3757,7 @@ declare namespace ts { function updateNamedImports(node: NamedImports, elements: ReadonlyArray): NamedImports; function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean, expression: Expression): ExportAssignment; + function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; function updateExportAssignment(node: ExportAssignment, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, expression: Expression): ExportAssignment; function createExportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; function updateExportDeclaration(node: ExportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; @@ -3873,16 +3887,16 @@ declare namespace ts { */ function setCommentRange(node: T, range: TextRange): T; function getSyntheticLeadingComments(node: Node): SynthesizedComment[] | undefined; - function setSyntheticLeadingComments(node: T, comments: SynthesizedComment[]): T; + function setSyntheticLeadingComments(node: T, comments: SynthesizedComment[] | undefined): T; function addSyntheticLeadingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T; function getSyntheticTrailingComments(node: Node): SynthesizedComment[] | undefined; - function setSyntheticTrailingComments(node: T, comments: SynthesizedComment[]): T; + function setSyntheticTrailingComments(node: T, comments: SynthesizedComment[] | undefined): T; function addSyntheticTrailingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T; function moveSyntheticComments(node: T, original: Node): T; /** * Gets the constant value to emit for an expression. */ - function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): string | number; + function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): string | number | undefined; /** * Sets the constant value to emit for an expression. */ @@ -3918,7 +3932,7 @@ declare namespace ts { * @param test A callback to execute to verify the Node is valid. * @param lift An optional callback to execute to lift a NodeArray into a valid Node. */ - function visitNode(node: T, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T; + function visitNode(node: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T; /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. * @@ -3927,7 +3941,7 @@ declare namespace ts { * @param test A callback to execute to verify the Node is valid. * @param lift An optional callback to execute to lift a NodeArray into a valid Node. */ - function visitNode(node: T | undefined, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T | undefined; + function visitNode(node: T | undefined, visitor: Visitor | undefined, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T | undefined; /** * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. * @@ -3937,7 +3951,7 @@ declare namespace ts { * @param start An optional value indicating the starting offset at which to start visiting. * @param count An optional value indicating the maximum number of nodes to visit. */ - function visitNodes(nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; + function visitNodes(nodes: NodeArray | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; /** * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. * @@ -3957,7 +3971,7 @@ declare namespace ts { * Starts a new lexical environment and visits a parameter list, suspending the lexical * environment upon completion. */ - function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): NodeArray; + function visitParameterList(nodes: NodeArray | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): NodeArray; /** * Resumes a suspended lexical environment and visits a function body, ending the lexical * environment and merging hoisted declarations upon completion. @@ -4006,8 +4020,19 @@ declare namespace ts { function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; - function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; + function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain | undefined, newLine: string): string; function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): ReadonlyArray; + /** + * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' + * that represent a compilation unit. + * + * Creating a program proceeds from a set of root files, expanding the set of inputs by following imports and + * triple-slash-reference-path directives transitively. '@types' and triple-slash-reference-types are also pulled in. + * + * @param createProgramOptions - The options for creating a program. + * @returns A 'Program' object. + */ + function createProgram(createProgramOptions: CreateProgramOptions): Program; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4022,7 +4047,6 @@ declare namespace ts { * @param configFileParsingDiagnostics - error during config file parsing * @returns A 'Program' object. */ - function createProgram(createProgramOptions: CreateProgramOptions): Program; function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; } declare namespace ts { @@ -4148,18 +4172,18 @@ declare namespace ts { * Create the builder to manage semantic diagnostics and cache them */ function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; - function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; /** * Create the builder that can handle the changes in program and iterate through changed files * to emit the those files and manage semantic diagnostics cache as well */ function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; - function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; /** * Creates a builder thats just abstraction over program and can be used with watch */ function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; - function createAbstractBuilder(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; + function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; } declare namespace ts { type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void; @@ -4201,11 +4225,11 @@ declare namespace ts { /** If provided would be used to write log about compilation */ trace?(s: string): void; /** If provided is used to get the environment variable */ - getEnvironmentVariable?(name: string): string; + getEnvironmentVariable?(name: string): string | undefined; /** If provided, used to resolve the module names, otherwise typescript's default module resolution */ resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; /** Used to watch changes in source files, missing files needed to update the program or config file */ watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; /** Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added */ @@ -4355,8 +4379,8 @@ declare namespace ts { getLeadingTriviaWidth(sourceFile?: SourceFile): number; getFullText(sourceFile?: SourceFile): string; getText(sourceFile?: SourceFile): string; - getFirstToken(sourceFile?: SourceFile): Node; - getLastToken(sourceFile?: SourceFile): Node; + getFirstToken(sourceFile?: SourceFile): Node | undefined; + getLastToken(sourceFile?: SourceFile): Node | undefined; forEachChild(cbNode: (node: Node) => T | undefined, cbNodeArray?: (nodes: NodeArray) => T | undefined): T | undefined; } interface Identifier { @@ -4444,7 +4468,7 @@ declare namespace ts { referencedFiles: FileReference[]; typeReferenceDirectives: FileReference[]; importedFiles: FileReference[]; - ambientExternalModules: string[]; + ambientExternalModules?: string[]; isLibFile: boolean; } interface HostCancellationToken { @@ -4477,7 +4501,7 @@ declare namespace ts { fileExists?(path: string): boolean; getTypeRootsVersion?(): number; resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames?: string[]): ResolvedModule[]; - getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations; + getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined; resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; getDirectories?(directoryName: string): string[]; /** @@ -4497,9 +4521,10 @@ declare namespace ts { } interface LanguageService { cleanupSemanticCache(): void; - getSyntacticDiagnostics(fileName: string): Diagnostic[]; + getSyntacticDiagnostics(fileName: string): DiagnosticWithLocation[]; + /** The first time this is called, it will return global diagnostics (no location). */ getSemanticDiagnostics(fileName: string): Diagnostic[]; - getSuggestionDiagnostics(fileName: string): Diagnostic[]; + getSuggestionDiagnostics(fileName: string): DiagnosticWithLocation[]; getCompilerOptionsDiagnostics(): Diagnostic[]; /** * @deprecated Use getEncodedSyntacticClassifications instead. @@ -4511,24 +4536,24 @@ declare namespace ts { getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[]; getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications; getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; - getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): CompletionInfo; - getCompletionEntryDetails(fileName: string, position: number, name: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails; - getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol; - getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; - getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan; - getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan; - getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems; + getCompletionsAtPosition(fileName: string, position: number, options: GetCompletionsAtPositionOptions | undefined): CompletionInfo | undefined; + getCompletionEntryDetails(fileName: string, position: number, name: string, formatOptions: FormatCodeOptions | FormatCodeSettings | undefined, source: string | undefined, preferences: UserPreferences | undefined): CompletionEntryDetails | undefined; + getCompletionEntrySymbol(fileName: string, position: number, name: string, source: string | undefined): Symbol | undefined; + getQuickInfoAtPosition(fileName: string, position: number): QuickInfo | undefined; + getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan | undefined; + getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; + getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[]; - getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; - getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan; - getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; - getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[]; - getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; - findReferences(fileName: string, position: number): ReferencedSymbol[]; - getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[]; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] | undefined; + getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; + getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[] | undefined; + getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] | undefined; + getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; + findReferences(fileName: string, position: number): ReferencedSymbol[] | undefined; + getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; /** @deprecated */ - getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[]; + getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -4539,9 +4564,14 @@ 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; + getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion | undefined; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan; + /** + * 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. + * Editors should call this after `>` is typed. + */ + getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined; + getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; @@ -4557,11 +4587,14 @@ declare namespace ts { getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined): 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): ReadonlyArray; - getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings): ReadonlyArray; + getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; - getProgram(): Program; + getProgram(): Program | undefined; dispose(): void; } + interface JsxClosingTagInfo { + readonly newText: string; + } interface CombinedCodeFixScope { type: "file"; fileName: string; @@ -4662,7 +4695,7 @@ declare namespace ts { } interface CombinedCodeActions { changes: ReadonlyArray; - commands: ReadonlyArray | undefined; + commands?: ReadonlyArray; } type CodeActionCommand = InstallPackageAction; interface InstallPackageAction { @@ -4712,8 +4745,8 @@ declare namespace ts { */ interface RefactorEditInfo { edits: FileTextChanges[]; - renameFilename: string | undefined; - renameLocation: number | undefined; + renameFilename?: string; + renameLocation?: number; commands?: CodeActionCommand[]; } interface TextInsertion { @@ -4834,7 +4867,7 @@ declare namespace ts { containerName: string; } interface DefinitionInfoAndBoundSpan { - definitions: ReadonlyArray; + definitions?: ReadonlyArray; textSpan: TextSpan; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { @@ -4880,13 +4913,13 @@ declare namespace ts { kind: ScriptElementKind; kindModifiers: string; textSpan: TextSpan; - displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - tags: JSDocTagInfo[]; + displayParts?: SymbolDisplayPart[]; + documentation?: SymbolDisplayPart[]; + tags?: JSDocTagInfo[]; } interface RenameInfo { canRename: boolean; - localizedErrorMessage: string; + localizedErrorMessage?: string; displayName: string; fullDisplayName: string; kind: ScriptElementKind; @@ -4938,7 +4971,7 @@ declare namespace ts { interface CompletionEntry { name: string; kind: ScriptElementKind; - kindModifiers: string; + kindModifiers?: string; sortText: string; insertText?: string; /** @@ -4956,8 +4989,8 @@ declare namespace ts { kind: ScriptElementKind; kindModifiers: string; displayParts: SymbolDisplayPart[]; - documentation: SymbolDisplayPart[]; - tags: JSDocTagInfo[]; + documentation?: SymbolDisplayPart[]; + tags?: JSDocTagInfo[]; codeActions?: CodeAction[]; source?: SymbolDisplayPart[]; } @@ -5270,12 +5303,12 @@ declare namespace ts { /** The version of the language service API */ const servicesVersion = "0.8"; function toEditorSettings(options: EditorOptions | EditorSettings): EditorSettings; - function displayPartsToString(displayParts: SymbolDisplayPart[]): string; + function displayPartsToString(displayParts: SymbolDisplayPart[] | undefined): string; function getDefaultCompilerOptions(): CompilerOptions; function getSupportedCodeFixes(): string[]; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean, scriptKind?: ScriptKind): SourceFile; let disableIncrementalParsing: boolean; - function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; + function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange | undefined, aggressiveChecks?: boolean): SourceFile; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry, syntaxOnly?: boolean): LanguageService; /** * Get the path of the default library files (lib.d.ts) as distributed with the typescript diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 5a20323ef59..84491873e2b 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -202,190 +202,191 @@ var ts; SyntaxKind[SyntaxKind["TypeKeyword"] = 139] = "TypeKeyword"; SyntaxKind[SyntaxKind["UndefinedKeyword"] = 140] = "UndefinedKeyword"; SyntaxKind[SyntaxKind["UniqueKeyword"] = 141] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 142] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 143] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 144] = "OfKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 142] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 143] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 144] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 145] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 145] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 146] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 146] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 147] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 147] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 148] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 149] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 148] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 149] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 150] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 150] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 151] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 152] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 153] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 154] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 155] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 156] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 157] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 158] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 159] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 151] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 152] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 153] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 154] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 155] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 156] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 157] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 158] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 159] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 160] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 160] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 161] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 162] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 163] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 164] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 165] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 166] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 167] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 168] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 169] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 170] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 171] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 172] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 173] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 174] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 175] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 176] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 177] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 178] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 161] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 162] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 163] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 164] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 165] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 166] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 167] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 168] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 169] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 170] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 171] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 172] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 173] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 174] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 175] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 176] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 177] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 178] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 179] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 179] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 180] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 181] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 180] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 181] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 182] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 182] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 183] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 184] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 185] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 186] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 187] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 188] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 189] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 190] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 191] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 192] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 193] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 194] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 195] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 196] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 197] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 198] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 199] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 200] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 201] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 202] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 203] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 204] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 205] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 206] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 207] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 208] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 209] = "MetaProperty"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 183] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 184] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 185] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 186] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 187] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 188] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 189] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 190] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 191] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 192] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 193] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 194] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 195] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 196] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 197] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 198] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 199] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 200] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 201] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 202] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 203] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 204] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 205] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 206] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 207] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 208] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 209] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 210] = "MetaProperty"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 210] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 211] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 211] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 212] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 212] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 213] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 214] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 215] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 216] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 217] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 218] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 219] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 220] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 221] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 222] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 223] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 224] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 225] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 226] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 227] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 228] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 229] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 230] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 231] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 232] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 233] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 234] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 235] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 236] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 237] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 238] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 239] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 240] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 241] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 242] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 243] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 244] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 245] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 246] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 247] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 248] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 249] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 250] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 251] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 252] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 213] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 214] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 215] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 216] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 217] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 218] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 219] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 220] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 221] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 222] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 223] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 224] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 225] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 226] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 227] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 228] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 229] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 230] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 231] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 232] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 233] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 234] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 235] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 236] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 237] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 238] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 239] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 240] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 241] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 242] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 243] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 244] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 245] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 246] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 247] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 248] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 249] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 250] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 251] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 252] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 253] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 253] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 254] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 254] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 255] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 256] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 257] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 258] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 259] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 260] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 261] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 262] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 263] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 264] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 255] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 256] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 257] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 258] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 259] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 260] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 261] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 262] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 263] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 264] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 265] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 265] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 266] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 267] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 268] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 266] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 267] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 268] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 269] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 269] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 270] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 271] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 270] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 271] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 272] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 272] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 273] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 273] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 274] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 275] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 276] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 274] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 275] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 276] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 277] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 277] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 278] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 278] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 279] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 279] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 280] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 281] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 282] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 283] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 284] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 285] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 286] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 287] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 288] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 289] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 290] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 291] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 292] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 293] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 294] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 295] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 296] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 297] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 280] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 281] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 282] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 283] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 284] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 285] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 286] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 287] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 288] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 289] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 290] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 291] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 292] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 293] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 294] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 295] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 296] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 297] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 298] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 298] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 299] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 299] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 300] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 301] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 302] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 303] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 300] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 301] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 302] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 303] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 304] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 304] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 305] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; @@ -394,15 +395,15 @@ var ts; SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 144] = "LastKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 145] = "LastKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 160] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 178] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 161] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 179] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 144] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 145] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; @@ -411,13 +412,13 @@ var ts; SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 145] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 277] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 297] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 288] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 297] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["FirstNode"] = 146] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 278] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 298] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 289] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 298] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 117] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 144] = "LastContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 145] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -857,89 +858,93 @@ var ts; var TypeFlags; (function (TypeFlags) { TypeFlags[TypeFlags["Any"] = 1] = "Any"; - TypeFlags[TypeFlags["String"] = 2] = "String"; - TypeFlags[TypeFlags["Number"] = 4] = "Number"; - TypeFlags[TypeFlags["Boolean"] = 8] = "Boolean"; - TypeFlags[TypeFlags["Enum"] = 16] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 32] = "StringLiteral"; - TypeFlags[TypeFlags["NumberLiteral"] = 64] = "NumberLiteral"; - TypeFlags[TypeFlags["BooleanLiteral"] = 128] = "BooleanLiteral"; - TypeFlags[TypeFlags["EnumLiteral"] = 256] = "EnumLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 512] = "ESSymbol"; - TypeFlags[TypeFlags["UniqueESSymbol"] = 1024] = "UniqueESSymbol"; - TypeFlags[TypeFlags["Void"] = 2048] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 4096] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 8192] = "Null"; - TypeFlags[TypeFlags["Never"] = 16384] = "Never"; - TypeFlags[TypeFlags["TypeParameter"] = 32768] = "TypeParameter"; - TypeFlags[TypeFlags["Object"] = 65536] = "Object"; - TypeFlags[TypeFlags["Union"] = 131072] = "Union"; - TypeFlags[TypeFlags["Intersection"] = 262144] = "Intersection"; - TypeFlags[TypeFlags["Index"] = 524288] = "Index"; - TypeFlags[TypeFlags["IndexedAccess"] = 1048576] = "IndexedAccess"; - TypeFlags[TypeFlags["Conditional"] = 2097152] = "Conditional"; - TypeFlags[TypeFlags["Substitution"] = 4194304] = "Substitution"; + TypeFlags[TypeFlags["Unknown"] = 2] = "Unknown"; + TypeFlags[TypeFlags["String"] = 4] = "String"; + TypeFlags[TypeFlags["Number"] = 8] = "Number"; + TypeFlags[TypeFlags["Boolean"] = 16] = "Boolean"; + TypeFlags[TypeFlags["Enum"] = 32] = "Enum"; + TypeFlags[TypeFlags["StringLiteral"] = 64] = "StringLiteral"; + TypeFlags[TypeFlags["NumberLiteral"] = 128] = "NumberLiteral"; + TypeFlags[TypeFlags["BooleanLiteral"] = 256] = "BooleanLiteral"; + TypeFlags[TypeFlags["EnumLiteral"] = 512] = "EnumLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 1024] = "ESSymbol"; + TypeFlags[TypeFlags["UniqueESSymbol"] = 2048] = "UniqueESSymbol"; + TypeFlags[TypeFlags["Void"] = 4096] = "Void"; + TypeFlags[TypeFlags["Undefined"] = 8192] = "Undefined"; + TypeFlags[TypeFlags["Null"] = 16384] = "Null"; + TypeFlags[TypeFlags["Never"] = 32768] = "Never"; + TypeFlags[TypeFlags["TypeParameter"] = 65536] = "TypeParameter"; + TypeFlags[TypeFlags["Object"] = 131072] = "Object"; + TypeFlags[TypeFlags["Union"] = 262144] = "Union"; + TypeFlags[TypeFlags["Intersection"] = 524288] = "Intersection"; + TypeFlags[TypeFlags["Index"] = 1048576] = "Index"; + TypeFlags[TypeFlags["IndexedAccess"] = 2097152] = "IndexedAccess"; + TypeFlags[TypeFlags["Conditional"] = 4194304] = "Conditional"; + TypeFlags[TypeFlags["Substitution"] = 8388608] = "Substitution"; + TypeFlags[TypeFlags["NonPrimitive"] = 16777216] = "NonPrimitive"; /* @internal */ - TypeFlags[TypeFlags["FreshLiteral"] = 8388608] = "FreshLiteral"; + TypeFlags[TypeFlags["FreshLiteral"] = 33554432] = "FreshLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsWideningType"] = 16777216] = "ContainsWideningType"; + TypeFlags[TypeFlags["UnionOfUnitTypes"] = 67108864] = "UnionOfUnitTypes"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 33554432] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ContainsWideningType"] = 134217728] = "ContainsWideningType"; /* @internal */ - TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 67108864] = "ContainsAnyFunctionType"; - TypeFlags[TypeFlags["NonPrimitive"] = 134217728] = "NonPrimitive"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 268435456] = "ContainsObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["UnionOfUnitTypes"] = 268435456] = "UnionOfUnitTypes"; + TypeFlags[TypeFlags["ContainsAnyFunctionType"] = 536870912] = "ContainsAnyFunctionType"; /* @internal */ - TypeFlags[TypeFlags["GenericMappedType"] = 536870912] = "GenericMappedType"; + TypeFlags[TypeFlags["AnyOrUnknown"] = 3] = "AnyOrUnknown"; /* @internal */ - TypeFlags[TypeFlags["Nullable"] = 12288] = "Nullable"; - TypeFlags[TypeFlags["Literal"] = 224] = "Literal"; - TypeFlags[TypeFlags["Unit"] = 13536] = "Unit"; - TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; + TypeFlags[TypeFlags["Nullable"] = 24576] = "Nullable"; + TypeFlags[TypeFlags["Literal"] = 448] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 27072] = "Unit"; + TypeFlags[TypeFlags["StringOrNumberLiteral"] = 192] = "StringOrNumberLiteral"; /* @internal */ - TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 1120] = "StringOrNumberLiteralOrUnique"; + TypeFlags[TypeFlags["StringOrNumberLiteralOrUnique"] = 2240] = "StringOrNumberLiteralOrUnique"; /* @internal */ - TypeFlags[TypeFlags["DefinitelyFalsy"] = 14560] = "DefinitelyFalsy"; - TypeFlags[TypeFlags["PossiblyFalsy"] = 14574] = "PossiblyFalsy"; + TypeFlags[TypeFlags["DefinitelyFalsy"] = 29120] = "DefinitelyFalsy"; + TypeFlags[TypeFlags["PossiblyFalsy"] = 29148] = "PossiblyFalsy"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 134249103] = "Intrinsic"; + TypeFlags[TypeFlags["Intrinsic"] = 16839967] = "Intrinsic"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 16382] = "Primitive"; - TypeFlags[TypeFlags["StringLike"] = 34] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = 84] = "NumberLike"; - TypeFlags[TypeFlags["BooleanLike"] = 136] = "BooleanLike"; - TypeFlags[TypeFlags["EnumLike"] = 272] = "EnumLike"; - TypeFlags[TypeFlags["ESSymbolLike"] = 1536] = "ESSymbolLike"; - TypeFlags[TypeFlags["VoidLike"] = 6144] = "VoidLike"; + TypeFlags[TypeFlags["Primitive"] = 32764] = "Primitive"; + TypeFlags[TypeFlags["StringLike"] = 68] = "StringLike"; + TypeFlags[TypeFlags["NumberLike"] = 168] = "NumberLike"; + TypeFlags[TypeFlags["BooleanLike"] = 272] = "BooleanLike"; + TypeFlags[TypeFlags["EnumLike"] = 544] = "EnumLike"; + TypeFlags[TypeFlags["ESSymbolLike"] = 3072] = "ESSymbolLike"; + TypeFlags[TypeFlags["VoidLike"] = 12288] = "VoidLike"; /* @internal */ - TypeFlags[TypeFlags["DisjointDomains"] = 134233854] = "DisjointDomains"; - TypeFlags[TypeFlags["UnionOrIntersection"] = 393216] = "UnionOrIntersection"; - TypeFlags[TypeFlags["StructuredType"] = 458752] = "StructuredType"; - TypeFlags[TypeFlags["TypeVariable"] = 1081344] = "TypeVariable"; - TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 7372800] = "InstantiableNonPrimitive"; - TypeFlags[TypeFlags["InstantiablePrimitive"] = 524288] = "InstantiablePrimitive"; - TypeFlags[TypeFlags["Instantiable"] = 7897088] = "Instantiable"; - TypeFlags[TypeFlags["StructuredOrInstantiable"] = 8355840] = "StructuredOrInstantiable"; + TypeFlags[TypeFlags["DisjointDomains"] = 16809468] = "DisjointDomains"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 786432] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 917504] = "StructuredType"; + TypeFlags[TypeFlags["TypeVariable"] = 2162688] = "TypeVariable"; + TypeFlags[TypeFlags["InstantiableNonPrimitive"] = 14745600] = "InstantiableNonPrimitive"; + TypeFlags[TypeFlags["InstantiablePrimitive"] = 1048576] = "InstantiablePrimitive"; + TypeFlags[TypeFlags["Instantiable"] = 15794176] = "Instantiable"; + TypeFlags[TypeFlags["StructuredOrInstantiable"] = 16711680] = "StructuredOrInstantiable"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never - TypeFlags[TypeFlags["Narrowable"] = 142575359] = "Narrowable"; - TypeFlags[TypeFlags["NotUnionOrUnit"] = 134283777] = "NotUnionOrUnit"; + TypeFlags[TypeFlags["Narrowable"] = 33492479] = "Narrowable"; + TypeFlags[TypeFlags["NotUnionOrUnit"] = 16909315] = "NotUnionOrUnit"; /* @internal */ - TypeFlags[TypeFlags["NotUnit"] = 8374815] = "NotUnit"; + TypeFlags[TypeFlags["NotUnit"] = 16749629] = "NotUnit"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 50331648] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 402653184] = "RequiresWidening"; /* @internal */ - TypeFlags[TypeFlags["PropagatingFlags"] = 117440512] = "PropagatingFlags"; + TypeFlags[TypeFlags["PropagatingFlags"] = 939524096] = "PropagatingFlags"; // The following flags are used for different purposes during union and intersection type construction /* @internal */ - TypeFlags[TypeFlags["NonWideningType"] = 16777216] = "NonWideningType"; + TypeFlags[TypeFlags["NonWideningType"] = 134217728] = "NonWideningType"; /* @internal */ - TypeFlags[TypeFlags["Wildcard"] = 33554432] = "Wildcard"; + TypeFlags[TypeFlags["Wildcard"] = 268435456] = "Wildcard"; /* @internal */ - TypeFlags[TypeFlags["EmptyObject"] = 67108864] = "EmptyObject"; + TypeFlags[TypeFlags["EmptyObject"] = 536870912] = "EmptyObject"; /* @internal */ - TypeFlags[TypeFlags["ConstructionFlags"] = 117440512] = "ConstructionFlags"; + TypeFlags[TypeFlags["ConstructionFlags"] = 939524096] = "ConstructionFlags"; + // The following flag is used for different purposes by maybeTypeOfKind + /* @internal */ + TypeFlags[TypeFlags["GenericMappedType"] = 134217728] = "GenericMappedType"; })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); var ObjectFlags; (function (ObjectFlags) { @@ -1325,6 +1330,7 @@ var ts; })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {})); var EmitFlags; (function (EmitFlags) { + EmitFlags[EmitFlags["None"] = 0] = "None"; EmitFlags[EmitFlags["SingleLine"] = 1] = "SingleLine"; EmitFlags[EmitFlags["AdviseOnEmitNode"] = 2] = "AdviseOnEmitNode"; EmitFlags[EmitFlags["NoSubstitution"] = 4] = "NoSubstitution"; @@ -1633,7 +1639,7 @@ var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "2.9"; + ts.versionMajorMinor = "3.0"; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); @@ -1781,6 +1787,10 @@ var ts; return array ? array.length : 0; } ts.length = length; + function hasEntries(map) { + return !!map && !!map.size; + } + ts.hasEntries = hasEntries; /** * Iterates through 'array' by index and performs the callback on each element of array until the callback * returns a truthy value, then returns that value. @@ -1937,7 +1947,7 @@ var ts; return result; } } - Debug.fail(); + return Debug.fail(); } ts.findMap = findMap; function contains(array, value, equalityComparer) { @@ -2055,11 +2065,6 @@ var ts; return array; } ts.sameMap = sameMap; - /** - * Flattens an array containing a mix of array or non-array elements. - * - * @param array The array to flatten. - */ function flatten(array) { var result; if (array) { @@ -2079,12 +2084,6 @@ var ts; return result; } ts.flatten = flatten; - /** - * Maps an array. If the mapped value is an array, it is spread into the result. - * - * @param array The array to map. - * @param mapfn The callback used to map the result into one or more values. - */ function flatMap(array, mapfn) { var result; if (array) { @@ -2207,13 +2206,6 @@ var ts; }; } ts.singleIterator = singleIterator; - /** - * Maps contiguous spans of values with the same key. - * - * @param array The array to map. - * @param keyfn A callback used to select the key for an element. - * @param mapfn A callback used to map a contiguous chunk of values to a single value. - */ function spanMap(array, keyfn, mapfn) { var result; if (array) { @@ -2331,12 +2323,6 @@ var ts; } return result; } - /** - * Deduplicates an unsorted array. - * @param equalityComparer An optional `EqualityComparer` used to determine if two values are duplicates. - * @param comparer An optional `Comparer` used to sort entries before comparison, though the - * result will remain in the original order in `array`. - */ function deduplicate(array, equalityComparer, comparer) { return !array ? undefined : array.length === 0 ? [] : @@ -2345,9 +2331,6 @@ var ts; deduplicateEquality(array, equalityComparer); } ts.deduplicate = deduplicate; - /** - * Deduplicates an array that has already been sorted. - */ function deduplicateSorted(array, comparer) { if (!array) return undefined; @@ -2490,14 +2473,6 @@ var ts; return result; } ts.sum = sum; - /** - * Appends a value to an array, returning the array. - * - * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array - * is created if `value` was appended. - * @param value The value to append to the array. If `value` is `undefined`, nothing is - * appended. - */ function append(to, value) { if (value === undefined) return to; @@ -2514,16 +2489,6 @@ var ts; function toOffset(array, offset) { return offset < 0 ? array.length + offset : offset; } - /** - * Appends a range of value to an array, returning the array. - * - * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array - * is created if `value` was appended. - * @param from The values to append to the array. If `from` is `undefined`, nothing is - * appended. If an element of `from` is `undefined`, that element is not appended. - * @param start The offset in `from` at which to start copying values. - * @param end The offset in `from` at which to stop copying values (non-inclusive). - */ function addRange(to, from, start, end) { if (from === undefined || from.length === 0) return to; @@ -2539,23 +2504,6 @@ var ts; return to; } ts.addRange = addRange; - /** - * Appends a range of value to begin of an array, returning the array. - * - * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array - * is created if `value` was appended. - * @param from The values to append to the array. If `from` is `undefined`, nothing is - * appended. If an element of `from` is `undefined`, that element is not appended. - */ - function prependRange(to, from) { - if (from === undefined || from.length === 0) - return to; - if (to === undefined) - return from.slice(); - to.unshift.apply(to, from); - return to; - } - ts.prependRange = prependRange; /** * @return Whether the value was added. */ @@ -2853,7 +2801,7 @@ var ts; var arg = args_1[_a]; for (var p in arg) { if (hasProperty(arg, p)) { - t[p] = arg[p]; + t[p] = arg[p]; // TODO: GH#23368 } } } @@ -3012,10 +2960,10 @@ var ts; if (value !== undefined && test(value)) return value; if (value && typeof value.kind === "number") { - Debug.fail("Invalid cast. The supplied " + Debug.showSyntaxKind(value) + " did not pass the test '" + Debug.getFunctionName(test) + "'."); + return Debug.fail("Invalid cast. The supplied " + Debug.showSyntaxKind(value) + " did not pass the test '" + Debug.getFunctionName(test) + "'."); } else { - Debug.fail("Invalid cast. The supplied value did not pass the test '" + Debug.getFunctionName(test) + "'."); + return Debug.fail("Invalid cast. The supplied value did not pass the test '" + Debug.getFunctionName(test) + "'."); } } ts.cast = cast; @@ -3101,7 +3049,7 @@ var ts; } ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { - baseIndex = baseIndex || 0; + if (baseIndex === void 0) { baseIndex = 0; } return text.replace(/{(\d+)}/g, function (_match, index) { return Debug.assertDefined(args[+index + baseIndex]); }); } ts.formatStringFromArgs = formatStringFromArgs; @@ -3409,7 +3357,9 @@ var ts; return compareValues(a ? 1 : 0, b ? 1 : 0); } ts.compareBooleans = compareBooleans; - function compareMessageText(text1, text2) { + function compareMessageText(t1, t2) { + var text1 = t1; + var text2 = t2; while (text1 && text2) { // We still have both chains. var string1 = isString(text1) ? text1 : text1.messageText; @@ -3446,6 +3396,14 @@ var ts; return moduleResolution; } ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; + function unreachableCodeIsError(options) { + return options.allowUnreachableCode === false; + } + ts.unreachableCodeIsError = unreachableCodeIsError; + function unusedLabelIsError(options) { + return options.allowUnusedLabels === false; + } + ts.unusedLabelIsError = unusedLabelIsError; function getAreDeclarationMapsEnabled(options) { return !!(options.declaration && options.declarationMap); } @@ -3464,7 +3422,7 @@ var ts; } ts.getEmitDeclarations = getEmitDeclarations; function getStrictOptionValue(compilerOptions, flag) { - return compilerOptions[flag] === undefined ? compilerOptions.strict : compilerOptions[flag]; + return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; } ts.getStrictOptionValue = getStrictOptionValue; function hasZeroOrOneAsteriskCharacter(str) { @@ -3947,6 +3905,23 @@ var ts; return startsWith(str, prefix) ? str.substr(prefix.length) : str; } ts.removePrefix = removePrefix; + function tryRemovePrefix(str, prefix) { + return startsWith(str, prefix) ? str.substring(prefix.length) : undefined; + } + ts.tryRemovePrefix = tryRemovePrefix; + function tryRemoveDirectoryPrefix(path, dirPath) { + var a = tryRemovePrefix(path, dirPath); + if (a === undefined) + return undefined; + switch (a.charCodeAt(0)) { + case 47 /* slash */: + case 92 /* backslash */: + return a.slice(1); + default: + return undefined; + } + } + ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; function endsWith(str, suffix) { var expectedPos = str.length - suffix.length; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; @@ -3956,6 +3931,10 @@ var ts; return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str; } ts.removeSuffix = removeSuffix; + function tryRemoveSuffix(str, suffix) { + return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : undefined; + } + ts.tryRemoveSuffix = tryRemoveSuffix; function stringContains(str, substring) { return str.indexOf(substring) !== -1; } @@ -3989,7 +3968,7 @@ var ts; /** * Matches any single directory segment unless it is the last segment and a .min.js file * Breakdown: - * [^./] # matches everything up to the first . character (excluding directory seperators) + * [^./] # matches everything up to the first . character (excluding directory separators) * (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension */ singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*", @@ -4051,7 +4030,7 @@ var ts; var subpattern = ""; var hasWrittenComponent = false; var components = getNormalizedPathComponents(spec, basePath); - var lastComponent = lastOrUndefined(components); + var lastComponent = last(components); if (usage !== "exclude" && lastComponent === "**") { return undefined; } @@ -4115,6 +4094,7 @@ var ts; function replaceWildcardCharacter(match, singleAsteriskRegexFragment) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match; } + /** @param path directory of the tsconfig.json */ function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); @@ -4128,14 +4108,18 @@ var ts; }; } ts.getFileMatcherPatterns = getFileMatcherPatterns; + function getRegexFromPattern(pattern, useCaseSensitiveFileNames) { + return new RegExp(pattern, useCaseSensitiveFileNames ? "" : "i"); + } + ts.getRegexFromPattern = getRegexFromPattern; + /** @param path directory of the tsconfig.json */ function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); - var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); - var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); - var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return getRegexFromPattern(pattern, useCaseSensitiveFileNames); }); + var includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames); + var excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames); // Associate an array of results with each include regex. This keeps results in order of the "include" order. // If there are no "includes", then just put everything in results[0]. var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; @@ -4277,11 +4261,11 @@ var ts; return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */; } function hasJavaScriptFileExtension(fileName) { - return forEach(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + return some(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); } ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; function hasTypeScriptFileExtension(fileName) { - return forEach(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + return some(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); } ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) { @@ -4487,7 +4471,8 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { - assert(value !== undefined && value !== null, message); + if (value === undefined || value === null) + return fail(message); return value; } Debug.assertDefined = assertDefined; @@ -4671,10 +4656,7 @@ var ts; */ function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - if (ext !== undefined) { - return ext; - } - Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : Debug.fail("File " + path + " has unknown extension."); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -5118,6 +5100,7 @@ var ts; return parseInt(version.substring(1, dot)); } ts.getNodeMajorVersion = getNodeMajorVersion; + // TODO: this is used as if it's certainly defined in many places. ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does @@ -5299,6 +5282,7 @@ var ts; return watchDirectoryRecursively(directoryName, callback); } watchDirectory(directoryName, callback); + return undefined; // TODO: GH#18217 }; } function createNonPollingWatchFile() { @@ -5330,7 +5314,7 @@ var ts; var watcher = fsWatchDirectory(dirName, function (_eventName, relativeFileName) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" var fileName = !ts.isString(relativeFileName) - ? undefined + ? undefined // TODO: GH#18217 : ts.getNormalizedAbsolutePath(relativeFileName, dirName); // Some applications save a working file via rename operations var callbacks = fileWatcherCallbacks.get(toCanonicalName(fileName)); @@ -5579,6 +5563,7 @@ var ts; switch (entryKind) { case 0 /* File */: return stat.isFile(); case 1 /* Directory */: return stat.isDirectory(); + default: return false; } } catch (e) { @@ -5770,6 +5755,7 @@ var ts; The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), + Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), @@ -6221,6 +6207,7 @@ var ts; Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2568, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators_2568", "Type '{0}' is not an array type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: diag(2570, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await_2570", "Property '{0}' does not exist on type '{1}'. Did you forget to use 'await'?"), + Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."), JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -6274,7 +6261,7 @@ var ts; _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: diag(2692, ts.DiagnosticCategory.Error, "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible."), _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: diag(2693, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", "'{0}' only refers to a type, but is being used as a value here."), 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."), + 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."), 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."), @@ -6304,6 +6291,7 @@ var ts; Cannot_invoke_an_object_which_is_possibly_undefined: diag(2722, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_undefined_2722", "Cannot invoke an object which is possibly 'undefined'."), Cannot_invoke_an_object_which_is_possibly_null_or_undefined: diag(2723, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_null_or_undefined_2723", "Cannot invoke an object which is possibly 'null' or 'undefined'."), Module_0_has_no_exported_member_1_Did_you_mean_2: diag(2724, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_2_2724", "Module '{0}' has no exported member '{1}'. Did you mean '{2}'?"), + Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."), 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}'."), @@ -6602,6 +6590,7 @@ var ts; _0_is_declared_but_never_used: diag(6196, ts.DiagnosticCategory.Error, "_0_is_declared_but_never_used_6196", "'{0}' is declared but never used.", /*reportsUnnecessary*/ true), Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"), All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", /*reportsUnnecessary*/ true), + All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), 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"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -6629,7 +6618,7 @@ var ts; Function_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: diag(7024, ts.DiagnosticCategory.Error, "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", "Function 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."), Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: diag(7025, ts.DiagnosticCategory.Error, "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type."), JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: diag(7026, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists."), - Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected."), + Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected.", /*reportsUnnecessary*/ true), Unused_label: diag(7028, ts.DiagnosticCategory.Error, "Unused_label_7028", "Unused label.", /*reportsUnnecessary*/ true), Fallthrough_case_in_switch: diag(7029, ts.DiagnosticCategory.Error, "Fallthrough_case_in_switch_7029", "Fallthrough case in switch."), Not_all_code_paths_return_a_value: diag(7030, ts.DiagnosticCategory.Error, "Not_all_code_paths_return_a_value_7030", "Not all code paths return a value."), @@ -6710,6 +6699,7 @@ var ts; Implement_inherited_abstract_class: diag(90007, ts.DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"), Add_0_to_unresolved_variable: diag(90008, ts.DiagnosticCategory.Message, "Add_0_to_unresolved_variable_90008", "Add '{0}.' to unresolved variable"), Remove_destructuring: diag(90009, ts.DiagnosticCategory.Message, "Remove_destructuring_90009", "Remove destructuring"), + Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"), Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""), Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"), Add_0_to_existing_import_declaration_from_1: diag(90015, ts.DiagnosticCategory.Message, "Add_0_to_existing_import_declaration_from_1_90015", "Add '{0}' to existing import declaration from \"{1}\""), @@ -6779,6 +6769,9 @@ var ts; Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing 'typeof'"), Remove_unused_label: diag(95053, ts.DiagnosticCategory.Message, "Remove_unused_label_95053", "Remove unused label"), Remove_all_unused_labels: diag(95054, ts.DiagnosticCategory.Message, "Remove_all_unused_labels_95054", "Remove all unused labels"), + Convert_0_to_mapped_object_type: diag(95055, ts.DiagnosticCategory.Message, "Convert_0_to_mapped_object_type_95055", "Convert '{0}' to mapped object type"), + Convert_namespace_import_to_named_imports: diag(95056, ts.DiagnosticCategory.Message, "Convert_namespace_import_to_named_imports_95056", "Convert namespace import to named imports"), + Convert_named_imports_to_namespace_import: diag(95057, ts.DiagnosticCategory.Message, "Convert_named_imports_to_namespace_import_95057", "Convert named imports to namespace import"), }; })(ts || (ts = {})); var ts; @@ -6817,7 +6810,7 @@ var ts; "false": 86 /* FalseKeyword */, "finally": 87 /* FinallyKeyword */, "for": 88 /* ForKeyword */, - "from": 142 /* FromKeyword */, + "from": 143 /* FromKeyword */, "function": 89 /* FunctionKeyword */, "get": 125 /* GetKeyword */, "if": 90 /* IfKeyword */, @@ -6843,7 +6836,7 @@ var ts; "public": 114 /* PublicKeyword */, "readonly": 132 /* ReadonlyKeyword */, "require": 133 /* RequireKeyword */, - "global": 143 /* GlobalKeyword */, + "global": 144 /* GlobalKeyword */, "return": 96 /* ReturnKeyword */, "set": 136 /* SetKeyword */, "static": 115 /* StaticKeyword */, @@ -6859,6 +6852,7 @@ var ts; "typeof": 103 /* TypeOfKeyword */, "undefined": 140 /* UndefinedKeyword */, "unique": 141 /* UniqueKeyword */, + "unknown": 142 /* UnknownKeyword */, "var": 104 /* VarKeyword */, "void": 105 /* VoidKeyword */, "while": 106 /* WhileKeyword */, @@ -6866,7 +6860,7 @@ var ts; "yield": 116 /* YieldKeyword */, "async": 120 /* AsyncKeyword */, "await": 121 /* AwaitKeyword */, - "of": 144 /* OfKeyword */, + "of": 145 /* OfKeyword */, "{": 17 /* OpenBraceToken */, "}": 18 /* CloseBraceToken */, "(": 19 /* OpenParenToken */, @@ -7485,8 +7479,9 @@ var ts; } ts.isIdentifierText = isIdentifierText; // Creates a scanner over a (possibly unspecified) range of a piece of text. - function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + var text = textInitial; // Current position (end position of text of current token) var pos; // end of text @@ -7942,7 +7937,7 @@ var ts; var isPreviousTokenSeparator = false; while (true) { var ch = text.charCodeAt(pos); - // Numeric seperators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator + // Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator if (ch === 95 /* _ */) { tokenFlags |= 512 /* ContainsSeparator */; if (separatorAllowed) { @@ -8758,7 +8753,7 @@ var ts; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function packageIdIsEqual(a, b) { - return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; + return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; } function packageIdToString(_a) { var name = _a.name, subModuleName = _a.subModuleName, version = _a.version; @@ -8809,7 +8804,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 273 /* SourceFile */) { + while (node && node.kind !== 274 /* SourceFile */) { node = node.parent; } return node; @@ -8817,11 +8812,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 212 /* Block */: - case 240 /* CaseBlock */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 213 /* Block */: + case 241 /* CaseBlock */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: return true; } return false; @@ -8866,11 +8861,11 @@ var ts; } ts.getEndLinePosition = getEndLinePosition; /** - * Returns a value indicating whether a name is unique globally or within the current file + * Returns a value indicating whether a name is unique globally or within the current file. + * Note: This does not consider whether a name appears as a free identifier or not, so at the expression `x.y` this includes both `x` and `y`. */ - function isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) { - return !(hasGlobalName && hasGlobalName(name)) - && !currentSourceFile.identifiers.has(name); + function isFileLevelUniqueName(sourceFile, name, hasGlobalName) { + return !(hasGlobalName && hasGlobalName(name)) && !sourceFile.identifiers.has(name); } ts.isFileLevelUniqueName = isFileLevelUniqueName; // Returns true if this node is missing from the actual source code. A 'missing' node is different @@ -8896,6 +8891,27 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + /** + * Appends a range of value to begin of an array, returning the array. + * + * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array + * is created if `value` was appended. + * @param from The values to append to the array. If `from` is `undefined`, nothing is + * appended. If an element of `from` is `undefined`, that element is not appended. + */ + function prependStatements(to, from) { + if (from === undefined || from.length === 0) + return to; + if (to === undefined) + return from.slice(); + var prologue = to.length && isPrologueDirective(to[0]) && to.shift(); + to.unshift.apply(to, from); + if (prologue) { + to.unshift(prologue); + } + return to; + } + ts.prependStatements = prependStatements; /** * Determine if the given comment is a triple-slash * @@ -8938,7 +8954,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 298 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 299 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -8985,7 +9001,7 @@ var ts; */ function getEmitFlags(node) { var emitNode = node.emitNode; - return emitNode && emitNode.flags; + return emitNode && emitNode.flags || 0; } ts.getEmitFlags = getEmitFlags; function getLiteralText(node, sourceFile) { @@ -9019,7 +9035,7 @@ var ts; case 12 /* RegularExpressionLiteral */: return node.text; } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); } ts.getLiteralText = getLiteralText; function getTextOfConstantValue(value) { @@ -9052,7 +9068,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 231 /* VariableDeclaration */ && node.parent.kind === 268 /* CatchClause */; + return node.kind === 232 /* VariableDeclaration */ && node.parent.kind === 269 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9074,11 +9090,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 === 238 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 239 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 273 /* SourceFile */ || - node.kind === 238 /* ModuleDeclaration */ || + return node.kind === 274 /* SourceFile */ || + node.kind === 239 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -9095,9 +9111,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: return ts.isExternalModule(node.parent); - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9109,53 +9125,53 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 273 /* SourceFile */: - case 240 /* CaseBlock */: - case 268 /* CatchClause */: - case 238 /* ModuleDeclaration */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 274 /* SourceFile */: + case 241 /* CaseBlock */: + case 269 /* CatchClause */: + case 239 /* ModuleDeclaration */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return true; - case 212 /* Block */: + case 213 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block - return parentNode && !ts.isFunctionLike(parentNode); + return !ts.isFunctionLike(parentNode); } return false; } ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 152 /* MethodSignature */: - case 159 /* IndexSignature */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 283 /* JSDocFunctionType */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 295 /* JSDocTemplateTag */: - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 291 /* JSDocCallbackTag */: - case 296 /* JSDocTypedefTag */: - case 287 /* JSDocSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 153 /* MethodSignature */: + case 160 /* IndexSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 284 /* JSDocFunctionType */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 296 /* JSDocTemplateTag */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 292 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 288 /* JSDocSignature */: return true; default: ts.assertTypeIsNever(node); @@ -9165,8 +9181,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9175,15 +9191,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 213 /* VariableStatement */: - case 234 /* ClassDeclaration */: - case 233 /* FunctionDeclaration */: - case 238 /* ModuleDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 214 /* VariableStatement */: + case 235 /* ClassDeclaration */: + case 234 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: return true; default: return false; @@ -9218,8 +9234,8 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return escapeLeadingUnderscores(name.text); - case 146 /* ComputedPropertyName */: - return isStringOrNumericLiteral(name.expression) ? escapeLeadingUnderscores(name.expression.text) : undefined; + case 147 /* ComputedPropertyName */: + return isStringOrNumericLiteral(name.expression) ? escapeLeadingUnderscores(name.expression.text) : undefined; // TODO: GH#18217 Almost all uses of this assume the result to be defined! default: ts.Debug.assertNever(name); } @@ -9229,10 +9245,12 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); + default: + throw ts.Debug.assertNever(name); } } ts.entityNameToString = entityNameToString; @@ -9251,11 +9269,6 @@ var ts; return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3); } ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; - function createDiagnosticForNodeSpan(sourceFile, startNode, endNode, message, arg0, arg1, arg2, arg3) { - var start = ts.skipTrivia(sourceFile.text, startNode.pos); - return ts.createFileDiagnostic(sourceFile, start, endNode.end - start, message, arg0, arg1, arg2, arg3); - } - ts.createDiagnosticForNodeSpan = createDiagnosticForNodeSpan; function createDiagnosticForNodeFromMessageChain(node, messageChain) { var sourceFile = getSourceFileOfNode(node); var span = getErrorSpanForNode(sourceFile, node); @@ -9278,7 +9291,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 212 /* Block */) { + if (node.body && node.body.kind === 213 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9292,7 +9305,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 273 /* SourceFile */: + case 274 /* 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 @@ -9301,25 +9314,25 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 231 /* VariableDeclaration */: - case 181 /* BindingElement */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 272 /* EnumMember */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 236 /* TypeAliasDeclaration */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 232 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 273 /* EnumMember */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 237 /* TypeAliasDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: errorNode = node.name; break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -9352,7 +9365,7 @@ var ts; } ts.isJsonSourceFile = isJsonSourceFile; function isConstEnumDeclaration(node) { - return node.kind === 237 /* EnumDeclaration */ && isConst(node); + return node.kind === 238 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -9365,21 +9378,21 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 186 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; + return n.kind === 187 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 186 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; + return n.kind === 187 /* CallExpression */ && n.expression.kind === 91 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 178 /* ImportType */ && - n.argument.kind === 177 /* LiteralType */ && + return n.kind === 179 /* ImportType */ && + n.argument.kind === 178 /* LiteralType */ && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 215 /* ExpressionStatement */ + return node.kind === 216 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9388,11 +9401,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 148 /* Parameter */ || - node.kind === 147 /* TypeParameter */ || - node.kind === 191 /* FunctionExpression */ || - node.kind === 192 /* ArrowFunction */ || - node.kind === 190 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 149 /* Parameter */ || + node.kind === 148 /* TypeParameter */ || + node.kind === 192 /* FunctionExpression */ || + node.kind === 193 /* ArrowFunction */ || + node.kind === 191 /* ParenthesizedExpression */) ? 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 '/**/' @@ -9408,11 +9421,12 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (160 /* FirstTypeNode */ <= node.kind && node.kind <= 178 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= node.kind && node.kind <= 179 /* LastTypeNode */) { return true; } switch (node.kind) { case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 134 /* NumberKeyword */: case 137 /* StringKeyword */: case 122 /* BooleanKeyword */: @@ -9421,32 +9435,32 @@ var ts; case 131 /* NeverKeyword */: return true; case 105 /* VoidKeyword */: - return node.parent.kind !== 195 /* VoidExpression */; - case 206 /* ExpressionWithTypeArguments */: + return node.parent.kind !== 196 /* VoidExpression */; + case 207 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 147 /* TypeParameter */: - return node.parent.kind === 176 /* MappedType */ || node.parent.kind === 171 /* InferType */; + case 148 /* TypeParameter */: + return node.parent.kind === 177 /* MappedType */ || node.parent.kind === 172 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container case 71 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 145 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 185 /* 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 === 71 /* Identifier */ || node.kind === 145 /* QualifiedName */ || node.kind === 184 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */ || node.kind === 185 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 145 /* QualifiedName */: - case 184 /* PropertyAccessExpression */: - case 99 /* ThisKeyword */: + case 146 /* QualifiedName */: + case 185 /* PropertyAccessExpression */: + case 99 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 164 /* TypeQuery */) { + if (parent.kind === 165 /* TypeQuery */) { return false; } - if (parent.kind === 178 /* ImportType */) { + if (parent.kind === 179 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9455,41 +9469,42 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (160 /* FirstTypeNode */ <= parent.kind && parent.kind <= 178 /* LastTypeNode */) { + if (161 /* FirstTypeNode */ <= parent.kind && parent.kind <= 179 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return node === parent.constraint; - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 148 /* Parameter */: - case 231 /* VariableDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 149 /* Parameter */: + case 232 /* VariableDeclaration */: return node === parent.type; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return node === parent.type; - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: return node === parent.type; - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: return node === parent.type; - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } + } } return false; } @@ -9510,23 +9525,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return visitor(node); - case 240 /* CaseBlock */: - case 212 /* Block */: - case 216 /* IfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 225 /* WithStatement */: - case 226 /* SwitchStatement */: - case 265 /* CaseClause */: - case 266 /* DefaultClause */: - case 227 /* LabeledStatement */: - case 229 /* TryStatement */: - case 268 /* CatchClause */: + case 241 /* CaseBlock */: + case 213 /* Block */: + case 217 /* IfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 226 /* WithStatement */: + case 227 /* SwitchStatement */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: + case 228 /* LabeledStatement */: + case 230 /* TryStatement */: + case 269 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9536,26 +9551,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 237 /* EnumDeclaration */: - case 235 /* InterfaceDeclaration */: - case 238 /* ModuleDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 238 /* EnumDeclaration */: + case 236 /* InterfaceDeclaration */: + case 239 /* ModuleDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 146 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 147 /* 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); @@ -9578,10 +9593,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 166 /* ArrayType */) { + if (node && node.kind === 167 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 161 /* TypeReference */) { + else if (node && node.kind === 162 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9591,12 +9606,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 235 /* InterfaceDeclaration */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 165 /* TypeLiteral */: + case 236 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 166 /* TypeLiteral */: return node.members; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return node.properties; } } @@ -9604,14 +9619,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 181 /* BindingElement */: - case 272 /* EnumMember */: - case 148 /* Parameter */: - case 269 /* PropertyAssignment */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 270 /* ShorthandPropertyAssignment */: - case 231 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 273 /* EnumMember */: + case 149 /* Parameter */: + case 270 /* PropertyAssignment */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 271 /* ShorthandPropertyAssignment */: + case 232 /* VariableDeclaration */: return true; } } @@ -9623,8 +9638,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 232 /* VariableDeclarationList */ - && node.parent.parent.kind === 213 /* VariableStatement */; + return node.parent.kind === 233 /* VariableDeclarationList */ + && node.parent.parent.kind === 214 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9635,13 +9650,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: return true; } return false; @@ -9652,7 +9667,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 227 /* LabeledStatement */) { + if (node.statement.kind !== 228 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -9660,17 +9675,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 212 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 213 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 153 /* MethodDeclaration */ && node.parent.kind === 183 /* ObjectLiteralExpression */; + return node && node.kind === 154 /* MethodDeclaration */ && node.parent.kind === 184 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 153 /* MethodDeclaration */ && - (node.parent.kind === 183 /* ObjectLiteralExpression */ || - node.parent.kind === 204 /* ClassExpression */); + return node.kind === 154 /* MethodDeclaration */ && + (node.parent.kind === 184 /* ObjectLiteralExpression */ || + node.parent.kind === 205 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -9682,31 +9697,35 @@ var ts; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { - return ts.filter(objectLiteral.properties, function (property) { - if (property.kind === 269 /* PropertyAssignment */) { + return objectLiteral.properties.filter(function (property) { + if (property.kind === 270 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); - return key === propName || (key2 && key2 === propName); + return key === propName || (!!key2 && key2 === propName); } + return false; }); } ts.getPropertyAssignment = getPropertyAssignment; function getTsConfigObjectLiteralExpression(tsConfigSourceFile) { if (tsConfigSourceFile && tsConfigSourceFile.statements.length) { var expression = tsConfigSourceFile.statements[0].expression; - return ts.isObjectLiteralExpression(expression) && expression; + return ts.tryCast(expression, ts.isObjectLiteralExpression); } } ts.getTsConfigObjectLiteralExpression = getTsConfigObjectLiteralExpression; function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) { - var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile); - return jsonObjectLiteral && - ts.firstDefined(getPropertyAssignment(jsonObjectLiteral, propKey), function (property) { - return ts.isArrayLiteralExpression(property.initializer) ? - ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) : - undefined; - }); + return ts.firstDefined(getTsConfigPropArray(tsConfigSourceFile, propKey), function (property) { + return ts.isArrayLiteralExpression(property.initializer) ? + ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) : + undefined; + }); } ts.getTsConfigPropArrayElementValue = getTsConfigPropArrayElementValue; + function getTsConfigPropArray(tsConfigSourceFile, propKey) { + var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile); + return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : ts.emptyArray; + } + ts.getTsConfigPropArray = getTsConfigPropArray; function getContainingFunction(node) { return ts.findAncestor(node.parent, ts.isFunctionLike); } @@ -9716,13 +9735,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { + ts.Debug.assert(node.kind !== 274 /* SourceFile */); while (true) { node = node.parent; if (!node) { - return undefined; + 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 146 /* ComputedPropertyName */: + case 147 /* 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 @@ -9737,9 +9757,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 149 /* Decorator */: + case 150 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 148 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 149 /* 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; @@ -9750,26 +9770,26 @@ var ts; node = node.parent; } break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 238 /* ModuleDeclaration */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 237 /* EnumDeclaration */: - case 273 /* SourceFile */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 239 /* ModuleDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 238 /* EnumDeclaration */: + case 274 /* SourceFile */: return node; } } @@ -9779,9 +9799,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 154 /* Constructor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 155 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: return container; } } @@ -9803,27 +9823,27 @@ var ts; return node; } switch (node.kind) { - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: node = node.parent; break; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return node; - case 149 /* Decorator */: + case 150 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 148 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 149 /* 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; @@ -9839,14 +9859,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 191 /* FunctionExpression */ || func.kind === 192 /* ArrowFunction */) { + if (func.kind === 192 /* FunctionExpression */ || func.kind === 193 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 190 /* ParenthesizedExpression */) { + while (parent.kind === 191 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 186 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 187 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -9857,7 +9877,7 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 184 /* PropertyAccessExpression */ || kind === 185 /* ElementAccessExpression */) + return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) && node.expression.kind === 97 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; @@ -9866,20 +9886,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 184 /* PropertyAccessExpression */ || kind === 185 /* ElementAccessExpression */) + return (kind === 185 /* PropertyAccessExpression */ || kind === 186 /* ElementAccessExpression */) && node.expression.kind === 99 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return node.typeName; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 71 /* Identifier */: - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return node; } return undefined; @@ -9887,10 +9907,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return node.tag; - case 256 /* JsxOpeningElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -9899,53 +9919,55 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: // classes are valid targets return true; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 234 /* ClassDeclaration */; - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 153 /* MethodDeclaration */: + return parent.kind === 235 /* ClassDeclaration */; + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 154 /* 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 === 234 /* ClassDeclaration */; - case 148 /* Parameter */: + && parent.kind === 235 /* ClassDeclaration */; + case 149 /* 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 === 154 /* Constructor */ - || parent.kind === 153 /* MethodDeclaration */ - || parent.kind === 156 /* SetAccessor */) - && grandparent.kind === 234 /* ClassDeclaration */; + && (parent.kind === 155 /* Constructor */ + || parent.kind === 154 /* MethodDeclaration */ + || parent.kind === 157 /* SetAccessor */) + && grandparent.kind === 235 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node, parent, grandparent) { return node.decorators !== undefined - && nodeCanBeDecorated(node, parent, grandparent); + && nodeCanBeDecorated(node, parent, grandparent); // TODO: GH#18217 } ts.nodeIsDecorated = nodeIsDecorated; function nodeOrChildIsDecorated(node, parent, grandparent) { - return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent); + return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent); // TODO: GH#18217 } ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 234 /* ClassDeclaration */: - return ts.forEach(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); - case 153 /* MethodDeclaration */: - case 156 /* SetAccessor */: - return ts.forEach(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); + case 235 /* ClassDeclaration */: + return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 + case 154 /* MethodDeclaration */: + case 157 /* SetAccessor */: + return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 + default: + return false; } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 256 /* JsxOpeningElement */ || - parent.kind === 255 /* JsxSelfClosingElement */ || - parent.kind === 257 /* JsxClosingElement */) { + if (parent.kind === 257 /* JsxOpeningElement */ || + parent.kind === 256 /* JsxSelfClosingElement */ || + parent.kind === 258 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -9958,45 +9980,45 @@ var ts; case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 12 /* RegularExpressionLiteral */: - case 182 /* ArrayLiteralExpression */: - case 183 /* ObjectLiteralExpression */: - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 188 /* TaggedTemplateExpression */: - case 207 /* AsExpression */: - case 189 /* TypeAssertionExpression */: - case 208 /* NonNullExpression */: - case 190 /* ParenthesizedExpression */: - case 191 /* FunctionExpression */: - case 204 /* ClassExpression */: - case 192 /* ArrowFunction */: - case 195 /* VoidExpression */: - case 193 /* DeleteExpression */: - case 194 /* TypeOfExpression */: - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: - case 199 /* BinaryExpression */: - case 200 /* ConditionalExpression */: - case 203 /* SpreadElement */: - case 201 /* TemplateExpression */: + case 183 /* ArrayLiteralExpression */: + case 184 /* ObjectLiteralExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 189 /* TaggedTemplateExpression */: + case 208 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 209 /* NonNullExpression */: + case 191 /* ParenthesizedExpression */: + case 192 /* FunctionExpression */: + case 205 /* ClassExpression */: + case 193 /* ArrowFunction */: + case 196 /* VoidExpression */: + case 194 /* DeleteExpression */: + case 195 /* TypeOfExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: + case 200 /* BinaryExpression */: + case 201 /* ConditionalExpression */: + case 204 /* SpreadElement */: + case 202 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: - case 205 /* OmittedExpression */: - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: - case 258 /* JsxFragment */: - case 202 /* YieldExpression */: - case 196 /* AwaitExpression */: - case 209 /* MetaProperty */: + case 206 /* OmittedExpression */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: + case 259 /* JsxFragment */: + case 203 /* YieldExpression */: + case 197 /* AwaitExpression */: + case 210 /* MetaProperty */: return true; - case 145 /* QualifiedName */: - while (node.parent.kind === 145 /* QualifiedName */) { + case 146 /* QualifiedName */: + while (node.parent.kind === 146 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 164 /* TypeQuery */ || isJSXTagName(node); + return node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node); case 71 /* Identifier */: - if (node.parent.kind === 164 /* TypeQuery */ || isJSXTagName(node)) { + if (node.parent.kind === 165 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through @@ -10012,47 +10034,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 272 /* EnumMember */: - case 269 /* PropertyAssignment */: - case 181 /* BindingElement */: + case 232 /* VariableDeclaration */: + case 149 /* Parameter */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 273 /* EnumMember */: + case 270 /* PropertyAssignment */: + case 182 /* BindingElement */: return parent.initializer === node; - case 215 /* ExpressionStatement */: - case 216 /* IfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 224 /* ReturnStatement */: - case 225 /* WithStatement */: - case 226 /* SwitchStatement */: - case 265 /* CaseClause */: - case 228 /* ThrowStatement */: + case 216 /* ExpressionStatement */: + case 217 /* IfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 225 /* ReturnStatement */: + case 226 /* WithStatement */: + case 227 /* SwitchStatement */: + case 266 /* CaseClause */: + case 229 /* ThrowStatement */: return parent.expression === node; - case 219 /* ForStatement */: + case 220 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 232 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 233 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 232 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233 /* VariableDeclarationList */) || forInStatement.expression === node; - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: return node === parent.expression; - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return node === parent.expression; - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return node === parent.expression; - case 149 /* Decorator */: - case 264 /* JsxExpression */: - case 263 /* JsxSpreadAttribute */: - case 271 /* SpreadAssignment */: + case 150 /* Decorator */: + case 265 /* JsxExpression */: + case 264 /* JsxSpreadAttribute */: + case 272 /* SpreadAssignment */: return true; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -10060,7 +10082,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 242 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 253 /* ExternalModuleReference */; + return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10069,7 +10091,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 242 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 253 /* ExternalModuleReference */; + return node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 254 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -10081,15 +10103,15 @@ var ts; } ts.isSourceFileNotJavaScript = isSourceFileNotJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 65536 /* JavaScriptFile */); + return !!node && !!(node.flags & 65536 /* JavaScriptFile */); } ts.isInJavaScriptFile = isInJavaScriptFile; function isInJsonFile(node) { - return node && !!(node.flags & 16777216 /* JsonFile */); + return !!node && !!(node.flags & 16777216 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return node && !!(node.flags & 2097152 /* JSDoc */); + return !!node && !!(node.flags & 2097152 /* JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -10101,7 +10123,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 186 /* CallExpression */) { + if (callExpression.kind !== 187 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -10123,30 +10145,49 @@ var ts; return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */; } ts.isStringDoubleQuoted = isStringDoubleQuoted; - /** - * Given the symbol of a declaration, find the symbol of its Javascript container-like initializer, - * if it has one. Otherwise just return the original symbol. - * - * Container-like initializer behave like namespaces, so the binder needs to add contained symbols - * to their exports. An example is a function with assignments to `this` inside. - */ - function getJSInitializerSymbol(symbol) { - if (!symbol || !symbol.valueDeclaration) { - return symbol; + function getDeclarationOfJSInitializer(node) { + if (!isInJavaScriptFile(node) || !node.parent) { + return undefined; } - var declaration = symbol.valueDeclaration; - var e = getDeclaredJavascriptInitializer(declaration) || getAssignedJavascriptInitializer(declaration); - return e && e.symbol ? e.symbol : symbol; - } - ts.getJSInitializerSymbol = getJSInitializerSymbol; - /** Get the declaration initializer, when the initializer is container-like (See getJavascriptInitializer) */ - function getDeclaredJavascriptInitializer(node) { - if (node && ts.isVariableDeclaration(node) && node.initializer) { - return getJavascriptInitializer(node.initializer, /*isPrototypeAssignment*/ false) || - ts.isIdentifier(node.name) && getDefaultedJavascriptInitializer(node.name, node.initializer, /*isPrototypeAssignment*/ false); + var name; + var decl; + if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) { + name = node.parent.name; + decl = node.parent; } + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.right === node) { + name = node.parent.left; + decl = name; + } + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 54 /* BarBarToken */) { + if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { + name = node.parent.parent.name; + decl = node.parent.parent; + } + else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 58 /* EqualsToken */ && node.parent.parent.right === node.parent) { + name = node.parent.parent.left; + decl = name; + } + if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { + return undefined; + } + } + if (!name || !getJavascriptInitializer(node, isPrototypeAccess(name))) { + return undefined; + } + return decl; } - ts.getDeclaredJavascriptInitializer = getDeclaredJavascriptInitializer; + ts.getDeclarationOfJSInitializer = getDeclarationOfJSInitializer; + /** Get the initializer, taking into account defaulted Javascript initializers */ + function getEffectiveInitializer(node) { + if (isInJavaScriptFile(node) && node.initializer && + ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 54 /* BarBarToken */ && + node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { + return node.initializer.right; + } + return node.initializer; + } + ts.getEffectiveInitializer = getEffectiveInitializer; /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getJavascriptInitializer). * We treat the right hand side of assignments with container-like initalizers as declarations. @@ -10172,11 +10213,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 191 /* FunctionExpression */ || e.kind === 192 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 192 /* FunctionExpression */ || e.kind === 193 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 191 /* FunctionExpression */ || - initializer.kind === 204 /* ClassExpression */ || - initializer.kind === 192 /* ArrowFunction */) { + if (initializer.kind === 192 /* FunctionExpression */ || + initializer.kind === 205 /* ClassExpression */ || + initializer.kind === 193 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10198,6 +10239,13 @@ var ts; return e; } } + function isDefaultedJavascriptInitializer(node) { + var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 /* EqualsToken */ ? node.parent.left : + undefined; + return name && getJavascriptInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); + } + ts.isDefaultedJavascriptInitializer = isDefaultedJavascriptInitializer; /** Given a Javascript initializer, return the outer name. That is, the lhs of the assignment or the declaration name. */ function getOuterNameOfJsInitializer(node) { if (ts.isBinaryExpression(node.parent)) { @@ -10307,7 +10355,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 215 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 216 /* ExpressionStatement */ && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10317,14 +10365,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: return node.parent; - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: return node.parent.parent; - case 186 /* CallExpression */: + case 187 /* CallExpression */: return node.parent; - case 177 /* LiteralType */: + case 178 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10334,12 +10382,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: return node.moduleSpecifier; - case 242 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 253 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 178 /* ImportType */: + case 243 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 254 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 179 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10348,11 +10396,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return node; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10360,19 +10408,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 243 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 244 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 148 /* Parameter */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 270 /* ShorthandPropertyAssignment */: - case 269 /* PropertyAssignment */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 149 /* Parameter */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 271 /* ShorthandPropertyAssignment */: + case 270 /* PropertyAssignment */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10380,14 +10428,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 283 /* JSDocFunctionType */ && + return node.kind === 284 /* JSDocFunctionType */ && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 296 /* JSDocTypedefTag */ || node.kind === 291 /* JSDocCallbackTag */; + return node.kind === 297 /* JSDocTypedefTag */ || node.kind === 292 /* JSDocCallbackTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10397,38 +10445,39 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 58 /* EqualsToken */ && - node.expression.right; + node.expression.operatorToken.kind === 58 /* EqualsToken */ + ? node.expression.right + : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && getSpecialPropertyAssignmentKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 54 /* BarBarToken */ && - node.expression.right.right; + node.expression.right.operatorToken.kind === 54 /* BarBarToken */ + ? node.expression.right.right + : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return node.initializer; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return node.initializer; } } function getSingleVariableOfVariableStatement(node) { - return ts.isVariableStatement(node) && - node.declarationList.declarations.length > 0 && - node.declarationList.declarations[0]; + return ts.isVariableStatement(node) ? ts.firstOrUndefined(node.declarationList.declarations) : undefined; } function getNestedModuleDeclaration(node) { - return node.kind === 238 /* ModuleDeclaration */ && + return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 238 /* ModuleDeclaration */ && - node.body; + node.body.kind === 239 /* ModuleDeclaration */ + ? node.body + : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; @@ -10438,7 +10487,7 @@ var ts; var parent = node.parent; if (!parent) return; - if (parent.kind === 269 /* PropertyAssignment */ || parent.kind === 151 /* PropertyDeclaration */ || getNestedModuleDeclaration(parent)) { + if (parent.kind === 270 /* PropertyAssignment */ || parent.kind === 152 /* PropertyDeclaration */ || getNestedModuleDeclaration(parent)) { getJSDocCommentsAndTagsWorker(parent); } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -10458,11 +10507,11 @@ var ts; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 /* EqualsToken */ || ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 /* EqualsToken */ || - node.kind === 184 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 215 /* ExpressionStatement */) { + node.kind === 185 /* PropertyAccessExpression */ && node.parent && node.parent.kind === 216 /* ExpressionStatement */) { getJSDocCommentsAndTagsWorker(parent); } // Pull parameter comments from declaring function as well - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); } if (isVariableLike(node) && ts.hasInitializer(node) && node.initializer !== hostNode && ts.hasJSDocNodes(node.initializer)) { @@ -10517,12 +10566,12 @@ var ts; ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { var last = ts.lastOrUndefined(s.parameters); - return last && isRestParameter(last); + return !!last && isRestParameter(last); } 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 === 284 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 285 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -10535,31 +10584,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 190 /* ParenthesizedExpression */: - case 182 /* ArrayLiteralExpression */: - case 203 /* SpreadElement */: - case 208 /* NonNullExpression */: + case 191 /* ParenthesizedExpression */: + case 183 /* ArrayLiteralExpression */: + case 204 /* SpreadElement */: + case 209 /* NonNullExpression */: node = parent; break; - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -10586,22 +10635,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 212 /* Block */: - case 213 /* VariableStatement */: - case 225 /* WithStatement */: - case 216 /* IfStatement */: - case 226 /* SwitchStatement */: - case 240 /* CaseBlock */: - case 265 /* CaseClause */: - case 266 /* DefaultClause */: - case 227 /* LabeledStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 229 /* TryStatement */: - case 268 /* CatchClause */: + case 213 /* Block */: + case 214 /* VariableStatement */: + case 226 /* WithStatement */: + case 217 /* IfStatement */: + case 227 /* SwitchStatement */: + case 241 /* CaseBlock */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: + case 228 /* LabeledStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 230 /* TryStatement */: + case 269 /* CatchClause */: return true; } return false; @@ -10618,15 +10667,15 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 172 /* ParenthesizedType */); + return walkUp(node, 173 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 190 /* ParenthesizedExpression */); + return walkUp(node, 191 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 190 /* ParenthesizedExpression */) { + while (node.kind === 191 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -10634,11 +10683,11 @@ var ts; ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 184 /* PropertyAccessExpression */ && node.kind !== 185 /* ElementAccessExpression */) { + if (node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 193 /* DeleteExpression */; + return node && node.kind === 194 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -10660,9 +10709,10 @@ var ts; switch (name.kind) { case 71 /* Identifier */: case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - if (ts.isDeclaration(name.parent)) { - return name.parent.name === name; + case 8 /* NumericLiteral */: { + var parent = name.parent; + if (ts.isDeclaration(parent)) { + return parent.name === name; } else if (ts.isQualifiedName(name.parent)) { var tag = name.parent.parent; @@ -10672,6 +10722,7 @@ var ts; var binExp = name.parent.parent; return ts.isBinaryExpression(binExp) && getSpecialPropertyAssignmentKind(binExp) !== 0 /* None */ && ts.getNameOfDeclaration(binExp) === name; } + } default: return false; } @@ -10679,7 +10730,7 @@ var ts; ts.isAnyDeclarationName = isAnyDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 146 /* ComputedPropertyName */ && + node.parent.kind === 147 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -10687,32 +10738,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 272 /* EnumMember */: - case 269 /* PropertyAssignment */: - case 184 /* PropertyAccessExpression */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 273 /* EnumMember */: + case 270 /* PropertyAssignment */: + case 185 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 145 /* QualifiedName */) { + while (parent.kind === 146 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 164 /* TypeQuery */ || parent.kind === 161 /* TypeReference */; + return parent.kind === 165 /* TypeQuery */ || parent.kind === 162 /* TypeReference */; } return false; - case 181 /* BindingElement */: - case 247 /* ImportSpecifier */: + case 182 /* BindingElement */: + case 248 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 251 /* ExportSpecifier */: - case 261 /* JsxAttribute */: + case 252 /* ExportSpecifier */: + case 262 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -10728,13 +10779,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 242 /* ImportEqualsDeclaration */ || - node.kind === 241 /* NamespaceExportDeclaration */ || - node.kind === 244 /* ImportClause */ && !!node.name || - node.kind === 245 /* NamespaceImport */ || - node.kind === 247 /* ImportSpecifier */ || - node.kind === 251 /* ExportSpecifier */ || - node.kind === 248 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + return node.kind === 243 /* ImportEqualsDeclaration */ || + node.kind === 242 /* NamespaceExportDeclaration */ || + node.kind === 245 /* ImportClause */ && !!node.name || + node.kind === 246 /* NamespaceImport */ || + node.kind === 248 /* ImportSpecifier */ || + node.kind === 252 /* ExportSpecifier */ || + node.kind === 249 /* ExportAssignment */ && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -10795,11 +10846,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 72 /* FirstKeyword */ <= token && token <= 144 /* LastKeyword */; + return 72 /* FirstKeyword */ <= token && token <= 145 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 117 /* FirstContextualKeyword */ <= token && token <= 144 /* LastContextualKeyword */; + return 117 /* FirstContextualKeyword */ <= token && token <= 145 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -10829,14 +10880,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -10850,10 +10901,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -10876,11 +10927,11 @@ var ts; */ function hasDynamicName(declaration) { var name = ts.getNameOfDeclaration(declaration); - return name && isDynamicName(name); + return !!name && isDynamicName(name); } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 146 /* ComputedPropertyName */ && + return name.kind === 147 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -10901,7 +10952,7 @@ var ts; if (name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */) { return escapeLeadingUnderscores(name.text); } - if (name.kind === 146 /* ComputedPropertyName */) { + if (name.kind === 147 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -10954,11 +11005,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 148 /* Parameter */; + return root.kind === 149 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 181 /* BindingElement */) { + while (node.kind === 182 /* BindingElement */) { node = node.parent.parent; } return node; @@ -10966,15 +11017,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 154 /* Constructor */ - || kind === 191 /* FunctionExpression */ - || kind === 233 /* FunctionDeclaration */ - || kind === 192 /* ArrowFunction */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */ - || kind === 238 /* ModuleDeclaration */ - || kind === 273 /* SourceFile */; + return kind === 155 /* Constructor */ + || kind === 192 /* FunctionExpression */ + || kind === 234 /* FunctionDeclaration */ + || kind === 193 /* ArrowFunction */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */ + || kind === 239 /* ModuleDeclaration */ + || kind === 274 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -10993,23 +11044,23 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 187 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 187 /* NewExpression */: + case 188 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 197 /* PrefixUnaryExpression */: - case 194 /* TypeOfExpression */: - case 195 /* VoidExpression */: - case 193 /* DeleteExpression */: - case 196 /* AwaitExpression */: - case 200 /* ConditionalExpression */: - case 202 /* YieldExpression */: + case 198 /* PrefixUnaryExpression */: + case 195 /* TypeOfExpression */: + case 196 /* VoidExpression */: + case 194 /* DeleteExpression */: + case 197 /* AwaitExpression */: + case 201 /* ConditionalExpression */: + case 203 /* YieldExpression */: return 1 /* Right */; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: switch (operator) { case 40 /* AsteriskAsteriskToken */: case 58 /* EqualsToken */: @@ -11033,15 +11084,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 187 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 188 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 199 /* BinaryExpression */) { + if (expression.kind === 200 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 197 /* PrefixUnaryExpression */ || expression.kind === 198 /* PostfixUnaryExpression */) { + else if (expression.kind === 198 /* PrefixUnaryExpression */ || expression.kind === 199 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11051,15 +11102,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: return 0; - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return 1; - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return 2; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return 4; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: switch (operatorKind) { case 26 /* CommaToken */: return 0; @@ -11080,21 +11131,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 197 /* PrefixUnaryExpression */: - case 194 /* TypeOfExpression */: - case 195 /* VoidExpression */: - case 193 /* DeleteExpression */: - case 196 /* AwaitExpression */: + case 198 /* PrefixUnaryExpression */: + case 195 /* TypeOfExpression */: + case 196 /* VoidExpression */: + case 194 /* DeleteExpression */: + case 197 /* AwaitExpression */: return 16; - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return 17; - case 186 /* CallExpression */: + case 187 /* CallExpression */: return 18; - case 187 /* NewExpression */: + case 188 /* NewExpression */: return hasArguments ? 19 : 18; - case 188 /* TaggedTemplateExpression */: - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: + case 189 /* TaggedTemplateExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: return 19; case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: @@ -11104,19 +11155,19 @@ var ts; case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 182 /* ArrayLiteralExpression */: - case 183 /* ObjectLiteralExpression */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 204 /* ClassExpression */: - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: - case 258 /* JsxFragment */: + case 183 /* ArrayLiteralExpression */: + case 184 /* ObjectLiteralExpression */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 205 /* ClassExpression */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: + case 259 /* JsxFragment */: case 12 /* RegularExpressionLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 201 /* TemplateExpression */: - case 190 /* ParenthesizedExpression */: - case 205 /* OmittedExpression */: + case 202 /* TemplateExpression */: + case 191 /* ParenthesizedExpression */: + case 206 /* OmittedExpression */: return 20; default: return -1; @@ -11169,7 +11220,7 @@ var ts; } ts.getBinaryOperatorPrecedence = getBinaryOperatorPrecedence; function createDiagnosticCollection() { - var nonFileDiagnostics = []; + var nonFileDiagnostics = []; // See GH#19873 var filesWithDiagnostics = []; var fileDiagnostics = ts.createMap(); var hasReadNonFileDiagnostics = false; @@ -11187,7 +11238,7 @@ var ts; if (diagnostic.file) { diagnostics = fileDiagnostics.get(diagnostic.file.fileName); if (!diagnostics) { - diagnostics = []; + diagnostics = []; // See GH#19873 fileDiagnostics.set(diagnostic.file.fileName, diagnostics); ts.insertSorted(filesWithDiagnostics, diagnostic.file.fileName, ts.compareStringsCaseSensitive); } @@ -11334,7 +11385,7 @@ var ts; var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + linePos = output.length - s.length + ts.last(lineStartsOfS); } } } @@ -11509,7 +11560,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 71 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 71 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { @@ -11517,16 +11568,17 @@ var ts; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { + // TODO: GH#18217 var firstAccessor; var secondAccessor; var getAccessor; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 155 /* GetAccessor */) { + if (accessor.kind === 156 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 156 /* SetAccessor */) { + else if (accessor.kind === 157 /* SetAccessor */) { setAccessor = accessor; } else { @@ -11535,7 +11587,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 155 /* GetAccessor */ || member.kind === 156 /* SetAccessor */) + if ((member.kind === 156 /* GetAccessor */ || member.kind === 157 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -11546,10 +11598,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 155 /* GetAccessor */ && !getAccessor) { + if (member.kind === 156 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 156 /* SetAccessor */ && !setAccessor) { + if (member.kind === 157 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -11596,25 +11648,20 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 285 /* JSDocComment */); - var templateTags = ts.flatMap(ts.filter(node.parent.tags, ts.isJSDocTemplateTag), function (tag) { return tag.typeParameters; }); - var templateTagNodes = templateTags; - templateTagNodes.pos = templateTagNodes.length > 0 ? ts.first(templateTagNodes).pos : node.pos; - templateTagNodes.end = templateTagNodes.length > 0 ? ts.last(templateTagNodes).end : node.end; - templateTagNodes.hasTrailingComma = false; - return templateTagNodes; + ts.Debug.assert(node.parent.kind === 286 /* JSDocComment */); + return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray); } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getJSDocTypeParameterDeclarations(node) { - // template tags are only available when a typedef isn't already using them - var tag = ts.find(ts.getJSDocTags(node), function (tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 285 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); - }); - return (tag && tag.typeParameters) || ts.emptyArray; + return ts.flatMap(ts.getJSDocTags(node), function (tag) { return isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined; }); } 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 === 286 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node * was parsed in a JavaScript file, gets the type annotation from JSDoc. @@ -11713,13 +11760,13 @@ var ts; // All comments look like they could have been part of the copyright header. Make // sure there is at least one blank line between it and the node. If not, it's not // a copyright header. - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.last(detachedComments).end); var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); if (nodeLine >= lastCommentLine + 2) { // Valid detachedComments emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); emitComments(text, lineMap, writer, detachedComments, /*leadingSeparator*/ false, /*trailingSeparator*/ true, newLine, writeComment); - currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.last(detachedComments).end }; } } } @@ -11888,7 +11935,7 @@ var ts; ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 206 /* ExpressionWithTypeArguments */ && + if (ts.isExpressionWithTypeArguments(node) && node.parent.token === 85 /* ExtendsKeyword */ && ts.isClassLike(node.parent.parent)) { return node.parent.parent; @@ -11906,8 +11953,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 183 /* ObjectLiteralExpression */ - || kind === 182 /* ArrayLiteralExpression */; + return kind === 184 /* ObjectLiteralExpression */ + || kind === 183 /* ArrayLiteralExpression */; } return false; } @@ -11917,7 +11964,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 206 /* ExpressionWithTypeArguments */ + return node.kind === 207 /* ExpressionWithTypeArguments */ && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 /* ImplementsKeyword */ @@ -11938,17 +11985,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 145 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 183 /* ObjectLiteralExpression */ && + return expression.kind === 184 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 182 /* ArrayLiteralExpression */ && + return expression.kind === 183 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12062,14 +12109,14 @@ var ts; return output; } function base64encode(host, input) { - if (host.base64encode) { + if (host && host.base64encode) { return host.base64encode(input); } return convertToBase64(input); } ts.base64encode = base64encode; function base64decode(host, input) { - if (host.base64decode) { + if (host && host.base64decode) { return host.base64decode(input); } var length = input.length; @@ -12289,8 +12336,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 237 /* EnumDeclaration */: - case 238 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 239 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12363,21 +12410,21 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 198 /* PostfixUnaryExpression */: - case 197 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: var operator = parent.operator; return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0 /* Read */; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : 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 && parent.parent.kind === 215 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && parent.parent.kind === 216 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function compareDataObjects(dst, src) { @@ -12468,7 +12515,7 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 65536 /* Object */ ? type.objectFlags : 0; + return type.flags & 131072 /* Object */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { @@ -12739,9 +12786,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 147 /* TypeParameter */) { + if (d && d.kind === 148 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 235 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236 /* InterfaceDeclaration */) { return current; } } @@ -12749,7 +12796,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 154 /* Constructor */; + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 155 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12767,7 +12814,7 @@ var ts; } ts.isEmptyBindingElement = isEmptyBindingElement; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 181 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 182 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -12775,14 +12822,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 231 /* VariableDeclaration */) { + if (node.kind === 232 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 232 /* VariableDeclarationList */) { + if (node && node.kind === 233 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 213 /* VariableStatement */) { + if (node && node.kind === 214 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -12798,14 +12845,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 231 /* VariableDeclaration */) { + if (node.kind === 232 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 232 /* VariableDeclarationList */) { + if (node && node.kind === 233 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 213 /* VariableStatement */) { + if (node && node.kind === 214 /* VariableStatement */) { flags |= node.flags; } return flags; @@ -12858,7 +12905,7 @@ var ts; // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) ts.localizedDiagnosticMessages = JSON.parse(fileContents); } - catch (e) { + catch (_a) { if (errors) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath)); } @@ -12942,17 +12989,17 @@ var ts; } // Covers remaining cases switch (hostNode.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: var expr = hostNode.expression; switch (expr.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return expr.name; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -12961,10 +13008,10 @@ var ts; return undefined; case 1 /* EndOfFileToken */: return undefined; - case 190 /* ParenthesizedExpression */: { + case 191 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 227 /* LabeledStatement */: { + case 228 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12987,28 +13034,29 @@ var ts; return !!node.name; // A 'name' property should always be a DeclarationName. } ts.isNamedDeclaration = isNamedDeclaration; + // TODO: GH#18217 This is often used as if it returns a defined result function getNameOfDeclaration(declaration) { if (!declaration) { return undefined; } switch (declaration.kind) { - case 204 /* ClassExpression */: - case 191 /* FunctionExpression */: + case 205 /* ClassExpression */: + case 192 /* FunctionExpression */: if (!declaration.name) { return getAssignedName(declaration); } break; case 71 /* Identifier */: return declaration; - case 297 /* JSDocPropertyTag */: - case 292 /* JSDocParameterTag */: { + case 298 /* JSDocPropertyTag */: + case 293 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 145 /* QualifiedName */) { + if (name.kind === 146 /* QualifiedName */) { return name.right; } break; } - case 199 /* BinaryExpression */: { + case 200 /* BinaryExpression */: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1 /* ExportsProperty */: @@ -13020,11 +13068,11 @@ var ts; return undefined; } } - case 291 /* JSDocCallbackTag */: + case 292 /* JSDocCallbackTag */: return declaration.name; - case 296 /* JSDocTypedefTag */: + case 297 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 248 /* ExportAssignment */: { + case 249 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -13214,637 +13262,637 @@ var ts; ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 145 /* QualifiedName */; + return node.kind === 146 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 146 /* ComputedPropertyName */; + return node.kind === 147 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 147 /* TypeParameter */; + return node.kind === 148 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 148 /* Parameter */; + return node.kind === 149 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 149 /* Decorator */; + return node.kind === 150 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 150 /* PropertySignature */; + return node.kind === 151 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 151 /* PropertyDeclaration */; + return node.kind === 152 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 152 /* MethodSignature */; + return node.kind === 153 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 153 /* MethodDeclaration */; + return node.kind === 154 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 154 /* Constructor */; + return node.kind === 155 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 155 /* GetAccessor */; + return node.kind === 156 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 156 /* SetAccessor */; + return node.kind === 157 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 157 /* CallSignature */; + return node.kind === 158 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 158 /* ConstructSignature */; + return node.kind === 159 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 159 /* IndexSignature */; + return node.kind === 160 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 156 /* SetAccessor */ || node.kind === 155 /* GetAccessor */; + return node.kind === 157 /* SetAccessor */ || node.kind === 156 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 160 /* TypePredicate */; + return node.kind === 161 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 161 /* TypeReference */; + return node.kind === 162 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 162 /* FunctionType */; + return node.kind === 163 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 163 /* ConstructorType */; + return node.kind === 164 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 164 /* TypeQuery */; + return node.kind === 165 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 165 /* TypeLiteral */; + return node.kind === 166 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 166 /* ArrayType */; + return node.kind === 167 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 167 /* TupleType */; + return node.kind === 168 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 168 /* UnionType */; + return node.kind === 169 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 169 /* IntersectionType */; + return node.kind === 170 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 170 /* ConditionalType */; + return node.kind === 171 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 171 /* InferType */; + return node.kind === 172 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 172 /* ParenthesizedType */; + return node.kind === 173 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 173 /* ThisType */; + return node.kind === 174 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 174 /* TypeOperator */; + return node.kind === 175 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 175 /* IndexedAccessType */; + return node.kind === 176 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 176 /* MappedType */; + return node.kind === 177 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 177 /* LiteralType */; + return node.kind === 178 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 178 /* ImportType */; + return node.kind === 179 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 179 /* ObjectBindingPattern */; + return node.kind === 180 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 180 /* ArrayBindingPattern */; + return node.kind === 181 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 181 /* BindingElement */; + return node.kind === 182 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 182 /* ArrayLiteralExpression */; + return node.kind === 183 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 183 /* ObjectLiteralExpression */; + return node.kind === 184 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 184 /* PropertyAccessExpression */; + return node.kind === 185 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 185 /* ElementAccessExpression */; + return node.kind === 186 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 186 /* CallExpression */; + return node.kind === 187 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 187 /* NewExpression */; + return node.kind === 188 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 188 /* TaggedTemplateExpression */; + return node.kind === 189 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 189 /* TypeAssertionExpression */; + return node.kind === 190 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 190 /* ParenthesizedExpression */; + return node.kind === 191 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 300 /* PartiallyEmittedExpression */) { + while (node.kind === 301 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 191 /* FunctionExpression */; + return node.kind === 192 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 192 /* ArrowFunction */; + return node.kind === 193 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 193 /* DeleteExpression */; + return node.kind === 194 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 194 /* TypeOfExpression */; + return node.kind === 195 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 195 /* VoidExpression */; + return node.kind === 196 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 196 /* AwaitExpression */; + return node.kind === 197 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 197 /* PrefixUnaryExpression */; + return node.kind === 198 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 198 /* PostfixUnaryExpression */; + return node.kind === 199 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 199 /* BinaryExpression */; + return node.kind === 200 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 200 /* ConditionalExpression */; + return node.kind === 201 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 201 /* TemplateExpression */; + return node.kind === 202 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 202 /* YieldExpression */; + return node.kind === 203 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 203 /* SpreadElement */; + return node.kind === 204 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 204 /* ClassExpression */; + return node.kind === 205 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 205 /* OmittedExpression */; + return node.kind === 206 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 206 /* ExpressionWithTypeArguments */; + return node.kind === 207 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 207 /* AsExpression */; + return node.kind === 208 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 208 /* NonNullExpression */; + return node.kind === 209 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 209 /* MetaProperty */; + return node.kind === 210 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 210 /* TemplateSpan */; + return node.kind === 211 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 211 /* SemicolonClassElement */; + return node.kind === 212 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 212 /* Block */; + return node.kind === 213 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 213 /* VariableStatement */; + return node.kind === 214 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 214 /* EmptyStatement */; + return node.kind === 215 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 215 /* ExpressionStatement */; + return node.kind === 216 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 216 /* IfStatement */; + return node.kind === 217 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 217 /* DoStatement */; + return node.kind === 218 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 218 /* WhileStatement */; + return node.kind === 219 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 219 /* ForStatement */; + return node.kind === 220 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 220 /* ForInStatement */; + return node.kind === 221 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 221 /* ForOfStatement */; + return node.kind === 222 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 222 /* ContinueStatement */; + return node.kind === 223 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 223 /* BreakStatement */; + return node.kind === 224 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 223 /* BreakStatement */ || node.kind === 222 /* ContinueStatement */; + return node.kind === 224 /* BreakStatement */ || node.kind === 223 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 224 /* ReturnStatement */; + return node.kind === 225 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 225 /* WithStatement */; + return node.kind === 226 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 226 /* SwitchStatement */; + return node.kind === 227 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 227 /* LabeledStatement */; + return node.kind === 228 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 228 /* ThrowStatement */; + return node.kind === 229 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 229 /* TryStatement */; + return node.kind === 230 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 230 /* DebuggerStatement */; + return node.kind === 231 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 231 /* VariableDeclaration */; + return node.kind === 232 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 232 /* VariableDeclarationList */; + return node.kind === 233 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 233 /* FunctionDeclaration */; + return node.kind === 234 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 234 /* ClassDeclaration */; + return node.kind === 235 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 235 /* InterfaceDeclaration */; + return node.kind === 236 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 236 /* TypeAliasDeclaration */; + return node.kind === 237 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 237 /* EnumDeclaration */; + return node.kind === 238 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 238 /* ModuleDeclaration */; + return node.kind === 239 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 239 /* ModuleBlock */; + return node.kind === 240 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 240 /* CaseBlock */; + return node.kind === 241 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 241 /* NamespaceExportDeclaration */; + return node.kind === 242 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 242 /* ImportEqualsDeclaration */; + return node.kind === 243 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 243 /* ImportDeclaration */; + return node.kind === 244 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 244 /* ImportClause */; + return node.kind === 245 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 245 /* NamespaceImport */; + return node.kind === 246 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 246 /* NamedImports */; + return node.kind === 247 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 247 /* ImportSpecifier */; + return node.kind === 248 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 248 /* ExportAssignment */; + return node.kind === 249 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 249 /* ExportDeclaration */; + return node.kind === 250 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 250 /* NamedExports */; + return node.kind === 251 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 251 /* ExportSpecifier */; + return node.kind === 252 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 252 /* MissingDeclaration */; + return node.kind === 253 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 253 /* ExternalModuleReference */; + return node.kind === 254 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 254 /* JsxElement */; + return node.kind === 255 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 255 /* JsxSelfClosingElement */; + return node.kind === 256 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 256 /* JsxOpeningElement */; + return node.kind === 257 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 257 /* JsxClosingElement */; + return node.kind === 258 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 258 /* JsxFragment */; + return node.kind === 259 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 259 /* JsxOpeningFragment */; + return node.kind === 260 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 260 /* JsxClosingFragment */; + return node.kind === 261 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 261 /* JsxAttribute */; + return node.kind === 262 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 262 /* JsxAttributes */; + return node.kind === 263 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 263 /* JsxSpreadAttribute */; + return node.kind === 264 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 264 /* JsxExpression */; + return node.kind === 265 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 265 /* CaseClause */; + return node.kind === 266 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 266 /* DefaultClause */; + return node.kind === 267 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 267 /* HeritageClause */; + return node.kind === 268 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 268 /* CatchClause */; + return node.kind === 269 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 269 /* PropertyAssignment */; + return node.kind === 270 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 270 /* ShorthandPropertyAssignment */; + return node.kind === 271 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 271 /* SpreadAssignment */; + return node.kind === 272 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 272 /* EnumMember */; + return node.kind === 273 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 273 /* SourceFile */; + return node.kind === 274 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 274 /* Bundle */; + return node.kind === 275 /* Bundle */; } ts.isBundle = isBundle; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 277 /* JSDocTypeExpression */; + return node.kind === 278 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 278 /* JSDocAllType */; + return node.kind === 279 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 279 /* JSDocUnknownType */; + return node.kind === 280 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 280 /* JSDocNullableType */; + return node.kind === 281 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 281 /* JSDocNonNullableType */; + return node.kind === 282 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 282 /* JSDocOptionalType */; + return node.kind === 283 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 283 /* JSDocFunctionType */; + return node.kind === 284 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 284 /* JSDocVariadicType */; + return node.kind === 285 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 285 /* JSDocComment */; + return node.kind === 286 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 289 /* JSDocAugmentsTag */; + return node.kind === 290 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 290 /* JSDocClassTag */; + return node.kind === 291 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocParameterTag(node) { - return node.kind === 292 /* JSDocParameterTag */; + return node.kind === 293 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 293 /* JSDocReturnTag */; + return node.kind === 294 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 294 /* JSDocTypeTag */; + return node.kind === 295 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 295 /* JSDocTemplateTag */; + return node.kind === 296 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 296 /* JSDocTypedefTag */; + return node.kind === 297 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 297 /* JSDocPropertyTag */; + return node.kind === 298 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 297 /* JSDocPropertyTag */ || node.kind === 292 /* JSDocParameterTag */; + return node.kind === 298 /* JSDocPropertyTag */ || node.kind === 293 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 286 /* JSDocTypeLiteral */; + return node.kind === 287 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 291 /* JSDocCallbackTag */; + return node.kind === 292 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 287 /* JSDocSignature */; + return node.kind === 288 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -13855,7 +13903,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 298 /* SyntaxList */; + return n.kind === 299 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -13865,7 +13913,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 145 /* FirstNode */; + return kind >= 146 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13874,7 +13922,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 144 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 145 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -13899,6 +13947,10 @@ var ts; return 13 /* FirstTemplateToken */ <= kind && kind <= 16 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isTemplateLiteralToken(node) { + return isTemplateLiteralKind(node.kind); + } + ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; return kind === 15 /* TemplateMiddle */ @@ -13912,7 +13964,6 @@ var ts; // Identifiers /* @internal */ function isGeneratedIdentifier(node) { - // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */; } ts.isGeneratedIdentifier = isGeneratedIdentifier; @@ -13952,7 +14003,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 145 /* QualifiedName */ + return kind === 146 /* QualifiedName */ || kind === 71 /* Identifier */; } ts.isEntityName = isEntityName; @@ -13961,14 +14012,14 @@ var ts; return kind === 71 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 146 /* ComputedPropertyName */; + || kind === 147 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 179 /* ObjectBindingPattern */ - || kind === 180 /* ArrayBindingPattern */; + || kind === 180 /* ObjectBindingPattern */ + || kind === 181 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13983,13 +14034,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return true; default: return false; @@ -13998,14 +14049,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 287 /* JSDocSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 162 /* FunctionType */: - case 283 /* JSDocFunctionType */: - case 163 /* ConstructorType */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 288 /* JSDocSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 163 /* FunctionType */: + case 284 /* JSDocFunctionType */: + case 164 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14020,29 +14071,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 154 /* Constructor */ - || kind === 151 /* PropertyDeclaration */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */ - || kind === 159 /* IndexSignature */ - || kind === 211 /* SemicolonClassElement */; + return kind === 155 /* Constructor */ + || kind === 152 /* PropertyDeclaration */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */ + || kind === 160 /* IndexSignature */ + || kind === 212 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 234 /* ClassDeclaration */ || node.kind === 204 /* ClassExpression */); + return node && (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 155 /* GetAccessor */ || node.kind === 156 /* SetAccessor */); + return node && (node.kind === 156 /* GetAccessor */ || node.kind === 157 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return true; default: return false; @@ -14052,11 +14103,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 158 /* ConstructSignature */ - || kind === 157 /* CallSignature */ - || kind === 150 /* PropertySignature */ - || kind === 152 /* MethodSignature */ - || kind === 159 /* IndexSignature */; + return kind === 159 /* ConstructSignature */ + || kind === 158 /* CallSignature */ + || kind === 151 /* PropertySignature */ + || kind === 153 /* MethodSignature */ + || kind === 160 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14065,18 +14116,19 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 269 /* PropertyAssignment */ - || kind === 270 /* ShorthandPropertyAssignment */ - || kind === 271 /* SpreadAssignment */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */; + return kind === 270 /* PropertyAssignment */ + || kind === 271 /* ShorthandPropertyAssignment */ + || kind === 272 /* SpreadAssignment */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 160 /* FirstTypeNode */ && kind <= 178 /* LastTypeNode */) + return (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) || kind === 119 /* AnyKeyword */ + || kind === 142 /* UnknownKeyword */ || kind === 134 /* NumberKeyword */ || kind === 135 /* ObjectKeyword */ || kind === 122 /* BooleanKeyword */ @@ -14087,14 +14139,14 @@ var ts; || kind === 140 /* UndefinedKeyword */ || kind === 95 /* NullKeyword */ || kind === 131 /* NeverKeyword */ - || kind === 206 /* ExpressionWithTypeArguments */ - || kind === 278 /* JSDocAllType */ - || kind === 279 /* JSDocUnknownType */ - || kind === 280 /* JSDocNullableType */ - || kind === 281 /* JSDocNonNullableType */ - || kind === 282 /* JSDocOptionalType */ - || kind === 283 /* JSDocFunctionType */ - || kind === 284 /* JSDocVariadicType */; + || kind === 207 /* ExpressionWithTypeArguments */ + || kind === 279 /* JSDocAllType */ + || kind === 280 /* JSDocUnknownType */ + || kind === 281 /* JSDocNullableType */ + || kind === 282 /* JSDocNonNullableType */ + || kind === 283 /* JSDocOptionalType */ + || kind === 284 /* JSDocFunctionType */ + || kind === 285 /* JSDocVariadicType */; } /** * Node test that determines whether a node is a valid type node. @@ -14107,8 +14159,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 162 /* FunctionType */: - case 163 /* ConstructorType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: return true; } return false; @@ -14119,8 +14171,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 180 /* ArrayBindingPattern */ - || kind === 179 /* ObjectBindingPattern */; + return kind === 181 /* ArrayBindingPattern */ + || kind === 180 /* ObjectBindingPattern */; } return false; } @@ -14128,15 +14180,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 182 /* ArrayLiteralExpression */ - || kind === 183 /* ObjectLiteralExpression */; + return kind === 183 /* ArrayLiteralExpression */ + || kind === 184 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 181 /* BindingElement */ - || kind === 205 /* OmittedExpression */; + return kind === 182 /* BindingElement */ + || kind === 206 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14145,9 +14197,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: - case 181 /* BindingElement */: + case 232 /* VariableDeclaration */: + case 149 /* Parameter */: + case 182 /* BindingElement */: return true; } return false; @@ -14168,8 +14220,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 179 /* ObjectBindingPattern */: - case 183 /* ObjectLiteralExpression */: + case 180 /* ObjectBindingPattern */: + case 184 /* ObjectLiteralExpression */: return true; } return false; @@ -14181,8 +14233,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180 /* ArrayBindingPattern */: - case 182 /* ArrayLiteralExpression */: + case 181 /* ArrayBindingPattern */: + case 183 /* ArrayLiteralExpression */: return true; } return false; @@ -14191,26 +14243,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 184 /* PropertyAccessExpression */ - || kind === 145 /* QualifiedName */ - || kind === 178 /* ImportType */; + return kind === 185 /* PropertyAccessExpression */ + || kind === 146 /* QualifiedName */ + || kind === 179 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 184 /* PropertyAccessExpression */ - || kind === 145 /* QualifiedName */; + return kind === 185 /* PropertyAccessExpression */ + || kind === 146 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 256 /* JsxOpeningElement */: - case 255 /* JsxSelfClosingElement */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 188 /* TaggedTemplateExpression */: - case 149 /* Decorator */: + case 257 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 189 /* TaggedTemplateExpression */: + case 150 /* Decorator */: return true; default: return false; @@ -14218,12 +14270,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 186 /* CallExpression */ || node.kind === 187 /* NewExpression */; + return node.kind === 187 /* CallExpression */ || node.kind === 188 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 201 /* TemplateExpression */ + return kind === 202 /* TemplateExpression */ || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14234,32 +14286,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: - case 187 /* NewExpression */: - case 186 /* CallExpression */: - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: - case 258 /* JsxFragment */: - case 188 /* TaggedTemplateExpression */: - case 182 /* ArrayLiteralExpression */: - case 190 /* ParenthesizedExpression */: - case 183 /* ObjectLiteralExpression */: - case 204 /* ClassExpression */: - case 191 /* FunctionExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: + case 188 /* NewExpression */: + case 187 /* CallExpression */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: + case 259 /* JsxFragment */: + case 189 /* TaggedTemplateExpression */: + case 183 /* ArrayLiteralExpression */: + case 191 /* ParenthesizedExpression */: + case 184 /* ObjectLiteralExpression */: + case 205 /* ClassExpression */: + case 192 /* FunctionExpression */: case 71 /* Identifier */: case 12 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 99 /* ThisKeyword */: case 101 /* TrueKeyword */: case 97 /* SuperKeyword */: - case 208 /* NonNullExpression */: - case 209 /* MetaProperty */: + case 209 /* NonNullExpression */: + case 210 /* MetaProperty */: case 91 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: @@ -14273,13 +14325,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: - case 193 /* DeleteExpression */: - case 194 /* TypeOfExpression */: - case 195 /* VoidExpression */: - case 196 /* AwaitExpression */: - case 189 /* TypeAssertionExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: + case 194 /* DeleteExpression */: + case 195 /* TypeOfExpression */: + case 196 /* VoidExpression */: + case 197 /* AwaitExpression */: + case 190 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -14288,9 +14340,9 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return true; - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; default: @@ -14309,15 +14361,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 200 /* ConditionalExpression */: - case 202 /* YieldExpression */: - case 192 /* ArrowFunction */: - case 199 /* BinaryExpression */: - case 203 /* SpreadElement */: - case 207 /* AsExpression */: - case 205 /* OmittedExpression */: - case 301 /* CommaListExpression */: - case 300 /* PartiallyEmittedExpression */: + case 201 /* ConditionalExpression */: + case 203 /* YieldExpression */: + case 193 /* ArrowFunction */: + case 200 /* BinaryExpression */: + case 204 /* SpreadElement */: + case 208 /* AsExpression */: + case 206 /* OmittedExpression */: + case 302 /* CommaListExpression */: + case 301 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -14325,18 +14377,18 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 189 /* TypeAssertionExpression */ - || kind === 207 /* AsExpression */; + return kind === 190 /* TypeAssertionExpression */ + || kind === 208 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 300 /* PartiallyEmittedExpression */; + return node.kind === 301 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 299 /* NotEmittedStatement */; + return node.kind === 300 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ @@ -14347,13 +14399,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: return true; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14361,7 +14413,7 @@ var ts; ts.isIterationStatement = isIterationStatement; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 220 /* ForInStatement */ || node.kind === 221 /* ForOfStatement */; + return node.kind === 221 /* ForInStatement */ || node.kind === 222 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14385,113 +14437,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 239 /* ModuleBlock */ - || kind === 238 /* ModuleDeclaration */ + return kind === 240 /* ModuleBlock */ + || kind === 239 /* ModuleDeclaration */ || kind === 71 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 239 /* ModuleBlock */ - || kind === 238 /* ModuleDeclaration */; + return kind === 240 /* ModuleBlock */ + || kind === 239 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 /* Identifier */ - || kind === 238 /* ModuleDeclaration */; + || kind === 239 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 246 /* NamedImports */ - || kind === 245 /* NamespaceImport */; + return kind === 247 /* NamedImports */ + || kind === 246 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 238 /* ModuleDeclaration */ || node.kind === 237 /* EnumDeclaration */; + return node.kind === 239 /* ModuleDeclaration */ || node.kind === 238 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 192 /* ArrowFunction */ - || kind === 181 /* BindingElement */ - || kind === 234 /* ClassDeclaration */ - || kind === 204 /* ClassExpression */ - || kind === 154 /* Constructor */ - || kind === 237 /* EnumDeclaration */ - || kind === 272 /* EnumMember */ - || kind === 251 /* ExportSpecifier */ - || kind === 233 /* FunctionDeclaration */ - || kind === 191 /* FunctionExpression */ - || kind === 155 /* GetAccessor */ - || kind === 244 /* ImportClause */ - || kind === 242 /* ImportEqualsDeclaration */ - || kind === 247 /* ImportSpecifier */ - || kind === 235 /* InterfaceDeclaration */ - || kind === 261 /* JsxAttribute */ - || kind === 153 /* MethodDeclaration */ - || kind === 152 /* MethodSignature */ - || kind === 238 /* ModuleDeclaration */ - || kind === 241 /* NamespaceExportDeclaration */ - || kind === 245 /* NamespaceImport */ - || kind === 148 /* Parameter */ - || kind === 269 /* PropertyAssignment */ - || kind === 151 /* PropertyDeclaration */ - || kind === 150 /* PropertySignature */ - || kind === 156 /* SetAccessor */ - || kind === 270 /* ShorthandPropertyAssignment */ - || kind === 236 /* TypeAliasDeclaration */ - || kind === 147 /* TypeParameter */ - || kind === 231 /* VariableDeclaration */ - || kind === 296 /* JSDocTypedefTag */ - || kind === 291 /* JSDocCallbackTag */ - || kind === 297 /* JSDocPropertyTag */; + return kind === 193 /* ArrowFunction */ + || kind === 182 /* BindingElement */ + || kind === 235 /* ClassDeclaration */ + || kind === 205 /* ClassExpression */ + || kind === 155 /* Constructor */ + || kind === 238 /* EnumDeclaration */ + || kind === 273 /* EnumMember */ + || kind === 252 /* ExportSpecifier */ + || kind === 234 /* FunctionDeclaration */ + || kind === 192 /* FunctionExpression */ + || kind === 156 /* GetAccessor */ + || kind === 245 /* ImportClause */ + || kind === 243 /* ImportEqualsDeclaration */ + || kind === 248 /* ImportSpecifier */ + || kind === 236 /* InterfaceDeclaration */ + || kind === 262 /* JsxAttribute */ + || kind === 154 /* MethodDeclaration */ + || kind === 153 /* MethodSignature */ + || kind === 239 /* ModuleDeclaration */ + || kind === 242 /* NamespaceExportDeclaration */ + || kind === 246 /* NamespaceImport */ + || kind === 149 /* Parameter */ + || kind === 270 /* PropertyAssignment */ + || kind === 152 /* PropertyDeclaration */ + || kind === 151 /* PropertySignature */ + || kind === 157 /* SetAccessor */ + || kind === 271 /* ShorthandPropertyAssignment */ + || kind === 237 /* TypeAliasDeclaration */ + || kind === 148 /* TypeParameter */ + || kind === 232 /* VariableDeclaration */ + || kind === 297 /* JSDocTypedefTag */ + || kind === 292 /* JSDocCallbackTag */ + || kind === 298 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 233 /* FunctionDeclaration */ - || kind === 252 /* MissingDeclaration */ - || kind === 234 /* ClassDeclaration */ - || kind === 235 /* InterfaceDeclaration */ - || kind === 236 /* TypeAliasDeclaration */ - || kind === 237 /* EnumDeclaration */ - || kind === 238 /* ModuleDeclaration */ - || kind === 243 /* ImportDeclaration */ - || kind === 242 /* ImportEqualsDeclaration */ - || kind === 249 /* ExportDeclaration */ - || kind === 248 /* ExportAssignment */ - || kind === 241 /* NamespaceExportDeclaration */; + return kind === 234 /* FunctionDeclaration */ + || kind === 253 /* MissingDeclaration */ + || kind === 235 /* ClassDeclaration */ + || kind === 236 /* InterfaceDeclaration */ + || kind === 237 /* TypeAliasDeclaration */ + || kind === 238 /* EnumDeclaration */ + || kind === 239 /* ModuleDeclaration */ + || kind === 244 /* ImportDeclaration */ + || kind === 243 /* ImportEqualsDeclaration */ + || kind === 250 /* ExportDeclaration */ + || kind === 249 /* ExportAssignment */ + || kind === 242 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 223 /* BreakStatement */ - || kind === 222 /* ContinueStatement */ - || kind === 230 /* DebuggerStatement */ - || kind === 217 /* DoStatement */ - || kind === 215 /* ExpressionStatement */ - || kind === 214 /* EmptyStatement */ - || kind === 220 /* ForInStatement */ - || kind === 221 /* ForOfStatement */ - || kind === 219 /* ForStatement */ - || kind === 216 /* IfStatement */ - || kind === 227 /* LabeledStatement */ - || kind === 224 /* ReturnStatement */ - || kind === 226 /* SwitchStatement */ - || kind === 228 /* ThrowStatement */ - || kind === 229 /* TryStatement */ - || kind === 213 /* VariableStatement */ - || kind === 218 /* WhileStatement */ - || kind === 225 /* WithStatement */ - || kind === 299 /* NotEmittedStatement */ - || kind === 303 /* EndOfDeclarationMarker */ - || kind === 302 /* MergeDeclarationMarker */; + return kind === 224 /* BreakStatement */ + || kind === 223 /* ContinueStatement */ + || kind === 231 /* DebuggerStatement */ + || kind === 218 /* DoStatement */ + || kind === 216 /* ExpressionStatement */ + || kind === 215 /* EmptyStatement */ + || kind === 221 /* ForInStatement */ + || kind === 222 /* ForOfStatement */ + || kind === 220 /* ForStatement */ + || kind === 217 /* IfStatement */ + || kind === 228 /* LabeledStatement */ + || kind === 225 /* ReturnStatement */ + || kind === 227 /* SwitchStatement */ + || kind === 229 /* ThrowStatement */ + || kind === 230 /* TryStatement */ + || kind === 214 /* VariableStatement */ + || kind === 219 /* WhileStatement */ + || kind === 226 /* WithStatement */ + || kind === 300 /* NotEmittedStatement */ + || kind === 304 /* EndOfDeclarationMarker */ + || kind === 303 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 147 /* TypeParameter */) { - return node.parent.kind !== 295 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); + if (node.kind === 148 /* TypeParameter */) { + return node.parent.kind !== 296 /* JSDocTemplateTag */ || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -14518,10 +14570,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 212 /* Block */) + if (node.kind !== 213 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 229 /* TryStatement */ || node.parent.kind === 268 /* CatchClause */) { + if (node.parent.kind === 230 /* TryStatement */ || node.parent.kind === 269 /* CatchClause */) { return false; } } @@ -14531,8 +14583,8 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 253 /* ExternalModuleReference */ - || kind === 145 /* QualifiedName */ + return kind === 254 /* ExternalModuleReference */ + || kind === 146 /* QualifiedName */ || kind === 71 /* Identifier */; } ts.isModuleReference = isModuleReference; @@ -14542,76 +14594,78 @@ var ts; var kind = node.kind; return kind === 99 /* ThisKeyword */ || kind === 71 /* Identifier */ - || kind === 184 /* PropertyAccessExpression */; + || kind === 185 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 254 /* JsxElement */ - || kind === 264 /* JsxExpression */ - || kind === 255 /* JsxSelfClosingElement */ + return kind === 255 /* JsxElement */ + || kind === 265 /* JsxExpression */ + || kind === 256 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */ - || kind === 258 /* JsxFragment */; + || kind === 259 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 261 /* JsxAttribute */ - || kind === 263 /* JsxSpreadAttribute */; + return kind === 262 /* JsxAttribute */ + || kind === 264 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 264 /* JsxExpression */; + || kind === 265 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 256 /* JsxOpeningElement */ - || kind === 255 /* JsxSelfClosingElement */; + return kind === 257 /* JsxOpeningElement */ + || kind === 256 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 265 /* CaseClause */ - || kind === 266 /* DefaultClause */; + return kind === 266 /* CaseClause */ + || kind === 267 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 277 /* FirstJSDocNode */ && node.kind <= 297 /* LastJSDocNode */; + return node.kind >= 278 /* FirstJSDocNode */ && node.kind <= 298 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 285 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 286 /* JSDocComment */ || 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 >= 288 /* FirstJSDocTagNode */ && node.kind <= 297 /* LastJSDocTagNode */; + return node.kind >= 289 /* FirstJSDocTagNode */ && node.kind <= 298 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 156 /* SetAccessor */; + return node.kind === 157 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 155 /* GetAccessor */; + return node.kind === 156 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ /* @internal */ + // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times function hasJSDocNodes(node) { - return !!node.jsDoc && node.jsDoc.length > 0; + var jsDoc = node.jsDoc; + return !!jsDoc && jsDoc.length > 0; } ts.hasJSDocNodes = hasJSDocNodes; /** True if has type node attached to it. */ @@ -14624,36 +14678,36 @@ var ts; /* @internal */ function couldHaveType(node) { switch (node.kind) { - case 148 /* Parameter */: - case 150 /* PropertySignature */: - case 151 /* PropertyDeclaration */: - case 152 /* MethodSignature */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 160 /* TypePredicate */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 172 /* ParenthesizedType */: - case 174 /* TypeOperator */: - case 176 /* MappedType */: - case 189 /* TypeAssertionExpression */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 207 /* AsExpression */: - case 231 /* VariableDeclaration */: - case 233 /* FunctionDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 277 /* JSDocTypeExpression */: - case 280 /* JSDocNullableType */: - case 281 /* JSDocNonNullableType */: - case 282 /* JSDocOptionalType */: - case 283 /* JSDocFunctionType */: - case 284 /* JSDocVariadicType */: + case 149 /* Parameter */: + case 151 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 153 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 161 /* TypePredicate */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 173 /* ParenthesizedType */: + case 175 /* TypeOperator */: + case 177 /* MappedType */: + case 190 /* TypeAssertionExpression */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 208 /* AsExpression */: + case 232 /* VariableDeclaration */: + case 234 /* FunctionDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 278 /* JSDocTypeExpression */: + case 281 /* JSDocNullableType */: + case 282 /* JSDocNonNullableType */: + case 283 /* JSDocOptionalType */: + case 284 /* JSDocFunctionType */: + case 285 /* JSDocVariadicType */: return true; } return false; @@ -14673,13 +14727,13 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 261 /* JsxAttribute */: - case 263 /* JsxSpreadAttribute */: - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 262 /* JsxAttribute */: + case 264 /* JsxSpreadAttribute */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return true; default: return false; @@ -14688,7 +14742,7 @@ var ts; ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 161 /* TypeReference */ || node.kind === 206 /* ExpressionWithTypeArguments */; + return node.kind === 162 /* TypeReference */ || node.kind === 207 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14722,7 +14776,7 @@ var ts; ts.isStringLiteralLike = isStringLiteralLike; /** @internal */ function isNamedImportsOrExports(node) { - return node.kind === 246 /* NamedImports */ || node.kind === 250 /* NamedExports */; + return node.kind === 247 /* NamedImports */ || node.kind === 251 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; })(ts || (ts = {})); @@ -14745,7 +14799,7 @@ var ts; var SourceFileConstructor; // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 273 /* SourceFile */) { + if (kind === 274 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71 /* Identifier */) { @@ -14797,28 +14851,28 @@ 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 <= 144 /* LastToken */) { + if (!node || node.kind <= 145 /* LastToken */) { return; } switch (node.kind) { - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 148 /* Parameter */: + case 149 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -14826,7 +14880,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -14834,51 +14888,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150 /* PropertySignature */: + case 151 /* 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 269 /* PropertyAssignment */: + case 270 /* 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 231 /* VariableDeclaration */: + case 232 /* 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 181 /* BindingElement */: + case 182 /* 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 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* 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 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -14889,304 +14943,304 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 165 /* TypeLiteral */: + case 166 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 167 /* TupleType */: + case 168 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 168 /* UnionType */: - case 169 /* IntersectionType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 171 /* InferType */: + case 172 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 178 /* ImportType */: + case 179 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 172 /* ParenthesizedType */: - case 174 /* TypeOperator */: + case 173 /* ParenthesizedType */: + case 175 /* TypeOperator */: return visitNode(cbNode, node.type); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 176 /* MappedType */: + case 177 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 177 /* LiteralType */: + case 178 /* LiteralType */: return visitNode(cbNode, node.literal); - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 194 /* TypeOfExpression */: + case 195 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 207 /* AsExpression */: + case 208 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return visitNode(cbNode, node.name); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 212 /* Block */: - case 239 /* ModuleBlock */: + case 213 /* Block */: + case 240 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 273 /* SourceFile */: + case 274 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222 /* ContinueStatement */: - case 223 /* BreakStatement */: + case 223 /* ContinueStatement */: + case 224 /* BreakStatement */: return visitNode(cbNode, node.label); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 265 /* CaseClause */: + case 266 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 149 /* Decorator */: + case 150 /* Decorator */: return visitNode(cbNode, node.expression); - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* 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 235 /* InterfaceDeclaration */: + case 236 /* 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 236 /* TypeAliasDeclaration */: + case 237 /* 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 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 272 /* EnumMember */: + case 273 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 246 /* NamedImports */: - case 250 /* NamedExports */: + case 247 /* NamedImports */: + case 251 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 252 /* MissingDeclaration */: + case 253 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 254 /* JsxElement */: + case 255 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 255 /* JsxSelfClosingElement */: - case 256 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 263 /* JsxSpreadAttribute */: + case 264 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 277 /* JSDocTypeExpression */: + case 278 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 281 /* JSDocNonNullableType */: + case 282 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 280 /* JSDocNullableType */: + case 281 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 282 /* JSDocOptionalType */: + case 283 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 285 /* JSDocComment */: + case 286 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 292 /* JSDocParameterTag */: - case 297 /* JSDocPropertyTag */: + case 293 /* JSDocParameterTag */: + case 298 /* JSDocPropertyTag */: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -15195,17 +15249,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 293 /* JSDocReturnTag */: + case 294 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 294 /* JSDocTypeTag */: + case 295 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 289 /* JSDocAugmentsTag */: + case 290 /* JSDocAugmentsTag */: return visitNode(cbNode, node.class); - case 295 /* JSDocTemplateTag */: + case 296 /* JSDocTemplateTag */: return visitNodes(cbNode, cbNodes, node.typeParameters); - case 296 /* JSDocTypedefTag */: + case 297 /* JSDocTypedefTag */: if (node.typeExpression && - node.typeExpression.kind === 277 /* JSDocTypeExpression */) { + node.typeExpression.kind === 278 /* JSDocTypeExpression */) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -15213,16 +15267,16 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 291 /* JSDocCallbackTag */: + case 292 /* JSDocCallbackTag */: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 287 /* JSDocSignature */: + case 288 /* JSDocSignature */: 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 286 /* JSDocTypeLiteral */: + case 287 /* JSDocTypeLiteral */: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -15230,7 +15284,7 @@ var ts; } } return; - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -15278,6 +15332,7 @@ var ts; // becoming detached from any SourceFile). It is recommended that this SourceFile not // be used once 'update' is called on it. function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + if (aggressiveChecks === void 0) { aggressiveChecks = false; } var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. @@ -15403,6 +15458,7 @@ var ts; // attached to the EOF token. var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { + if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); if (scriptKind === 6 /* JSON */) { var result_1 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); @@ -15433,6 +15489,7 @@ var ts; initializeState(sourceText, languageVersion, syntaxCursor, 6 /* JSON */); // Set source file so that errors will be reported with this file name sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false); + sourceFile.flags = contextFlags; // Prime the scanner. nextToken(); var pos = getNodePos(); @@ -15441,7 +15498,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(215 /* ExpressionStatement */); + var statement = createNode(216 /* ExpressionStatement */); switch (token()) { case 21 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); @@ -15600,10 +15657,11 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(273 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(274 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; + sourceFile.bindSuggestionDiagnostics = undefined; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); sourceFile.languageVariant = getLanguageVariant(scriptKind); @@ -15987,7 +16045,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(146 /* ComputedPropertyName */); + var node = createNode(147 /* ComputedPropertyName */); parseExpected(21 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -16124,7 +16182,7 @@ var ts; case 14 /* JsxChildren */: return true; } - ts.Debug.fail("Non-exhaustive case in 'isListElement'."); + return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { ts.Debug.assert(token() === 17 /* OpenBraceToken */); @@ -16213,6 +16271,8 @@ var ts; return token() === 29 /* GreaterThanToken */ || token() === 41 /* SlashToken */; case 14 /* JsxChildren */: return token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + default: + return false; } } function isVariableDeclaratorListTerminator() { @@ -16399,14 +16459,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 154 /* Constructor */: - case 159 /* IndexSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 151 /* PropertyDeclaration */: - case 211 /* SemicolonClassElement */: + case 155 /* Constructor */: + case 160 /* IndexSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 212 /* SemicolonClassElement */: return true; - case 153 /* MethodDeclaration */: + case 154 /* 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. @@ -16421,8 +16481,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: return true; } } @@ -16431,58 +16491,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 213 /* VariableStatement */: - case 212 /* Block */: - case 216 /* IfStatement */: - case 215 /* ExpressionStatement */: - case 228 /* ThrowStatement */: - case 224 /* ReturnStatement */: - case 226 /* SwitchStatement */: - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 219 /* ForStatement */: - case 218 /* WhileStatement */: - case 225 /* WithStatement */: - case 214 /* EmptyStatement */: - case 229 /* TryStatement */: - case 227 /* LabeledStatement */: - case 217 /* DoStatement */: - case 230 /* DebuggerStatement */: - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 249 /* ExportDeclaration */: - case 248 /* ExportAssignment */: - case 238 /* ModuleDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 234 /* FunctionDeclaration */: + case 214 /* VariableStatement */: + case 213 /* Block */: + case 217 /* IfStatement */: + case 216 /* ExpressionStatement */: + case 229 /* ThrowStatement */: + case 225 /* ReturnStatement */: + case 227 /* SwitchStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 220 /* ForStatement */: + case 219 /* WhileStatement */: + case 226 /* WithStatement */: + case 215 /* EmptyStatement */: + case 230 /* TryStatement */: + case 228 /* LabeledStatement */: + case 218 /* DoStatement */: + case 231 /* DebuggerStatement */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 250 /* ExportDeclaration */: + case 249 /* ExportAssignment */: + case 239 /* ModuleDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 272 /* EnumMember */; + return node.kind === 273 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 158 /* ConstructSignature */: - case 152 /* MethodSignature */: - case 159 /* IndexSignature */: - case 150 /* PropertySignature */: - case 157 /* CallSignature */: + case 159 /* ConstructSignature */: + case 153 /* MethodSignature */: + case 160 /* IndexSignature */: + case 151 /* PropertySignature */: + case 158 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 231 /* VariableDeclaration */) { + if (node.kind !== 232 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -16503,7 +16563,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 148 /* Parameter */) { + if (node.kind !== 149 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -16544,6 +16604,7 @@ var ts; case 22 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; case 13 /* JsxAttributes */: return ts.Diagnostics.Identifier_expected; case 14 /* JsxChildren */: return ts.Diagnostics.Identifier_expected; + default: return undefined; // TODO: GH#18217 `default: Debug.assertNever(context);` } } // Parses a comma-delimited list of elements @@ -16632,7 +16693,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(145 /* QualifiedName */, entity.pos); + var node = createNode(146 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -16669,19 +16730,19 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(201 /* TemplateExpression */); + var template = createNode(202 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); var list = []; var listPos = getNodePos(); do { list.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(list).literal.kind === 15 /* TemplateMiddle */); + } while (ts.last(list).literal.kind === 15 /* TemplateMiddle */); template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { - var span = createNode(210 /* TemplateSpan */); + var span = createNode(211 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18 /* CloseBraceToken */) { @@ -16732,7 +16793,7 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(161 /* TypeReference */); + var node = createNode(162 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token() === 27 /* LessThanToken */) { node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */); @@ -16741,20 +16802,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(160 /* TypePredicate */, lhs.pos); + var node = createNode(161 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(173 /* ThisType */); + var node = createNode(174 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(278 /* JSDocAllType */); + var result = createNode(279 /* JSDocAllType */); if (postFixEquals) { - return createJSDocPostfixType(282 /* JSDocOptionalType */, result); + return createJSDocPostfixType(283 /* JSDocOptionalType */, result); } else { nextToken(); @@ -16762,7 +16823,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(281 /* JSDocNonNullableType */); + var result = createNode(282 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -16786,28 +16847,28 @@ var ts; token() === 29 /* GreaterThanToken */ || token() === 58 /* EqualsToken */ || token() === 49 /* BarToken */) { - var result = createNode(279 /* JSDocUnknownType */, pos); + var result = createNode(280 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(280 /* JSDocNullableType */, pos); + var result = createNode(281 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(283 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(284 /* JSDocFunctionType */); nextToken(); fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(161 /* TypeReference */); + var node = createNode(162 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(148 /* Parameter */); + var parameter = createNode(149 /* Parameter */); if (token() === 99 /* ThisKeyword */ || token() === 94 /* NewKeyword */) { parameter.name = parseIdentifierName(); parseExpected(56 /* ColonToken */); @@ -16819,23 +16880,23 @@ var ts; var dotdotdot = parseOptionalToken(24 /* DotDotDotToken */); var type = parseType(); if (dotdotdot) { - var variadic = createNode(284 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(285 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58 /* EqualsToken */) { - return createJSDocPostfixType(282 /* JSDocOptionalType */, type); + return createJSDocPostfixType(283 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(164 /* TypeQuery */); + var node = createNode(165 /* TypeQuery */); parseExpected(103 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(147 /* TypeParameter */); + var node = createNode(148 /* TypeParameter */); node.name = parseIdentifier(); if (parseOptional(85 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the @@ -16880,7 +16941,7 @@ var ts; isStartOfType(/*inStartOfParameter*/ true); } function parseParameter() { - var node = createNodeWithJSDoc(148 /* Parameter */); + var node = createNodeWithJSDoc(149 /* Parameter */); if (token() === 99 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); @@ -16915,7 +16976,7 @@ var ts; if (!(flags & 32 /* JSDoc */)) { signature.typeParameters = parseTypeParameters(); } - signature.parameters = parseParameterList(flags); + signature.parameters = parseParameterList(flags); // TODO: GH#18217 if (shouldParseReturnType(returnToken, !!(flags & 4 /* Type */))) { signature.type = parseTypeOrTypePredicate(); return signature.type !== undefined; @@ -16983,7 +17044,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 158 /* ConstructSignature */) { + if (kind === 159 /* ConstructSignature */) { parseExpected(94 /* NewKeyword */); } fillSignature(56 /* ColonToken */, 4 /* Type */, node); @@ -17044,7 +17105,7 @@ var ts; return token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 22 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 159 /* IndexSignature */; + node.kind = 160 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -17054,13 +17115,13 @@ var ts; node.name = parsePropertyName(); node.questionToken = parseOptionalToken(55 /* QuestionToken */); if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - node.kind = 152 /* MethodSignature */; + node.kind = 153 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] fillSignature(56 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 150 /* PropertySignature */; + node.kind = 151 /* PropertySignature */; node.type = parseTypeAnnotation(); if (token() === 58 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt @@ -17077,7 +17138,7 @@ var ts; if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { return true; } - var idToken; + var idToken = false; // Eat up all modifiers, but hold on to the last one in case it is actually an identifier while (ts.isModifierKind(token())) { idToken = true; @@ -17106,10 +17167,10 @@ var ts; } function parseTypeMember() { if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { - return parseSignatureMember(157 /* CallSignature */); + return parseSignatureMember(158 /* CallSignature */); } if (token() === 94 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(158 /* ConstructSignature */); + return parseSignatureMember(159 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -17135,7 +17196,7 @@ var ts; return false; } function parseTypeLiteral() { - var node = createNode(165 /* TypeLiteral */); + var node = createNode(166 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -17161,14 +17222,14 @@ var ts; return token() === 21 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 92 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(147 /* TypeParameter */); + var node = createNode(148 /* TypeParameter */); node.name = parseIdentifier(); parseExpected(92 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(176 /* MappedType */); + var node = createNode(177 /* MappedType */); parseExpected(17 /* OpenBraceToken */); if (token() === 132 /* ReadonlyKeyword */ || token() === 37 /* PlusToken */ || token() === 38 /* MinusToken */) { node.readonlyToken = parseTokenNode(); @@ -17191,23 +17252,23 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(167 /* TupleType */); + var node = createNode(168 /* TupleType */); node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(172 /* ParenthesizedType */); + var node = createNode(173 /* ParenthesizedType */); parseExpected(19 /* OpenParenToken */); node.type = parseType(); if (!node.type) { - return undefined; + return undefined; // TODO: GH#18217 } parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 163 /* ConstructorType */) { + if (kind === 164 /* ConstructorType */) { parseExpected(94 /* NewKeyword */); } if (!fillSignature(36 /* EqualsGreaterThanToken */, 4 /* Type */ | (sourceFile.languageVariant === 1 /* JSX */ ? 8 /* RequireCompleteParameterList */ : 0), node)) { @@ -17223,10 +17284,10 @@ var ts; return token() === 23 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(177 /* LiteralType */); + var node = createNode(178 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(197 /* PrefixUnaryExpression */); + unaryMinusExpression = createNode(198 /* PrefixUnaryExpression */); unaryMinusExpression.operator = 38 /* MinusToken */; nextToken(); } @@ -17247,7 +17308,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(178 /* ImportType */); + var node = createNode(179 /* ImportType */); if (parseOptional(103 /* TypeOfKeyword */)) { node.isTypeOf = true; } @@ -17267,6 +17328,7 @@ var ts; function parseNonArrayType() { switch (token()) { case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 137 /* StringKeyword */: case 134 /* NumberKeyword */: case 138 /* SymbolKeyword */: @@ -17323,6 +17385,7 @@ var ts; function isStartOfType(inStartOfParameter) { switch (token()) { case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 137 /* StringKeyword */: case 134 /* NumberKeyword */: case 122 /* BooleanKeyword */: @@ -17371,26 +17434,26 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51 /* ExclamationToken */: - type = createJSDocPostfixType(281 /* JSDocNonNullableType */, type); + type = createJSDocPostfixType(282 /* JSDocNonNullableType */, type); break; case 55 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createJSDocPostfixType(280 /* JSDocNullableType */, type); + type = createJSDocPostfixType(281 /* JSDocNullableType */, type); break; case 21 /* OpenBracketToken */: parseExpected(21 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(175 /* IndexedAccessType */, type.pos); + var node = createNode(176 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(166 /* ArrayType */, type.pos); + var node = createNode(167 /* ArrayType */, type.pos); node.elementType = type; parseExpected(22 /* CloseBracketToken */); type = finishNode(node); @@ -17409,16 +17472,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(174 /* TypeOperator */); + var node = createNode(175 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(171 /* InferType */); + var node = createNode(172 /* InferType */); parseExpected(126 /* InferKeyword */); - var typeParameter = createNode(147 /* TypeParameter */); + var typeParameter = createNode(148 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -17449,10 +17512,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(169 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); + return parseUnionOrIntersectionType(170 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(168 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); + return parseUnionOrIntersectionType(169 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); } function isStartOfFunctionType() { if (token() === 27 /* LessThanToken */) { @@ -17509,7 +17572,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(160 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(161 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -17532,14 +17595,14 @@ var ts; } function parseTypeWorker(noConditionalTypes) { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(162 /* FunctionType */); + return parseFunctionOrConstructorType(163 /* FunctionType */); // TODO: GH#18217 } if (token() === 94 /* NewKeyword */) { - return parseFunctionOrConstructorType(163 /* ConstructorType */); + return parseFunctionOrConstructorType(164 /* ConstructorType */); } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85 /* ExtendsKeyword */)) { - var node = createNode(170 /* ConditionalType */, type.pos); + var node = createNode(171 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); @@ -17732,7 +17795,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(202 /* YieldExpression */); + var node = createNode(203 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] @@ -17754,13 +17817,13 @@ var ts; ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(192 /* ArrowFunction */, asyncModifier.pos); + node = createNode(193 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(192 /* ArrowFunction */, identifier.pos); + node = createNode(193 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(148 /* Parameter */, identifier.pos); + var parameter = createNode(149 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); @@ -17956,7 +18019,7 @@ var ts; return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(192 /* ArrowFunction */); + var node = createNodeWithJSDoc(193 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -18024,7 +18087,7 @@ var ts; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(200 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(201 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -18039,7 +18102,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 92 /* InKeyword */ || t === 144 /* OfKeyword */; + return t === 92 /* InKeyword */ || t === 145 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -18104,39 +18167,39 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(199 /* BinaryExpression */, left.pos); + var node = createNode(200 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(207 /* AsExpression */, left.pos); + var node = createNode(208 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(197 /* PrefixUnaryExpression */); + var node = createNode(198 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(193 /* DeleteExpression */); + var node = createNode(194 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(194 /* TypeOfExpression */); + var node = createNode(195 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(195 /* VoidExpression */); + var node = createNode(196 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18152,7 +18215,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(196 /* AwaitExpression */); + var node = createNode(197 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -18196,7 +18259,7 @@ var ts; if (token() === 40 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 189 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 190 /* 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 { @@ -18293,7 +18356,7 @@ var ts; */ function parseUpdateExpression() { if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { - var node = createNode(197 /* PrefixUnaryExpression */); + var node = createNode(198 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -18306,7 +18369,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(198 /* PostfixUnaryExpression */, expression.pos); + var node = createNode(199 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -18362,7 +18425,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(209 /* MetaProperty */, fullStart); + var node = createNode(210 /* MetaProperty */, fullStart); node.keywordToken = 91 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); @@ -18437,33 +18500,17 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(184 /* PropertyAccessExpression */, expression.pos); + var node = createNode(185 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(23 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } - function tagNamesAreEquivalent(lhs, rhs) { - if (lhs.kind !== rhs.kind) { - return false; - } - if (lhs.kind === 71 /* Identifier */) { - return lhs.escapedText === rhs.escapedText; - } - if (lhs.kind === 99 /* ThisKeyword */) { - return true; - } - // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only - // take forms of JsxTagNameExpression which includes an identifier, "this" expression, or another propertyAccessExpression - // it is safe to case the expression property as such. See parseJsxElementName for how we parse tag name in Jsx element - return lhs.name.escapedText === rhs.name.escapedText && - tagNamesAreEquivalent(lhs.expression, rhs.expression); - } function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 256 /* JsxOpeningElement */) { - var node = createNode(254 /* JsxElement */, opening.pos); + if (opening.kind === 257 /* JsxOpeningElement */) { + var node = createNode(255 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -18472,15 +18519,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 259 /* JsxOpeningFragment */) { - var node = createNode(258 /* JsxFragment */, opening.pos); + else if (opening.kind === 260 /* JsxOpeningFragment */) { + var node = createNode(259 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 255 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 256 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -18495,11 +18542,11 @@ var ts; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(199 /* BinaryExpression */, result.pos); + var badNode = createNode(200 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(26 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); + badNode.operatorToken = createMissingNode(26 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); // TODO: GH#18217 badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -18553,7 +18600,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(262 /* JsxAttributes */); + var jsxAttributes = createNode(263 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -18562,7 +18609,7 @@ var ts; parseExpected(27 /* LessThanToken */); if (token() === 29 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(259 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(260 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -18574,7 +18621,7 @@ var ts; // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(256 /* JsxOpeningElement */, fullStart); + node = createNode(257 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { @@ -18586,7 +18633,7 @@ var ts; parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(255 /* JsxSelfClosingElement */, fullStart); + node = createNode(256 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -18603,7 +18650,7 @@ var ts; var expression = token() === 99 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23 /* DotToken */)) { - var propertyAccess = createNode(184 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18611,7 +18658,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(264 /* JsxExpression */); + var node = createNode(265 /* JsxExpression */); if (!parseExpected(17 /* OpenBraceToken */)) { return undefined; } @@ -18633,7 +18680,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(261 /* JsxAttribute */); + var node = createNode(262 /* JsxAttribute */); node.name = parseIdentifierName(); if (token() === 58 /* EqualsToken */) { switch (scanJsxAttributeValue()) { @@ -18648,7 +18695,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(263 /* JsxSpreadAttribute */); + var node = createNode(264 /* JsxSpreadAttribute */); parseExpected(17 /* OpenBraceToken */); parseExpected(24 /* DotDotDotToken */); node.expression = parseExpression(); @@ -18656,7 +18703,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(257 /* JsxClosingElement */); + var node = createNode(258 /* JsxClosingElement */); parseExpected(28 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -18669,7 +18716,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(260 /* JsxClosingFragment */); + var node = createNode(261 /* JsxClosingFragment */); parseExpected(28 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -18684,7 +18731,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(189 /* TypeAssertionExpression */); + var node = createNode(190 /* TypeAssertionExpression */); parseExpected(27 /* LessThanToken */); node.type = parseType(); parseExpected(29 /* GreaterThanToken */); @@ -18695,7 +18742,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(184 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(185 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -18703,14 +18750,14 @@ var ts; } if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(208 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(209 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(21 /* OpenBracketToken */)) { - var indexedAccess = createNode(185 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(186 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; if (token() === 22 /* CloseBracketToken */) { indexedAccess.argumentExpression = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -18737,7 +18784,7 @@ var ts; return token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(188 /* TaggedTemplateExpression */, tag.pos); + var tagExpression = createNode(189 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ @@ -18761,7 +18808,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(186 /* CallExpression */, expression.pos); + var callExpr = createNode(187 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -18769,7 +18816,7 @@ var ts; continue; } else if (token() === 19 /* OpenParenToken */) { - var callExpr = createNode(186 /* CallExpression */, expression.pos); + var callExpr = createNode(187 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -18881,28 +18928,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(190 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(191 /* ParenthesizedExpression */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(203 /* SpreadElement */); + var node = createNode(204 /* SpreadElement */); parseExpected(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 26 /* CommaToken */ ? createNode(205 /* OmittedExpression */) : + token() === 26 /* CommaToken */ ? createNode(206 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(182 /* ArrayLiteralExpression */); + var node = createNode(183 /* ArrayLiteralExpression */); parseExpected(21 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -18914,17 +18961,17 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(24 /* DotDotDotToken */)) { - node.kind = 271 /* SpreadAssignment */; + node.kind = 272 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 155 /* GetAccessor */); + return parseAccessorDeclaration(node, 156 /* GetAccessor */); } if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* SetAccessor */); + return parseAccessorDeclaration(node, 157 /* SetAccessor */); } var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); @@ -18941,7 +18988,7 @@ var ts; // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */); if (isShorthandPropertyAssignment) { - node.kind = 270 /* ShorthandPropertyAssignment */; + node.kind = 271 /* ShorthandPropertyAssignment */; var equalsToken = parseOptionalToken(58 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; @@ -18949,14 +18996,14 @@ var ts; } } else { - node.kind = 269 /* PropertyAssignment */; + node.kind = 270 /* PropertyAssignment */; parseExpected(56 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(183 /* ObjectLiteralExpression */); + var node = createNode(184 /* ObjectLiteralExpression */); parseExpected(17 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -18975,7 +19022,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(191 /* FunctionExpression */); + var node = createNodeWithJSDoc(192 /* FunctionExpression */); node.modifiers = parseModifiers(); parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); @@ -19000,7 +19047,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94 /* NewKeyword */); if (parseOptional(23 /* DotToken */)) { - var node_2 = createNode(209 /* MetaProperty */, fullStart); + var node_2 = createNode(210 /* MetaProperty */, fullStart); node_2.keywordToken = 94 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -19017,7 +19064,7 @@ var ts; } break; } - var node = createNode(187 /* NewExpression */, fullStart); + var node = createNode(188 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19 /* OpenParenToken */) { @@ -19027,7 +19074,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(212 /* Block */); + var node = createNode(213 /* Block */); if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -19060,12 +19107,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(214 /* EmptyStatement */); + var node = createNode(215 /* EmptyStatement */); parseExpected(25 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(216 /* IfStatement */); + var node = createNode(217 /* IfStatement */); parseExpected(90 /* IfKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19075,7 +19122,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(217 /* DoStatement */); + var node = createNode(218 /* DoStatement */); parseExpected(81 /* DoKeyword */); node.statement = parseStatement(); parseExpected(106 /* WhileKeyword */); @@ -19090,7 +19137,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(218 /* WhileStatement */); + var node = createNode(219 /* WhileStatement */); parseExpected(106 /* WhileKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19113,8 +19160,8 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(144 /* OfKeyword */) : parseOptional(144 /* OfKeyword */)) { - var forOfStatement = createNode(221 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(145 /* OfKeyword */) : parseOptional(145 /* OfKeyword */)) { + var forOfStatement = createNode(222 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -19122,14 +19169,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92 /* InKeyword */)) { - var forInStatement = createNode(220 /* ForInStatement */, pos); + var forInStatement = createNode(221 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(219 /* ForStatement */, pos); + var forStatement = createNode(220 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(25 /* SemicolonToken */); if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { @@ -19147,7 +19194,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 223 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); + parseExpected(kind === 224 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -19155,7 +19202,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(224 /* ReturnStatement */); + var node = createNode(225 /* ReturnStatement */); parseExpected(96 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -19164,7 +19211,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(225 /* WithStatement */); + var node = createNode(226 /* WithStatement */); parseExpected(107 /* WithKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); @@ -19173,7 +19220,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(265 /* CaseClause */); + var node = createNode(266 /* CaseClause */); parseExpected(73 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); parseExpected(56 /* ColonToken */); @@ -19181,7 +19228,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(266 /* DefaultClause */); + var node = createNode(267 /* DefaultClause */); parseExpected(79 /* DefaultKeyword */); parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); @@ -19191,12 +19238,12 @@ var ts; return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(226 /* SwitchStatement */); + var node = createNode(227 /* SwitchStatement */); parseExpected(98 /* SwitchKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(20 /* CloseParenToken */); - var caseBlock = createNode(240 /* CaseBlock */); + var caseBlock = createNode(241 /* CaseBlock */); parseExpected(17 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(18 /* CloseBraceToken */); @@ -19211,7 +19258,7 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(228 /* ThrowStatement */); + var node = createNode(229 /* ThrowStatement */); parseExpected(100 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); @@ -19219,7 +19266,7 @@ var ts; } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(229 /* TryStatement */); + var node = createNode(230 /* TryStatement */); parseExpected(102 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; @@ -19232,7 +19279,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(268 /* CatchClause */); + var result = createNode(269 /* CatchClause */); parseExpected(74 /* CatchKeyword */); if (parseOptional(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); @@ -19246,7 +19293,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(230 /* DebuggerStatement */); + var node = createNode(231 /* DebuggerStatement */); parseExpected(78 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); @@ -19258,12 +19305,12 @@ var ts; var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { - node.kind = 227 /* LabeledStatement */; + node.kind = 228 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 215 /* ExpressionStatement */; + node.kind = 216 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -19335,7 +19382,7 @@ var ts; return false; } continue; - case 143 /* GlobalKeyword */: + case 144 /* GlobalKeyword */: nextToken(); return token() === 17 /* OpenBraceToken */ || token() === 71 /* Identifier */ || token() === 84 /* ExportKeyword */; case 91 /* ImportKeyword */: @@ -19399,7 +19446,7 @@ var ts; case 129 /* ModuleKeyword */: case 130 /* NamespaceKeyword */: case 139 /* TypeKeyword */: - case 143 /* GlobalKeyword */: + case 144 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; case 114 /* PublicKeyword */: @@ -19430,16 +19477,16 @@ var ts; case 17 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); case 104 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(231 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); case 110 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(231 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(232 /* VariableDeclaration */)); } break; case 89 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(233 /* FunctionDeclaration */)); + return parseFunctionDeclaration(createNodeWithJSDoc(234 /* FunctionDeclaration */)); case 75 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(234 /* ClassDeclaration */)); + return parseClassDeclaration(createNodeWithJSDoc(235 /* ClassDeclaration */)); case 90 /* IfKeyword */: return parseIfStatement(); case 81 /* DoKeyword */: @@ -19449,9 +19496,9 @@ var ts; case 88 /* ForKeyword */: return parseForOrForInOrForOfStatement(); case 77 /* ContinueKeyword */: - return parseBreakOrContinueStatement(222 /* ContinueStatement */); + return parseBreakOrContinueStatement(223 /* ContinueStatement */); case 72 /* BreakKeyword */: - return parseBreakOrContinueStatement(223 /* BreakStatement */); + return parseBreakOrContinueStatement(224 /* BreakStatement */); case 96 /* ReturnKeyword */: return parseReturnStatement(); case 107 /* WithKeyword */: @@ -19485,7 +19532,7 @@ var ts; case 117 /* AbstractKeyword */: case 115 /* StaticKeyword */: case 132 /* ReadonlyKeyword */: - case 143 /* GlobalKeyword */: + case 144 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -19527,7 +19574,7 @@ var ts; return parseTypeAliasDeclaration(node); case 83 /* EnumKeyword */: return parseEnumDeclaration(node); - case 143 /* GlobalKeyword */: + case 144 /* GlobalKeyword */: case 129 /* ModuleKeyword */: case 130 /* NamespaceKeyword */: return parseModuleDeclaration(node); @@ -19548,12 +19595,13 @@ var ts; if (node.decorators || node.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(252 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(253 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; return finishNode(missing); } + return undefined; // TODO: GH#18217 } } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { @@ -19570,16 +19618,16 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 26 /* CommaToken */) { - return createNode(205 /* OmittedExpression */); + return createNode(206 /* OmittedExpression */); } - var node = createNode(181 /* BindingElement */); + var node = createNode(182 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(181 /* BindingElement */); + var node = createNode(182 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -19595,14 +19643,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(179 /* ObjectBindingPattern */); + var node = createNode(180 /* ObjectBindingPattern */); parseExpected(17 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(180 /* ArrayBindingPattern */); + var node = createNode(181 /* ArrayBindingPattern */); parseExpected(21 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(22 /* CloseBracketToken */); @@ -19624,7 +19672,7 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(231 /* VariableDeclaration */); + var node = createNode(232 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 /* Identifier */ && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { @@ -19637,7 +19685,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(232 /* VariableDeclarationList */); + var node = createNode(233 /* VariableDeclarationList */); switch (token()) { case 104 /* VarKeyword */: break; @@ -19660,7 +19708,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 144 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 145 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -19675,13 +19723,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 213 /* VariableStatement */; + node.kind = 214 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 233 /* FunctionDeclaration */; + node.kind = 234 /* FunctionDeclaration */; parseExpected(89 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); @@ -19692,14 +19740,14 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(node) { - node.kind = 154 /* Constructor */; + node.kind = 155 /* Constructor */; parseExpected(123 /* ConstructorKeyword */); fillSignature(56 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 153 /* MethodDeclaration */; + node.kind = 154 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; @@ -19708,7 +19756,7 @@ var ts; return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 151 /* PropertyDeclaration */; + node.kind = 152 /* PropertyDeclaration */; if (!node.questionToken && token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } @@ -19813,7 +19861,7 @@ var ts; if (!parseOptional(57 /* AtToken */)) { break; } - var decorator = createNode(149 /* Decorator */, decoratorStart); + var decorator = createNode(150 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -19863,7 +19911,7 @@ var ts; } function parseClassElement() { if (token() === 25 /* SemicolonToken */) { - var result = createNode(211 /* SemicolonClassElement */); + var result = createNode(212 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -19871,10 +19919,10 @@ var ts; node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); if (parseContextualModifier(125 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 155 /* GetAccessor */); + return parseAccessorDeclaration(node, 156 /* GetAccessor */); } if (parseContextualModifier(136 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 156 /* SetAccessor */); + return parseAccessorDeclaration(node, 157 /* SetAccessor */); } if (token() === 123 /* ConstructorKeyword */) { return parseConstructorDeclaration(node); @@ -19897,13 +19945,13 @@ var ts; return parsePropertyDeclaration(node); } // 'isClassMemberStart' should have hinted not to attempt parsing. - ts.Debug.fail("Should not have attempted to parse class member declaration."); + return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 204 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 205 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 234 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 235 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -19945,17 +19993,15 @@ var ts; } function parseHeritageClause() { var tok = token(); - if (tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */) { - var node = createNode(267 /* HeritageClause */); - node.token = tok; - nextToken(); - node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); - return finishNode(node); - } - return undefined; + ts.Debug.assert(tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(268 /* HeritageClause */); + node.token = tok; + nextToken(); + node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(206 /* ExpressionWithTypeArguments */); + var node = createNode(207 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -19972,7 +20018,7 @@ var ts; return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 235 /* InterfaceDeclaration */; + node.kind = 236 /* InterfaceDeclaration */; parseExpected(109 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -19981,7 +20027,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 236 /* TypeAliasDeclaration */; + node.kind = 237 /* TypeAliasDeclaration */; parseExpected(139 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -19995,13 +20041,13 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(272 /* EnumMember */); + var node = createNodeWithJSDoc(273 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 237 /* EnumDeclaration */; + node.kind = 238 /* EnumDeclaration */; parseExpected(83 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(17 /* OpenBraceToken */)) { @@ -20014,7 +20060,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(239 /* ModuleBlock */); + var node = createNode(240 /* ModuleBlock */); if (parseExpected(17 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(18 /* CloseBraceToken */); @@ -20025,7 +20071,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 238 /* ModuleDeclaration */; + node.kind = 239 /* ModuleDeclaration */; // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -20037,8 +20083,8 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 238 /* ModuleDeclaration */; - if (token() === 143 /* GlobalKeyword */) { + node.kind = 239 /* ModuleDeclaration */; + if (token() === 144 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -20057,7 +20103,7 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 143 /* GlobalKeyword */) { + if (token() === 144 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } @@ -20083,7 +20129,7 @@ var ts; return nextToken() === 41 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 241 /* NamespaceExportDeclaration */; + node.kind = 242 /* NamespaceExportDeclaration */; parseExpected(118 /* AsKeyword */); parseExpected(130 /* NamespaceKeyword */); node.name = parseIdentifier(); @@ -20096,12 +20142,12 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 26 /* CommaToken */ && token() !== 142 /* FromKeyword */) { + if (token() !== 26 /* CommaToken */ && token() !== 143 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 243 /* ImportDeclaration */; + node.kind = 244 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; @@ -20109,14 +20155,14 @@ var ts; token() === 39 /* AsteriskToken */ || // import * token() === 17 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(142 /* FromKeyword */); + parseExpected(143 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 242 /* ImportEqualsDeclaration */; + node.kind = 243 /* ImportEqualsDeclaration */; node.name = identifier; parseExpected(58 /* EqualsToken */); node.moduleReference = parseModuleReference(); @@ -20130,7 +20176,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(244 /* ImportClause */, fullStart); + var importClause = createNode(245 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -20140,7 +20186,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(26 /* CommaToken */)) { - importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(246 /* NamedImports */); + importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(247 /* NamedImports */); } return finishNode(importClause); } @@ -20150,7 +20196,7 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(253 /* ExternalModuleReference */); + var node = createNode(254 /* ExternalModuleReference */); parseExpected(133 /* RequireKeyword */); parseExpected(19 /* OpenParenToken */); node.expression = parseModuleSpecifier(); @@ -20173,7 +20219,7 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(245 /* NamespaceImport */); + var namespaceImport = createNode(246 /* NamespaceImport */); parseExpected(39 /* AsteriskToken */); parseExpected(118 /* AsKeyword */); namespaceImport.name = parseIdentifier(); @@ -20188,14 +20234,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 246 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 247 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(251 /* ExportSpecifier */); + return parseImportOrExportSpecifier(252 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(247 /* ImportSpecifier */); + return parseImportOrExportSpecifier(248 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -20220,24 +20266,24 @@ var ts; else { node.name = identifierName; } - if (kind === 247 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 248 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 249 /* ExportDeclaration */; + node.kind = 250 /* ExportDeclaration */; if (parseOptional(39 /* AsteriskToken */)) { - parseExpected(142 /* FromKeyword */); + parseExpected(143 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(250 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(251 /* 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() === 142 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(142 /* FromKeyword */); + if (token() === 143 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(143 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -20245,7 +20291,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 248 /* ExportAssignment */; + node.kind = 249 /* ExportAssignment */; if (parseOptional(58 /* EqualsToken */)) { node.isExportEquals = true; } @@ -20265,10 +20311,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 242 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 253 /* ExternalModuleReference */ - || node.kind === 243 /* ImportDeclaration */ - || node.kind === 248 /* ExportAssignment */ - || node.kind === 249 /* ExportDeclaration */ + || node.kind === 243 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 254 /* ExternalModuleReference */ + || node.kind === 244 /* ImportDeclaration */ + || node.kind === 249 /* ExportAssignment */ + || node.kind === 250 /* ExportDeclaration */ ? node : undefined; } @@ -20331,7 +20377,7 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(277 /* JSDocTypeExpression */, scanner.getTokenPos()); + var result = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17 /* OpenBraceToken */); result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -20384,8 +20430,8 @@ var ts; PropertyLikeParse[PropertyLikeParse["CallbackParameter"] = 4] = "CallbackParameter"; })(PropertyLikeParse || (PropertyLikeParse = {})); function parseJSDocCommentWorker(start, length) { + if (start === void 0) { start = 0; } var content = sourceText; - start = start || 0; var end = length === undefined ? content.length : start + length; length = end - start; ts.Debug.assert(start >= 0); @@ -20415,17 +20461,15 @@ var ts; comments.push(text); indent += text.length; } - var t = nextJSDocToken(); - while (t === 5 /* WhitespaceTrivia */) { - t = nextJSDocToken(); - } - if (t === 4 /* NewLineTrivia */) { + nextJSDocToken(); + while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) + ; + if (parseOptionalJsdoc(4 /* NewLineTrivia */)) { state = 0 /* BeginningOfLine */; indent = 0; - t = nextJSDocToken(); } loop: while (true) { - switch (t) { + switch (token()) { case 57 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingNewlines(comments); @@ -20485,7 +20529,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - t = nextJSDocToken(); + nextJSDocToken(); } removeLeadingNewlines(comments); removeTrailingNewlines(comments); @@ -20503,7 +20547,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(285 /* JSDocComment */, start); + var result = createNode(286 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -20650,7 +20694,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(288 /* JSDocTag */, atToken.pos); + var result = createNode(289 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -20694,7 +20738,7 @@ var ts; switch (node.kind) { case 135 /* ObjectKeyword */: return true; - case 166 /* ArrayType */: + case 167 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -20710,12 +20754,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(297 /* JSDocPropertyTag */, atToken.pos) : - createNode(292 /* JSDocParameterTag */, atToken.pos); + createNode(298 /* JSDocPropertyTag */, atToken.pos) : + createNode(293 /* JSDocParameterTag */, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); - var nestedTypeLiteral = parseNestedTypeLiteral(typeExpression, name, target); + var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; @@ -20731,20 +20775,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(277 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(278 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) { - if (child.kind === 292 /* JSDocParameterTag */ || child.kind === 297 /* JSDocPropertyTag */) { + if (child.kind === 293 /* JSDocParameterTag */ || child.kind === 298 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(286 /* JSDocTypeLiteral */, start_2); + jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 166 /* ArrayType */) { + if (typeExpression.type.kind === 167 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -20753,27 +20797,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 293 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocReturnTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(293 /* JSDocReturnTag */, atToken.pos); + var result = createNode(294 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 294 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 295 /* JSDocTypeTag */; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(294 /* JSDocTypeTag */, atToken.pos); + var result = createNode(295 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(289 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(290 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -20781,7 +20825,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17 /* OpenBraceToken */); - var node = createNode(206 /* ExpressionWithTypeArguments */); + var node = createNode(207 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -20793,15 +20837,15 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(/*createIfMissing*/ true); while (parseOptional(23 /* DotToken */)) { - var prop = createNode(184 /* PropertyAccessExpression */, node.pos); + var prop = createNode(185 /* PropertyAccessExpression */, node.pos); prop.expression = node; - prop.name = parseJSDocIdentifierName(); + prop.name = parseJSDocIdentifierName(); // TODO: GH#18217 node = finishNode(prop); } return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(290 /* JSDocClassTag */, atToken.pos); + var tag = createNode(291 /* JSDocClassTag */, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); @@ -20809,7 +20853,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(296 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(297 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -20825,9 +20869,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(286 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(287 /* JSDocTypeLiteral */, start_3); } - if (child.kind === 294 /* JSDocTypeTag */) { + if (child.kind === 295 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -20840,7 +20884,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 166 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 167 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -20856,7 +20900,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(23 /* DotToken */)) { - var jsDocNamespaceNode = createNode(238 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(239 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -20870,7 +20914,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(291 /* JSDocCallbackTag */, atToken.pos); + var callbackTag = createNode(292 /* JSDocCallbackTag */, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -20879,16 +20923,15 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(287 /* JSDocSignature */, start); + var jsdocSignature = createNode(288 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (token() === 57 /* AtToken */) { - nextJSDocToken(); + if (parseOptionalJsdoc(57 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 293 /* JSDocReturnTag */) { + if (tag && tag.kind === 294 /* JSDocReturnTag */) { return tag; } } @@ -20933,9 +20976,9 @@ var ts; case 57 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 292 /* JSDocParameterTag */ && + if (child && child.kind === 293 /* JSDocParameterTag */ && target !== 4 /* CallbackParameter */ && - (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { + (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { // TODO: GH#18217 return false; } return child; @@ -20994,49 +21037,45 @@ var ts; return tag; } function parseTemplateTag(atToken, tagName) { - if (ts.some(tags, ts.isJSDocTemplateTag)) { - parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); + // the template tag looks like '@template {Constraint} T,U,V' + var constraint; + if (token() === 17 /* OpenBraceToken */) { + constraint = parseJSDocTypeExpression(); } - // Type parameter list looks like '@template T,U,V' var typeParameters = []; var typeParametersPos = getNodePos(); - while (true) { - var typeParameter = createNode(147 /* TypeParameter */); - var name = parseJSDocIdentifierNameWithOptionalBraces(); + do { skipWhitespace(); - if (!name) { - parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); + var typeParameter = createNode(148 /* TypeParameter */); + if (!ts.tokenIsIdentifierOrKeyword(token())) { + parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); return undefined; } - typeParameter.name = name; + typeParameter.name = parseJSDocIdentifierName(); + skipWhitespace(); finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 26 /* CommaToken */) { - nextJSDocToken(); - skipWhitespace(); - } - else { - break; - } + } while (parseOptionalJsdoc(26 /* CommaToken */)); + if (constraint) { + ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(295 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(296 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); finishNode(result); return result; } - function parseJSDocIdentifierNameWithOptionalBraces() { - var parsedBrace = parseOptional(17 /* OpenBraceToken */); - var res = parseJSDocIdentifierName(); - if (parsedBrace) { - parseExpected(18 /* CloseBraceToken */); - } - return res; - } function nextJSDocToken() { return currentToken = scanner.scanJSDocToken(); } + function parseOptionalJsdoc(t) { + if (token() === t) { + nextJSDocToken(); + return true; + } + return false; + } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(/*createIfMissing*/ true); if (parseOptional(21 /* OpenBracketToken */)) { @@ -21581,7 +21620,7 @@ var ts; context.pragmas = ts.createMap(); for (var _i = 0, pragmas_1 = pragmas; _i < pragmas_1.length; _i++) { var pragma = pragmas_1[_i]; - if (context.pragmas.has(pragma.name)) { + if (context.pragmas.has(pragma.name)) { // TODO: GH#18217 var currentValue = context.pragmas.get(pragma.name); if (currentValue instanceof Array) { currentValue.push(pragma.args); @@ -21610,6 +21649,7 @@ var ts; var referencedFiles_1 = context.referencedFiles; var typeReferenceDirectives_1 = context.typeReferenceDirectives; ts.forEach(ts.toArray(entryOrList), function (arg) { + // TODO: GH#18217 if (arg.arguments["no-default-lib"]) { context.hasNoDefaultLib = true; } @@ -21626,10 +21666,7 @@ var ts; break; } case "amd-dependency": { - context.amdDependencies = ts.map(ts.toArray(entryOrList), function (_a) { - var _b = _a.arguments, name = _b.name, path = _b.path; - return ({ name: name, path: path }); - }); + context.amdDependencies = ts.map(ts.toArray(entryOrList), function (x) { return ({ name: x.arguments.name, path: x.arguments.path }); }); // TODO: GH#18217 break; } case "amd-module": { @@ -21652,7 +21689,7 @@ var ts; case "ts-check": { // _last_ of either nocheck or check in a file is the "winner" ts.forEach(ts.toArray(entryOrList), function (entry) { - if (!context.checkJsDirective || entry.range.pos > context.checkJsDirective.pos) { + if (!context.checkJsDirective || entry.range.pos > context.checkJsDirective.pos) { // TODO: GH#18217 context.checkJsDirective = { enabled: key === "ts-check", end: entry.range.end, @@ -21763,6 +21800,24 @@ var ts; } return argMap; } + /** @internal */ + function tagNamesAreEquivalent(lhs, rhs) { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === 71 /* Identifier */) { + return lhs.escapedText === rhs.escapedText; + } + if (lhs.kind === 99 /* ThisKeyword */) { + return true; + } + // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only + // take forms of JsxTagNameExpression which includes an identifier, "this" expression, or another propertyAccessExpression + // it is safe to case the expression property as such. See parseJsxElementName for how we parse tag name in Jsx element + return lhs.name.escapedText === rhs.name.escapedText && + tagNamesAreEquivalent(lhs.expression, rhs.expression); + } + ts.tagNamesAreEquivalent = tagNamesAreEquivalent; })(ts || (ts = {})); /* @internal */ var ts; @@ -21781,24 +21836,24 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: if (ts.isConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; // 4. other uninstantiated module declarations. - case 239 /* ModuleBlock */: { + case 240 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateWorker(n); @@ -21820,7 +21875,7 @@ var ts; }); return state_1; } - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return getModuleInstanceState(node); case 71 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should @@ -21970,7 +22025,7 @@ var ts; if (symbolFlags & 67216319 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 238 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 239 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -21979,7 +22034,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 === 248 /* ExportAssignment */) { + if (node.kind === 249 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -21988,7 +22043,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 146 /* ComputedPropertyName */) { + if (name.kind === 147 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteral(nameExpression)) { @@ -22000,43 +22055,43 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 154 /* Constructor */: + case 155 /* Constructor */: return "__constructor" /* Constructor */; - case 162 /* FunctionType */: - case 157 /* CallSignature */: - case 287 /* JSDocSignature */: + case 163 /* FunctionType */: + case 158 /* CallSignature */: + case 288 /* JSDocSignature */: return "__call" /* Call */; - case 163 /* ConstructorType */: - case 158 /* ConstructSignature */: + case 164 /* ConstructorType */: + case 159 /* ConstructSignature */: return "__new" /* New */; - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: return "__index" /* Index */; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 273 /* SourceFile */: + case 274 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 148 /* Parameter */: + case 149 /* 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 === 283 /* 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 === 284 /* 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; } } function getDisplayName(node) { - return ts.isNamedDeclaration(node) ? ts.declarationNameToString(node.name) : ts.unescapeLeadingUnderscores(getDeclarationName(node)); + return ts.isNamedDeclaration(node) ? ts.declarationNameToString(node.name) : ts.unescapeLeadingUnderscores(getDeclarationName(node)); // TODO: GH#18217 } /** * Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names. @@ -22123,7 +22178,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 === 248 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 249 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -22148,7 +22203,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 251 /* ExportSpecifier */ || (node.kind === 242 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 252 /* ExportSpecifier */ || (node.kind === 243 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -22215,7 +22270,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 !== 192 /* ArrowFunction */) { + if (node.kind !== 193 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -22247,7 +22302,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 intialization checks. - currentReturnTarget = isIIFE || node.kind === 154 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 155 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; @@ -22260,13 +22315,13 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 154 /* Constructor */) { + if (node.kind === 155 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -22309,8 +22364,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 233 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 233 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 234 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -22342,77 +22397,77 @@ var ts; return; } switch (node.kind) { - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: bindWhileStatement(node); break; - case 217 /* DoStatement */: + case 218 /* DoStatement */: bindDoStatement(node); break; - case 219 /* ForStatement */: + case 220 /* ForStatement */: bindForStatement(node); break; - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 216 /* IfStatement */: + case 217 /* IfStatement */: bindIfStatement(node); break; - case 224 /* ReturnStatement */: - case 228 /* ThrowStatement */: + case 225 /* ReturnStatement */: + case 229 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 229 /* TryStatement */: + case 230 /* TryStatement */: bindTryStatement(node); break; - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: bindSwitchStatement(node); break; - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: bindCaseBlock(node); break; - case 265 /* CaseClause */: + case 266 /* CaseClause */: bindCaseClause(node); break; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: bindLabeledStatement(node); break; - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 186 /* CallExpression */: + case 187 /* CallExpression */: bindCallExpressionFlow(node); break; - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 273 /* SourceFile */: + case 274 /* SourceFile */: bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; - case 212 /* Block */: - case 239 /* ModuleBlock */: + case 213 /* Block */: + case 240 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -22425,15 +22480,15 @@ var ts; switch (expr.kind) { case 71 /* Identifier */: case 99 /* ThisKeyword */: - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return hasNarrowableArgument(expr); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; @@ -22442,7 +22497,7 @@ var ts; return expr.kind === 71 /* Identifier */ || expr.kind === 99 /* ThisKeyword */ || expr.kind === 97 /* SuperKeyword */ || - expr.kind === 184 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + expr.kind === 185 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -22453,7 +22508,7 @@ var ts; } } } - if (expr.expression.kind === 184 /* PropertyAccessExpression */ && + if (expr.expression.kind === 185 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -22486,9 +22541,9 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: switch (expr.operatorToken.kind) { case 58 /* EqualsToken */: return isNarrowableOperand(expr.left); @@ -22566,33 +22621,33 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 216 /* IfStatement */: - case 218 /* WhileStatement */: - case 217 /* DoStatement */: + case 217 /* IfStatement */: + case 219 /* WhileStatement */: + case 218 /* DoStatement */: return parent.expression === node; - case 219 /* ForStatement */: - case 200 /* ConditionalExpression */: + case 220 /* ForStatement */: + case 201 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 190 /* ParenthesizedExpression */) { + if (node.kind === 191 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 197 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { + else if (node.kind === 198 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 199 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || + return node.kind === 200 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 54 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 190 /* ParenthesizedExpression */ || - node.parent.kind === 197 /* PrefixUnaryExpression */ && + while (node.parent.kind === 191 /* ParenthesizedExpression */ || + node.parent.kind === 198 /* PrefixUnaryExpression */ && node.parent.operator === 51 /* ExclamationToken */) { node = node.parent; } @@ -22634,7 +22689,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 227 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 228 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -22668,13 +22723,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 221 /* ForOfStatement */) { + if (node.kind === 222 /* ForOfStatement */) { bind(node.awaitModifier); } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 232 /* VariableDeclarationList */) { + if (node.initializer.kind !== 233 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -22696,7 +22751,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 224 /* ReturnStatement */) { + if (node.kind === 225 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -22716,7 +22771,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 223 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 224 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -22812,7 +22867,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 266 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 267 /* 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). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -22836,6 +22891,7 @@ var ts; } var preCaseLabel = createBranchLabel(); addAntecedent(preCaseLabel, createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1)); + addAntecedent(preCaseLabel, createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1)); addAntecedent(preCaseLabel, fallthroughFlow); currentFlow = finishFlowLabel(preCaseLabel); var clause = clauses[i]; @@ -22877,16 +22933,16 @@ var ts; bind(node.statement); popActiveLabel(); if (!activeLabel.referenced && !options.allowUnusedLabels) { - file.bindDiagnostics.push(createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); + errorOrSuggestionOnFirstToken(ts.unusedLabelIsError(options), node, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 217 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 218 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 199 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { + if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -22897,10 +22953,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 182 /* ArrayLiteralExpression */) { + else if (node.kind === 183 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 203 /* SpreadElement */) { + if (e.kind === 204 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -22908,16 +22964,16 @@ var ts; } } } - else if (node.kind === 183 /* ObjectLiteralExpression */) { + else if (node.kind === 184 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 269 /* PropertyAssignment */) { + if (p.kind === 270 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 270 /* ShorthandPropertyAssignment */) { + else if (p.kind === 271 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 271 /* SpreadAssignment */) { + else if (p.kind === 272 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -22973,7 +23029,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 58 /* EqualsToken */ && node.left.kind === 185 /* ElementAccessExpression */) { + if (operator === 58 /* EqualsToken */ && node.left.kind === 186 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -22984,7 +23040,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 184 /* PropertyAccessExpression */) { + if (node.expression.kind === 185 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -23031,10 +23087,10 @@ 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 = node.expression; - while (expr.kind === 190 /* ParenthesizedExpression */) { + while (expr.kind === 191 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 191 /* FunctionExpression */ || expr.kind === 192 /* ArrowFunction */) { + if (expr.kind === 192 /* FunctionExpression */ || expr.kind === 193 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -23042,7 +23098,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 184 /* PropertyAccessExpression */) { + if (node.expression.kind === 185 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -23051,54 +23107,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 204 /* ClassExpression */: - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: - case 183 /* ObjectLiteralExpression */: - case 165 /* TypeLiteral */: - case 286 /* JSDocTypeLiteral */: - case 262 /* JsxAttributes */: + case 205 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 184 /* ObjectLiteralExpression */: + case 166 /* TypeLiteral */: + case 287 /* JSDocTypeLiteral */: + case 263 /* JsxAttributes */: return 1 /* IsContainer */; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 238 /* ModuleDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 176 /* MappedType */: + case 239 /* ModuleDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 177 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 273 /* SourceFile */: + case 274 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 154 /* Constructor */: - case 233 /* FunctionDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 157 /* CallSignature */: - case 287 /* JSDocSignature */: - case 283 /* JSDocFunctionType */: - case 162 /* FunctionType */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 163 /* ConstructorType */: + case 155 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 158 /* CallSignature */: + case 288 /* JSDocSignature */: + case 284 /* JSDocFunctionType */: + case 163 /* FunctionType */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 164 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 268 /* CatchClause */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 240 /* CaseBlock */: + case 269 /* CatchClause */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 241 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 212 /* Block */: + case 213 /* 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 @@ -23131,45 +23187,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 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 273 /* SourceFile */: + case 274 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 204 /* ClassExpression */: - case 234 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 235 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 165 /* TypeLiteral */: - case 286 /* JSDocTypeLiteral */: - case 183 /* ObjectLiteralExpression */: - case 235 /* InterfaceDeclaration */: - case 262 /* JsxAttributes */: + case 166 /* TypeLiteral */: + case 287 /* JSDocTypeLiteral */: + case 184 /* ObjectLiteralExpression */: + case 236 /* InterfaceDeclaration */: + case 263 /* 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 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 287 /* JSDocSignature */: - case 159 /* IndexSignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 283 /* JSDocFunctionType */: - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: - case 236 /* TypeAliasDeclaration */: - case 176 /* MappedType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 288 /* JSDocSignature */: + case 160 /* IndexSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 284 /* JSDocFunctionType */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 237 /* TypeAliasDeclaration */: + case 177 /* 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 @@ -23190,11 +23246,11 @@ var ts; : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 273 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 273 /* SourceFile */ || body.kind === 239 /* ModuleBlock */)) { + var body = node.kind === 274 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 274 /* SourceFile */ || body.kind === 240 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 249 /* ExportDeclaration */ || stat.kind === 248 /* ExportAssignment */) { + if (stat.kind === 250 /* ExportDeclaration */ || stat.kind === 249 /* ExportAssignment */) { return true; } } @@ -23261,7 +23317,7 @@ var ts; // We do that by making an anonymous type literal symbol, and then setting the function // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); + var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); // TODO: GH#18217 addDeclarationToSymbol(symbol, node, 131072 /* Signature */); var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); @@ -23278,7 +23334,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 271 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { + if (prop.kind === 272 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { continue; } var identifier = prop.name; @@ -23290,7 +23346,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 === 269 /* PropertyAssignment */ || prop.kind === 270 /* ShorthandPropertyAssignment */ || prop.kind === 153 /* MethodDeclaration */ + var currentKind = prop.kind === 270 /* PropertyAssignment */ || prop.kind === 271 /* ShorthandPropertyAssignment */ || prop.kind === 154 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -23318,13 +23374,14 @@ var ts; symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); + return symbol; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -23465,8 +23522,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 273 /* SourceFile */ && - blockScopeContainer.kind !== 238 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 274 /* SourceFile */ && + blockScopeContainer.kind !== 239 /* 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. @@ -23507,6 +23564,16 @@ var ts; var span = ts.getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } + function errorOrSuggestionOnFirstToken(isError, node, message, arg0, arg1, arg2) { + var span = ts.getSpanOfTokenAtPosition(file, node.pos); + var diag = ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2); + if (isError) { + file.bindDiagnostics.push(diag); + } + else { + file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + } + } function bind(node) { if (!node) { return; @@ -23538,7 +23605,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 > 144 /* LastToken */) { + if (node.kind > 145 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -23610,11 +23677,11 @@ var ts; } // falls through case 99 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 270 /* ShorthandPropertyAssignment */)) { + if (currentFlow && (ts.isExpression(node) || parent.kind === 271 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } @@ -23622,7 +23689,7 @@ var ts; bindSpecialPropertyDeclaration(node); } break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var specialKind = ts.getSpecialPropertyAssignmentKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -23650,137 +23717,137 @@ var ts; ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return checkStrictModeCatchClause(node); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return checkStrictModeWithStatement(node); - case 173 /* ThisType */: + case 174 /* ThisType */: seenThisKeyword = true; return; - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: break; // Binding the children will handle everything - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return bindTypeParameter(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return bindParameter(node); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 181 /* BindingElement */: + case 182 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return bindPropertyWorker(node); - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 272 /* EnumMember */: + case 273 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 68008959 /* EnumMemberExcludes */); - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* 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 */ : 67208127 /* MethodExcludes */); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 67150783 /* GetAccessorExcludes */); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 67183551 /* SetAccessorExcludes */); - case 162 /* FunctionType */: - case 283 /* JSDocFunctionType */: - case 287 /* JSDocSignature */: - case 163 /* ConstructorType */: + case 163 /* FunctionType */: + case 284 /* JSDocFunctionType */: + case 288 /* JSDocSignature */: + case 164 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 165 /* TypeLiteral */: - case 286 /* JSDocTypeLiteral */: - case 176 /* MappedType */: + case 166 /* TypeLiteral */: + case 287 /* JSDocTypeLiteral */: + case 177 /* MappedType */: return bindAnonymousTypeWorker(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return bindFunctionExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 204 /* ClassExpression */: - case 234 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 235 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 67901832 /* InterfaceExcludes */); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 67901928 /* TypeAliasExcludes */); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return bindJsxAttributes(node); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 242 /* ImportEqualsDeclaration */: - case 245 /* NamespaceImport */: - case 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 243 /* ImportEqualsDeclaration */: + case 246 /* NamespaceImport */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return bindImportClause(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return bindExportDeclaration(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return bindExportAssignment(node); - case 273 /* SourceFile */: + case 274 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 212 /* Block */: + case 213 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 292 /* JSDocParameterTag */: - if (node.parent.kind === 287 /* JSDocSignature */) { + case 293 /* JSDocParameterTag */: + if (node.parent.kind === 288 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 286 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 287 /* JSDocTypeLiteral */) { break; } // falls through - case 297 /* JSDocPropertyTag */: + case 298 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 282 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 283 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -23812,7 +23879,7 @@ var ts; bindAnonymousDeclaration(node, 2097152 /* Alias */, getDeclarationName(node)); } else { - var flags = node.kind === 248 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 249 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; ? 2097152 /* Alias */ // An export default clause with any other expression exports a value @@ -23826,7 +23893,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 273 /* SourceFile */) { + if (node.parent.kind !== 274 /* SourceFile */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -23872,13 +23939,11 @@ var ts; // expression is the declaration setCommonJsModuleIndicator(node); var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, function (id, original) { - if (!original) { - return undefined; + var symbol = forEachIdentifierInEntityName(lhs.expression, /*parent*/ undefined, function (id, symbol) { + if (symbol) { + addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* JSContainer */); } - var s = ts.getJSInitializerSymbol(original); - addDeclarationToSymbol(s, id, 1536 /* Module */ | 67108864 /* JSContainer */); - return s; + return symbol; }); if (symbol) { var flags = ts.isClassExpression(node.right) ? @@ -23909,14 +23974,14 @@ var ts; ts.Debug.assert(ts.isInJavaScriptFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 192 /* 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 === 58 /* EqualsToken */) { var l = thisContainer.parent.left; if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { - constructorSymbol = getJSInitializerSymbolFromName(l.expression.expression, thisParentContainer); + constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } if (constructorSymbol) { @@ -23926,18 +23991,18 @@ var ts; declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); } break; - case 154 /* Constructor */: - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 155 /* Constructor */: + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); break; - case 273 /* SourceFile */: + case 274 /* SourceFile */: // this.foo assignment in a source file // Do not bind. It would be nice to support this someday though. break; @@ -23949,7 +24014,7 @@ var ts; if (node.expression.kind === 99 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 273 /* SourceFile */) { + else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 274 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -24003,43 +24068,65 @@ var ts; node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); } - function getJSInitializerSymbolFromName(name, lookupContainer) { - return ts.getJSInitializerSymbol(lookupSymbolForPropertyAccess(name, lookupContainer)); - } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { - var symbol = getJSInitializerSymbolFromName(name); + var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevelNamespaceableInitializer = ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 273 /* SourceFile */ && + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 274 /* SourceFile */ && !!ts.getJavascriptInitializer(ts.getInitializerOfBinaryExpression(propertyAccess.parent), ts.isPrototypeAccess(propertyAccess.parent.left)) - : propertyAccess.parent.parent.kind === 273 /* SourceFile */; - if (!isPrototypeProperty && (!symbol || !(symbol.flags & 1920 /* Namespace */)) && isToplevelNamespaceableInitializer) { + : propertyAccess.parent.parent.kind === 274 /* SourceFile */; + if (!isPrototypeProperty && (!namespaceSymbol || !(namespaceSymbol.flags & 1920 /* Namespace */)) && isToplevelNamespaceableInitializer) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* JSContainer */; var excludeFlags_1 = 67215503 /* ValueModuleExcludes */ & ~67108864 /* JSContainer */; - forEachIdentifierInEntityName(propertyAccess.expression, function (id, original) { - if (original) { - // Note: add declaration to original symbol, not the special-syntax's symbol, so that namespaces work for type lookup - addDeclarationToSymbol(original, id, flags_1); - return original; + namespaceSymbol = forEachIdentifierInEntityName(propertyAccess.expression, namespaceSymbol, function (id, symbol, parent) { + if (symbol) { + addDeclarationToSymbol(symbol, id, flags_1); + return symbol; } else { - return symbol = declareSymbol(symbol ? symbol.exports : container.locals, symbol, id, flags_1, excludeFlags_1); + return declareSymbol(parent ? parent.exports : container.locals, parent, id, flags_1, excludeFlags_1); } }); } - if (!symbol || !(symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */ | 4096 /* ObjectLiteral */))) { + if (!namespaceSymbol || !isJavascriptContainer(namespaceSymbol)) { return; } // Set up the members collection if it doesn't exist already var symbolTable = isPrototypeProperty ? - (symbol.members || (symbol.members = ts.createSymbolTable())) : - (symbol.exports || (symbol.exports = ts.createSymbolTable())); + (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : + (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); // Declare the method/property var jsContainerFlag = isToplevelNamespaceableInitializer ? 67108864 /* JSContainer */ : 0; var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedJavascriptInitializer(propertyAccess)); var symbolFlags = (isMethod ? 8192 /* Method */ : 4 /* Property */) | jsContainerFlag; var symbolExcludes = (isMethod ? 67208127 /* MethodExcludes */ : 0 /* PropertyExcludes */) & ~jsContainerFlag; - declareSymbol(symbolTable, symbol, propertyAccess, symbolFlags, symbolExcludes); + declareSymbol(symbolTable, namespaceSymbol, propertyAccess, symbolFlags, symbolExcludes); + } + /** + * Javascript containers are: + * - Functions + * - classes + * - namespaces + * - variables initialized with function expressions + * - with class expressions + * - with empty object literals + * - with non-empty object literals if assigned to the prototype property + */ + function isJavascriptContainer(symbol) { + if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) { + return true; + } + var node = symbol.valueDeclaration; + var init = !node ? undefined : + ts.isVariableDeclaration(node) ? node.initializer : + ts.isBinaryExpression(node) ? node.right : + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) ? node.parent.right : + undefined; + if (init) { + var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); + return !!ts.getJavascriptInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 54 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + } + return false; } function getParentOfBinaryExpression(expr) { while (ts.isBinaryExpression(expr.parent)) { @@ -24053,21 +24140,22 @@ var ts; return lookupSymbolForNameWorker(lookupContainer, node.escapedText); } else { - var symbol = ts.getJSInitializerSymbol(lookupSymbolForPropertyAccess(node.expression)); + var symbol = lookupSymbolForPropertyAccess(node.expression); return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); } } - function forEachIdentifierInEntityName(e, action) { + function forEachIdentifierInEntityName(e, parent, action) { if (isExportsOrModuleExportsOrAlias(file, e)) { return file.symbol; } else if (ts.isIdentifier(e)) { - return action(e, lookupSymbolForPropertyAccess(e)); + return action(e, lookupSymbolForPropertyAccess(e), parent); } else { - var s = ts.getJSInitializerSymbol(forEachIdentifierInEntityName(e.expression, action)); - ts.Debug.assert(!!s && !!s.exports); - return action(e.name, s.exports.get(e.name.escapedText)); + var s = forEachIdentifierInEntityName(e.expression, parent, action); + if (!s || !s.exports) + return ts.Debug.fail(); + return action(e.name, s.exports.get(e.name.escapedText), s); } } function bindCallExpression(node) { @@ -24078,7 +24166,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 234 /* ClassDeclaration */) { + if (node.kind === 235 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 68008383 /* ClassExcludes */); } else { @@ -24124,7 +24212,7 @@ var ts; bindBlockScopedVariableDeclaration(node); } else if (ts.isParameterDeclaration(node)) { - // It is safe to walk up parent chain to find whether the node is a destructing parameter declaration + // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration // because its parent chain has already been set up, since parents are set before descending into children. // // If node is a binding element in parameter declaration, we need to use ParameterExcludes. @@ -24141,7 +24229,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 292 /* JSDocParameterTag */ && container.kind !== 287 /* JSDocSignature */) { + if (node.kind === 293 /* JSDocParameterTag */ && container.kind !== 288 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { @@ -24207,7 +24295,7 @@ var ts; } function bindTypeParameter(node) { if (ts.isJSDocTemplateTag(node.parent)) { - var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent); + var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent); // TODO: GH#18217 if (container_1) { if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); @@ -24218,7 +24306,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 171 /* InferType */) { + else if (node.parent.kind === 172 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -24227,7 +24315,7 @@ var ts; declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 67639784 /* TypeParameterExcludes */); } else { - bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { @@ -24237,7 +24325,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 */ && !!options.preserveConstEnums); } function checkUnreachable(node) { if (!(currentFlow.flags & 1 /* Unreachable */)) { @@ -24246,31 +24334,31 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 214 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 215 /* EmptyStatement */) || // report error on class declarations - node.kind === 234 /* ClassDeclaration */ || + node.kind === 235 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 238 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 239 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 237 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 238 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; - // unreachable code is reported if - // - user has explicitly asked about it AND - // - statement is in not ambient context (statements in ambient context is already an error - // so we should not report extras) AND - // - node is not variable statement OR - // - node is block scoped variable statement OR - // - node is not block scoped variable statement and at least one variable declaration has initializer - // Rationale: we don't want to report errors on non-initialized var's since they are hoisted - // On the other side we do want to report errors on non-initialized 'lets' because of TDZ - var reportUnreachableCode = !options.allowUnreachableCode && - !(node.flags & 4194304 /* Ambient */) && - (node.kind !== 213 /* VariableStatement */ || - ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || - ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); - if (reportUnreachableCode) { - errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); + if (!options.allowUnreachableCode) { + // unreachable code is reported if + // - user has explicitly asked about it AND + // - statement is in not ambient context (statements in ambient context is already an error + // so we should not report extras) AND + // - node is not variable statement OR + // - node is block scoped variable statement OR + // - node is not block scoped variable statement and at least one variable declaration has initializer + // Rationale: we don't want to report errors on non-initialized var's since they are hoisted + // On the other side we do want to report errors on non-initialized 'lets' because of TDZ + var isError = ts.unreachableCodeIsError(options) && + !(node.flags & 4194304 /* Ambient */) && + (!ts.isVariableStatement(node) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || + node.declarationList.declarations.some(function (d) { return !!d.initializer; })); + errorOrSuggestionOnFirstToken(isError, node, ts.Diagnostics.Unreachable_code_detected); } } } @@ -24286,8 +24374,8 @@ var ts; ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias; function isNameOfExportsOrModuleExportsAliasDeclaration(sourceFile, node) { var symbol = lookupSymbolForNameWorker(sourceFile, node.escapedText); - return symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && - symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer); + return !!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && + !!symbol.valueDeclaration.initializer && isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, symbol.valueDeclaration.initializer); } function isExportsOrModuleExportsOrAliasOrAssignment(sourceFile, node) { return isExportsOrModuleExportsOrAlias(sourceFile, node) || @@ -24309,58 +24397,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 186 /* CallExpression */: + case 187 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 148 /* Parameter */: + case 149 /* Parameter */: return computeParameter(node, subtreeFlags); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 154 /* Constructor */: + case 155 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -24412,12 +24500,12 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 183 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 184 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ESNext if they contain rest transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 182 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 183 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } @@ -24466,8 +24554,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 207 /* AsExpression */ - || expressionKind === 189 /* TypeAssertionExpression */) { + if (expressionKind === 208 /* AsExpression */ + || expressionKind === 190 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -24844,13 +24932,13 @@ var ts; var excludeFlags = 939525441 /* NodeExcludes */; switch (kind) { case 120 /* AsyncKeyword */: - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: - case 300 /* PartiallyEmittedExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: + case 301 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; excludeFlags = 536872257 /* OuterExpressionExcludes */; @@ -24861,25 +24949,25 @@ var ts; case 117 /* AbstractKeyword */: case 124 /* DeclareKeyword */: case 76 /* ConstKeyword */: - case 237 /* EnumDeclaration */: - case 272 /* EnumMember */: - case 208 /* NonNullExpression */: + case 238 /* EnumDeclaration */: + case 273 /* EnumMember */: + case 209 /* NonNullExpression */: case 132 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: - case 256 /* JsxOpeningElement */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: case 10 /* JsxText */: - case 257 /* JsxClosingElement */: - case 258 /* JsxFragment */: - case 259 /* JsxOpeningFragment */: - case 260 /* JsxClosingFragment */: - case 261 /* JsxAttribute */: - case 262 /* JsxAttributes */: - case 263 /* JsxSpreadAttribute */: - case 264 /* JsxExpression */: + case 258 /* JsxClosingElement */: + case 259 /* JsxFragment */: + case 260 /* JsxOpeningFragment */: + case 261 /* JsxClosingFragment */: + case 262 /* JsxAttribute */: + case 263 /* JsxAttributes */: + case 264 /* JsxSpreadAttribute */: + case 265 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; @@ -24887,11 +24975,11 @@ var ts; case 14 /* TemplateHead */: case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: - case 201 /* TemplateExpression */: - case 188 /* TaggedTemplateExpression */: - case 270 /* ShorthandPropertyAssignment */: + case 202 /* TemplateExpression */: + case 189 /* TaggedTemplateExpression */: + case 271 /* ShorthandPropertyAssignment */: case 115 /* StaticKeyword */: - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; @@ -24905,14 +24993,14 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 8 /* AssertESNext */; } transformFlags |= 192 /* AssertES2015 */; break; - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; @@ -24925,38 +25013,38 @@ var ts; case 122 /* BooleanKeyword */: case 138 /* SymbolKeyword */: case 105 /* VoidKeyword */: - case 147 /* TypeParameter */: - case 150 /* PropertySignature */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 160 /* TypePredicate */: - case 161 /* TypeReference */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 164 /* TypeQuery */: - case 165 /* TypeLiteral */: - case 166 /* ArrayType */: - case 167 /* TupleType */: - case 168 /* UnionType */: - case 169 /* IntersectionType */: - case 170 /* ConditionalType */: - case 171 /* InferType */: - case 172 /* ParenthesizedType */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 173 /* ThisType */: - case 174 /* TypeOperator */: - case 175 /* IndexedAccessType */: - case 176 /* MappedType */: - case 177 /* LiteralType */: - case 241 /* NamespaceExportDeclaration */: + case 148 /* TypeParameter */: + case 151 /* PropertySignature */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 161 /* TypePredicate */: + case 162 /* TypeReference */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 165 /* TypeQuery */: + case 166 /* TypeLiteral */: + case 167 /* ArrayType */: + case 168 /* TupleType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: + case 171 /* ConditionalType */: + case 172 /* InferType */: + case 173 /* ParenthesizedType */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 174 /* ThisType */: + case 175 /* TypeOperator */: + case 176 /* IndexedAccessType */: + case 177 /* MappedType */: + case 178 /* LiteralType */: + case 242 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. @@ -24973,10 +25061,10 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; case 97 /* SuperKeyword */: @@ -24988,28 +25076,28 @@ var ts; // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 940049729 /* BindingPatternExcludes */; break; - case 181 /* BindingElement */: + case 182 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; } break; - case 149 /* Decorator */: + case 150 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: excludeFlags = 942740801 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -25027,8 +25115,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 182 /* ArrayLiteralExpression */: - case 187 /* NewExpression */: + case 183 /* ArrayLiteralExpression */: + case 188 /* NewExpression */: excludeFlags = 940049729 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -25036,23 +25124,26 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 224 /* ReturnStatement */: - case 222 /* ContinueStatement */: - case 223 /* BreakStatement */: + case 225 /* ReturnStatement */: + // Return statements may require an `await` in ESNext. + transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */ | 8 /* AssertESNext */; + break; + case 223 /* ContinueStatement */: + case 224 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -25068,33 +25159,33 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 160 /* FirstTypeNode */ && kind <= 178 /* LastTypeNode */) { + if (kind >= 161 /* FirstTypeNode */ && kind <= 179 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 182 /* ArrayLiteralExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 183 /* ArrayLiteralExpression */: return 940049729 /* ArrayLiteralOrCallOrNewExcludes */; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return 977327425 /* ModuleExcludes */; - case 148 /* Parameter */: + case 149 /* Parameter */: return 939525441 /* ParameterExcludes */; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return 1003902273 /* ArrowFunctionExcludes */; - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: return 1003935041 /* FunctionExcludes */; - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return 948962625 /* VariableDeclarationListExcludes */; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: return 942011713 /* ClassExcludes */; - case 154 /* Constructor */: + case 155 /* Constructor */: return 1003668801 /* ConstructorExcludes */; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return 1003668801 /* MethodOrAccessorExcludes */; case 119 /* AnyKeyword */: case 134 /* NumberKeyword */: @@ -25104,30 +25195,30 @@ var ts; case 122 /* BooleanKeyword */: case 138 /* SymbolKeyword */: case 105 /* VoidKeyword */: - case 147 /* TypeParameter */: - case 150 /* PropertySignature */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 148 /* TypeParameter */: + case 151 /* PropertySignature */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return 942740801 /* ObjectLiteralExcludes */; - case 268 /* CatchClause */: + case 269 /* CatchClause */: return 940574017 /* CatchClauseExcludes */; - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: return 940049729 /* BindingPatternExcludes */; - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: - case 300 /* PartiallyEmittedExpression */: - case 190 /* ParenthesizedExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: + case 301 /* PartiallyEmittedExpression */: + case 191 /* ParenthesizedExpression */: case 97 /* SuperKeyword */: return 536872257 /* OuterExpressionExcludes */; - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: return 671089985 /* PropertyAccessExcludes */; default: return 939525441 /* NodeExcludes */; @@ -25188,7 +25279,7 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var objectType = type; var objectFlags = objectType.objectFlags; if (objectFlags & 4 /* Reference */) { @@ -25204,16 +25295,16 @@ var ts; visitObjectType(objectType); } } - if (type.flags & 32768 /* TypeParameter */) { + if (type.flags & 65536 /* TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 393216 /* UnionOrIntersection */) { + if (type.flags & 786432 /* UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 524288 /* Index */) { + if (type.flags & 1048576 /* Index */) { visitIndexType(type); } - if (type.flags & 1048576 /* IndexedAccess */) { + if (type.flags & 2097152 /* IndexedAccess */) { visitIndexedAccessType(type); } } @@ -25282,11 +25373,11 @@ var ts; } function visitSymbol(symbol) { if (!symbol) { - return; + return false; } var symbolId = ts.getSymbolId(symbol); if (visitedSymbols[symbolId]) { - return; + return false; } visitedSymbols[symbolId] = symbol; if (!accept(symbol)) { @@ -25302,12 +25393,13 @@ 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 === 164 /* TypeQuery */) { + if (d.type && d.type.kind === 165 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); } }); + return false; } } } @@ -25321,7 +25413,7 @@ var ts; ts.trace = trace; /* @internal */ function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; + return !!compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; function withPackageId(packageId, r) { @@ -25501,7 +25593,6 @@ var ts; } } function secondaryLookup() { - var resolvedFile; var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); if (initialLocationForSecondaryLookup !== undefined) { // check secondary locations @@ -25509,7 +25600,7 @@ var ts; trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, /*cache*/ undefined); - resolvedFile = resolvedTypeScriptOnly(result && result.value); + var resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -25582,7 +25673,7 @@ var ts; } function getOrCreateCacheForModuleName(nonRelativeModuleName) { if (ts.isExternalModuleNameRelative(nonRelativeModuleName)) { - return undefined; + return undefined; // TODO: GH#18217 } var perModuleNameCache = moduleNameToDirectoryMap.get(nonRelativeModuleName); if (!perModuleNameCache) { @@ -25694,7 +25785,7 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); break; default: - ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } if (perFolderCache) { perFolderCache.set(moduleName, result); @@ -25947,7 +26038,7 @@ var ts; var originalPath = void 0; if (!compilerOptions.preserveSymlinks && resolvedValue) { originalPath = resolvedValue.path; - var path = realPath(resolved_1.value.path, host, traceEnabled); + var path = realPath(resolvedValue.path, host, traceEnabled); if (path === originalPath) { originalPath = undefined; } @@ -26066,7 +26157,7 @@ var ts; function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (extensions === Extensions.Json) { var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); - return extensionLess && tryAddingExtensions(extensionLess, extensions, failedLookupLocations, onlyRecordFailures, state); + return extensionLess === undefined ? undefined : tryAddingExtensions(extensionLess, extensions, failedLookupLocations, onlyRecordFailures, state); } // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); @@ -26105,7 +26196,7 @@ var ts; } function tryExtension(ext) { var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); - return path && { path: path, ext: ext }; + return path === undefined ? undefined : { path: path, ext: ext }; } } /** Return the file if it exists. */ @@ -26525,11 +26616,12 @@ var ts; getGlobalDiagnostics: getGlobalDiagnostics, getTypeOfSymbolAtLocation: function (symbol, location) { location = ts.getParseTreeNode(location); - return location ? getTypeOfSymbolAtLocation(symbol, location) : unknownType; + return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType; }, - getSymbolsOfParameterPropertyDeclaration: function (parameter, parameterName) { - parameter = ts.getParseTreeNode(parameter, ts.isParameter); - ts.Debug.assert(parameter !== undefined, "Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); + getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) { + var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter); + if (parameter === undefined) + return ts.Debug.fail("Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); return getSymbolsOfParameterPropertyDeclaration(parameter, ts.escapeLeadingUnderscores(parameterName)); }, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, @@ -26541,9 +26633,9 @@ var ts; getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, getWidenedType: getWidenedType, - getTypeFromTypeNode: function (node) { - node = ts.getParseTreeNode(node, ts.isTypeNode); - return node ? getTypeFromTypeNode(node) : unknownType; + getTypeFromTypeNode: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode); + return node ? getTypeFromTypeNode(node) : errorType; }, getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, @@ -26569,8 +26661,8 @@ var ts; node = ts.getParseTreeNode(node); return node ? getShorthandAssignmentValueSymbol(node) : undefined; }, - getExportSpecifierLocalTargetSymbol: function (node) { - node = ts.getParseTreeNode(node, ts.isExportSpecifier); + getExportSpecifierLocalTargetSymbol: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isExportSpecifier); return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; }, getExportSymbolOfSymbol: function (symbol) { @@ -26578,10 +26670,10 @@ var ts; }, getTypeAtLocation: function (node) { node = ts.getParseTreeNode(node); - return node ? getTypeOfNode(node) : unknownType; + return node ? getTypeOfNode(node) : errorType; }, - getPropertySymbolOfDestructuringAssignment: function (location) { - location = ts.getParseTreeNode(location, ts.isIdentifier); + getPropertySymbolOfDestructuringAssignment: function (locationIn) { + var location = ts.getParseTreeNode(locationIn, ts.isIdentifier); return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined; }, signatureToString: function (signature, enclosingDeclaration, flags, kind) { @@ -26611,41 +26703,41 @@ var ts; getSymbolDisplayBuilder: getSymbolDisplayBuilder, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: function (node) { - node = ts.getParseTreeNode(node, ts.isExpression); + getContextualType: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isExpression); return node ? getContextualType(node) : undefined; }, - getContextualTypeForArgumentAtIndex: function (node, argIndex) { - node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) { + var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); return node && getContextualTypeForArgumentAtIndex(node, argIndex); }, - getContextualTypeForJsxAttribute: function (node) { - node = ts.getParseTreeNode(node, ts.isJsxAttributeLike); + getContextualTypeForJsxAttribute: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike); return node && getContextualTypeForJsxAttribute(node); }, isContextSensitive: isContextSensitive, getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: function (node, candidatesOutArray, theArgumentCount) { - node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + getResolvedSignature: function (nodeIn, candidatesOutArray, theArgumentCount) { + var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); apparentArgumentCount = theArgumentCount; var res = node ? getResolvedSignature(node, candidatesOutArray) : undefined; apparentArgumentCount = undefined; return res; }, - getConstantValue: function (node) { - node = ts.getParseTreeNode(node, canHaveConstantValue); + getConstantValue: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue); return node ? getConstantValue(node) : undefined; }, - isValidPropertyAccess: function (node, propertyName) { - node = ts.getParseTreeNode(node, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode); + isValidPropertyAccess: function (nodeIn, propertyName) { + var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode); return !!node && isValidPropertyAccess(node, ts.escapeLeadingUnderscores(propertyName)); }, - isValidPropertyAccessForCompletions: function (node, type, property) { - node = ts.getParseTreeNode(node, ts.isPropertyAccessExpression); + isValidPropertyAccessForCompletions: function (nodeIn, type, property) { + var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessExpression); return !!node && isValidPropertyAccessForCompletions(node, type, property); }, - getSignatureFromDeclaration: function (declaration) { - declaration = ts.getParseTreeNode(declaration, ts.isFunctionLike); + getSignatureFromDeclaration: function (declarationIn) { + var declaration = ts.getParseTreeNode(declarationIn, ts.isFunctionLike); return declaration ? getSignatureFromDeclaration(declaration) : undefined; }, isImplementationOfOverload: function (node) { @@ -26657,7 +26749,8 @@ var ts; var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); + if (!node) + return ts.Debug.fail(); links.immediateTarget = getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true); } return links.immediateTarget; @@ -26668,13 +26761,13 @@ var ts; getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintFromTypeParameter, getFirstIdentifier), getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { - node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); + getAllAttributesTypeFromJsxOpeningLikeElement: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isJsxOpeningLikeElement); return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; }, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, - isOptionalParameter: function (node) { - node = ts.getParseTreeNode(node, ts.isParameter); + isOptionalParameter: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isParameter); return node ? isOptionalParameter(node) : false; }, tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); }, @@ -26708,7 +26801,7 @@ var ts; getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); }, getSuggestionForNonexistentModule: function (node, target) { return getSuggestionForNonexistentModule(node, target); }, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 32768 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 65536 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -26720,24 +26813,35 @@ var ts; node = ts.getParseTreeNode(node); return node && tryGetThisTypeAt(node); }, - getTypeArgumentConstraint: function (node) { - node = ts.getParseTreeNode(node, ts.isTypeNode); + getTypeArgumentConstraint: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode); return node && getTypeArgumentConstraint(node); }, - getSuggestionDiagnostics: function (file) { - return (suggestionDiagnostics.get(file.fileName) || ts.emptyArray).concat(getUnusedDiagnostics()); - function getUnusedDiagnostics() { - if (file.isDeclarationFile) - return ts.emptyArray; + getSuggestionDiagnostics: function (file, ct) { + var diagnostics; + try { + // Record the cancellation token so it can be checked later on during checkSourceElement. + // Do this in a finally block so we can ensure that it gets reset back to nothing after + // this call is done. + cancellationToken = ct; + // Ensure file is type checked checkSourceFile(file); - var diagnostics = []; ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); + diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.get(file.fileName)); + if (!file.isDeclarationFile && (!unusedIsError(0 /* Local */) || !unusedIsError(1 /* Parameter */))) { + addUnusedDiagnostics(); + } + return diagnostics || ts.emptyArray; + } + finally { + cancellationToken = undefined; + } + function addUnusedDiagnostics() { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (kind, diag) { if (!unusedIsError(kind)) { - diagnostics.push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); + (diagnostics || (diagnostics = [])).push(__assign({}, diag, { category: ts.DiagnosticCategory.Suggestion })); } }); - return diagnostics; } }, runWithCancellationToken: function (token, callback) { @@ -26762,22 +26866,23 @@ var ts; var anyType = createIntrinsicType(1 /* Any */, "any"); var autoType = createIntrinsicType(1 /* Any */, "any"); var wildcardType = createIntrinsicType(1 /* Any */, "any"); - var unknownType = createIntrinsicType(1 /* Any */, "unknown"); - var undefinedType = createIntrinsicType(4096 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(4096 /* Undefined */ | 16777216 /* ContainsWideningType */, "undefined"); - var nullType = createIntrinsicType(8192 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(8192 /* Null */ | 16777216 /* ContainsWideningType */, "null"); - var stringType = createIntrinsicType(2 /* String */, "string"); - var numberType = createIntrinsicType(4 /* Number */, "number"); - var trueType = createIntrinsicType(128 /* BooleanLiteral */, "true"); - var falseType = createIntrinsicType(128 /* BooleanLiteral */, "false"); + var errorType = createIntrinsicType(1 /* Any */, "error"); + var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); + var undefinedType = createIntrinsicType(8192 /* Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(8192 /* Undefined */ | 134217728 /* ContainsWideningType */, "undefined"); + var nullType = createIntrinsicType(16384 /* Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(16384 /* Null */ | 134217728 /* ContainsWideningType */, "null"); + var stringType = createIntrinsicType(4 /* String */, "string"); + var numberType = createIntrinsicType(8 /* Number */, "number"); + var trueType = createIntrinsicType(256 /* BooleanLiteral */, "true"); + var falseType = createIntrinsicType(256 /* BooleanLiteral */, "false"); var booleanType = createBooleanType([trueType, falseType]); - var esSymbolType = createIntrinsicType(512 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(2048 /* Void */, "void"); - var neverType = createIntrinsicType(16384 /* Never */, "never"); - var silentNeverType = createIntrinsicType(16384 /* Never */, "never"); - var implicitNeverType = createIntrinsicType(16384 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(134217728 /* NonPrimitive */, "object"); + var esSymbolType = createIntrinsicType(1024 /* ESSymbol */, "symbol"); + var voidType = createIntrinsicType(4096 /* Void */, "void"); + var neverType = createIntrinsicType(32768 /* Never */, "never"); + var silentNeverType = createIntrinsicType(32768 /* Never */, "never"); + var implicitNeverType = createIntrinsicType(32768 /* Never */, "never"); + var nonPrimitiveType = createIntrinsicType(16777216 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); @@ -26789,17 +26894,17 @@ 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.flags |= 67108864 /* ContainsAnyFunctionType */; + anyFunctionType.flags |= 536870912 /* ContainsAnyFunctionType */; 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); - var markerSuperType = createType(32768 /* TypeParameter */); - var markerSubType = createType(32768 /* TypeParameter */); + var markerSuperType = createType(65536 /* TypeParameter */); + var markerSubType = createType(65536 /* TypeParameter */); markerSubType.constraint = markerSuperType; - var markerOtherType = createType(32768 /* TypeParameter */); + var markerOtherType = createType(65536 /* TypeParameter */); var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, unknownType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var resolvingSignaturesArray = [resolvingSignature]; @@ -27028,6 +27133,7 @@ var ts; typeToString(type, enclosingDeclaration, flags, emitTextWriterWrapper(writer)); }, buildSymbolDisplay: function (symbol, writer, enclosingDeclaration, meaning, flags) { + if (flags === void 0) { flags = 0 /* None */; } symbolToString(symbol, enclosingDeclaration, meaning, flags | 4 /* AllowAnyNodeKind */, emitTextWriterWrapper(writer)); }, buildSignatureDisplay: function (signature, writer, enclosing, flags, kind) { @@ -27041,12 +27147,12 @@ var ts; buildParameterDisplay: function (symbol, writer, enclosing, flags) { var node = nodeBuilder.symbolToParameterDeclaration(symbol, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); + printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 }, buildTypeParameterDisplay: function (tp, writer, enclosing, flags) { var node = nodeBuilder.typeParameterToDeclaration(tp, enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 8192 /* OmitParameterModifiers */, writer); var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); + printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 }, buildTypePredicateDisplay: function (predicate, writer, enclosing, flags) { typePredicateToString(predicate, enclosing, flags, emitTextWriterWrapper(writer)); @@ -27059,13 +27165,13 @@ var ts; buildDisplayForParametersAndDelimiters: function (thisParameter, parameters, writer, enclosing, originalFlags) { var printer = ts.createPrinter({ removeComments: true }); var flags = 8192 /* OmitParameterModifiers */ | 3112960 /* IgnoreErrors */ | toNodeBuilderFlags(originalFlags); - var thisParameterArray = thisParameter ? [nodeBuilder.symbolToParameterDeclaration(thisParameter, enclosing, flags)] : []; - var params = ts.createNodeArray(thisParameterArray.concat(ts.map(parameters, function (param) { return nodeBuilder.symbolToParameterDeclaration(param, enclosing, flags); }))); + var thisParameterArray = thisParameter ? [nodeBuilder.symbolToParameterDeclaration(thisParameter, enclosing, flags)] : []; // TODO: GH#18217 + var params = ts.createNodeArray(thisParameterArray.concat(ts.map(parameters, function (param) { return nodeBuilder.symbolToParameterDeclaration(param, enclosing, flags); }))); // TODO: GH#18217 printer.writeList(1296 /* CallExpressionArguments */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); }, buildDisplayForTypeParametersAndDelimiters: function (typeParameters, writer, enclosing, flags) { var printer = ts.createPrinter({ removeComments: true }); - var args = ts.createNodeArray(ts.map(typeParameters, function (p) { return nodeBuilder.typeParameterToDeclaration(p, enclosing, toNodeBuilderFlags(flags)); })); + var args = ts.createNodeArray(ts.map(typeParameters, function (p) { return nodeBuilder.typeParameterToDeclaration(p, enclosing, toNodeBuilderFlags(flags)); })); // TODO: GH#18217 printer.writeList(26896 /* TypeParameters */, args, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); }, buildReturnTypeDisplay: function (signature, writer, enclosing, flags) { @@ -27077,7 +27183,7 @@ var ts; } var node = nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosing, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); var printer = ts.createPrinter({ removeComments: true }); - printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); + printer.writeNode(4 /* Unspecified */, node, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosing)), emitTextWriterWrapper(writer)); // TODO: GH#18217 } }; function emitTextWriterWrapper(underlying) { @@ -27164,7 +27270,7 @@ var ts; } var jsxPragma = file_1.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 file_1.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file_1.localJsxFactory) { return file_1.localJsxNamespace = getFirstIdentifier(file_1.localJsxFactory).escapedText; @@ -27276,11 +27382,17 @@ var ts; recordMergedSymbol(result, symbol); return result; } + /** + * Note: if target is transient, then it is mutable, and mergeSymbol with both mutate and return it. + * If target is not transient, mergeSymbol will produce a transient clone, mutate that and return it. + */ function mergeSymbol(target, source) { if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864 /* JSContainer */) { - var targetValueDeclaration = target.valueDeclaration; - ts.Debug.assert(!!(target.flags & 33554432 /* Transient */)); + ts.Debug.assert(source !== target); + if (!(target.flags & 33554432 /* Transient */)) { + target = cloneSymbol(target); + } // Javascript static-property-assignment declarations always merge, even though they are also values if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { // reset flag when merging instantiated module into value module that has only const enums @@ -27289,7 +27401,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 238 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 238 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 239 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 239 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -27304,18 +27416,6 @@ var ts; target.exports = ts.createSymbolTable(); mergeSymbolTable(target.exports, source.exports); } - if ((source.flags | target.flags) & 67108864 /* JSContainer */) { - var sourceInitializer = ts.getJSInitializerSymbol(source); - var init = ts.getDeclaredJavascriptInitializer(targetValueDeclaration) || ts.getAssignedJavascriptInitializer(targetValueDeclaration); - var targetInitializer = init && init.symbol ? init.symbol : target; - if (!(targetInitializer.flags & 33554432 /* Transient */)) { - var mergedInitializer = getMergedSymbol(targetInitializer); - targetInitializer = mergedInitializer === targetInitializer ? cloneSymbol(targetInitializer) : mergedInitializer; - } - if (sourceInitializer !== source || targetInitializer !== target) { - mergeSymbol(targetInitializer, sourceInitializer); - } - } recordMergedSymbol(target, source); } else if (target.flags & 1024 /* NamespaceModule */) { @@ -27336,11 +27436,12 @@ var ts; error(errorNode, message_2, symbolToString(source)); }); } + return target; } function combineSymbolTables(first, second) { - if (!first || first.size === 0) + if (!ts.hasEntries(first)) return second; - if (!second || second.size === 0) + if (!ts.hasEntries(second)) return first; var combined = ts.createSymbolTable(); mergeSymbolTable(combined, first); @@ -27349,17 +27450,7 @@ var ts; } function mergeSymbolTable(target, source) { source.forEach(function (sourceSymbol, id) { - var targetSymbol = target.get(id); - if (!targetSymbol) { - target.set(id, sourceSymbol); - } - else { - if (!(targetSymbol.flags & 33554432 /* Transient */)) { - targetSymbol = cloneSymbol(targetSymbol); - target.set(id, targetSymbol); - } - mergeSymbol(targetSymbol, sourceSymbol); - } + target.set(id, target.has(id) ? mergeSymbol(target.get(id), sourceSymbol) : sourceSymbol); }); } function mergeModuleAugmentation(moduleName) { @@ -27387,10 +27478,7 @@ var ts; // obtain item referenced by 'export=' mainModule = resolveExternalModuleSymbol(mainModule); if (mainModule.flags & 1920 /* Namespace */) { - // if module symbol has already been merged - it is safe to use it. - // otherwise clone it - mainModule = mainModule.flags & 33554432 /* Transient */ ? mainModule : cloneSymbol(mainModule); - mergeSymbol(mainModule, moduleAugmentation.symbol); + mainModule = mergeSymbol(mainModule, moduleAugmentation.symbol); } else { // moduleName will be a StringLiteral since this is not `declare global`. @@ -27424,7 +27512,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 273 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 274 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -27459,7 +27547,7 @@ var ts; if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } - ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration"); + return ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration"); } function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { var declarationFile = ts.getSourceFileOfNode(declaration); @@ -27482,17 +27570,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 181 /* BindingElement */) { + if (declaration.kind === 182 /* 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, 181 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 182 /* 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, 231 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 232 /* VariableDeclaration */), usage); } - else if (declaration.kind === 231 /* VariableDeclaration */) { + else if (declaration.kind === 232 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -27510,12 +27598,12 @@ var ts; // 5. inside a TS export= declaration (since we will move the export statement during emit to avoid TDZ) // or if usage is in a type context: // 1. inside a type query (typeof in type position) - if (usage.parent.kind === 251 /* ExportSpecifier */ || (usage.parent.kind === 248 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 252 /* ExportSpecifier */ || (usage.parent.kind === 249 /* 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 === 248 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 249 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); @@ -27523,9 +27611,9 @@ var ts; function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 213 /* VariableStatement */: - case 219 /* ForStatement */: - case 221 /* ForOfStatement */: + case 214 /* VariableStatement */: + case 220 /* ForStatement */: + case 222 /* 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, container)) { @@ -27534,7 +27622,8 @@ var ts; break; } // ForIn/ForOf case - use site should not be used in expression part - return ts.isForInOrOfStatement(declaration.parent.parent) && isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container); + var grandparent = declaration.parent.parent; + return ts.isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, container); } function isUsedInFunctionOrInstanceProperty(usage, declaration, container) { return !!ts.findAncestor(usage, function (current) { @@ -27545,21 +27634,22 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 151 /* PropertyDeclaration */ && + current.parent.kind === 152 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 153 /* MethodDeclaration */) { + if (declaration.kind === 154 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 151 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 152 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } } } + return false; }); } } @@ -27595,12 +27685,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 & 67901928 /* Type */ && lastLocation.kind !== 285 /* JSDocComment */) { + if (meaning & result.flags & 67901928 /* Type */ && lastLocation.kind !== 286 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 148 /* Parameter */ || - lastLocation.kind === 147 /* TypeParameter */ + lastLocation.kind === 149 /* Parameter */ || + lastLocation.kind === 148 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -27610,12 +27700,12 @@ 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 === 148 /* Parameter */ || + lastLocation.kind === 149 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } - else if (location.kind === 170 /* ConditionalType */) { + else if (location.kind === 171 /* 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; @@ -27629,14 +27719,14 @@ var ts; } } switch (location.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 273 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 274 /* SourceFile */ || ts.isAmbientModule(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 */)) { @@ -27660,21 +27750,27 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 251 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 252 /* ExportSpecifier */)) { 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 */))) { - break loop; + if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) { + result = undefined; + } + else { + break loop; + } } break; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: // 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 @@ -27691,9 +27787,9 @@ var ts; } } break; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: if (result = lookup(getMembersOfSymbol(getSymbolOfNode(location)), name, meaning & 67901928 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container @@ -27709,7 +27805,7 @@ var ts; } break loop; } - if (location.kind === 204 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 205 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -27717,7 +27813,7 @@ var ts; } } break; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. if (lastLocation === location.expression && location.parent.token === 85 /* ExtendsKeyword */) { var container = location.parent.parent; @@ -27737,9 +27833,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 235 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 236 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 67901928 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -27747,19 +27843,19 @@ var ts; } } break; - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -27772,7 +27868,7 @@ var ts; } } break; - case 149 /* Decorator */: + case 150 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -27781,7 +27877,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 === 148 /* Parameter */) { + if (location.parent && location.parent.kind === 149 /* Parameter */) { location = location.parent; } // @@ -27794,12 +27890,11 @@ var ts; location = location.parent; } break; - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: // js type aliases do not resolve names from their host, so skip past it - lastLocation = location; - location = ts.getJSDocHost(location).parent; - continue; + location = ts.getJSDocHost(location); + break; } if (isSelfReferenceLocation(location)) { lastSelfReferenceLocation = location; @@ -27815,7 +27910,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 273 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 274 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports") { return lastLocation.symbol; } @@ -27838,7 +27933,7 @@ var ts; if (!result) { if (nameNotFoundMessage) { if (!errorLocation || - !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && + !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217 !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) && @@ -27889,8 +27984,8 @@ var ts; // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 67216319 /* Value */) === 67216319 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 241 /* NamespaceExportDeclaration */) { - error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); + if (decls && decls.length === 1 && decls[0].kind === 242 /* NamespaceExportDeclaration */) { + error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); // TODO: GH#18217 } } } @@ -27898,12 +27993,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 238 /* ModuleDeclaration */: // For `namespace N { N; }` + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 239 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -27915,10 +28010,10 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 147 /* TypeParameter */) { + if (decl.kind === 148 /* 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)); + return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 } } } @@ -27945,7 +28040,7 @@ var ts; // No static member is present. // Check if we're in an instance method and look for a relevant instance member. if (location === container && !ts.hasModifier(location, 32 /* Static */)) { - var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; + var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType; // TODO: GH#18217 if (getPropertyOfType(instanceType, name)) { error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg)); return true; @@ -27958,11 +28053,11 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - var isError = !!(expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)); - if (isError) { + if (expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); + return true; } - return isError; + return false; } /** * Climbs up parents to an ExpressionWithTypeArguments, and returns its expression, @@ -27971,9 +28066,9 @@ var ts; function getEntityNameForExtendingInterface(node) { switch (node.kind) { case 71 /* Identifier */: - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -28037,8 +28132,9 @@ var ts; function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); // Block-scoped variables cannot be used before their definition - var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 237 /* EnumDeclaration */) ? d : undefined; }); - ts.Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined"); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 238 /* EnumDeclaration */) ? d : undefined; }); + if (declaration === undefined) + return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { if (result.flags & 2 /* BlockScopedVariable */) { error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(ts.getNameOfDeclaration(declaration))); @@ -28056,17 +28152,17 @@ var ts; * Return false if 'stopAt' node is reached or isFunctionLike(current) === true. */ function isSameScopeDescendentOf(initial, parent, stopAt) { - return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); + return !!parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); } function getAnyImportSyntax(node) { switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return node; - case 244 /* ImportClause */: + case 245 /* ImportClause */: return node.parent; - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return node.parent.parent; - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -28076,7 +28172,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 253 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -28088,7 +28184,7 @@ var ts; : resolveSymbol(moduleSymbol.exports.get(name), dontResolveAlias); } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasModifier(node, 512 /* Default */)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasModifier(node, 512 /* Default */) || ts.isExportSpecifier(node)); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias) { if (!allowSyntheticDefaultImports) { @@ -28191,12 +28287,13 @@ var ts; if (symbol.flags & 3 /* Variable */) { var typeAnnotation = symbol.valueDeclaration.type; if (typeAnnotation) { - return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); + return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); // TODO: GH#18217 } } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); + if (dontResolveAlias === void 0) { dontResolveAlias = false; } + var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); if (targetSymbol) { var name = specifier.propertyName || specifier.name; @@ -28261,22 +28358,25 @@ var ts; return getNodeLinks(expression).resolvedSymbol; } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { + if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 251 /* ExportSpecifier */: + case 252 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 248 /* ExportAssignment */: - case 199 /* BinaryExpression */: + case 249 /* ExportAssignment */: + case 200 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + default: + return ts.Debug.fail(); } } /** @@ -28287,11 +28387,10 @@ var ts; if (excludes === void 0) { excludes = 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */; } if (!symbol) return false; - return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || (symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* JSContainer */); + return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* JSContainer */); } function resolveSymbol(symbol, dontResolveAlias) { - var shouldResolve = !dontResolveAlias && isNonLocalAlias(symbol); - return shouldResolve ? resolveAlias(symbol) : symbol; + return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); @@ -28299,7 +28398,8 @@ var ts; if (!links.target) { links.target = resolvingSymbol; var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); + if (!node) + return ts.Debug.fail(); var target = getTargetOfAliasDeclaration(node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; @@ -28332,12 +28432,13 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - ts.Debug.assert(!!node); - if (node.kind === 248 /* ExportAssignment */) { + if (!node) + return ts.Debug.fail(); + if (node.kind === 249 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 251 /* ExportSpecifier */) { + else if (node.kind === 252 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -28359,13 +28460,13 @@ var ts; entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 71 /* Identifier */ || entityName.parent.kind === 145 /* QualifiedName */) { + if (entityName.kind === 71 /* Identifier */ || entityName.parent.kind === 146 /* 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 === 242 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 243 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -28389,9 +28490,9 @@ var ts; return symbolFromJSPrototype; } } - else if (name.kind === 145 /* QualifiedName */ || name.kind === 184 /* PropertyAccessExpression */) { - var left = name.kind === 145 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 145 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 146 /* QualifiedName */ || name.kind === 185 /* PropertyAccessExpression */) { + var left = name.kind === 146 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 146 /* QualifiedName */ ? name.right : name.name; var namespace_1 = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace_1 || ts.nodeIsMissing(right)) { return undefined; @@ -28400,14 +28501,6 @@ var ts; return namespace_1; } if (ts.isInJavaScriptFile(name)) { - var initializer = ts.getDeclaredJavascriptInitializer(namespace_1.valueDeclaration) || ts.getAssignedJavascriptInitializer(namespace_1.valueDeclaration); - if (initializer) { - namespace_1 = getSymbolOfNode(initializer); - } - // Currently, IIFEs may not have a symbol and we don't know about their contents. Give up in this case. - if (!namespace_1) { - return undefined; - } if (namespace_1.valueDeclaration && ts.isVariableDeclaration(namespace_1.valueDeclaration) && namespace_1.valueDeclaration.initializer && @@ -28431,7 +28524,7 @@ var ts; } } else { - ts.Debug.assertNever(name, "Unknown entity name kind."); + 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."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -28492,7 +28585,7 @@ var ts; return ambientModule; } var currentSourceFile = ts.getSourceFileOfNode(location); - var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference); + var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference); // TODO: GH#18217 var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule); var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName); if (sourceFile) { @@ -28566,8 +28659,6 @@ var ts; /*details*/ undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, ts.getMangledNameForScopedPackage(packageId.name)); errorOrSuggestion(isError, errorNode, ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedFileName)); } - // An external module with an 'export =' declaration resolves to the target of the 'export =' declaration, - // and an external module with no 'export =' declaration resolves to the module itself. function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { return moduleSymbol && getMergedSymbol(getCommonJsExportEquals(resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias), moduleSymbol)) || moduleSymbol; } @@ -28583,14 +28674,7 @@ var ts; moduleSymbol.exports.forEach(function (s, name) { if (name === "export=" /* ExportEquals */) return; - if (!merged.exports.has(name)) { - merged.exports.set(name, s); - } - else { - var ms = cloneSymbol(merged.exports.get(name)); - mergeSymbol(ms, s); - merged.exports.set(name, ms); - } + merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); return merged; } @@ -28668,7 +28752,7 @@ var ts; return undefined; } var type = getTypeOfSymbol(exportEquals); - return type.flags & 16382 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); + return type.flags & 32764 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : @@ -28758,6 +28842,43 @@ var ts; function getParentOfSymbol(symbol) { return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent)); } + /** + * Attempts to find the symbol corresponding to the container a symbol is in - usually this + * is just its' `.parent`, but for locals, this value is `undefined` + */ + function getContainerOfSymbol(symbol) { + var container = getParentOfSymbol(symbol); + if (container) { + return container; + } + var candidate = ts.forEach(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + if (!candidate) { + return undefined; + } + var alias = getAliasForSymbolInContainer(candidate, symbol); + return alias ? candidate : undefined; + } + function getAliasForSymbolInContainer(container, symbol) { + if (container === getParentOfSymbol(symbol)) { + // fast path, `symbol` is either already the alias or isn't aliased + return symbol; + } + var exports = getExportsOfSymbol(container); + var quick = exports.get(symbol.escapedName); + if (quick && symbolRefersToTarget(quick)) { + return quick; + } + return ts.forEachEntry(exports, function (exported) { + if (symbolRefersToTarget(exported)) { + return exported; + } + }); + function symbolRefersToTarget(s) { + if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { + return s; + } + } + } function getExportSymbolOfValueSymbolIfExported(symbol) { return symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 ? getMergedSymbol(symbol.exportSymbol) @@ -28770,7 +28891,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 154 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 155 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -28788,12 +28909,12 @@ var ts; } function createBooleanType(trueFalseTypes) { var type = getUnionType(trueFalseTypes); - type.flags |= 8 /* Boolean */; + type.flags |= 16 /* Boolean */; type.intrinsicName = "boolean"; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(65536 /* Object */); + var type = createType(131072 /* Object */); type.objectFlags = objectFlags; type.symbol = symbol; return type; @@ -28848,12 +28969,12 @@ var ts; } } switch (location.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -28899,7 +29020,7 @@ var ts; // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible - !ts.some(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); } function trySymbolTable(symbols, ignoreQualification) { @@ -28927,6 +29048,11 @@ var ts; return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); } } + if (symbolFromSymbolTable.escapedName === symbol.escapedName && symbolFromSymbolTable.exportSymbol) { + if (isAccessible(getMergedSymbol(symbolFromSymbolTable.exportSymbol), /*aliasSymbol*/ undefined, ignoreQualification)) { + return [symbol]; + } + } }); } } @@ -28934,7 +29060,7 @@ var ts; var qualify = false; forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) { // If symbol of this name is not available in the symbol table we are ok - var symbolFromSymbolTable = symbolTable.get(symbol.escapedName); + var symbolFromSymbolTable = getMergedSymbol(symbolTable.get(symbol.escapedName)); if (!symbolFromSymbolTable) { // Continue to the next symbol table return false; @@ -28945,7 +29071,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, 251 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 252 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -28960,10 +29086,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: continue; default: return false; @@ -29008,7 +29134,7 @@ var ts; return hasAccessibleDeclarations; } else { - if (ts.some(symbol.declarations, hasExternalModuleSymbol)) { + if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // Any meaning of a module symbol is always accessible via an `import` type return { accessibility: 0 /* Accessible */ @@ -29028,7 +29154,7 @@ var ts; // But it can't, hence the accessible is going to be undefined, but that doesn't mean m.c is inaccessible // It is accessible if the parent m is accessible because then m.c can be accessed through qualification meaningToLook = getQualifiedLeftMeaning(meaning); - symbol = getParentOfSymbol(symbol); + symbol = getContainerOfSymbol(symbol); } // This could be a symbol that is not exported in the external module // or it could be a symbol from different external module that is not aliased and hence cannot be named @@ -29057,7 +29183,10 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 273 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + } + function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -29104,14 +29233,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 164 /* TypeQuery */ || + if (entityName.parent.kind === 165 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 146 /* ComputedPropertyName */) { + entityName.parent.kind === 147 /* ComputedPropertyName */) { // Typeof value meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 145 /* QualifiedName */ || entityName.kind === 184 /* PropertyAccessExpression */ || - entityName.parent.kind === 242 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 146 /* QualifiedName */ || entityName.kind === 185 /* PropertyAccessExpression */ || + entityName.parent.kind === 243 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -29144,7 +29273,7 @@ var ts; var builder = flags & 4 /* AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker); function symbolToStringWorker(writer) { - var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); + var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); @@ -29152,27 +29281,29 @@ var ts; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { + if (flags === void 0) { flags = 0 /* None */; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 163 /* ConstructorType */ : 162 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 164 /* ConstructorType */ : 163 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 158 /* ConstructSignature */ : 157 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 159 /* ConstructSignature */ : 158 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, writer); // TODO: GH#18217 return writer; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */; } + if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; } if (writer === void 0) { writer = ts.createTextWriter(""); } var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */, writer); - ts.Debug.assert(typeNode !== undefined, "should always get typenode"); + if (typeNode === undefined) + return ts.Debug.fail("should always get typenode"); var options = { removeComments: true }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); @@ -29185,6 +29316,7 @@ var ts; return result; } function toNodeBuilderFlags(flags) { + if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; } function createNodeBuilder() { @@ -29201,7 +29333,7 @@ var ts; var context = createNodeBuilderContext(enclosingDeclaration, flags, tracker); var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); var result = context.encounteredError ? undefined : resultingNode; - return result; + return result; // TODO: GH#18217 }, signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); @@ -29249,7 +29381,7 @@ var ts; function createNodeBuilderContext(enclosingDeclaration, flags, tracker) { return { enclosingDeclaration: enclosingDeclaration, - flags: flags, + flags: flags || 0 /* None */, tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop }, encounteredError: false, visitedSymbols: undefined, @@ -29264,40 +29396,43 @@ var ts; context.flags &= ~8388608 /* InTypeAlias */; if (!type) { context.encounteredError = true; - return undefined; + return undefined; // TODO: GH#18217 } if (type.flags & 1 /* Any */) { return ts.createKeywordTypeNode(119 /* AnyKeyword */); } - if (type.flags & 2 /* String */) { + if (type.flags & 2 /* Unknown */) { + return ts.createKeywordTypeNode(142 /* UnknownKeyword */); + } + if (type.flags & 4 /* String */) { return ts.createKeywordTypeNode(137 /* StringKeyword */); } - if (type.flags & 4 /* Number */) { + if (type.flags & 8 /* Number */) { return ts.createKeywordTypeNode(134 /* NumberKeyword */); } - if (type.flags & 8 /* Boolean */) { + if (type.flags & 16 /* Boolean */) { return ts.createKeywordTypeNode(122 /* BooleanKeyword */); } - if (type.flags & 256 /* EnumLiteral */ && !(type.flags & 131072 /* Union */)) { + if (type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); var parentName = symbolToName(parentSymbol, context, 67901928 /* Type */, /*expectsIdentifier*/ false); var enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : ts.createQualifiedName(parentName, ts.symbolName(type.symbol)); return ts.createTypeReferenceNode(enumLiteralName, /*typeArguments*/ undefined); } - if (type.flags & 272 /* EnumLike */) { + if (type.flags & 544 /* EnumLike */) { var name = symbolToName(type.symbol, context, 67901928 /* Type */, /*expectsIdentifier*/ false); return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); } - if (type.flags & (32 /* StringLiteral */)) { + if (type.flags & (64 /* StringLiteral */)) { return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value), 16777216 /* NoAsciiEscaping */)); } - if (type.flags & (64 /* NumberLiteral */)) { + if (type.flags & (128 /* NumberLiteral */)) { return ts.createLiteralTypeNode((ts.createLiteral(type.value))); } - if (type.flags & 128 /* BooleanLiteral */) { + if (type.flags & 256 /* BooleanLiteral */) { return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); } - if (type.flags & 1024 /* UniqueESSymbol */) { + if (type.flags & 2048 /* UniqueESSymbol */) { if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return symbolToTypeNode(type.symbol, context, 67216319 /* Value */); @@ -29308,25 +29443,25 @@ var ts; } return ts.createTypeOperatorNode(141 /* UniqueKeyword */, ts.createKeywordTypeNode(138 /* SymbolKeyword */)); } - if (type.flags & 2048 /* Void */) { + if (type.flags & 4096 /* Void */) { return ts.createKeywordTypeNode(105 /* VoidKeyword */); } - if (type.flags & 4096 /* Undefined */) { + if (type.flags & 8192 /* Undefined */) { return ts.createKeywordTypeNode(140 /* UndefinedKeyword */); } - if (type.flags & 8192 /* Null */) { + if (type.flags & 16384 /* Null */) { return ts.createKeywordTypeNode(95 /* NullKeyword */); } - if (type.flags & 16384 /* Never */) { + if (type.flags & 32768 /* Never */) { return ts.createKeywordTypeNode(131 /* NeverKeyword */); } - if (type.flags & 512 /* ESSymbol */) { + if (type.flags & 1024 /* ESSymbol */) { return ts.createKeywordTypeNode(138 /* SymbolKeyword */); } - if (type.flags & 134217728 /* NonPrimitive */) { + if (type.flags & 16777216 /* NonPrimitive */) { return ts.createKeywordTypeNode(135 /* ObjectKeyword */); } - if (type.flags & 32768 /* TypeParameter */ && type.isThisType) { + if (type.flags & 65536 /* TypeParameter */ && type.isThisType) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { context.encounteredError = true; @@ -29339,24 +29474,25 @@ var ts; } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 65536 /* Object */)); + ts.Debug.assert(!!(type.flags & 131072 /* Object */)); return typeReferenceToTypeNode(type); } - if (type.flags & 32768 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 32768 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 65536 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { + if (type.flags & 65536 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 32768 /* TypeParameter */ && + type.flags & 65536 /* TypeParameter */ && ts.length(type.symbol.declarations) && ts.isTypeParameterDeclaration(type.symbol.declarations[0]) && typeParameterShadowsNameInScope(type, context) && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { return ts.createTypeReferenceNode(ts.getGeneratedNameForNode(type.symbol.declarations[0].name, 16 /* Optimistic */ | 8 /* ReservedInNestedScopes */), /*typeArguments*/ undefined); } - var name = type.symbol ? symbolToName(type.symbol, context, 67901928 /* Type */, /*expectsIdentifier*/ false) : ts.createIdentifier("?"); // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. - return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + return type.symbol + ? symbolToTypeNode(type.symbol, context, 67901928 /* Type */) + : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); @@ -29364,36 +29500,36 @@ var ts; return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); return symbolToTypeNode(type.aliasSymbol, context, 67901928 /* Type */, typeArgumentNodes); } - if (type.flags & (131072 /* Union */ | 262144 /* Intersection */)) { - var types = type.flags & 131072 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (262144 /* Union */ | 524288 /* Intersection */)) { + var types = type.flags & 262144 /* Union */ ? formatUnionTypes(type.types) : type.types; var typeNodes = mapToTypeNodes(types, context); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 131072 /* Union */ ? 168 /* UnionType */ : 169 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 262144 /* Union */ ? 169 /* UnionType */ : 170 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { if (!context.encounteredError && !(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; } - return undefined; + return undefined; // TODO: GH#18217 } } if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 65536 /* Object */)); + ts.Debug.assert(!!(type.flags & 131072 /* Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 524288 /* Index */) { + if (type.flags & 1048576 /* Index */) { var indexedType = type.type; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); return ts.createTypeOperatorNode(indexTypeNode); } - if (type.flags & 1048576 /* IndexedAccess */) { + if (type.flags & 2097152 /* IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 2097152 /* Conditional */) { + if (type.flags & 4194304 /* Conditional */) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -29403,12 +29539,12 @@ var ts; var falseTypeNode = typeToTypeNodeHelper(getFalseTypeFromConditionalType(type), context); return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } - if (type.flags & 4194304 /* Substitution */) { + if (type.flags & 8388608 /* Substitution */) { return typeToTypeNodeHelper(type.typeVariable, context); } - ts.Debug.fail("Should be unreachable."); + return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 65536 /* Object */)); + ts.Debug.assert(!!(type.flags & 131072 /* Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -29437,7 +29573,7 @@ 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 === 204 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 205 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 67216319 /* Value */); @@ -29475,12 +29611,12 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 273 /* SourceFile */ || declaration.parent.kind === 239 /* ModuleBlock */; + return declaration.parent.kind === 274 /* SourceFile */ || declaration.parent.kind === 240 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedSymbols && context.visitedSymbols.has(id))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } @@ -29495,12 +29631,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 162 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 163 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 163 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 164 /* ConstructorType */, context); return signatureNode; } } @@ -29532,7 +29668,7 @@ var ts; return ts.createTupleTypeNode([]); } context.encounteredError = true; - return undefined; + return undefined; // TODO: GH#18217 } else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && @@ -29621,11 +29757,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 157 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 158 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 158 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 159 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexInfo = resolvedType.objectFlags & 2048 /* ReverseMapped */ ? @@ -29655,7 +29791,7 @@ var ts; var saveEnclosingDeclaration = context.enclosingDeclaration; context.enclosingDeclaration = undefined; if (ts.getCheckFlags(propertySymbol) & 1024 /* Late */) { - var decl = ts.firstOrUndefined(propertySymbol.declarations); + var decl = ts.first(propertySymbol.declarations); var name = hasLateBindableName(decl) && resolveEntityName(decl.name.expression, 67216319 /* Value */); if (name && context.tracker.trackSymbol) { context.tracker.trackSymbol(name, saveEnclosingDeclaration, 67216319 /* Value */); @@ -29668,7 +29804,7 @@ var ts; var signatures = getSignaturesOfType(propertyType, 0 /* Call */); for (var _e = 0, signatures_1 = signatures; _e < signatures_1.length; _e++) { var signature = signatures_1[_e]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 152 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 153 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; if (propertySymbol.valueDeclaration) { @@ -29718,7 +29854,7 @@ var ts; /*dotDotDotToken*/ undefined, name, /*questionToken*/ undefined, indexerTypeNode, /*initializer*/ undefined); - var typeNode = indexInfo.type ? typeToTypeNodeHelper(indexInfo.type, context) : typeToTypeNodeHelper(anyType, context); + var typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); if (!indexInfo.type && !(context.flags & 2097152 /* AllowEmptyIndexInfoType */)) { context.encounteredError = true; } @@ -29734,7 +29870,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 154 /* Constructor */); }); + var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 155 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -29786,22 +29922,22 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 148 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 149 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 292 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 293 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); - var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(ts.getSynthesizedClone); + var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration ? ts.isRestParameter(parameterDeclaration) : parameterSymbol.isRestParameter; var dotDotDotToken = isRest ? ts.createToken(24 /* DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? parameterDeclaration.name.kind === 71 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 145 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 146 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); @@ -29815,7 +29951,7 @@ var ts; function elideInitializerAndSetEmitFlags(node) { var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 181 /* BindingElement */) { + if (clone.kind === 182 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); @@ -29823,12 +29959,12 @@ var ts; } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { - context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); + context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); // TODO: GH#18217 // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */)) { - chain = getSymbolChain(symbol, meaning, /*endOfChain*/ true); + chain = ts.Debug.assertDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); ts.Debug.assert(chain && chain.length > 0); } else { @@ -29842,12 +29978,12 @@ var ts; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + var parent = getContainerOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); if (parent) { var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { parentSymbol = parent; - accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); } } } @@ -29858,7 +29994,7 @@ var ts; // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) - (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol))) && + (yieldModuleSymbol || !(!parentSymbol && ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol))) && // If a parent symbol is an anonymous type, don't write it. !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { return [symbol]; @@ -30035,6 +30171,7 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { + if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 3112960 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */)); @@ -30050,10 +30187,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 12288 /* Nullable */)) { - if (t.flags & (128 /* BooleanLiteral */ | 256 /* EnumLiteral */)) { - var baseType = t.flags & 128 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 131072 /* Union */) { + if (!(t.flags & 24576 /* Nullable */)) { + if (t.flags & (256 /* BooleanLiteral */ | 512 /* EnumLiteral */)) { + var baseType = t.flags & 256 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 262144 /* Union */) { var count = baseType.types.length; if (i + count <= types.length && types[i + count - 1] === baseType.types[count - 1]) { result.push(baseType); @@ -30065,9 +30202,9 @@ var ts; result.push(t); } } - if (flags & 8192 /* Null */) + if (flags & 16384 /* Null */) result.push(nullType); - if (flags & 4096 /* Undefined */) + if (flags & 8192 /* Undefined */) result.push(undefinedType); return result || types; } @@ -30082,8 +30219,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 172 /* ParenthesizedType */; }); - if (node.kind === 236 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 173 /* ParenthesizedType */; }); + if (node.kind === 237 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -30091,11 +30228,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 239 /* ModuleBlock */ && + node.parent.kind === 240 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 273 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 274 /* SourceFile */ || ts.isAmbientModule(location); } /** * Gets a human-readable name for a symbol. @@ -30115,15 +30252,15 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { - var file_3 = ts.getDeclarationOfKind(symbol, 273 /* SourceFile */); + if (ts.some(symbol.declarations, hasExternalModuleSymbol) && context.enclosingDeclaration) { // TODO: GH#18217 + var file_3 = ts.getDeclarationOfKind(symbol, 274 /* SourceFile */); if (!file_3 || !context.tracker.moduleResolverHost) { 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]; - context.tracker.trackReferencedAmbientModule(decl); + context.tracker.trackReferencedAmbientModule(decl); // TODO: GH#18217 } } } @@ -30138,26 +30275,26 @@ var ts; if (name) { return ts.declarationNameToString(name); } - if (declaration.parent && declaration.parent.kind === 231 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 232 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } switch (declaration.kind) { - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return "(Anonymous class)"; - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return "(Anonymous function)"; } } var nameType = symbol.nameType; if (nameType) { - if (nameType.flags & 32 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { + if (nameType.flags & 64 /* StringLiteral */ && !ts.isIdentifierText(nameType.value, compilerOptions.target)) { return "\"" + ts.escapeString(nameType.value, 34 /* doubleQuote */) + "\""; } - if (nameType && nameType.flags & 1024 /* UniqueESSymbol */) { + if (nameType && nameType.flags & 2048 /* UniqueESSymbol */) { return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; } } @@ -30174,27 +30311,27 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 291 /* JSDocCallbackTag */: - case 296 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: // 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 181 /* BindingElement */: + case 182 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 231 /* VariableDeclaration */: + case 232 /* 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 238 /* ModuleDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 233 /* FunctionDeclaration */: - case 237 /* EnumDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 239 /* ModuleDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 234 /* FunctionDeclaration */: + case 238 /* EnumDeclaration */: + case 243 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -30202,53 +30339,53 @@ 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 !== 242 /* ImportEqualsDeclaration */ && parent.kind !== 273 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 243 /* ImportEqualsDeclaration */ && parent.kind !== 274 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.hasModifier(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 154 /* Constructor */: - case 158 /* ConstructSignature */: - case 157 /* CallSignature */: - case 159 /* IndexSignature */: - case 148 /* Parameter */: - case 239 /* ModuleBlock */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 165 /* TypeLiteral */: - case 161 /* TypeReference */: - case 166 /* ArrayType */: - case 167 /* TupleType */: - case 168 /* UnionType */: - case 169 /* IntersectionType */: - case 172 /* ParenthesizedType */: + case 155 /* Constructor */: + case 159 /* ConstructSignature */: + case 158 /* CallSignature */: + case 160 /* IndexSignature */: + case 149 /* Parameter */: + case 240 /* ModuleBlock */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 166 /* TypeLiteral */: + case 162 /* TypeReference */: + case 167 /* ArrayType */: + case 168 /* TupleType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: + case 173 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 244 /* ImportClause */: - case 245 /* NamespaceImport */: - case 247 /* ImportSpecifier */: + case 245 /* ImportClause */: + case 246 /* NamespaceImport */: + case 248 /* ImportSpecifier */: return false; // Type parameters are always visible - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: // Source file and namespace export are always visible - case 273 /* SourceFile */: - case 241 /* NamespaceExportDeclaration */: + case 274 /* SourceFile */: + case 242 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return false; default: return false; @@ -30257,10 +30394,10 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 248 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 249 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 251 /* ExportSpecifier */) { + else if (node.parent.kind === 252 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; @@ -30329,22 +30466,22 @@ var ts; } function hasType(target, propertyName) { if (propertyName === 0 /* Type */) { - return getSymbolLinks(target).type; + return !!getSymbolLinks(target).type; } if (propertyName === 2 /* DeclaredType */) { - return getSymbolLinks(target).declaredType; + return !!getSymbolLinks(target).declaredType; } if (propertyName === 1 /* ResolvedBaseConstructorType */) { - return target.resolvedBaseConstructorType; + return !!target.resolvedBaseConstructorType; } if (propertyName === 3 /* ResolvedReturnType */) { - return target.resolvedReturnType; + return !!target.resolvedReturnType; } if (propertyName === 4 /* ResolvedBaseConstraint */) { var bc = target.resolvedBaseConstraint; - return bc && bc !== circularConstraintType; + return !!bc && bc !== circularConstraintType; } - ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); + return ts.Debug.fail("Unhandled TypeSystemPropertyName " + propertyName); } // Pop an entry from the type resolution stack and return its associated result value. The result value will // be true if no circularities were detected, or false if a circularity was found. @@ -30354,20 +30491,19 @@ var ts; return resolutionResults.pop(); } function getDeclarationContainer(node) { - node = ts.findAncestor(ts.getRootDeclaration(node), function (node) { + return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 231 /* VariableDeclaration */: - case 232 /* VariableDeclarationList */: - case 247 /* ImportSpecifier */: - case 246 /* NamedImports */: - case 245 /* NamespaceImport */: - case 244 /* ImportClause */: + case 232 /* VariableDeclaration */: + case 233 /* VariableDeclarationList */: + case 248 /* ImportSpecifier */: + case 247 /* NamedImports */: + case 246 /* NamespaceImport */: + case 245 /* ImportClause */: return false; default: return true; } - }); - return node && node.parent; + }).parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -30392,14 +30528,14 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 146 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 147 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 12288 /* Nullable */); }); - if (source.flags & 16384 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 24576 /* Nullable */); }); + if (source.flags & 32768 /* Never */) { return emptyObjectType; } - if (source.flags & 131072 /* Union */) { + if (source.flags & 262144 /* Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var members = ts.createSymbolTable(); @@ -30426,8 +30562,8 @@ var ts; var pattern = declaration.parent; var parentType = getTypeForBindingElementParent(pattern.parent); // If parent has the unknown (error) type, then so does this binding element - if (parentType === unknownType) { - return unknownType; + if (parentType === errorType) { + return errorType; } // If no type was specified or inferred for parent, // infer from the initializer of the binding element if one is present. @@ -30439,11 +30575,11 @@ var ts; return parentType; } var type; - if (pattern.kind === 179 /* ObjectBindingPattern */) { + if (pattern.kind === 180 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { - if (!isValidSpreadType(parentType)) { + if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); - return unknownType; + return errorType; } var literalMembers = []; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { @@ -30461,13 +30597,13 @@ var ts; var isWellKnown = ts.isComputedPropertyName(name) && ts.isWellKnownSymbolSyntactically(name.expression); if (!isLate && !isWellKnown && isComputedNonLiteralName(name)) { var exprType = checkExpression(name.expression); - if (isTypeAssignableToKind(exprType, 1536 /* ESSymbolLike */)) { + if (isTypeAssignableToKind(exprType, 3072 /* ESSymbolLike */)) { if (noImplicitAny) { error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(exprType), typeToString(parentType)); } return anyType; } - var indexerType = isTypeAssignableToKind(exprType, 84 /* NumberLike */) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); + var indexerType = isTypeAssignableToKind(exprType, 168 /* NumberLike */) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); if (!indexerType && noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { if (getIndexTypeOfType(parentType, 1 /* Number */)) { error(declaration, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); @@ -30480,7 +30616,7 @@ var ts; } // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. - var nameType = isLate && checkComputedPropertyName(name); + var nameType = isLate ? checkComputedPropertyName(name) : undefined; var text = isLate ? getLateBoundNameFromType(nameType) : isWellKnown ? ts.getPropertyNameForKnownSymbolName(ts.idText(name.expression.name)) : ts.getTextOfPropertyName(name); @@ -30488,7 +30624,7 @@ var ts; if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } - if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 1536 /* ESSymbolLike */)) { + if (isLate && nameType && !getPropertyOfType(parentType, text) && isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */)) { if (noImplicitAny) { error(declaration, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(nameType), typeToString(parentType)); } @@ -30500,7 +30636,7 @@ var ts; getIndexTypeOfType(parentType, 0 /* String */); if (!type) { error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name)); - return unknownType; + return errorType; } } } @@ -30526,13 +30662,13 @@ var ts; else { error(declaration, ts.Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); } - return unknownType; + return errorType; } } } // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 4096 /* Undefined */)) { + if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & 8192 /* Undefined */)) { type = getTypeWithFacts(type, 131072 /* NEUndefined */); } return declaration.initializer ? @@ -30552,7 +30688,7 @@ var ts; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 182 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 183 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } @@ -30562,11 +30698,11 @@ var ts; 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 === 220 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 221 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); - return indexType.flags & (32768 /* TypeParameter */ | 524288 /* Index */) ? getExtractStringType(indexType) : stringType; + return indexType.flags & (65536 /* TypeParameter */ | 1048576 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 221 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 222 /* 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, @@ -30585,7 +30721,7 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJavaScriptFile(declaration)) && - declaration.kind === 231 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + declaration.kind === 232 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -30599,11 +30735,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 148 /* Parameter */) { + if (declaration.kind === 149 /* Parameter */) { 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 === 156 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 155 /* GetAccessor */); + if (func.kind === 157 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 156 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -30657,20 +30793,20 @@ var ts; var jsDocType; var _loop_3 = function (declaration) { var declarationInConstructor = false; - var expression = declaration.kind === 199 /* BinaryExpression */ ? declaration : - declaration.kind === 184 /* PropertyAccessExpression */ ? ts.cast(declaration.parent, ts.isBinaryExpression) : + var expression = declaration.kind === 200 /* BinaryExpression */ ? declaration : + declaration.kind === 185 /* PropertyAccessExpression */ ? ts.cast(declaration.parent, ts.isBinaryExpression) : undefined; if (!expression) { - return { value: unknownType }; + return { value: errorType }; } var special = ts.getSpecialPropertyAssignmentKind(expression); if (special === 4 /* ThisProperty */) { 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. - declarationInConstructor = thisContainer.kind === 154 /* Constructor */ || - thisContainer.kind === 233 /* FunctionDeclaration */ || - (thisContainer.kind === 191 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + declarationInConstructor = thisContainer.kind === 155 /* Constructor */ || + thisContainer.kind === 234 /* FunctionDeclaration */ || + (thisContainer.kind === 192 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); if (declarationInConstructor) { definedInConstructor = true; } @@ -30685,7 +30821,7 @@ var ts; if (!jsDocType) { jsDocType = declarationType; } - else if (jsDocType !== unknownType && declarationType !== unknownType && + else if (jsDocType !== errorType && declarationType !== errorType && !isTypeIdenticalTo(jsDocType, declarationType) && !(symbol.flags & 67108864 /* JSContainer */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(jsDocType, declaration, declarationType); @@ -30742,11 +30878,11 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(12288 /* Nullable */ | 16777216 /* ContainsWideningType */)); }) ? constructorTypes : types; + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~(24576 /* Nullable */ | 134217728 /* ContainsWideningType */)); }) ? constructorTypes : types; // TODO: GH#18217 type = getUnionType(sourceTypes, 2 /* Subtype */); } var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); - if (filterType(widened, function (t) { return !!(t.flags & ~12288 /* Nullable */); }) === neverType) { + if (filterType(widened, function (t) { return !!(t.flags & ~24576 /* Nullable */); }) === neverType) { if (noImplicitAny) { reportImplicitAnyError(symbol.valueDeclaration, anyType); } @@ -30807,7 +30943,7 @@ var ts; members.set(symbol.escapedName, symbol); }); var result = createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); - result.flags |= 33554432 /* ContainsObjectLiteral */; + result.flags |= 268435456 /* ContainsObjectLiteral */; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; @@ -30818,7 +30954,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - if (elements.length === 0 || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { + if (!lastElement || (!ts.isOmittedExpression(lastElement) && lastElement.dotDotDotToken)) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. @@ -30838,7 +30974,9 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 179 /* ObjectBindingPattern */ + if (includePatternInType === void 0) { includePatternInType = false; } + if (reportErrors === void 0) { reportErrors = false; } + return pattern.kind === 180 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -30858,7 +30996,7 @@ var ts; reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 1024 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 2048 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -30875,7 +31013,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 148 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 149 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -30905,7 +31043,7 @@ var ts; var jsonSourceFile = ts.cast(declaration, ts.isJsonSourceFile); return links.type = jsonSourceFile.statements.length ? checkExpression(jsonSourceFile.statements[0].expression) : emptyObjectType; } - if (declaration.kind === 248 /* ExportAssignment */) { + if (declaration.kind === 249 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } if (ts.isInJavaScriptFile(declaration) && ts.isJSDocPropertyLikeTag(declaration) && declaration.typeExpression) { @@ -30913,7 +31051,7 @@ var ts; } // Handle variable, parameter or property if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; + return errorType; } var type = void 0; // Handle certain special assignment kinds, which happen to union across multiple declarations: @@ -30921,13 +31059,15 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 199 /* BinaryExpression */ || - declaration.kind === 184 /* PropertyAccessExpression */ && declaration.parent.kind === 199 /* BinaryExpression */) { + if (declaration.kind === 200 /* BinaryExpression */ || + declaration.kind === 185 /* PropertyAccessExpression */ && declaration.parent.kind === 200 /* BinaryExpression */) { type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isClassDeclaration(declaration) + || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) || ts.isMethodSignature(declaration)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` @@ -30956,7 +31096,7 @@ var ts; type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); } else { - ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration)); + return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.showSyntaxKind(declaration) + " for " + ts.Debug.showSymbol(symbol)); } if (!popTypeResolution()) { type = reportCircularityError(symbol); @@ -30967,7 +31107,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 155 /* GetAccessor */) { + if (accessor.kind === 156 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation && getTypeFromTypeNode(getterTypeAnnotation); } @@ -30988,8 +31128,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 155 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 156 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 157 /* SetAccessor */); if (getter && ts.isInJavaScriptFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -30997,7 +31137,7 @@ var ts; } } if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; + return errorType; } var type = void 0; // First try to see if the user specified a return type on the get-accessor. @@ -31034,7 +31174,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 155 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 156 /* GetAccessor */); error(getter_1, 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)); } } @@ -31044,16 +31184,33 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 1081344 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 2162688 /* TypeVariable */ ? baseConstructorType : undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { + var jsDeclaration = ts.getDeclarationOfJSInitializer(symbol.valueDeclaration); + if (jsDeclaration) { + var jsSymbol = getSymbolOfNode(jsDeclaration); + if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { + symbol = cloneSymbol(symbol); + // note:we overwrite links because we just cloned the symbol + links = symbol; + if (ts.hasEntries(jsSymbol.exports)) { + symbol.exports = symbol.exports || ts.createSymbolTable(); + mergeSymbolTable(symbol.exports, jsSymbol.exports); + } + if (ts.hasEntries(jsSymbol.members)) { + symbol.members = symbol.members || ts.createSymbolTable(); + mergeSymbolTable(symbol.members, jsSymbol.members); + } + } + } if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { links.type = anyType; } - else if (symbol.valueDeclaration.kind === 199 /* BinaryExpression */ || - symbol.valueDeclaration.kind === 184 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 199 /* BinaryExpression */) { + else if (symbol.valueDeclaration.kind === 200 /* BinaryExpression */ || + symbol.valueDeclaration.kind === 185 /* PropertyAccessExpression */ && symbol.valueDeclaration.parent.kind === 200 /* BinaryExpression */) { links.type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { @@ -31087,7 +31244,7 @@ var ts; // up recursively calling getTypeOfAlias, causing a stack overflow. links.type = targetSymbol.flags & 67216319 /* Value */ ? getTypeOfSymbol(targetSymbol) - : unknownType; + : errorType; } return links.type; } @@ -31096,11 +31253,11 @@ var ts; if (!links.type) { if (symbolInstantiationDepth === 100) { error(symbol.valueDeclaration, ts.Diagnostics.Generic_type_instantiation_is_excessively_deep_and_possibly_infinite); - links.type = unknownType; + links.type = errorType; } else { if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; + return errorType; } symbolInstantiationDepth++; var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); @@ -31117,7 +31274,7 @@ var ts; // Check if variable has type annotation that circularly references the variable itself if (ts.getEffectiveTypeAnnotationNode(symbol.valueDeclaration)) { error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); - return unknownType; + return errorType; } // Otherwise variable has initializer that circularly references the variable itself if (noImplicitAny) { @@ -31147,7 +31304,7 @@ var ts; if (symbol.flags & 2097152 /* Alias */) { return getTypeOfAlias(symbol); } - return unknownType; + return errorType; } function isReferenceToType(type, target) { return type !== undefined @@ -31158,16 +31315,18 @@ var ts; function getTargetType(type) { return ts.getObjectFlags(type) & 4 /* Reference */ ? type.target : type; } + // TODO: GH#18217 If `checkBase` is undefined, we should not call this because this will always return false. function hasBaseType(type, checkBase) { return check(type); function check(type) { if (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { var target = getTargetType(type); - return target === checkBase || ts.forEach(getBaseTypes(target), check); + return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 262144 /* Intersection */) { - return ts.forEach(type.types, check); + else if (type.flags & 524288 /* Intersection */) { + return ts.some(type.types, check); } + return false; } } // Appends the type parameters given by a list of declarations to a set of type parameters and returns the resulting set. @@ -31183,40 +31342,40 @@ var ts; // Return the outer type parameters of a node or undefined if the node has no outer type parameters. function getOuterTypeParameters(node, includeThisTypes) { while (true) { - node = node.parent; + node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead if (!node) { return undefined; } switch (node.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 152 /* MethodSignature */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 283 /* JSDocFunctionType */: - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 236 /* TypeAliasDeclaration */: - case 295 /* JSDocTemplateTag */: - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: - case 176 /* MappedType */: - case 170 /* ConditionalType */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 153 /* MethodSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 284 /* JSDocFunctionType */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 237 /* TypeAliasDeclaration */: + case 296 /* JSDocTemplateTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 177 /* MappedType */: + case 171 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 176 /* MappedType */) { + if (node.kind === 177 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 170 /* ConditionalType */) { + else if (node.kind === 171 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 234 /* ClassDeclaration */ || node.kind === 204 /* ClassExpression */ || node.kind === 235 /* InterfaceDeclaration */) && + (node.kind === 235 /* ClassDeclaration */ || node.kind === 205 /* ClassExpression */ || node.kind === 236 /* InterfaceDeclaration */) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -31224,7 +31383,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 235 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 236 /* InterfaceDeclaration */); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -31233,9 +31392,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 235 /* InterfaceDeclaration */ || - node.kind === 234 /* ClassDeclaration */ || - node.kind === 204 /* ClassExpression */ || + if (node.kind === 236 /* InterfaceDeclaration */ || + node.kind === 235 /* ClassDeclaration */ || + node.kind === 205 /* ClassExpression */ || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -31262,9 +31421,9 @@ var ts; if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } - if (type.flags & 1081344 /* TypeVariable */) { + if (type.flags & 2162688 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } return false; } @@ -31306,25 +31465,25 @@ var ts; return type.resolvedBaseConstructorType = undefinedType; } if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { - return unknownType; + return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); if (extended && baseTypeNode !== extended) { ts.Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag checkExpression(extended.expression); } - if (baseConstructorType.flags & (65536 /* Object */ | 262144 /* Intersection */)) { + if (baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */)) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); - return type.resolvedBaseConstructorType = unknownType; + return type.resolvedBaseConstructorType = errorType; } if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - return type.resolvedBaseConstructorType = unknownType; + return type.resolvedBaseConstructorType = errorType; } type.resolvedBaseConstructorType = baseConstructorType; } @@ -31352,7 +31511,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (65536 /* Object */ | 262144 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 1 /* Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -31380,7 +31539,7 @@ var ts; } baseType = getReturnTypeOfSignature(constructors[0]); } - if (baseType === unknownType) { + if (baseType === errorType) { return type.resolvedBaseTypes = ts.emptyArray; } if (!isValidBaseType(baseType)) { @@ -31396,7 +31555,7 @@ var ts; // (otherwise there'd be an error from hasBaseType) - this is fine, but `.members` should be reset // as `getIndexedAccessType` via `instantiateType` via `getTypeFromClassOrInterfaceReference` forces a // partial instantiation of the members without the base types fully resolved - type.members = undefined; + type.members = undefined; // TODO: GH#18217 } return type.resolvedBaseTypes = [baseType]; } @@ -31414,18 +31573,18 @@ var ts; // A valid base type is `any`, any non-generic object type or intersection of non-generic // object types. function isValidBaseType(type) { - return type.flags & (65536 /* Object */ | 134217728 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || - type.flags & 262144 /* Intersection */ && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); + return !!(type.flags & (131072 /* Object */ | 16777216 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || + !!(type.flags & 524288 /* Intersection */) && !ts.some(type.types, function (t) { return !isValidBaseType(t); }); } 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 === 235 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 236 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); - if (baseType !== unknownType) { + if (baseType !== errorType) { if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { if (type.resolvedBaseTypes === ts.emptyArray) { @@ -31457,7 +31616,7 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 235 /* InterfaceDeclaration */) { + if (declaration.kind === 236 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -31498,7 +31657,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(32768 /* TypeParameter */); + type.thisType = createType(65536 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.symbol = symbol; type.thisType.constraint = type; @@ -31512,14 +31671,14 @@ var ts; // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { - return unknownType; + return errorType; } var declaration = ts.find(symbol.declarations, function (d) { - return ts.isJSDocTypeAlias(d) || d.kind === 236 /* TypeAliasDeclaration */; + return ts.isJSDocTypeAlias(d) || d.kind === 237 /* TypeAliasDeclaration */; }); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. - var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType; + var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { @@ -31531,7 +31690,7 @@ var ts; } } else { - type = unknownType; + type = errorType; error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } links.declaredType = type; @@ -31542,7 +31701,7 @@ var ts; if (expr.kind === 9 /* StringLiteral */) { return true; } - else if (expr.kind === 199 /* BinaryExpression */) { + else if (expr.kind === 200 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -31556,12 +31715,12 @@ var ts; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return true; - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; case 71 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -31575,7 +31734,7 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 237 /* EnumDeclaration */) { + if (declaration.kind === 238 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && member.initializer.kind === 9 /* StringLiteral */) { @@ -31590,7 +31749,7 @@ var ts; return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 256 /* EnumLiteral */ && !(type.flags & 131072 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 512 /* EnumLiteral */ && !(type.flags & 262144 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); @@ -31602,10 +31761,10 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 237 /* EnumDeclaration */) { + if (declaration.kind === 238 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); + var memberType = getLiteralType(getEnumMemberValue(member), enumCount, getSymbolOfNode(member)); // TODO: GH#18217 getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType; memberTypeList.push(memberType); } @@ -31613,14 +31772,14 @@ var ts; } if (memberTypeList.length) { var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 131072 /* Union */) { - enumType_1.flags |= 256 /* EnumLiteral */; + if (enumType_1.flags & 262144 /* Union */) { + enumType_1.flags |= 512 /* EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(16 /* Enum */); + var enumType = createType(32 /* Enum */); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -31637,7 +31796,7 @@ var ts; function getDeclaredTypeOfTypeParameter(symbol) { var links = getSymbolLinks(symbol); if (!links.declaredType) { - var type = createType(32768 /* TypeParameter */); + var type = createType(65536 /* TypeParameter */); type.symbol = symbol; links.declaredType = type; } @@ -31651,7 +31810,7 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - return tryGetDeclaredTypeOfSymbol(symbol) || unknownType; + return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { @@ -31682,6 +31841,7 @@ var ts; function isThislessType(node) { switch (node.kind) { case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 137 /* StringKeyword */: case 134 /* NumberKeyword */: case 122 /* BooleanKeyword */: @@ -31691,11 +31851,11 @@ var ts; case 140 /* UndefinedKeyword */: case 95 /* NullKeyword */: case 131 /* NeverKeyword */: - case 177 /* LiteralType */: + case 178 /* LiteralType */: return true; - case 166 /* ArrayType */: + case 167 /* ArrayType */: return isThislessType(node.elementType); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -31720,7 +31880,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 154 /* Constructor */ || (returnType && isThislessType(returnType))) && + return (node.kind === 155 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -31736,12 +31896,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -31785,7 +31945,7 @@ var ts; * Indicates whether a type can be used as a late-bound name. */ function isTypeUsableAsLateBoundName(type) { - return !!(type.flags & 1120 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 2240 /* StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -31805,7 +31965,7 @@ var ts; */ function hasLateBindableName(node) { var name = ts.getNameOfDeclaration(node); - return name && isLateBindableName(name); + return !!name && isLateBindableName(name); } /** * Indicates whether a declaration has a dynamic name that cannot be late-bound. @@ -31823,12 +31983,13 @@ var ts; * Gets the symbolic name for a late-bound member from its type. */ function getLateBoundNameFromType(type) { - if (type.flags & 1024 /* UniqueESSymbol */) { + if (type.flags & 2048 /* UniqueESSymbol */) { return "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); } - if (type.flags & 96 /* StringOrNumberLiteral */) { + if (type.flags & 192 /* StringOrNumberLiteral */) { return ts.escapeLeadingUnderscores("" + type.value); } + return ts.Debug.fail(); } /** * Adds a declaration to a late-bound dynamic member. This performs the same function for @@ -31846,8 +32007,7 @@ var ts; symbol.declarations.push(member); } if (symbolFlags & 67216319 /* Value */) { - var valueDeclaration = symbol.valueDeclaration; - if (!valueDeclaration || valueDeclaration.kind !== member.kind) { + if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } } @@ -31991,7 +32151,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 262144 /* Intersection */) { + else if (type.flags & 524288 /* Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); })); } return needApparentType ? getApparentType(type) : type; @@ -32075,7 +32235,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJavaScriptFile(baseTypeNode); @@ -32147,6 +32307,7 @@ var ts; if (unionSignatures.length > 1) { var thisParameter = signature.thisParameter; if (ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; })) { + // TODO: GH#18217 We tested that *some* has thisParameter and now act as if *all* do var thisType = getUnionType(ts.map(unionSignatures, function (sig) { return sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType; }), 2 /* Subtype */); thisParameter = createSymbolWithType(signature.thisParameter, thisType); } @@ -32273,7 +32434,7 @@ var ts; if (symbol.flags & 32 /* Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (65536 /* Object */ | 262144 /* Intersection */ | 1081344 /* TypeVariable */)) { + if (baseConstructorType.flags & (131072 /* Object */ | 524288 /* Intersection */ | 2162688 /* TypeVariable */)) { members = ts.createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -32334,7 +32495,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 32 /* StringLiteral */ : 1120 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 64 /* StringLiteral */ : 2240 /* StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { @@ -32352,8 +32513,8 @@ var ts; // First, if the constraint type is a type parameter, obtain the base constraint. Then, // if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X. // Finally, iterate over the constituents of the resulting iteration type. - var keyType = constraintType.flags & 7372800 /* InstantiableNonPrimitive */ ? getApparentType(constraintType) : constraintType; - var iterationType = keyType.flags & 524288 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType; + var keyType = constraintType.flags & 14745600 /* InstantiableNonPrimitive */ ? getApparentType(constraintType) : constraintType; + var iterationType = keyType.flags & 1048576 /* Index */ ? getIndexType(getApparentType(keyType.type)) : keyType; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); @@ -32365,7 +32526,7 @@ var ts; var propType = instantiateType(templateType, templateMapper); // If the current iteration type constituent is a string literal type, create a property. // Otherwise, for type string create a string index signature. - if (t.flags & 1120 /* StringOrNumberLiteralOrUnique */) { + if (t.flags & 2240 /* StringOrNumberLiteralOrUnique */) { var propName = getLateBoundNameFromType(t); var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || @@ -32386,10 +32547,10 @@ var ts; prop.nameType = t; members.set(propName, prop); } - else if (t.flags & (1 /* Any */ | 2 /* String */)) { + else if (t.flags & (1 /* Any */ | 4 /* String */)) { stringIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1 /* IncludeReadonly */)); } - else if (t.flags & 4 /* Number */) { + else if (t.flags & 8 /* Number */) { numberIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1 /* IncludeReadonly */)); } } @@ -32400,20 +32561,20 @@ var ts; } function getConstraintTypeFromMappedType(type) { return type.constraintType || - (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || unknownType); + (type.constraintType = instantiateType(getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)), type.mapper || identityMapper) || errorType); } function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper || identityMapper) : - unknownType); + errorType); } function getConstraintDeclarationForMappedType(type) { return type.declaration.typeParameter.constraint; } function isMappedTypeWithKeyofConstraintDeclaration(type) { - var constraintDeclaration = getConstraintDeclarationForMappedType(type); - return constraintDeclaration.kind === 174 /* TypeOperator */ && + var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 + return constraintDeclaration.kind === 175 /* TypeOperator */ && constraintDeclaration.operator === 128 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { @@ -32430,8 +32591,8 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is {}. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 32768 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 524288 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; + var extendedConstraint = constraint && constraint.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 1048576 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : emptyObjectType; } } return type.modifiersType; @@ -32454,11 +32615,11 @@ var ts; return !!(ts.getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */); } function isGenericMappedType(type) { - return ts.getObjectFlags(type) & 32 /* Mapped */ && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { if (type.objectFlags & 4 /* Reference */) { resolveTypeReferenceMembers(type); } @@ -32475,10 +32636,10 @@ var ts; resolveMappedTypeMembers(type); } } - else if (type.flags & 131072 /* Union */) { + else if (type.flags & 262144 /* Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 262144 /* Intersection */) { + else if (type.flags & 524288 /* Intersection */) { resolveIntersectionTypeMembers(type); } } @@ -32486,7 +32647,7 @@ var ts; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -32495,7 +32656,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -32519,7 +32680,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { break; } } @@ -32529,13 +32690,13 @@ var ts; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 393216 /* UnionOrIntersection */ ? + return type.flags & 786432 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 131072 /* Union */)) { + if (!(unionType.flags & 262144 /* Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -32554,9 +32715,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 32768 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 1048576 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 2097152 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 65536 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 2097152 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 4194304 /* Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -32566,12 +32727,12 @@ var ts; var objectType = getBaseConstraintOfType(type.objectType) || type.objectType; var indexType = getBaseConstraintOfType(type.indexType) || type.indexType; var constraint = !isGenericObjectType(objectType) && !isGenericIndexType(indexType) ? getIndexedAccessType(objectType, indexType) : undefined; - return constraint && constraint !== unknownType ? constraint : undefined; + return constraint && constraint !== errorType ? constraint : undefined; } function getDefaultConstraintOfConditionalType(type) { if (!type.resolvedDefaultConstraint) { var rootTrueType = type.root.trueType; - var rootTrueConstraint = rootTrueType.flags & 4194304 /* Substitution */ ? rootTrueType.substitute : rootTrueType; + var rootTrueConstraint = rootTrueType.flags & 8388608 /* Substitution */ ? rootTrueType.substitute : rootTrueType; type.resolvedDefaultConstraint = getUnionType([instantiateType(rootTrueConstraint, type.combinedMapper || type.mapper), getFalseTypeFromConditionalType(type)]); } return type.resolvedDefaultConstraint; @@ -32587,7 +32748,7 @@ var ts; if (constraint) { var mapper = makeUnaryTypeMapper(type.root.checkType, constraint); var instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper)); - if (!(instantiated.flags & 16384 /* Never */)) { + if (!(instantiated.flags & 32768 /* Never */)) { return instantiated; } } @@ -32602,23 +32763,23 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 7897088 /* Instantiable */) { + if (t.flags & 15794176 /* Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (32768 /* TypeParameter */ | 524288 /* Index */ | 2097152 /* Conditional */)) { + while (constraint && constraint.flags & (65536 /* TypeParameter */ | 1048576 /* Index */ | 4194304 /* Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { // A constraint that isn't a union type implies that the final type would be a non-union // type as well. Since non-union constraints are of no interest, we can exit here. - if (!(constraint.flags & 131072 /* Union */)) { + if (!(constraint.flags & 262144 /* Union */)) { return undefined; } constraints = ts.append(constraints, constraint); } } - else if (t.flags & 134233854 /* DisjointDomains */) { + else if (t.flags & 16809468 /* DisjointDomains */) { hasDisjointDomainType = true; } } @@ -32630,7 +32791,7 @@ var ts; // intersection operation to reduce the union constraints. for (var _b = 0, _c = type.types; _b < _c.length; _b++) { var t = _c[_b]; - if (t.flags & 134233854 /* DisjointDomains */) { + if (t.flags & 16809468 /* DisjointDomains */) { constraints = ts.append(constraints, t); } } @@ -32640,7 +32801,7 @@ var ts; return undefined; } function getBaseConstraintOfInstantiableNonPrimitiveUnionOrIntersection(type) { - if (type.flags & (7372800 /* InstantiableNonPrimitive */ | 393216 /* UnionOrIntersection */)) { + if (type.flags & (14745600 /* InstantiableNonPrimitive */ | 786432 /* UnionOrIntersection */)) { var constraint = getResolvedBaseConstraint(type); if (constraint !== noConstraintType && constraint !== circularConstraintType) { return constraint; @@ -32649,7 +32810,7 @@ var ts; } function getBaseConstraintOfType(type) { var constraint = getBaseConstraintOfInstantiableNonPrimitiveUnionOrIntersection(type); - if (!constraint && type.flags & 524288 /* Index */) { + if (!constraint && type.flags & 1048576 /* Index */) { return keyofConstraintType; } return constraint; @@ -32689,13 +32850,13 @@ var ts; return result; } function computeBaseConstraint(t) { - if (t.flags & 32768 /* TypeParameter */) { + if (t.flags & 65536 /* TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 393216 /* UnionOrIntersection */) { + if (t.flags & 786432 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { @@ -32705,24 +32866,24 @@ var ts; baseTypes.push(baseType); } } - return t.flags & 131072 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 262144 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 262144 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 524288 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 524288 /* Index */) { + if (t.flags & 1048576 /* Index */) { return keyofConstraintType; } - if (t.flags & 1048576 /* IndexedAccess */) { + if (t.flags & 2097152 /* IndexedAccess */) { var baseObjectType = getBaseConstraint(t.objectType); var baseIndexType = getBaseConstraint(t.indexType); var baseIndexedAccess = baseObjectType && baseIndexType ? getIndexedAccessType(baseObjectType, baseIndexType) : undefined; - return baseIndexedAccess && baseIndexedAccess !== unknownType ? getBaseConstraint(baseIndexedAccess) : undefined; + return baseIndexedAccess && baseIndexedAccess !== errorType ? getBaseConstraint(baseIndexedAccess) : undefined; } - if (t.flags & 2097152 /* Conditional */) { + if (t.flags & 4194304 /* Conditional */) { var constraint = getConstraintOfConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 4194304 /* Substitution */) { + if (t.flags & 8388608 /* Substitution */) { return getBaseConstraint(t.substitute); } if (isGenericMappedType(t)) { @@ -32783,19 +32944,19 @@ var ts; * type itself. Note that the apparent type of a union type is the union type itself. */ function getApparentType(type) { - var t = type.flags & 7897088 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; - return t.flags & 262144 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 34 /* StringLike */ ? globalStringType : - t.flags & 84 /* NumberLike */ ? globalNumberType : - t.flags & 136 /* BooleanLike */ ? globalBooleanType : - t.flags & 1536 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : - t.flags & 134217728 /* NonPrimitive */ ? emptyObjectType : - t.flags & 524288 /* Index */ ? keyofConstraintType : + var t = type.flags & 15794176 /* Instantiable */ ? getBaseConstraintOfType(type) || emptyObjectType : type; + return t.flags & 524288 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 68 /* StringLike */ ? globalStringType : + t.flags & 168 /* NumberLike */ ? globalNumberType : + t.flags & 272 /* BooleanLike */ ? globalBooleanType : + t.flags & 3072 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : + t.flags & 16777216 /* NonPrimitive */ ? emptyObjectType : + t.flags & 1048576 /* Index */ ? keyofConstraintType : t; } function createUnionOrIntersectionProperty(containingType, name) { var props; - var isUnion = containingType.flags & 131072 /* Union */; + var isUnion = containingType.flags & 262144 /* Union */; var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols var commonFlags = isUnion ? 0 /* None */ : 16777216 /* Optional */; @@ -32804,7 +32965,7 @@ var ts; for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var current = _a[_i]; var type = getApparentType(current); - if (type !== unknownType) { + if (type !== errorType) { var prop = getPropertyOfType(type, name); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop && !(modifiers & excludeModifiers)) { @@ -32900,7 +33061,7 @@ var ts; */ function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -32914,13 +33075,13 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 393216 /* UnionOrIntersection */) { + if (type.flags & 786432 /* UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 458752 /* StructuredType */) { + if (type.flags & 917504 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -32934,7 +33095,7 @@ var ts; return getSignaturesOfStructuredType(getApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { - if (type.flags & 458752 /* StructuredType */) { + if (type.flags & 917504 /* StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexInfo : resolved.numberIndexInfo; } @@ -32990,10 +33151,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJavaScriptFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 282 /* JSDocOptionalType */ + node.type && node.type.kind === 283 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 282 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -33027,7 +33188,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 282 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 283 /* JSDocOptionalType */; } function createTypePredicateFromTypePredicateNode(node) { var parameterName = node.parameterName; @@ -33061,14 +33222,6 @@ var ts; } return minTypeArgumentCount; } - /** - * Fill in default types for unsupplied type arguments. If `typeArguments` is undefined - * when a default type is supplied, a new array will be created and returned. - * - * @param typeArguments The supplied type arguments. - * @param typeParameters The requested type parameters. - * @param minTypeArgumentCount The minimum number of required type arguments. - */ function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) { var numTypeParameters = ts.length(typeParameters); if (numTypeParameters) { @@ -33103,7 +33256,7 @@ var ts; var hasLiteralTypes = false; var minArgumentCount = 0; var thisParameter = void 0; - var hasThisParameter = void 0; + var hasThisParameter = false; var iife = ts.getImmediatelyInvokedFunctionExpression(declaration); var isJSConstructSignature = ts.isJSDocConstructSignature(declaration); var isUntypedSignatureInJSFile = !iife && @@ -33130,7 +33283,7 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 177 /* LiteralType */) { + if (type && type.kind === 178 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -33144,16 +33297,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 === 155 /* GetAccessor */ || declaration.kind === 156 /* SetAccessor */) && + if ((declaration.kind === 156 /* GetAccessor */ || declaration.kind === 157 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 155 /* GetAccessor */ ? 156 /* SetAccessor */ : 155 /* GetAccessor */; + var otherKind = declaration.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 154 /* Constructor */ ? + var classType = declaration.kind === 155 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); @@ -33190,7 +33343,7 @@ var ts; } function getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType) { if (isJSConstructSignature) { - return getTypeFromTypeNode(declaration.parameters[0].type); + return getTypeFromTypeNode(declaration.parameters[0].type); // TODO: GH#18217 } else if (classType) { return classType; @@ -33201,8 +33354,8 @@ var ts; } // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 155 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 156 /* SetAccessor */); + if (declaration.kind === 156 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 157 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { @@ -33226,14 +33379,14 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - return node.name.kind === 146 /* ComputedPropertyName */ + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + return node.name.kind === 147 /* ComputedPropertyName */ && traverse(node.name); default: - return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && ts.forEachChild(node, traverse); + return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); } } } @@ -33243,19 +33396,18 @@ var ts; var result = []; for (var i = 0; i < symbol.declarations.length; i++) { var decl = symbol.declarations[i]; - var node = ts.isPropertyAccessExpression(decl) ? ts.getAssignedJavascriptInitializer(decl) : decl; - if (!ts.isFunctionLike(node)) + if (!ts.isFunctionLike(decl)) continue; // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). - if (i > 0 && node.body) { + if (i > 0 && decl.body) { var previous = symbol.declarations[i - 1]; - if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { + if (decl.parent === previous.parent && decl.kind === previous.kind && decl.pos === previous.end) { continue; } } - result.push(getSignatureFromDeclaration(node)); + result.push(getSignatureFromDeclaration(decl)); } return result; } @@ -33288,7 +33440,7 @@ var ts; } else { var declaration = signature.declaration; - signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 160 /* TypePredicate */ ? + signature.resolvedTypePredicate = declaration && declaration.type && declaration.type.kind === 161 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : noTypePredicate; } @@ -33299,7 +33451,7 @@ var ts; function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { - return unknownType; + return errorType; } var type = void 0; if (signature.target) { @@ -33333,7 +33485,7 @@ var ts; } function getRestTypeOfSignature(signature) { if (signature.hasRestParameter) { - var type = getTypeOfSymbol(ts.lastOrUndefined(signature.parameters)); + var type = getTypeOfSymbol(ts.last(signature.parameters)); if (ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType) { return type.typeArguments[0]; } @@ -33394,7 +33546,7 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 154 /* Constructor */ || signature.declaration.kind === 158 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 155 /* Constructor */ || signature.declaration.kind === 159 /* ConstructSignature */; // TODO: GH#18217 var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -33435,7 +33587,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 147 /* TypeParameter */); + var decl = type.symbol && ts.getDeclarationOfKind(type.symbol, 148 /* TypeParameter */); return decl && decl.constraint; } function getInferredTypeParameterConstraint(typeParameter) { @@ -33447,7 +33599,7 @@ var ts; // (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. - if (declaration.parent.kind === 171 /* InferType */ && declaration.parent.parent.kind === 161 /* TypeReference */) { + if (declaration.parent.kind === 172 /* InferType */ && declaration.parent.parent.kind === 162 /* TypeReference */) { var typeReference = declaration.parent.parent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -33489,7 +33641,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 147 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 148 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; @@ -33526,7 +33678,7 @@ var ts; result |= type.flags; } } - return result & 117440512 /* PropagatingFlags */; + return result & 939524096 /* PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -33563,7 +33715,7 @@ var ts; var isJs = ts.isInJavaScriptFile(node); var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { - var missingAugmentsTag = isJs && node.parent.kind !== 289 /* JSDocAugmentsTag */; + var missingAugmentsTag = isJs && node.parent.kind !== 290 /* JSDocAugmentsTag */; var diag = minTypeArgumentCount === typeParameters.length ? missingAugmentsTag ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag @@ -33575,7 +33727,7 @@ var ts; error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) - return unknownType; + return errorType; } } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -33584,7 +33736,7 @@ var ts; var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } - return checkNoTypeArguments(node, symbol) ? type : unknownType; + return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeAliasInstantiation(symbol, typeArguments) { var type = getDeclaredTypeOfSymbol(symbol); @@ -33612,17 +33764,17 @@ var ts; error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); - return unknownType; + return errorType; } return getTypeAliasInstantiation(symbol, typeArguments); } - return checkNoTypeArguments(node, symbol) ? type : unknownType; + return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return node.typeName; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -33642,7 +33794,7 @@ var ts; function getTypeReferenceType(node, symbol) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { - return unknownType; + return errorType; } var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); if (type) { @@ -33652,11 +33804,11 @@ var ts; var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { return checkNoTypeArguments(node, symbol) ? - res.flags & 32768 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : res : - unknownType; + res.flags & 65536 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : res : + errorType; } if (!(symbol.flags & 67216319 /* Value */ && isJSDocTypeReference(node))) { - return unknownType; + return errorType; } var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); if (jsdocType) { @@ -33676,7 +33828,8 @@ var ts; var valueType = getTypeOfSymbol(symbol); var referenceType = valueType.symbol && valueType.symbol !== symbol && !isInferredClassType(valueType) && getTypeReferenceTypeWorker(node, valueType.symbol, typeArguments); if (referenceType || assignedType) { - return referenceType && assignedType ? getIntersectionType([assignedType, referenceType]) : referenceType || assignedType; + // TODO: GH#18217 (should the `|| assignedType` be at a lower precedence?) + return (referenceType && assignedType ? getIntersectionType([assignedType, referenceType]) : referenceType || assignedType); } } function getTypeReferenceTypeWorker(node, symbol, typeArguments) { @@ -33699,13 +33852,13 @@ var ts; } } function getSubstitutionType(typeVariable, substitute) { - var result = createType(4194304 /* Substitution */); + var result = createType(8388608 /* Substitution */); result.typeVariable = typeVariable; result.substitute = substitute; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 167 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 168 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -33714,9 +33867,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 285 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 286 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 170 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 171 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -33727,7 +33880,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return node.flags & 2097152 /* JSDoc */ && node.kind === 161 /* TypeReference */; + return !!(node.flags & 2097152 /* JSDoc */) && node.kind === 162 /* TypeReference */; } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -33774,7 +33927,7 @@ var ts; var indexed = getTypeFromTypeNode(typeArgs[0]); var target = getTypeFromTypeNode(typeArgs[1]); var index = createIndexInfo(target, /*isReadonly*/ false); - return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType && index, indexed === numberType && index); + return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType ? index : undefined, indexed === numberType ? index : undefined); } return anyType; } @@ -33785,7 +33938,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 8192 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 16384 /* Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -33828,9 +33981,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: return declaration; } } @@ -33839,7 +33992,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 65536 /* Object */)) { + if (!(type.flags & 131072 /* Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -33911,7 +34064,7 @@ var ts; return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { - return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); + return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288 /* TypeAlias */, ts.Diagnostics.Cannot_find_global_type_0)); // TODO: GH#18217 } /** * Instantiates a global type that is generic with some element type, and returns that instantiation. @@ -33955,7 +34108,7 @@ var ts; var typeParameters = []; var properties = []; for (var i = 0; i < arity; i++) { - var typeParameter = createType(32768 /* TypeParameter */); + var typeParameter = createType(65536 /* TypeParameter */); typeParameters.push(typeParameter); var property = createSymbol(4 /* Property */, "" + i); property.type = typeParameter; @@ -33972,7 +34125,7 @@ var ts; type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; type.typeArguments = type.typeParameters; - type.thisType = createType(32768 /* TypeParameter */); + type.thisType = createType(65536 /* TypeParameter */); type.thisType.isThisType = true; type.thisType.constraint = type; type.declaredProperties = properties; @@ -34013,16 +34166,16 @@ var ts; var combined = 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 13536 /* Unit */ && combined & 13536 /* Unit */) { + if (t.flags & 27072 /* Unit */ && combined & 27072 /* Unit */) { return true; } combined |= t.flags; - if (combined & 12288 /* Nullable */ && combined & (65536 /* Object */ | 134217728 /* NonPrimitive */) || - combined & 134217728 /* NonPrimitive */ && combined & (134233854 /* DisjointDomains */ & ~134217728 /* NonPrimitive */) || - combined & 34 /* StringLike */ && combined & (134233854 /* DisjointDomains */ & ~34 /* StringLike */) || - combined & 84 /* NumberLike */ && combined & (134233854 /* DisjointDomains */ & ~84 /* NumberLike */) || - combined & 1536 /* ESSymbolLike */ && combined & (134233854 /* DisjointDomains */ & ~1536 /* ESSymbolLike */) || - combined & 6144 /* VoidLike */ && combined & (134233854 /* DisjointDomains */ & ~6144 /* VoidLike */)) { + if (combined & 24576 /* Nullable */ && combined & (131072 /* Object */ | 16777216 /* NonPrimitive */) || + combined & 16777216 /* NonPrimitive */ && combined & (16809468 /* DisjointDomains */ & ~16777216 /* NonPrimitive */) || + combined & 68 /* StringLike */ && combined & (16809468 /* DisjointDomains */ & ~68 /* StringLike */) || + combined & 168 /* NumberLike */ && combined & (16809468 /* DisjointDomains */ & ~168 /* NumberLike */) || + combined & 3072 /* ESSymbolLike */ && combined & (16809468 /* DisjointDomains */ & ~3072 /* ESSymbolLike */) || + combined & 12288 /* VoidLike */ && combined & (16809468 /* DisjointDomains */ & ~12288 /* VoidLike */)) { return true; } } @@ -34030,28 +34183,28 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 131072 /* Union */) { + if (flags & 262144 /* Union */) { return addTypesToUnion(typeSet, includes, type.types); } // We ignore 'never' types in unions. Likewise, we ignore intersections of unit types as they are // another form of 'never' (in that they have an empty value domain). We could in theory turn // intersections of unit types into 'never' upon construction, but deferring the reduction makes it // easier to reason about their origin. - if (!(flags & 16384 /* Never */ || flags & 262144 /* Intersection */ && isEmptyIntersectionType(type))) { - includes |= flags & ~117440512 /* ConstructionFlags */; - if (flags & 1 /* Any */) { + if (!(flags & 32768 /* Never */ || flags & 524288 /* Intersection */ && isEmptyIntersectionType(type))) { + includes |= flags & ~939524096 /* ConstructionFlags */; + if (flags & 3 /* AnyOrUnknown */) { if (type === wildcardType) - includes |= 33554432 /* Wildcard */; + includes |= 268435456 /* Wildcard */; } - else if (!strictNullChecks && flags & 12288 /* Nullable */) { - if (!(flags & 16777216 /* ContainsWideningType */)) - includes |= 16777216 /* NonWideningType */; + else if (!strictNullChecks && flags & 24576 /* Nullable */) { + if (!(flags & 134217728 /* ContainsWideningType */)) + includes |= 134217728 /* NonWideningType */; } else { var len = typeSet.length; var index = len && type.id > typeSet[len - 1].id ? ~len : ts.binarySearch(typeSet, type, getTypeId, ts.compareValues); if (index < 0) { - if (!(flags & 65536 /* Object */ && type.objectFlags & 16 /* Anonymous */ && + if (!(flags & 131072 /* Object */ && type.objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */) && containsIdenticalType(typeSet, type))) { typeSet.splice(~index, 0, type); } @@ -34091,11 +34244,11 @@ var ts; } function isSetOfLiteralsFromSameEnum(types) { var first = types[0]; - if (first.flags & 256 /* EnumLiteral */) { + if (first.flags & 512 /* EnumLiteral */) { var firstEnum = getParentOfSymbol(first.symbol); for (var i = 1; i < types.length; i++) { var other = types[i]; - if (!(other.flags & 256 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { + if (!(other.flags & 512 /* EnumLiteral */) || (firstEnum !== getParentOfSymbol(other.symbol))) { return false; } } @@ -34120,10 +34273,10 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 32 /* StringLiteral */ && includes & 2 /* String */ || - t.flags & 64 /* NumberLiteral */ && includes & 4 /* Number */ || - t.flags & 1024 /* UniqueESSymbol */ && includes & 512 /* ESSymbol */ || - t.flags & 96 /* StringOrNumberLiteral */ && t.flags & 8388608 /* FreshLiteral */ && containsType(types, t.regularType); + var remove = t.flags & 64 /* StringLiteral */ && includes & 4 /* String */ || + t.flags & 128 /* NumberLiteral */ && includes & 8 /* Number */ || + t.flags & 2048 /* UniqueESSymbol */ && includes & 1024 /* ESSymbol */ || + t.flags & 192 /* StringOrNumberLiteral */ && t.flags & 33554432 /* FreshLiteral */ && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -34146,12 +34299,12 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (includes & 1 /* Any */) { - return includes & 33554432 /* Wildcard */ ? wildcardType : anyType; + if (includes & 3 /* AnyOrUnknown */) { + return includes & 1 /* Any */ ? includes & 268435456 /* Wildcard */ ? wildcardType : anyType : unknownType; } switch (unionReduction) { case 1 /* Literal */: - if (includes & 1120 /* StringOrNumberLiteralOrUnique */) { + if (includes & 2240 /* StringOrNumberLiteralOrUnique */) { removeRedundantLiteralTypes(typeSet, includes); } break; @@ -34160,11 +34313,11 @@ var ts; break; } if (typeSet.length === 0) { - return includes & 8192 /* Null */ ? includes & 16777216 /* NonWideningType */ ? nullType : nullWideningType : - includes & 4096 /* Undefined */ ? includes & 16777216 /* NonWideningType */ ? undefinedType : undefinedWideningType : + return includes & 16384 /* Null */ ? includes & 134217728 /* NonWideningType */ ? nullType : nullWideningType : + includes & 8192 /* Undefined */ ? includes & 134217728 /* NonWideningType */ ? undefinedType : undefinedWideningType : neverType; } - return getUnionTypeFromSortedList(typeSet, includes & 8374815 /* NotUnit */ ? 0 : 268435456 /* UnionOfUnitTypes */, aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, includes & 16749629 /* NotUnit */ ? 0 : 67108864 /* UnionOfUnitTypes */, aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -34211,8 +34364,8 @@ var ts; var id = getTypeListId(types); var type = unionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 12288 /* Nullable */); - type = createType(131072 /* Union */ | propagatedFlags | unionOfUnitTypes); + var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 24576 /* Nullable */); + type = createType(262144 /* Union */ | propagatedFlags | unionOfUnitTypes); unionTypes.set(id, type); type.types = types; /* @@ -34236,20 +34389,20 @@ var ts; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 262144 /* Intersection */) { + if (flags & 524288 /* Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } if (ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type)) { - includes |= 67108864 /* EmptyObject */; + includes |= 536870912 /* EmptyObject */; } else { - includes |= flags & ~117440512 /* ConstructionFlags */; - if (flags & 1 /* Any */) { + includes |= flags & ~939524096 /* ConstructionFlags */; + if (flags & 3 /* AnyOrUnknown */) { if (type === wildcardType) - includes |= 33554432 /* Wildcard */; + includes |= 268435456 /* Wildcard */; } - else if ((strictNullChecks || !(flags & 12288 /* Nullable */)) && !ts.contains(typeSet, type) && - !(flags & 65536 /* Object */ && type.objectFlags & 16 /* Anonymous */ && + else if ((strictNullChecks || !(flags & 24576 /* Nullable */)) && !ts.contains(typeSet, type) && + !(flags & 131072 /* Object */ && type.objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */) && containsIdenticalType(typeSet, type))) { typeSet.push(type); @@ -34271,9 +34424,9 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 2 /* String */ && includes & 32 /* StringLiteral */ || - t.flags & 4 /* Number */ && includes & 64 /* NumberLiteral */ || - t.flags & 512 /* ESSymbol */ && includes & 1024 /* UniqueESSymbol */; + var remove = t.flags & 4 /* String */ && includes & 64 /* StringLiteral */ || + t.flags & 8 /* Number */ && includes & 128 /* NumberLiteral */ || + t.flags & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -34283,13 +34436,13 @@ var ts; // Here we remove all unions of unit types from the given list and replace them with a // a single union containing an intersection of the unit types. function intersectUnionsOfUnitTypes(types) { - var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 268435456 /* UnionOfUnitTypes */) !== 0; }); + var unionIndex = ts.findIndex(types, function (t) { return (t.flags & 67108864 /* UnionOfUnitTypes */) !== 0; }); var unionType = types[unionIndex]; var intersection = unionType.types; var i = types.length - 1; var _loop_5 = function () { var t = types[i]; - if (t.flags & 268435456 /* UnionOfUnitTypes */) { + if (t.flags & 67108864 /* UnionOfUnitTypes */) { intersection = ts.filter(intersection, function (u) { return containsType(t.types, u); }); ts.orderedRemoveItemAt(types, i); } @@ -34301,7 +34454,7 @@ var ts; if (intersection === unionType.types) { return false; } - types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 268435456 /* UnionOfUnitTypes */); + types[unionIndex] = getUnionTypeFromSortedList(intersection, unionType.flags & 67108864 /* UnionOfUnitTypes */); return true; } // We normalize combinations of intersection and union types based on the distributive property of the '&' @@ -34315,30 +34468,33 @@ var ts; // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution // for intersections of types with signatures can be deterministic. function getIntersectionType(types, aliasSymbol, aliasTypeArguments) { - if (types.length === 0) { - return emptyObjectType; - } var typeSet = []; var includes = addTypesToIntersection(typeSet, 0, types); - if (includes & 16384 /* Never */) { + if (includes & 32768 /* Never */) { return neverType; } if (includes & 1 /* Any */) { - return includes & 33554432 /* Wildcard */ ? wildcardType : anyType; + return includes & 268435456 /* Wildcard */ ? wildcardType : anyType; } - if (includes & 2 /* String */ && includes & 32 /* StringLiteral */ || - includes & 4 /* Number */ && includes & 64 /* NumberLiteral */ || - includes & 512 /* ESSymbol */ && includes & 1024 /* UniqueESSymbol */) { + if (!strictNullChecks && includes & 24576 /* Nullable */) { + return includes & 8192 /* Undefined */ ? undefinedType : nullType; + } + if (includes & 4 /* String */ && includes & 64 /* StringLiteral */ || + includes & 8 /* Number */ && includes & 128 /* NumberLiteral */ || + includes & 1024 /* ESSymbol */ && includes & 2048 /* UniqueESSymbol */) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 67108864 /* EmptyObject */ && !(includes & 65536 /* Object */)) { + if (includes & 536870912 /* EmptyObject */ && !(includes & 131072 /* Object */)) { typeSet.push(emptyObjectType); } + if (typeSet.length === 0) { + return unknownType; + } if (typeSet.length === 1) { return typeSet[0]; } - if (includes & 131072 /* Union */) { - if (includes & 268435456 /* UnionOfUnitTypes */ && intersectUnionsOfUnitTypes(typeSet)) { + if (includes & 262144 /* Union */) { + if (includes & 67108864 /* UnionOfUnitTypes */ && intersectUnionsOfUnitTypes(typeSet)) { // When the intersection creates a reduced set (which might mean that *all* union types have // disappeared), we restart the operation to get a new set of combined flags. Once we have // reduced we'll never reduce again, so this occurs at most once. @@ -34346,15 +34502,15 @@ var ts; } // We are attempting to construct a type of the form X & (A | B) & Y. Transform this into a type of // the form X & A & Y | X & B & Y and recursively reduce until no union type constituents remain. - var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 131072 /* Union */) !== 0; }); + var unionIndex_1 = ts.findIndex(typeSet, function (t) { return (t.flags & 262144 /* Union */) !== 0; }); var unionType = typeSet[unionIndex_1]; return getUnionType(ts.map(unionType.types, function (t) { return getIntersectionType(ts.replaceElement(typeSet, unionIndex_1, t)); }), 1 /* Literal */, aliasSymbol, aliasTypeArguments); } var id = getTypeListId(typeSet); var type = intersectionTypes.get(id); if (!type) { - var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 12288 /* Nullable */); - type = createType(262144 /* Intersection */ | propagatedFlags); + var propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ 24576 /* Nullable */); + type = createType(524288 /* Intersection */ | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. @@ -34371,7 +34527,7 @@ var ts; return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(524288 /* Index */); + var result = createType(1048576 /* Index */); result.type = type; result.stringsOnly = stringsOnly; return result; @@ -34387,7 +34543,7 @@ var ts; if (!type && !ts.isKnownSymbol(prop)) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); type = name && ts.isNumericLiteral(name) ? getLiteralType(+name.text) : - name && name.kind === 146 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : + name && name.kind === 147 /* ComputedPropertyName */ && ts.isNumericLiteral(name.expression) ? getLiteralType(+name.expression.text) : getLiteralType(ts.symbolName(prop)); } if (type && type.flags & include) { @@ -34405,16 +34561,16 @@ var ts; } function getIndexType(type, stringsOnly) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } - return type.flags & 131072 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - type.flags & 262144 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : - maybeTypeOfKind(type, 7372800 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : + return type.flags & 262144 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + type.flags & 524288 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly); })) : + maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : ts.getObjectFlags(type) & 32 /* Mapped */ ? getConstraintTypeFromMappedType(type) : type === wildcardType ? wildcardType : type.flags & 1 /* Any */ ? keyofConstraintType : - stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromPropertyNames(type, 32 /* StringLiteral */) : - getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 1024 /* UniqueESSymbol */)]) : - getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 32 /* StringLiteral */ | 1024 /* UniqueESSymbol */)]) : - getLiteralTypeFromPropertyNames(type, 1120 /* StringOrNumberLiteralOrUnique */); + stringsOnly ? getIndexInfoOfType(type, 0 /* String */) ? stringType : getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */) : + getIndexInfoOfType(type, 0 /* String */) ? getUnionType([stringType, numberType, getLiteralTypeFromPropertyNames(type, 2048 /* UniqueESSymbol */)]) : + getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type, 64 /* StringLiteral */ | 2048 /* UniqueESSymbol */)]) : + getLiteralTypeFromPropertyNames(type, 2240 /* StringOrNumberLiteralOrUnique */); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -34425,7 +34581,7 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 16384 /* Never */ ? stringType : indexType; + return indexType.flags & 32768 /* Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); @@ -34437,20 +34593,20 @@ var ts; case 141 /* UniqueKeyword */: links.resolvedType = node.type.kind === 138 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) - : unknownType; + : errorType; break; } } - return links.resolvedType; + return links.resolvedType; // TODO: GH#18217 } function createIndexedAccessType(objectType, indexType) { - var type = createType(1048576 /* IndexedAccess */); + var type = createType(2097152 /* IndexedAccess */); type.objectType = objectType; type.indexType = indexType; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 185 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode : undefined; var propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) : @@ -34462,7 +34618,7 @@ var ts; markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 99 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(prop)); - return unknownType; + return errorType; } if (cacheSymbol) { getNodeLinks(accessNode).resolvedSymbol = prop; @@ -34471,16 +34627,16 @@ var ts; return getTypeOfSymbol(prop); } } - if (!(indexType.flags & 12288 /* Nullable */) && isTypeAssignableToKind(indexType, 34 /* StringLike */ | 84 /* NumberLike */ | 1536 /* ESSymbolLike */)) { + if (!(indexType.flags & 24576 /* Nullable */) && isTypeAssignableToKind(indexType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */)) { if (isTypeAny(objectType)) { return objectType; } - var indexInfo = isTypeAssignableToKind(indexType, 84 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || + var indexInfo = isTypeAssignableToKind(indexType, 168 /* NumberLike */) && getIndexInfoOfType(objectType, 1 /* Number */) || getIndexInfoOfType(objectType, 0 /* String */) || undefined; if (indexInfo) { - if (accessNode && !isTypeAssignableToKind(indexType, 2 /* String */ | 4 /* Number */)) { - var indexNode = accessNode.kind === 185 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + if (accessNode && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } else if (accessExpression && indexInfo.isReadonly && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) { @@ -34488,7 +34644,7 @@ var ts; } return indexInfo.type; } - if (indexType.flags & 16384 /* Never */) { + if (indexType.flags & 32768 /* Never */) { return neverType; } if (accessExpression && !isConstEnumObjectType(objectType)) { @@ -34504,41 +34660,41 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 185 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; - if (indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */)) { + var indexNode = accessNode.kind === 186 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + if (indexType.flags & (64 /* StringLiteral */ | 128 /* NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (2 /* String */ | 4 /* Number */)) { + else if (indexType.flags & (4 /* String */ | 8 /* Number */)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } } - return unknownType; + return errorType; } function isGenericObjectType(type) { - return maybeTypeOfKind(type, 7372800 /* InstantiableNonPrimitive */ | 536870912 /* GenericMappedType */); + return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 134217728 /* GenericMappedType */); } function isGenericIndexType(type) { - return maybeTypeOfKind(type, 7372800 /* InstantiableNonPrimitive */ | 524288 /* Index */); + return maybeTypeOfKind(type, 14745600 /* InstantiableNonPrimitive */ | 1048576 /* Index */); } // Return true if the given type is a non-generic object type with a string index signature and no // other members. function isStringIndexOnlyType(type) { - if (type.flags & 65536 /* Object */ && !isGenericMappedType(type)) { + if (type.flags & 131072 /* Object */ && !isGenericMappedType(type)) { var t = resolveStructuredTypeMembers(type); return t.properties.length === 0 && t.callSignatures.length === 0 && t.constructSignatures.length === 0 && - t.stringIndexInfo && !t.numberIndexInfo; + !!t.stringIndexInfo && !t.numberIndexInfo; } return false; } function isMappedTypeToNever(type) { - return ts.getObjectFlags(type) & 32 /* Mapped */ && getTemplateTypeFromMappedType(type) === neverType; + return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && getTemplateTypeFromMappedType(type) === neverType; } function getSimplifiedType(type) { - return type.flags & 1048576 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; + return type.flags & 2097152 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type) : type; } // Transform an indexed access to a simpler form, if possible. Return the simpler form, or return // the type itself if no transformation is possible. @@ -34547,8 +34703,10 @@ var ts; return type.simplified === circularConstraintType ? type : type.simplified; } type.simplified = circularConstraintType; - var objectType = type.objectType; - if (objectType.flags & 262144 /* Intersection */ && isGenericObjectType(objectType)) { + // We recursively simplify the object type as it may in turn be an indexed access type. For example, with + // '{ [P in T]: { [Q in U]: number } }[T][U]' we want to first simplify the inner indexed access type. + var objectType = getSimplifiedType(type.objectType); + if (objectType.flags & 524288 /* Intersection */ && isGenericObjectType(objectType)) { // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or // more object types with only a string index signature, e.g. '(U & V & { [x: string]: D })[K]', return a // transformed type of the form '(U & V)[K] | D'. This allows us to properly reason about higher order indexed @@ -34586,7 +34744,7 @@ var ts; if (isGenericMappedType(objectType)) { return type.simplified = substituteIndexedMappedType(objectType, type); } - if (objectType.flags & 32768 /* TypeParameter */) { + if (objectType.flags & 65536 /* TypeParameter */) { var constraint = getConstraintFromTypeParameter(objectType); if (constraint && isGenericMappedType(constraint)) { return type.simplified = substituteIndexedMappedType(constraint, type); @@ -34608,8 +34766,8 @@ var ts; // 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 === 185 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { - if (objectType.flags & 1 /* Any */) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 186 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { + if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. @@ -34624,13 +34782,13 @@ var ts; // We treat boolean as different from other unions to improve errors; // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getApparentType(objectType); - if (indexType.flags & 131072 /* Union */ && !(indexType.flags & 8 /* Boolean */)) { + if (indexType.flags & 262144 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { var propTypes = []; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; var propType = getPropertyTypeForIndexType(apparentObjectType, t, accessNode, /*cacheSymbol*/ false); - if (propType === unknownType) { - return unknownType; + if (propType === errorType) { + return errorType; } propTypes.push(propType); } @@ -34644,7 +34802,7 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var resolved = getIndexedAccessType(objectType, indexType, node); - links.resolvedType = resolved.flags & 1048576 /* IndexedAccess */ && + links.resolvedType = resolved.flags & 2097152 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConstrainedTypeVariable(resolved, node) : resolved; @@ -34666,7 +34824,7 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - return type.flags & 4194304 /* Substitution */ ? type.typeVariable : type; + return type.flags & 8388608 /* Substitution */ ? type.typeVariable : type; } function getConditionalType(root, mapper) { var checkType = instantiateType(root.checkType, mapper); @@ -34677,7 +34835,7 @@ var ts; // If this is a distributive conditional type and the check type is generic we need to defer // resolution of the conditional type such that a later instantiation will properly distribute // over union types. - var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 7897088 /* Instantiable */); + var isDeferred = root.isDistributive && maybeTypeOfKind(checkType, 15794176 /* Instantiable */); var combinedMapper; if (root.inferTypeParameters) { var context_1 = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */); @@ -34690,6 +34848,9 @@ var ts; combinedMapper = combineTypeMappers(mapper, context_1); } if (!isDeferred) { + if (extendsType.flags & 3 /* AnyOrUnknown */) { + return instantiateType(root.trueType, mapper); + } // Return union of trueType and falseType for 'any' since it matches anything if (checkType.flags & 1 /* Any */) { return getUnionType([instantiateType(root.trueType, combinedMapper || mapper), instantiateType(root.falseType, mapper)]); @@ -34713,14 +34874,14 @@ var ts; } // Return a deferred type for a check that is neither definitely true nor definitely false var erasedCheckType = getActualTypeVariable(checkType); - var result = createType(2097152 /* Conditional */); + var result = createType(4194304 /* Conditional */); result.root = root; result.checkType = erasedCheckType; result.extendsType = extendsType; result.mapper = mapper; result.combinedMapper = combinedMapper; result.aliasSymbol = root.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper); + result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 return result; } function getTrueTypeFromConditionalType(type) { @@ -34745,7 +34906,7 @@ var ts; return true; } while (node) { - if (node.kind === 170 /* ConditionalType */) { + if (node.kind === 171 /* ConditionalType */) { if (isTypeParameterPossiblyReferenced(tp, node.extendsType)) { return true; } @@ -34768,7 +34929,7 @@ var ts; extendsType: getTypeFromTypeNode(node.extendsType), trueType: getTypeFromTypeNode(node.trueType), falseType: getTypeFromTypeNode(node.falseType), - isDistributive: !!(checkType.flags & 32768 /* TypeParameter */), + isDistributive: !!(checkType.flags & 65536 /* TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -34804,12 +34965,12 @@ var ts; if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments error(node, ts.Diagnostics.Type_arguments_cannot_be_used_here); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } if (!ts.isLiteralImportTypeNode(node)) { error(node.argument, ts.Diagnostics.String_literal_expected); links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } var argumentType = getTypeFromTypeNode(node.argument); var targetMeaning = node.isTypeOf ? 67216319 /* Value */ : 67901928 /* Type */; @@ -34818,7 +34979,7 @@ var ts; var innerModuleSymbol = resolveExternalModule(node, moduleName, ts.Diagnostics.Cannot_find_module_0, node, /*isForAugmentation*/ false); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } var moduleSymbol_1 = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false); if (!ts.nodeIsMissing(node.qualifier)) { @@ -34830,7 +34991,7 @@ var ts; var next = getSymbol(getExportsOfSymbol(getMergedSymbol(resolveSymbol(currentNamespace))), current.escapedText, meaning); if (!next) { error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current)); - return links.resolvedType = unknownType; + return links.resolvedType = errorType; } getNodeLinks(current).resolvedSymbol = next; getNodeLinks(current.parent).resolvedSymbol = next; @@ -34845,11 +35006,11 @@ var ts; else { error(node, targetMeaning === 67216319 /* Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here, moduleName); links.resolvedSymbol = unknownSymbol; - links.resolvedType = unknownType; + links.resolvedType = errorType; } } } - return links.resolvedType; + return links.resolvedType; // TODO: GH#18217 } function resolveImportSymbolType(node, links, symbol, meaning) { links.resolvedSymbol = symbol; @@ -34895,19 +35056,22 @@ var ts; if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { return anyType; } - if (left.flags & 16384 /* Never */) { + if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { + return unknownType; + } + if (left.flags & 32768 /* Never */) { return right; } - if (right.flags & 16384 /* Never */) { + if (right.flags & 32768 /* Never */) { return left; } - if (left.flags & 131072 /* Union */) { + if (left.flags & 262144 /* Union */) { return mapType(left, function (t) { return getSpreadType(t, right, symbol, typeFlags, objectFlags); }); } - if (right.flags & 131072 /* Union */) { + if (right.flags & 262144 /* Union */) { return mapType(right, function (t) { return getSpreadType(left, t, symbol, typeFlags, objectFlags); }); } - if (right.flags & (136 /* BooleanLike */ | 84 /* NumberLike */ | 34 /* StringLike */ | 272 /* EnumLike */ | 134217728 /* NonPrimitive */ | 524288 /* Index */)) { + if (right.flags & (272 /* BooleanLike */ | 168 /* NumberLike */ | 68 /* StringLike */ | 544 /* EnumLike */ | 16777216 /* NonPrimitive */ | 1048576 /* Index */)) { return left; } var members = ts.createSymbolTable(); @@ -34961,7 +35125,7 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getNonReadonlyIndexSignature(stringIndexInfo), getNonReadonlyIndexSignature(numberIndexInfo)); - spread.flags |= typeFlags | 33554432 /* ContainsObjectLiteral */; + spread.flags |= typeFlags | 268435456 /* ContainsObjectLiteral */; spread.objectFlags |= objectFlags | (128 /* ObjectLiteral */ | 1024 /* ContainsSpread */); return spread; } @@ -34993,9 +35157,9 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 96 /* StringOrNumberLiteral */ && !(type.flags & 8388608 /* FreshLiteral */)) { + if (type.flags & 192 /* StringOrNumberLiteral */ && !(type.flags & 33554432 /* FreshLiteral */)) { if (!type.freshType) { - var freshType = createLiteralType(type.flags | 8388608 /* FreshLiteral */, type.value, type.symbol); + var freshType = createLiteralType(type.flags | 33554432 /* FreshLiteral */, type.value, type.symbol); freshType.regularType = type; type.freshType = freshType; } @@ -35004,7 +35168,9 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 8388608 /* FreshLiteral */ ? type.regularType : type; + return type.flags & 192 /* StringOrNumberLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? type.regularType : + type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : + type; } function getLiteralType(value, enumId, symbol) { // We store all literal types in a single map with keys of the form '#NNN' and '@SSS', @@ -35015,7 +35181,7 @@ var ts; var key = enumId ? enumId + qualifier + value : qualifier + value; var type = literalTypes.get(key); if (!type) { - var flags = (typeof value === "number" ? 64 /* NumberLiteral */ : 32 /* StringLiteral */) | (enumId ? 256 /* EnumLiteral */ : 0); + var flags = (typeof value === "number" ? 128 /* NumberLiteral */ : 64 /* StringLiteral */) | (enumId ? 512 /* EnumLiteral */ : 0); literalTypes.set(key, type = createLiteralType(flags, value, symbol)); } return type; @@ -35028,7 +35194,7 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(1024 /* UniqueESSymbol */); + var type = createType(2048 /* UniqueESSymbol */); type.symbol = symbol; return type; } @@ -35043,14 +35209,14 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 235 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 236 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 154 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 155 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); - return unknownType; + return errorType; } function getTypeFromThisTypeNode(node) { var links = getNodeLinks(node); @@ -35062,9 +35228,11 @@ var ts; function getTypeFromTypeNode(node) { switch (node.kind) { case 119 /* AnyKeyword */: - case 278 /* JSDocAllType */: - case 279 /* JSDocUnknownType */: + case 279 /* JSDocAllType */: + case 280 /* JSDocUnknownType */: return anyType; + case 142 /* UnknownKeyword */: + return unknownType; case 137 /* StringKeyword */: return stringType; case 134 /* NumberKeyword */: @@ -35083,64 +35251,64 @@ var ts; return neverType; case 135 /* ObjectKeyword */: return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 173 /* ThisType */: + case 174 /* ThisType */: case 99 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 177 /* LiteralType */: + case 178 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return getTypeFromTypeReference(node); - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return booleanType; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 167 /* TupleType */: + case 168 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 168 /* UnionType */: + case 169 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 169 /* IntersectionType */: + case 170 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 280 /* JSDocNullableType */: + case 281 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 282 /* JSDocOptionalType */: + case 283 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 172 /* ParenthesizedType */: - case 281 /* JSDocNonNullableType */: - case 277 /* JSDocTypeExpression */: + case 173 /* ParenthesizedType */: + case 282 /* JSDocNonNullableType */: + case 278 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 165 /* TypeLiteral */: - case 286 /* JSDocTypeLiteral */: - case 283 /* JSDocFunctionType */: - case 287 /* JSDocSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 166 /* TypeLiteral */: + case 287 /* JSDocTypeLiteral */: + case 284 /* JSDocFunctionType */: + case 288 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 174 /* TypeOperator */: + case 175 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 176 /* MappedType */: + case 177 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 171 /* InferType */: + case 172 /* InferType */: return getTypeFromInferTypeNode(node); - case 178 /* ImportType */: + case 179 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case 71 /* Identifier */: - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: var symbol = getSymbolAtLocation(node); - return symbol && getDeclaredTypeOfSymbol(symbol); + return (symbol && getDeclaredTypeOfSymbol(symbol)); // TODO: GH#18217 default: - return unknownType; + return errorType; } } function instantiateList(items, mapper, instantiator) { @@ -35217,10 +35385,10 @@ var ts; return function (t) { return t === source ? target : baseMapper(t); }; } function wildcardMapper(type) { - return type.flags & 32768 /* TypeParameter */ ? wildcardType : type; + return type.flags & 65536 /* TypeParameter */ ? wildcardType : type; } function cloneTypeParameter(typeParameter) { - var result = createType(32768 /* TypeParameter */); + var result = createType(65536 /* TypeParameter */); result.symbol = typeParameter.symbol; result.target = typeParameter; return result; @@ -35266,7 +35434,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 65536 /* Object */ | 7897088 /* Instantiable */)) { + if (links.type && !maybeTypeOfKind(links.type, 131072 /* Object */ | 15794176 /* Instantiable */)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -35351,8 +35519,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 145 /* QualifiedName */ || - node.parent.kind === 161 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); + return !(node.kind === 146 /* QualifiedName */ || + node.parent.kind === 162 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -35360,22 +35528,22 @@ var ts; // type parameter, or if the node contains type queries, we consider the type parameter possibly referenced. if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container_3 = tp.symbol.declarations[0].parent; - if (ts.findAncestor(node, function (n) { return n.kind === 212 /* Block */ ? "quit" : n === container_3; })) { - return ts.forEachChild(node, containsReference); + if (ts.findAncestor(node, function (n) { return n.kind === 213 /* Block */ ? "quit" : n === container_3; })) { + return !!ts.forEachChild(node, containsReference); } } return true; function containsReference(node) { switch (node.kind) { - case 173 /* ThisType */: - return tp.isThisType; + case 174 /* ThisType */: + return !!tp.isThisType; case 71 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return true; } - return ts.forEachChild(node, containsReference); + return !!ts.forEachChild(node, containsReference); } } function instantiateMappedType(type, mapper) { @@ -35385,9 +35553,9 @@ var ts; // homomorphic mapped types we leave primitive types alone. For example, when T is instantiated to a // union type A | undefined, we produce { [P in keyof A]: X } | undefined. var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 524288 /* Index */) { + if (constraintType.flags & 1048576 /* Index */) { var typeVariable_1 = constraintType.type; - if (typeVariable_1.flags & 32768 /* TypeParameter */) { + if (typeVariable_1.flags & 65536 /* TypeParameter */) { var mappedTypeVariable = instantiateType(typeVariable_1, mapper); if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { @@ -35402,7 +35570,7 @@ var ts; return instantiateAnonymousType(type, mapper); } function isMappableType(type) { - return type.flags & (1 /* Any */ | 7372800 /* InstantiableNonPrimitive */ | 65536 /* Object */ | 262144 /* Intersection */); + return type.flags & (3 /* AnyOrUnknown */ | 14745600 /* InstantiableNonPrimitive */ | 131072 /* Object */ | 524288 /* Intersection */); } function instantiateAnonymousType(type, mapper) { var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); @@ -35440,7 +35608,7 @@ var ts; if (root.isDistributive) { var checkType_1 = root.checkType; var instantiatedType = mapper(checkType_1); - if (checkType_1 !== instantiatedType && instantiatedType.flags & (131072 /* Union */ | 16384 /* Never */)) { + if (checkType_1 !== instantiatedType && instantiatedType.flags & (262144 /* Union */ | 32768 /* Never */)) { return mapType(instantiatedType, function (t) { return getConditionalType(root, createReplacementMapper(checkType_1, t, mapper)); }); } } @@ -35448,10 +35616,10 @@ var ts; } function instantiateType(type, mapper) { if (type && mapper && mapper !== identityMapper) { - if (type.flags & 32768 /* TypeParameter */) { + if (type.flags & 65536 /* TypeParameter */) { return mapper(type); } - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { if (type.objectFlags & 16 /* Anonymous */) { // If the anonymous type originates in a declaration of a function, method, class, or // interface, in an object type literal, or in an object literal expression, we may need @@ -35468,33 +35636,33 @@ var ts; return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; } } - if (type.flags & 131072 /* Union */ && !(type.flags & 16382 /* Primitive */)) { + if (type.flags & 262144 /* Union */ && !(type.flags & 32764 /* Primitive */)) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (type.flags & 262144 /* Intersection */) { + if (type.flags & 524288 /* Intersection */) { var types = type.types; var newTypes = instantiateTypes(types, mapper); return newTypes !== types ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } - if (type.flags & 524288 /* Index */) { + if (type.flags & 1048576 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (type.flags & 1048576 /* IndexedAccess */) { + if (type.flags & 2097152 /* IndexedAccess */) { return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - if (type.flags & 2097152 /* Conditional */) { + if (type.flags & 4194304 /* Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); } - if (type.flags & 4194304 /* Substitution */) { + if (type.flags & 8388608 /* Substitution */) { return instantiateType(type.typeVariable, mapper); } } return type; } function getWildcardInstantiation(type) { - return type.flags & (16382 /* Primitive */ | 1 /* Any */ | 16384 /* Never */) ? type : + return type.flags & (32764 /* Primitive */ | 3 /* AnyOrUnknown */ | 32768 /* Never */) ? type : type.wildcardInstantiation || (type.wildcardInstantiation = instantiateType(type, wildcardMapper)); } function instantiateIndexInfo(info, mapper) { @@ -35503,34 +35671,38 @@ 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 !== 153 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); - case 183 /* ObjectLiteralExpression */: - return ts.forEach(node.properties, isContextSensitive); - case 182 /* ArrayLiteralExpression */: - return ts.forEach(node.elements, isContextSensitive); - case 200 /* ConditionalExpression */: + case 184 /* ObjectLiteralExpression */: + return ts.some(node.properties, isContextSensitive); + case 183 /* ArrayLiteralExpression */: + return ts.some(node.elements, isContextSensitive); + case 201 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return node.operatorToken.kind === 54 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 262 /* JsxAttributes */: - return ts.forEach(node.properties, isContextSensitive); - case 261 /* JsxAttribute */: + case 263 /* JsxAttributes */: + return ts.some(node.properties, isContextSensitive); + case 262 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. - return node.initializer && isContextSensitive(node.initializer); - case 264 /* JsxExpression */: + var initializer = node.initializer; + return !!initializer && isContextSensitive(initializer); + } + case 265 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) - return node.expression && isContextSensitive(node.expression); + var expression = node.expression; + return !!expression && isContextSensitive(expression); + } } return false; } @@ -35540,10 +35712,10 @@ var ts; return false; } // Functions with any parameters that lack type annotations are context sensitive. - if (ts.forEach(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { + if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 192 /* ArrowFunction */) { + if (node.kind !== 193 /* 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); @@ -35552,14 +35724,15 @@ var ts; } } // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return node.body.kind === 212 /* Block */ ? false : isContextSensitive(node.body); + var body = node.body; + return body.kind === 213 /* Block */ ? false : isContextSensitive(body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJavaScriptFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(16 /* Anonymous */, type.symbol); @@ -35570,7 +35743,7 @@ var ts; return result; } } - else if (type.flags & 262144 /* Intersection */) { + else if (type.flags & 524288 /* Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -35600,9 +35773,9 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 131072 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 131072 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 7372800 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : + return source.flags & 262144 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 262144 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 14745600 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || emptyObjectType, target) : target === globalObjectType || target === globalFunctionType ? isTypeSubtypeOf(source, target) : hasBaseType(source, getTargetType(target)); } @@ -35652,8 +35825,8 @@ var ts; source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 153 /* MethodDeclaration */ && - kind !== 152 /* MethodSignature */ && kind !== 154 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 154 /* MethodDeclaration */ && + kind !== 153 /* MethodSignature */ && kind !== 155 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -35690,8 +35863,9 @@ var ts; var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && - (getFalsyFlags(sourceType) & 12288 /* Nullable */) === (getFalsyFlags(targetType) & 12288 /* Nullable */); + (getFalsyFlags(sourceType) & 24576 /* Nullable */) === (getFalsyFlags(targetType) & 24576 /* Nullable */); var related = callbacks ? + // TODO: GH#18217 It will work if they're both `undefined`, but not if only one is compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { @@ -35713,7 +35887,7 @@ var ts; if (targetTypePredicate) { var sourceTypePredicate = getTypePredicateOfSignature(source); if (sourceTypePredicate) { - result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, source.declaration, target.declaration, reportErrors, errorReporter, compareTypes); + result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, source.declaration, target.declaration, reportErrors, errorReporter, compareTypes); // TODO: GH#18217 } else if (ts.isIdentifierTypePredicate(targetTypePredicate)) { if (reportErrors) { @@ -35803,10 +35977,10 @@ var ts; !t.numberIndexInfo; } function isEmptyObjectType(type) { - return type.flags & 65536 /* Object */ ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 134217728 /* NonPrimitive */ ? true : - type.flags & 131072 /* Union */ ? ts.forEach(type.types, isEmptyObjectType) : - type.flags & 262144 /* Intersection */ ? !ts.forEach(type.types, function (t) { return !isEmptyObjectType(t); }) : + return type.flags & 131072 /* Object */ ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 16777216 /* NonPrimitive */ ? true : + type.flags & 262144 /* Union */ ? ts.some(type.types, isEmptyObjectType) : + type.flags & 524288 /* Intersection */ ? !ts.some(type.types, function (t) { return !isEmptyObjectType(t); }) : false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -35842,43 +36016,43 @@ var ts; function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 1 /* Any */ || s & 16384 /* Never */ || source === wildcardType) + if (t & 3 /* AnyOrUnknown */ || s & 32768 /* Never */ || source === wildcardType) return true; - if (t & 16384 /* Never */) + if (t & 32768 /* Never */) return false; - if (s & 34 /* StringLike */ && t & 2 /* String */) + if (s & 68 /* StringLike */ && t & 4 /* String */) return true; - if (s & 32 /* StringLiteral */ && s & 256 /* EnumLiteral */ && - t & 32 /* StringLiteral */ && !(t & 256 /* EnumLiteral */) && + if (s & 64 /* StringLiteral */ && s & 512 /* EnumLiteral */ && + t & 64 /* StringLiteral */ && !(t & 512 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 84 /* NumberLike */ && t & 4 /* Number */) + if (s & 168 /* NumberLike */ && t & 8 /* Number */) return true; - if (s & 64 /* NumberLiteral */ && s & 256 /* EnumLiteral */ && - t & 64 /* NumberLiteral */ && !(t & 256 /* EnumLiteral */) && + if (s & 128 /* NumberLiteral */ && s & 512 /* EnumLiteral */ && + t & 128 /* NumberLiteral */ && !(t & 512 /* EnumLiteral */) && source.value === target.value) return true; - if (s & 136 /* BooleanLike */ && t & 8 /* Boolean */) + if (s & 272 /* BooleanLike */ && t & 16 /* Boolean */) return true; - if (s & 1536 /* ESSymbolLike */ && t & 512 /* ESSymbol */) + if (s & 3072 /* ESSymbolLike */ && t & 1024 /* ESSymbol */) return true; - if (s & 16 /* Enum */ && t & 16 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 256 /* EnumLiteral */ && t & 256 /* EnumLiteral */) { - if (s & 131072 /* Union */ && t & 131072 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 512 /* EnumLiteral */ && t & 512 /* EnumLiteral */) { + if (s & 262144 /* Union */ && t & 262144 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 224 /* Literal */ && t & 224 /* Literal */ && + if (s & 448 /* Literal */ && t & 448 /* Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } - if (s & 4096 /* Undefined */ && (!strictNullChecks || t & (4096 /* Undefined */ | 2048 /* Void */))) + if (s & 8192 /* Undefined */ && (!strictNullChecks || t & (8192 /* Undefined */ | 4096 /* Void */))) return true; - if (s & 8192 /* Null */ && (!strictNullChecks || t & 8192 /* Null */)) + if (s & 16384 /* Null */ && (!strictNullChecks || t & 16384 /* Null */)) return true; - if (s & 65536 /* Object */ && t & 134217728 /* NonPrimitive */) + if (s & 131072 /* Object */ && t & 16777216 /* NonPrimitive */) return true; - if (s & 1024 /* UniqueESSymbol */ || t & 1024 /* UniqueESSymbol */) + if (s & 2048 /* UniqueESSymbol */ || t & 2048 /* UniqueESSymbol */) return false; if (relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) { if (s & 1 /* Any */) @@ -35886,30 +36060,30 @@ 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 & (4 /* Number */ | 64 /* NumberLiteral */) && !(s & 256 /* EnumLiteral */) && (t & 16 /* Enum */ || t & 64 /* NumberLiteral */ && t & 256 /* EnumLiteral */)) + if (s & (8 /* Number */ | 128 /* NumberLiteral */) && !(s & 512 /* EnumLiteral */) && (t & 32 /* Enum */ || t & 128 /* NumberLiteral */ && t & 512 /* EnumLiteral */)) return true; } return false; } function isTypeRelatedTo(source, target, relation) { - if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 8388608 /* FreshLiteral */) { + if (source.flags & 192 /* StringOrNumberLiteral */ && source.flags & 33554432 /* FreshLiteral */) { source = source.regularType; } - if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 8388608 /* FreshLiteral */) { + if (target.flags & 192 /* StringOrNumberLiteral */ && target.flags & 33554432 /* FreshLiteral */) { target = target.regularType; } if (source === target || - relation === comparableRelation && !(target.flags & 16384 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } - if (source.flags & 65536 /* Object */ && target.flags & 65536 /* Object */) { + if (source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */) { var related = relation.get(getRelationKey(source, target, relation)); if (related !== undefined) { return related === 1 /* Succeeded */; } } - if (source.flags & 8355840 /* StructuredOrInstantiable */ || target.flags & 8355840 /* StructuredOrInstantiable */) { + if (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; @@ -35949,7 +36123,7 @@ var ts; errorInfo = ts.concatenateDiagnosticMessageChains(chain_1, errorInfo); } } - diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); // TODO: GH#18217 } // Check if we should issue an extra diagnostic to produce a quickfix for a slightly incorrect import statement if (headMessage && errorNode && !result && source.symbol) { @@ -35998,7 +36172,7 @@ var ts; } } function isUnionOrIntersectionTypeWithoutNullableConstituents(type) { - if (!(type.flags & 393216 /* UnionOrIntersection */)) { + if (!(type.flags & 786432 /* UnionOrIntersection */)) { return false; } // at this point we know that this is union or intersection type possibly with nullable constituents. @@ -36006,7 +36180,7 @@ var ts; var seenNonNullable = false; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 12288 /* Nullable */) { + if (t.flags & 24576 /* Nullable */) { continue; } if (seenNonNullable) { @@ -36023,22 +36197,23 @@ var ts; * * Ternary.False if they are not related. */ function isRelatedTo(source, target, reportErrors, headMessage) { - if (source.flags & 96 /* StringOrNumberLiteral */ && source.flags & 8388608 /* FreshLiteral */) { + if (reportErrors === void 0) { reportErrors = false; } + if (source.flags & 192 /* StringOrNumberLiteral */ && source.flags & 33554432 /* FreshLiteral */) { source = source.regularType; } - if (target.flags & 96 /* StringOrNumberLiteral */ && target.flags & 8388608 /* FreshLiteral */) { + if (target.flags & 192 /* StringOrNumberLiteral */ && target.flags & 33554432 /* FreshLiteral */) { target = target.regularType; } - if (source.flags & 4194304 /* Substitution */) { + if (source.flags & 8388608 /* Substitution */) { source = relation === definitelyAssignableRelation ? source.typeVariable : source.substitute; } - if (target.flags & 4194304 /* Substitution */) { + if (target.flags & 8388608 /* Substitution */) { target = target.typeVariable; } - if (source.flags & 1048576 /* IndexedAccess */) { + if (source.flags & 2097152 /* IndexedAccess */) { source = getSimplifiedType(source); } - if (target.flags & 1048576 /* IndexedAccess */) { + if (target.flags & 2097152 /* IndexedAccess */) { target = getSimplifiedType(target); } // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases @@ -36047,11 +36222,11 @@ var ts; if (relation === identityRelation) { return isIdenticalTo(source, target); } - if (relation === comparableRelation && !(target.flags & 16384 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 32768 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; - if (isObjectLiteralType(source) && source.flags & 8388608 /* FreshLiteral */) { - var discriminantType = target.flags & 131072 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; + if (isObjectLiteralType(source) && source.flags & 33554432 /* FreshLiteral */) { + var discriminantType = target.flags & 262144 /* Union */ ? findMatchingDiscriminantType(source, target) : undefined; if (hasExcessProperties(source, target, discriminantType, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, target); @@ -36067,8 +36242,8 @@ var ts; } } if (relation !== comparableRelation && - !(source.flags & 393216 /* UnionOrIntersection */) && - !(target.flags & 131072 /* Union */) && + !(source.flags & 786432 /* UnionOrIntersection */) && + !(target.flags & 262144 /* Union */) && !isIntersectionConstituent && source !== globalObjectType && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)) && @@ -36094,20 +36269,20 @@ var ts; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. - if (source.flags & 131072 /* Union */) { + if (source.flags & 262144 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 16382 /* Primitive */)) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 16382 /* Primitive */)); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */)); } else { - if (target.flags & 131072 /* Union */) { - result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 16382 /* Primitive */) && !(target.flags & 16382 /* Primitive */)); + if (target.flags & 262144 /* Union */) { + result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 32764 /* Primitive */) && !(target.flags & 32764 /* Primitive */)); } - else if (target.flags & 262144 /* Intersection */) { + else if (target.flags & 524288 /* Intersection */) { isIntersectionConstituent = true; result = typeRelatedToEachType(source, target, reportErrors); } - else if (source.flags & 262144 /* Intersection */) { + else if (source.flags & 524288 /* Intersection */) { // 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 @@ -36123,13 +36298,13 @@ var ts; // breaking the intersection apart. result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } - if (!result && (source.flags & 8355840 /* StructuredOrInstantiable */ || target.flags & 8355840 /* StructuredOrInstantiable */)) { + if (!result && (source.flags & 16711680 /* StructuredOrInstantiable */ || target.flags & 16711680 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { errorInfo = saveErrorInfo; } } } - if (!result && source.flags & 262144 /* Intersection */) { + if (!result && source.flags & 524288 /* Intersection */) { // The combined constraint of an intersection type is the intersection of the constraints of // the constituents. When an intersection type contains instantiable types with union type // constraints, there are situations where we need to examine the combined constraint. One is @@ -36139,7 +36314,7 @@ var ts; // we need to check this constraint against a union on the target side. Also, given a type // variable V constrained to 'string | number', 'V & number' has a combined constraint of // 'string & number | number & number' which reduces to just 'number'. - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 131072 /* Union */)); + var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 262144 /* Union */)); if (constraint) { if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; @@ -36148,12 +36323,22 @@ var ts; } isIntersectionConstituent = saveIsIntersectionConstituent; if (!result && reportErrors) { - if (source.flags & 65536 /* Object */ && target.flags & 16382 /* Primitive */) { + if (source.flags & 131072 /* Object */ && target.flags & 32764 /* Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 65536 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 131072 /* Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } + else if (ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && target.flags & 524288 /* Intersection */) { + var targetTypes = target.types; + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); + var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); + if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType && + (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) { + // do not report top error + return result; + } + } reportRelationError(headMessage, source, target); } return result; @@ -36161,27 +36346,27 @@ var ts; function isIdenticalTo(source, target) { var result; var flags = source.flags & target.flags; - if (flags & 65536 /* Object */) { + if (flags & 131072 /* Object */) { return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false); } - if (flags & (131072 /* Union */ | 262144 /* Intersection */)) { + if (flags & (262144 /* Union */ | 524288 /* Intersection */)) { if (result = eachTypeRelatedToSomeType(source, target)) { if (result &= eachTypeRelatedToSomeType(target, source)) { return result; } } } - if (flags & 524288 /* Index */) { + if (flags & 1048576 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } - if (flags & 1048576 /* IndexedAccess */) { + if (flags & 2097152 /* IndexedAccess */) { if (result = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { if (result &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { return result; } } } - if (flags & 2097152 /* Conditional */) { + if (flags & 4194304 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { if (result = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { if (result &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { @@ -36194,13 +36379,13 @@ var ts; } } } - if (flags & 4194304 /* Substitution */) { + if (flags & 8388608 /* Substitution */) { return isRelatedTo(source.substitute, target.substitute, /*reportErrors*/ false); } return 0 /* False */; } function hasExcessProperties(source, target, discriminant, reportErrors) { - if (maybeTypeOfKind(target, 65536 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + if (maybeTypeOfKind(target, 131072 /* Object */) && !(ts.getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096 /* JsxAttributes */); if ((relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { @@ -36216,7 +36401,8 @@ var ts; // We know *exactly* where things went wrong when comparing the types. // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. - ts.Debug.assert(!!errorNode); + if (!errorNode) + return { value: ts.Debug.fail() }; if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. @@ -36230,8 +36416,9 @@ var ts; var propDeclaration = prop.valueDeclaration; ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike); errorNode = propDeclaration; - if (ts.isIdentifier(propDeclaration.name)) { - suggestion = getSuggestionForNonexistentProperty(propDeclaration.name, target); + var name = propDeclaration.name; + if (ts.isIdentifier(name)) { + suggestion = getSuggestionForNonexistentProperty(name, target); } } if (suggestion !== undefined) { @@ -36269,7 +36456,7 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 131072 /* Union */ && containsType(targetTypes, source)) { + if (target.flags & 262144 /* Union */ && containsType(targetTypes, source)) { return -1 /* True */; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { @@ -36327,7 +36514,7 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; - if (source.flags & 131072 /* Union */ && containsType(sourceTypes, target)) { + if (source.flags & 262144 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; @@ -36479,7 +36666,7 @@ var ts; var result; var originalErrorInfo; var saveErrorInfo = errorInfo; - if (target.flags & 32768 /* TypeParameter */) { + if (target.flags & 65536 /* TypeParameter */) { // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. if (ts.getObjectFlags(source) & 32 /* Mapped */ && getConstraintTypeFromMappedType(source) === getIndexType(target)) { if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { @@ -36491,9 +36678,9 @@ var ts; } } } - else if (target.flags & 524288 /* Index */) { + else if (target.flags & 1048576 /* Index */) { // A keyof S is related to a keyof T if T is related to S. - if (source.flags & 524288 /* Index */) { + if (source.flags & 1048576 /* Index */) { if (result = isRelatedTo(target.type, source.type, /*reportErrors*/ false)) { return result; } @@ -36510,7 +36697,7 @@ var ts; } } } - else if (target.flags & 1048576 /* IndexedAccess */) { + else if (target.flags & 2097152 /* IndexedAccess */) { // A type S is related to a type T[K] if S is related to C, where C is the // constraint of T[K] var constraint = getConstraintForRelation(target); @@ -36526,7 +36713,7 @@ var ts; var template = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); if (!(modifiers & 8 /* ExcludeOptional */)) { - if (template.flags & 1048576 /* IndexedAccess */ && template.objectType === source && + if (template.flags & 2097152 /* IndexedAccess */ && template.objectType === source && template.indexType === getTypeParameterFromMappedType(target)) { return -1 /* True */; } @@ -36541,8 +36728,8 @@ var ts; } } } - if (source.flags & 1081344 /* TypeVariable */) { - if (source.flags & 1048576 /* IndexedAccess */ && target.flags & 1048576 /* IndexedAccess */) { + if (source.flags & 2162688 /* TypeVariable */) { + if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* 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); @@ -36553,9 +36740,9 @@ var ts; } } var constraint = getConstraintForRelation(source); - if (!constraint || (source.flags & 32768 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { + if (!constraint || (source.flags & 65536 /* TypeParameter */ && constraint.flags & 3 /* AnyOrUnknown */)) { // A type variable with no constraint is not related to the non-primitive object type. - if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~134217728 /* NonPrimitive */))) { + if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~16777216 /* NonPrimitive */))) { errorInfo = saveErrorInfo; return result; } @@ -36568,14 +36755,14 @@ var ts; } } } - else if (source.flags & 524288 /* Index */) { + else if (source.flags & 1048576 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 2097152 /* Conditional */) { - if (target.flags & 2097152 /* Conditional */) { + else if (source.flags & 4194304 /* Conditional */) { + if (target.flags & 4194304 /* Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. @@ -36643,14 +36830,14 @@ var ts; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. - var sourceIsPrimitive = !!(source.flags & 16382 /* Primitive */); + var sourceIsPrimitive = !!(source.flags & 32764 /* Primitive */); if (relation !== identityRelation) { source = getApparentType(source); } // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (source.flags & (65536 /* Object */ | 262144 /* Intersection */) && target.flags & 65536 /* Object */) { + if (source.flags & (131072 /* Object */ | 524288 /* Intersection */) && target.flags & 131072 /* Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; // An empty object type is related to any mapped type that includes a '?' modifier. @@ -36805,14 +36992,14 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo && resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); } - if (type.flags & 262144 /* Intersection */) { + if (type.flags & 524288 /* Intersection */) { return ts.every(type.types, isWeakType); } return false; @@ -36828,7 +37015,7 @@ var ts; return false; } function propertiesIdenticalTo(source, target) { - if (!(source.flags & 65536 /* Object */ && target.flags & 65536 /* Object */)) { + if (!(source.flags & 131072 /* Object */ && target.flags & 131072 /* Object */)) { return 0 /* False */; } var sourceProperties = getPropertiesOfObjectType(source); @@ -36896,7 +37083,7 @@ var ts; // in the context of the target signature before checking the relationship. Ideally we'd do // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. - var eraseGenerics = relation === comparableRelation || compilerOptions.noStrictGenericChecks; + var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); } else { @@ -36952,7 +37139,7 @@ var ts; continue; } // Skip over symbol-named members - if (prop.nameType && prop.nameType.flags & 1024 /* UniqueESSymbol */) { + if (prop.nameType && prop.nameType.flags & 2048 /* UniqueESSymbol */) { continue; } if (kind === 0 /* String */ || isNumericLiteralName(prop.escapedName)) { @@ -36980,7 +37167,7 @@ var ts; return indexTypesIdenticalTo(source, target, kind); } var targetInfo = getIndexInfoOfType(target, kind); - if (!targetInfo || targetInfo.type.flags & 1 /* Any */ && !sourceIsPrimitive) { + if (!targetInfo || targetInfo.type.flags & 3 /* AnyOrUnknown */ && !sourceIsPrimitive) { // Index signature of type any permits assignment from everything but primitives return -1 /* True */; } @@ -36992,7 +37179,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors); + return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -37102,17 +37289,17 @@ var ts; // See comment at call in recursiveTypeRelatedTo for when this case matters. function hasCovariantVoidArgument(type, variances) { for (var i = 0; i < variances.length; i++) { - if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 2048 /* Void */) { + if (variances[i] === 1 /* Covariant */ && type.typeArguments[i].flags & 4096 /* Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 32768 /* TypeParameter */ && !getConstraintFromTypeParameter(type); + return type.flags & 65536 /* TypeParameter */ && !getConstraintFromTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -37202,13 +37389,13 @@ var ts; // levels, but unequal at some level beyond that. function isDeeplyNestedType(type, stack, depth) { // We track all object types that have an associated symbol (representing the origin of the type) - if (depth >= 5 && type.flags & 65536 /* Object */) { + if (depth >= 5 && type.flags & 131072 /* Object */) { var symbol = type.symbol; if (symbol) { var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & 65536 /* Object */ && t.symbol === symbol) { + if (t.flags & 131072 /* Object */ && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -37356,9 +37543,9 @@ var ts; if (!strictNullChecks) { return getSupertypeOrUnion(types); } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 12288 /* Nullable */); }); + var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 24576 /* Nullable */); }); return primaryTypes.length ? - getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 12288 /* Nullable */) : + getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 24576 /* Nullable */) : getUnionType(types, 2 /* Subtype */); } // Return the leftmost type for which no type to the right is a subtype. @@ -37366,13 +37553,13 @@ var ts; return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalArrayType; + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalArrayType; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray return ts.getObjectFlags(type) & 4 /* Reference */ && (type.target === globalArrayType || type.target === globalReadonlyArrayType) || - !(type.flags & 12288 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + !(type.flags & 24576 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; @@ -37382,35 +37569,35 @@ var ts; return !!getPropertyOfType(type, "0"); } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (13536 /* Unit */ | 16384 /* Never */)); + return !(type.flags & (27072 /* Unit */ | 32768 /* Never */)); } function isUnitType(type) { - return !!(type.flags & 13536 /* Unit */); + return !!(type.flags & 27072 /* Unit */); } function isLiteralType(type) { - return type.flags & 8 /* Boolean */ ? true : - type.flags & 131072 /* Union */ ? type.flags & 256 /* EnumLiteral */ ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : + return type.flags & 16 /* Boolean */ ? true : + type.flags & 262144 /* Union */ ? type.flags & 512 /* EnumLiteral */ ? true : !ts.forEach(type.types, function (t) { return !isUnitType(t); }) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 256 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 32 /* StringLiteral */ ? stringType : - type.flags & 64 /* NumberLiteral */ ? numberType : - type.flags & 128 /* BooleanLiteral */ ? booleanType : - type.flags & 131072 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : + return type.flags & 512 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 64 /* StringLiteral */ ? stringType : + type.flags & 128 /* NumberLiteral */ ? numberType : + type.flags & 256 /* BooleanLiteral */ ? booleanType : + type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getBaseTypeOfLiteralType)) : type; } function getWidenedLiteralType(type) { - return type.flags & 256 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 32 /* StringLiteral */ && type.flags & 8388608 /* FreshLiteral */ ? stringType : - type.flags & 64 /* NumberLiteral */ && type.flags & 8388608 /* FreshLiteral */ ? numberType : - type.flags & 128 /* BooleanLiteral */ ? booleanType : - type.flags & 131072 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : + return type.flags & 512 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 64 /* StringLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? stringType : + type.flags & 128 /* NumberLiteral */ && type.flags & 33554432 /* FreshLiteral */ ? numberType : + type.flags & 256 /* BooleanLiteral */ ? booleanType : + type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedLiteralType)) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 1024 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 131072 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : + return type.flags & 2048 /* UniqueESSymbol */ ? esSymbolType : + type.flags & 262144 /* Union */ ? getUnionType(ts.sameMap(type.types, getWidenedUniqueESSymbolType)) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -37438,27 +37625,27 @@ var ts; // flags for the string, number, boolean, "", 0, false, void, undefined, or null types respectively. Returns // no flags for all other types (including non-falsy literal types). function getFalsyFlags(type) { - return type.flags & 131072 /* Union */ ? getFalsyFlagsOfTypes(type.types) : - type.flags & 32 /* StringLiteral */ ? type.value === "" ? 32 /* StringLiteral */ : 0 : - type.flags & 64 /* NumberLiteral */ ? type.value === 0 ? 64 /* NumberLiteral */ : 0 : - type.flags & 128 /* BooleanLiteral */ ? type === falseType ? 128 /* BooleanLiteral */ : 0 : - type.flags & 14574 /* PossiblyFalsy */; + return type.flags & 262144 /* Union */ ? getFalsyFlagsOfTypes(type.types) : + type.flags & 64 /* StringLiteral */ ? type.value === "" ? 64 /* StringLiteral */ : 0 : + type.flags & 128 /* NumberLiteral */ ? type.value === 0 ? 128 /* NumberLiteral */ : 0 : + type.flags & 256 /* BooleanLiteral */ ? type === falseType ? 256 /* BooleanLiteral */ : 0 : + type.flags & 29148 /* PossiblyFalsy */; } function removeDefinitelyFalsyTypes(type) { - return getFalsyFlags(type) & 14560 /* DefinitelyFalsy */ ? - filterType(type, function (t) { return !(getFalsyFlags(t) & 14560 /* DefinitelyFalsy */); }) : + return getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ ? + filterType(type, function (t) { return !(getFalsyFlags(t) & 29120 /* DefinitelyFalsy */); }) : type; } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 2 /* String */ ? emptyStringType : - type.flags & 4 /* Number */ ? zeroType : - type.flags & 8 /* Boolean */ || type === falseType ? falseType : - type.flags & (2048 /* Void */ | 4096 /* Undefined */ | 8192 /* Null */) || - type.flags & 32 /* StringLiteral */ && type.value === "" || - type.flags & 64 /* NumberLiteral */ && type.value === 0 ? type : + return type.flags & 4 /* String */ ? emptyStringType : + type.flags & 8 /* Number */ ? zeroType : + type.flags & 16 /* Boolean */ || type === falseType ? falseType : + type.flags & (4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */) || + type.flags & 64 /* StringLiteral */ && type.value === "" || + type.flags & 128 /* NumberLiteral */ && type.value === 0 ? type : neverType; } /** @@ -37467,15 +37654,15 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (4096 /* Undefined */ | 8192 /* Null */); + var missing = (flags & ~type.flags) & (8192 /* Undefined */ | 16384 /* Null */); return missing === 0 ? type : - missing === 4096 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 8192 /* Null */ ? getUnionType([type, nullType]) : + missing === 8192 /* Undefined */ ? getUnionType([type, undefinedType]) : + missing === 16384 /* Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type) { ts.Debug.assert(strictNullChecks); - return type.flags & 4096 /* Undefined */ ? type : getUnionType([type, undefinedType]); + return type.flags & 8192 /* Undefined */ ? type : getUnionType([type, undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { @@ -37528,7 +37715,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && type.flags & 8388608 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && type.flags & 33554432 /* FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -37538,7 +37725,7 @@ var ts; var resolved = type; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo); - regularNew.flags = resolved.flags & ~8388608 /* FreshLiteral */; + regularNew.flags = resolved.flags & ~33554432 /* FreshLiteral */; regularNew.objectFlags |= 128 /* ObjectLiteral */; type.regularType = regularNew; return regularNew; @@ -37620,16 +37807,16 @@ var ts; return getWidenedTypeWithContext(type, /*context*/ undefined); } function getWidenedTypeWithContext(type, context) { - if (type.flags & 50331648 /* RequiresWidening */) { - if (type.flags & 12288 /* Nullable */) { + if (type.flags & 402653184 /* RequiresWidening */) { + if (type.flags & 24576 /* Nullable */) { return anyType; } if (isObjectLiteralType(type)) { return getWidenedTypeOfObjectLiteral(type, context); } - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 12288 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 24576 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). @@ -37654,8 +37841,8 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (type.flags & 16777216 /* ContainsWideningType */) { - if (type.flags & 131072 /* Union */) { + if (type.flags & 134217728 /* ContainsWideningType */) { + if (type.flags & 262144 /* Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -37680,7 +37867,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (t.flags & 16777216 /* ContainsWideningType */) { + if (t.flags & 134217728 /* ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -37695,33 +37882,33 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 199 /* BinaryExpression */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 200 /* BinaryExpression */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 148 /* Parameter */: + case 149 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 181 /* BindingElement */: + case 182 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } diagnostic = ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 176 /* MappedType */: + case 177 /* MappedType */: error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); return; default: @@ -37730,7 +37917,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && noImplicitAny && type.flags & 16777216 /* ContainsWideningType */) { + if (produceDiagnostics && noImplicitAny && type.flags & 134217728 /* ContainsWideningType */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -37803,26 +37990,26 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - return !!(type.flags & 7897088 /* Instantiable */ || + return !!(type.flags & 15794176 /* Instantiable */ || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) || objectFlags & 32 /* Mapped */ || - type.flags & 393216 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); + type.flags & 786432 /* UnionOrIntersection */ && couldUnionOrIntersectionContainTypeVariables(type)); } function couldUnionOrIntersectionContainTypeVariables(type) { if (type.couldContainTypeVariables === undefined) { - type.couldContainTypeVariables = ts.forEach(type.types, couldContainTypeVariables); + type.couldContainTypeVariables = ts.some(type.types, couldContainTypeVariables); } return type.couldContainTypeVariables; } function isTypeParameterAtTopLevel(type, typeParameter) { - return type === typeParameter || type.flags & 393216 /* UnionOrIntersection */ && ts.forEach(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); + return type === typeParameter || !!(type.flags & 786432 /* UnionOrIntersection */) && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }); } /** Create an object with properties named in the string literal type. Every property has type `any` */ function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 32 /* StringLiteral */)) { + if (!(t.flags & 64 /* StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); @@ -37834,7 +38021,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfo = type.flags & 2 /* String */ ? createIndexInfo(emptyObjectType, /*isReadonly*/ false) : undefined; + var indexInfo = type.flags & 4 /* String */ ? createIndexInfo(emptyObjectType, /*isReadonly*/ false) : undefined; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfo, undefined); } /** @@ -37862,7 +38049,7 @@ var ts; // is incomplete and we can't infer a meaningful input type. for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { var prop = properties_4[_i]; - if (getTypeOfSymbol(prop).flags & 67108864 /* ContainsAnyFunctionType */) { + if (getTypeOfSymbol(prop).flags & 536870912 /* ContainsAnyFunctionType */) { return undefined; } } @@ -37882,7 +38069,7 @@ var ts; return getTypeFromInference(inference); } function getUnmatchedProperty(source, target, requireOptionalProperties) { - var properties = target.flags & 262144 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); + var properties = target.flags & 524288 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(target) : getPropertiesOfObjectType(target); for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { var targetProp = properties_5[_i]; if (requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */)) { @@ -37936,8 +38123,8 @@ var ts; } return; } - if (source.flags & 131072 /* Union */ && target.flags & 131072 /* Union */ && !(source.flags & 256 /* EnumLiteral */ && target.flags & 256 /* EnumLiteral */) || - source.flags & 262144 /* Intersection */ && target.flags & 262144 /* Intersection */) { + if (source.flags & 262144 /* Union */ && target.flags & 262144 /* Union */ && !(source.flags & 512 /* EnumLiteral */ && target.flags & 512 /* EnumLiteral */) || + source.flags & 524288 /* Intersection */ && target.flags & 524288 /* Intersection */) { // Source and target are both unions or both intersections. If source and target // are the same type, just relate each constituent type to itself. if (source === target) { @@ -37960,7 +38147,7 @@ var ts; (matchingTypes || (matchingTypes = [])).push(t); inferFromTypes(t, t); } - else if (t.flags & (64 /* NumberLiteral */ | 32 /* StringLiteral */)) { + else if (t.flags & (128 /* NumberLiteral */ | 64 /* StringLiteral */)) { var b = getBaseTypeOfLiteralType(t); if (typeIdenticalToSomeType(b, target.types)) { (matchingTypes || (matchingTypes = [])).push(t, b); @@ -37975,7 +38162,7 @@ var ts; target = removeTypesFromUnionOrIntersection(target, matchingTypes); } } - if (target.flags & 1081344 /* TypeVariable */) { + if (target.flags & 2162688 /* TypeVariable */) { // If target is a type parameter, make an inference, unless the source type contains // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). // Because the anyFunctionType is internal, it should not be exposed to the user by adding @@ -37983,7 +38170,7 @@ 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 (source.flags & 67108864 /* ContainsAnyFunctionType */ || source === silentNeverType) { + if (source.flags & 536870912 /* ContainsAnyFunctionType */ || source === silentNeverType) { return; } var inference = getInferenceInfoForType(target); @@ -38003,7 +38190,7 @@ var ts; inference.candidates = ts.append(inference.candidates, candidate); } } - if (!(priority & 8 /* ReturnType */) && target.flags & 32768 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 8 /* ReturnType */) && target.flags & 65536 /* TypeParameter */ && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; } } @@ -38025,12 +38212,12 @@ var ts; } } } - else if (source.flags & 524288 /* Index */ && target.flags & 524288 /* Index */) { + else if (source.flags & 1048576 /* Index */ && target.flags & 1048576 /* Index */) { contravariant = !contravariant; inferFromTypes(source.type, target.type); contravariant = !contravariant; } - else if ((isLiteralType(source) || source.flags & 2 /* String */) && target.flags & 524288 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 1048576 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; var savePriority = priority; @@ -38039,17 +38226,17 @@ var ts; priority = savePriority; contravariant = !contravariant; } - else if (source.flags & 1048576 /* IndexedAccess */ && target.flags & 1048576 /* IndexedAccess */) { + else if (source.flags & 2097152 /* IndexedAccess */ && target.flags & 2097152 /* IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 2097152 /* Conditional */ && target.flags & 2097152 /* Conditional */) { + else if (source.flags & 4194304 /* Conditional */ && target.flags & 4194304 /* Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } - else if (target.flags & 393216 /* UnionOrIntersection */) { + else if (target.flags & 786432 /* UnionOrIntersection */) { var targetTypes = target.types; var typeVariableCount = 0; var typeVariable = void 0; @@ -38074,7 +38261,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 131072 /* Union */) { + else if (source.flags & 262144 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { @@ -38083,10 +38270,10 @@ var ts; } } else { - if (!(priority & 32 /* NoConstraints */ && source.flags & (262144 /* Intersection */ | 7897088 /* Instantiable */))) { + if (!(priority & 32 /* NoConstraints */ && source.flags & (524288 /* Intersection */ | 15794176 /* Instantiable */))) { source = getApparentType(source); } - if (source.flags & (65536 /* Object */ | 262144 /* Intersection */)) { + if (source.flags & (131072 /* Object */ | 524288 /* Intersection */)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -38096,7 +38283,7 @@ var ts; // an instantiation of the same generic type), we do not explore this target as it would yield // no further inferences. We exclude the static side of classes from this check since it shares // its symbol with the instance side which would lead to false positives. - var isNonConstructorObject = target.flags & 65536 /* Object */ && + var isNonConstructorObject = target.flags & 131072 /* Object */ && !(ts.getObjectFlags(target) & 16 /* Anonymous */ && target.symbol && target.symbol.flags & 32 /* Class */); var symbol = isNonConstructorObject ? target.symbol : undefined; if (symbol) { @@ -38124,7 +38311,7 @@ var ts; } } function getInferenceInfoForType(type) { - if (type.flags & 1081344 /* TypeVariable */) { + if (type.flags & 2162688 /* TypeVariable */) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { var inference = inferences_1[_i]; if (type === inference.typeParameter) { @@ -38143,7 +38330,7 @@ var ts; } if (ts.getObjectFlags(target) & 32 /* Mapped */) { var constraintType = getConstraintTypeFromMappedType(target); - if (constraintType.flags & 524288 /* Index */) { + if (constraintType.flags & 1048576 /* Index */) { // We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X }, // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference @@ -38160,7 +38347,7 @@ var ts; } return; } - if (constraintType.flags & 32768 /* TypeParameter */) { + if (constraintType.flags & 65536 /* TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. var savePriority = priority; @@ -38251,11 +38438,11 @@ var ts; reducedTypes.push(t); } } - return type.flags & 131072 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); + return type.flags & 262144 /* Union */ ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return constraint && maybeTypeOfKind(constraint, 16382 /* Primitive */ | 524288 /* Index */); + return !!constraint && maybeTypeOfKind(constraint, 32764 /* Primitive */ | 1048576 /* Index */); } function isObjectLiteralType(type) { return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); @@ -38280,10 +38467,12 @@ var ts; // all inferences were made to top-level occurrences of the type parameter, and // the type parameter has no constraint or its constraint includes no primitive or literal types, and // the type parameter was fixed during inference or does not occur at top-level in the return type. - var widenLiteralTypes = inference.topLevel && - !hasPrimitiveConstraint(inference.typeParameter) && + var primitiveConstraint = hasPrimitiveConstraint(inference.typeParameter); + var widenLiteralTypes = !primitiveConstraint && inference.topLevel && (inference.isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), inference.typeParameter)); - var baseCandidates = widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) : candidates; + var baseCandidates = primitiveConstraint ? ts.sameMap(candidates, getRegularTypeOfLiteralType) : + widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) : + candidates; // If all inferences were made from contravariant positions, infer a common subtype. Otherwise, if // union types were requested or if all inferences were made from the return type position, infer a // union type. Otherwise, infer a common supertype. @@ -38302,7 +38491,7 @@ var ts; inferredType = getCovariantInference(inference, context, signature); // If we have inferred 'never' but have contravariant candidates. To get a more specific type we // infer from the contravariant candidates instead. - if (inferredType.flags & 16384 /* Never */ && inference.contraCandidates) { + if (inferredType.flags & 32768 /* Never */ && inference.contraCandidates) { inferredType = getContravariantInference(inference); } } @@ -38369,7 +38558,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 164 /* TypeQuery */ ? true : n.kind === 71 /* Identifier */ || n.kind === 145 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 165 /* TypeQuery */ ? true : n.kind === 71 /* Identifier */ || n.kind === 146 /* 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 @@ -38385,13 +38574,13 @@ var ts; if (node.kind === 99 /* ThisKeyword */) { return "0"; } - if (node.kind === 184 /* PropertyAccessExpression */) { + if (node.kind === 185 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + ts.idText(node.name); } - if (node.kind === 181 /* BindingElement */) { + if (node.kind === 182 /* BindingElement */) { var container = node.parent.parent; - var key = container.kind === 181 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); + var key = container.kind === 182 /* BindingElement */ ? getFlowCacheKey(container) : (container.initializer && getFlowCacheKey(container.initializer)); var text = getBindingElementNameText(node); var result = key && text && (key + "." + text); return result; @@ -38399,12 +38588,13 @@ var ts; return undefined; } function getBindingElementNameText(element) { - if (element.parent.kind === 179 /* ObjectBindingPattern */) { + var parent = element.parent; + if (parent.kind === 180 /* ObjectBindingPattern */) { var name = element.propertyName || element.name; switch (name.kind) { case 71 /* Identifier */: return ts.idText(name); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return ts.isStringOrNumericLiteral(name.expression) ? name.expression.text : undefined; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: @@ -38415,41 +38605,41 @@ var ts; } } else { - return "" + element.parent.elements.indexOf(element); + return "" + parent.elements.indexOf(element); } } function isMatchingReference(source, target) { switch (source.kind) { case 71 /* Identifier */: return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 231 /* VariableDeclaration */ || target.kind === 181 /* BindingElement */) && + (target.kind === 232 /* VariableDeclaration */ || target.kind === 182 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); case 99 /* ThisKeyword */: return target.kind === 99 /* ThisKeyword */; case 97 /* SuperKeyword */: return target.kind === 97 /* SuperKeyword */; - case 184 /* PropertyAccessExpression */: - return target.kind === 184 /* PropertyAccessExpression */ && + case 185 /* PropertyAccessExpression */: + return target.kind === 185 /* PropertyAccessExpression */ && source.name.escapedText === target.name.escapedText && isMatchingReference(source.expression, target.expression); - case 181 /* BindingElement */: - if (target.kind !== 184 /* PropertyAccessExpression */) + case 182 /* BindingElement */: + if (target.kind !== 185 /* PropertyAccessExpression */) return false; var t = target; if (t.name.escapedText !== getBindingElementNameText(source)) return false; - if (source.parent.parent.kind === 181 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { + if (source.parent.parent.kind === 182 /* BindingElement */ && isMatchingReference(source.parent.parent, t.expression)) { return true; } - if (source.parent.parent.kind === 231 /* VariableDeclaration */) { + if (source.parent.parent.kind === 232 /* VariableDeclaration */) { var maybeId = source.parent.parent.initializer; - return maybeId && isMatchingReference(maybeId, t.expression); + return !!maybeId && isMatchingReference(maybeId, t.expression); } } return false; } function containsMatchingReference(source, target) { - while (source.kind === 184 /* PropertyAccessExpression */) { + while (source.kind === 185 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -38462,7 +38652,7 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 184 /* PropertyAccessExpression */ && + return target.kind === 185 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.escapedText); } @@ -38470,18 +38660,18 @@ var ts; if (expr.kind === 71 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 184 /* PropertyAccessExpression */) { + if (expr.kind === 185 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.escapedText); } return undefined; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 131072 /* Union */) { + if (type && type.flags & 262144 /* Union */) { var prop = getUnionOrIntersectionProperty(type, name); if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.checkFlags & 32 /* HasNonUniformType */ && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = !!(prop.checkFlags & 32 /* HasNonUniformType */) && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -38514,7 +38704,7 @@ var ts; } } } - if (callExpression.expression.kind === 184 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 185 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -38528,7 +38718,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 131072 /* Union */)) { + if (!(source.flags & 262144 /* Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -38544,11 +38734,11 @@ var ts; // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { if (declaredType !== assignedType) { - if (assignedType.flags & 16384 /* Never */) { + if (assignedType.flags & 32768 /* Never */) { return assignedType; } var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (!(reducedType.flags & 16384 /* Never */)) { + if (!(reducedType.flags & 32768 /* Never */)) { return reducedType; } } @@ -38571,53 +38761,53 @@ var ts; } function getTypeFacts(type) { var flags = type.flags; - if (flags & 2 /* String */) { + if (flags & 4 /* String */) { return strictNullChecks ? 4079361 /* StringStrictFacts */ : 4194049 /* StringFacts */; } - if (flags & 32 /* StringLiteral */) { + if (flags & 64 /* StringLiteral */) { var isEmpty = type.value === ""; return strictNullChecks ? isEmpty ? 3030785 /* EmptyStringStrictFacts */ : 1982209 /* NonEmptyStringStrictFacts */ : isEmpty ? 3145473 /* EmptyStringFacts */ : 4194049 /* NonEmptyStringFacts */; } - if (flags & (4 /* Number */ | 16 /* Enum */)) { + if (flags & (8 /* Number */ | 32 /* Enum */)) { return strictNullChecks ? 4079234 /* NumberStrictFacts */ : 4193922 /* NumberFacts */; } - if (flags & 64 /* NumberLiteral */) { + if (flags & 128 /* NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? isZero ? 3030658 /* ZeroStrictFacts */ : 1982082 /* NonZeroStrictFacts */ : isZero ? 3145346 /* ZeroFacts */ : 4193922 /* NonZeroFacts */; } - if (flags & 8 /* Boolean */) { + if (flags & 16 /* Boolean */) { return strictNullChecks ? 4078980 /* BooleanStrictFacts */ : 4193668 /* BooleanFacts */; } - if (flags & 136 /* BooleanLike */) { + if (flags & 272 /* BooleanLike */) { return strictNullChecks ? type === falseType ? 3030404 /* FalseStrictFacts */ : 1981828 /* TrueStrictFacts */ : type === falseType ? 3145092 /* FalseFacts */ : 4193668 /* TrueFacts */; } - if (flags & 65536 /* Object */) { + if (flags & 131072 /* Object */) { return isFunctionObjectType(type) ? strictNullChecks ? 1970144 /* FunctionStrictFacts */ : 4181984 /* FunctionFacts */ : strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; } - if (flags & (2048 /* Void */ | 4096 /* Undefined */)) { + if (flags & (4096 /* Void */ | 8192 /* Undefined */)) { return 2457472 /* UndefinedFacts */; } - if (flags & 8192 /* Null */) { + if (flags & 16384 /* Null */) { return 2340752 /* NullFacts */; } - if (flags & 1536 /* ESSymbolLike */) { + if (flags & 3072 /* ESSymbolLike */) { return strictNullChecks ? 1981320 /* SymbolStrictFacts */ : 4193160 /* SymbolFacts */; } - if (flags & 134217728 /* NonPrimitive */) { + if (flags & 16777216 /* NonPrimitive */) { return strictNullChecks ? 1972176 /* ObjectStrictFacts */ : 4184016 /* ObjectFacts */; } - if (flags & 7897088 /* Instantiable */) { + if (flags & 15794176 /* Instantiable */) { return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } - if (flags & 393216 /* UnionOrIntersection */) { + if (flags & 786432 /* UnionOrIntersection */) { return getTypeFactsOfTypes(type.types); } return 4194303 /* All */; @@ -38637,26 +38827,26 @@ var ts; return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) || isNumericLiteralName(text) && getIndexTypeOfType(type, 1 /* Number */) || getIndexTypeOfType(type, 0 /* String */) || - unknownType; + errorType; } function getTypeOfDestructuredArrayElement(type, index) { return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || - unknownType; + errorType; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType); + return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 182 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 269 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 183 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 270 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 199 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 221 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 200 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 222 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -38673,29 +38863,29 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return stringType; - case 221 /* ForOfStatement */: - return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || unknownType; - case 199 /* BinaryExpression */: + case 222 /* ForOfStatement */: + return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; + case 200 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return undefinedType; - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } - return unknownType; + return errorType; } function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 179 /* ObjectBindingPattern */ ? + var type = pattern.kind === 180 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -38713,35 +38903,35 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 220 /* ForInStatement */) { + if (node.parent.parent.kind === 221 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 221 /* ForOfStatement */) { - return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || unknownType; + if (node.parent.parent.kind === 222 /* ForOfStatement */) { + return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } - return unknownType; + return errorType; } function getInitialType(node) { - return node.kind === 231 /* VariableDeclaration */ ? + return node.kind === 232 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 231 /* VariableDeclaration */ || node.kind === 181 /* BindingElement */ ? + return node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 231 /* VariableDeclaration */ && node.initializer && + return node.kind === 232 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 181 /* BindingElement */ && node.parent.kind === 199 /* BinaryExpression */ && + node.kind !== 182 /* BindingElement */ && node.parent.kind === 200 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: switch (node.operatorToken.kind) { case 58 /* EqualsToken */: return getReferenceCandidate(node.left); @@ -38753,13 +38943,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 190 /* ParenthesizedExpression */ || - parent.kind === 199 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || - parent.kind === 199 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? + return parent.kind === 191 /* ParenthesizedExpression */ || + parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || + parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 265 /* CaseClause */) { + if (clause.kind === 266 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -38776,13 +38966,13 @@ var ts; return links.switchTypes; } function eachTypeContainedIn(source, types) { - return source.flags & 131072 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 262144 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 131072 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 262144 /* Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 131072 /* Union */) { + if (source.flags & 262144 /* Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -38791,30 +38981,27 @@ var ts; } return true; } - if (source.flags & 256 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 512 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 131072 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 262144 /* Union */ ? ts.forEach(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { var types = type.types; var filtered = ts.filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 268435456 /* UnionOfUnitTypes */); + return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.flags & 67108864 /* UnionOfUnitTypes */); } return f(type) ? type : neverType; } - // Apply a mapping function to a type and return the resulting type. If the source type - // is a union type, the mapping function is applied to each constituent type and a union - // of the resulting types is returned. function mapType(type, mapper, noReductions) { - if (type.flags & 16384 /* Never */) { + if (type.flags & 32768 /* Never */) { return type; } - if (!(type.flags & 131072 /* Union */)) { + if (!(type.flags & 262144 /* Union */)) { return mapper(type); } var types = type.types; @@ -38844,11 +39031,11 @@ var ts; // typeWithPrimitives have been replaced with occurrences of string literals and numeric // literals in typeWithLiterals, respectively. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 32 /* StringLiteral */) || - isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64 /* NumberLiteral */)) { + if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 64 /* StringLiteral */) || + isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128 /* NumberLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 2 /* String */ ? extractTypesOfKind(typeWithLiterals, 2 /* String */ | 32 /* StringLiteral */) : - t.flags & 4 /* Number */ ? extractTypesOfKind(typeWithLiterals, 4 /* Number */ | 64 /* NumberLiteral */) : + return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 64 /* StringLiteral */) : + t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 128 /* NumberLiteral */) : t; }); } @@ -38883,9 +39070,9 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 16384 /* Never */ ? + return elementType.flags & 32768 /* Never */ ? autoArrayType : - createArrayType(elementType.flags & 131072 /* Union */ ? + createArrayType(elementType.flags & 262144 /* Union */ ? getUnionType(elementType.types, 2 /* Subtype */) : elementType); } @@ -38903,7 +39090,7 @@ var ts; var hasEvolvingArrayType = false; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var t = types_14[_i]; - if (!(t.flags & 16384 /* Never */)) { + if (!(t.flags & 32768 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; } @@ -38925,15 +39112,15 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 184 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 186 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 185 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 185 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 187 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 186 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 199 /* BinaryExpression */ && + parent.parent.kind === 200 /* BinaryExpression */ && parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 84 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 168 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -38948,7 +39135,7 @@ var ts; var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); - return apparentType !== unknownType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); + return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); } } return false; @@ -38964,9 +39151,9 @@ var ts; var key; var flowDepth = 0; if (flowAnalysisDisabled) { - return unknownType; + return errorType; } - if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 142575359 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 33492479 /* Narrowable */)) { return declaredType; } var sharedFlowStart = sharedFlowCount; @@ -38977,7 +39164,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) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 208 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 16384 /* Never */) { + if (reference.parent && reference.parent.kind === 209 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 32768 /* Never */) { return declaredType; } return resultType; @@ -38987,7 +39174,7 @@ var ts; // and disable further control flow analysis in the containing function or module body. flowAnalysisDisabled = true; reportFlowControlError(reference); - return unknownType; + return errorType; } flowDepth++; while (true) { @@ -39048,7 +39235,7 @@ var ts; else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 184 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { + if (container && container !== flowContainer && reference.kind !== 185 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -39086,7 +39273,7 @@ var ts; var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 131072 /* Union */) { + if (declaredType.flags & 262144 /* Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)); } return declaredType; @@ -39104,7 +39291,7 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 186 /* CallExpression */ ? + var expr = node.kind === 187 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -39112,7 +39299,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 186 /* CallExpression */) { + if (node.kind === 187 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -39120,7 +39307,7 @@ var ts; } else { var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 84 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 168 /* NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -39134,7 +39321,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 16384 /* Never */) { + if (type.flags & 32768 /* Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -39151,7 +39338,7 @@ var ts; return flowType; } var incomplete = isIncomplete(flowType); - var resultType = incomplete && narrowedType.flags & 16384 /* Never */ ? silentNeverType : narrowedType; + var resultType = incomplete && narrowedType.flags & 32768 /* Never */ ? silentNeverType : narrowedType; return createFlowType(resultType, incomplete); } function getTypeAtSwitchClause(flow) { @@ -39277,8 +39464,8 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr, computedType) { - return expr.kind === 184 /* PropertyAccessExpression */ && - computedType.flags & 131072 /* Union */ && + return expr.kind === 185 /* PropertyAccessExpression */ && + computedType.flags & 262144 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(computedType, expr.name.escapedText); } @@ -39311,7 +39498,7 @@ var ts; return !assumeTrue; } function narrowByInKeyword(type, literal, assumeTrue) { - if ((type.flags & (131072 /* Union */ | 65536 /* Object */)) || (type.flags & 32768 /* TypeParameter */ && type.isThisType)) { + if ((type.flags & (262144 /* Union */ | 131072 /* Object */)) || (type.flags & 65536 /* TypeParameter */ && type.isThisType)) { var propName_1 = ts.escapeLeadingUnderscores(literal.text); return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); }); } @@ -39328,10 +39515,10 @@ var ts; var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 194 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 194 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 195 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -39371,24 +39558,24 @@ var ts; assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if (valueType.flags & 12288 /* Nullable */) { + if (valueType.flags & 24576 /* Nullable */) { if (!strictNullChecks) { return type; } var doubleEquals = operator === 32 /* EqualsEqualsToken */ || operator === 33 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ : - valueType.flags & 8192 /* Null */ ? + valueType.flags & 16384 /* Null */ ? assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ : assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); } - if (type.flags & 134283777 /* NotUnionOrUnit */) { + if (type.flags & 16909315 /* NotUnionOrUnit */) { return type; } if (assumeTrue) { var narrowedType = filterType(type, function (t) { return areTypesComparable(t, valueType); }); - return narrowedType.flags & 16384 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); + return narrowedType.flags & 32768 /* Never */ ? type : replacePrimitivesWithLiterals(narrowedType, valueType); } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); @@ -39410,16 +39597,19 @@ var ts; if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } - if (assumeTrue && !(type.flags & 131072 /* Union */)) { + if (type.flags & 1 /* Any */ && literal.text === "function") { + return type; + } + if (assumeTrue && !(type.flags & 262144 /* Union */)) { // We narrow a non-union type to an exact primitive type if the non-union type // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. - var targetType = typeofTypesByName.get(literal.text); + var targetType = literal.text === "function" ? globalFunctionType : typeofTypesByName.get(literal.text); if (targetType) { if (isTypeSubtypeOf(targetType, type)) { return targetType; } - if (type.flags & 7897088 /* Instantiable */) { + if (type.flags & 15794176 /* Instantiable */) { var constraint = getBaseConstraintOfType(type) || anyType; if (isTypeSubtypeOf(targetType, constraint)) { return getIntersectionType([type, targetType]); @@ -39441,13 +39631,13 @@ var ts; var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 16384 /* Never */ ? neverType : + var caseType = discriminantType.flags & 32768 /* Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); }); - return caseType.flags & 16384 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 32768 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); } function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); @@ -39501,9 +39691,9 @@ var ts; } // If the current type is a union type, remove all constituents that couldn't be instances of // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 16384 /* Never */)) { + if (!(assignableType.flags & 32768 /* Never */)) { return assignableType; } } @@ -39543,7 +39733,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 185 /* ElementAccessExpression */ || invokedExpression.kind === 184 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 186 /* ElementAccessExpression */ || invokedExpression.kind === 185 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -39563,15 +39753,15 @@ var ts; case 71 /* Identifier */: case 99 /* ThisKeyword */: case 97 /* SuperKeyword */: - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: if (expr.operator === 51 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } @@ -39607,9 +39797,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 239 /* ModuleBlock */ || - node.kind === 273 /* SourceFile */ || - node.kind === 151 /* PropertyDeclaration */; + node.kind === 240 /* ModuleBlock */ || + node.kind === 274 /* SourceFile */ || + node.kind === 152 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -39631,7 +39821,7 @@ var ts; if (node.kind === 71 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 148 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 149 /* Parameter */) { symbol.isAssigned = true; } } @@ -39646,21 +39836,21 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 148 /* Parameter */ && + declaration.kind === 149 /* Parameter */ && declaration.initializer && - getFalsyFlags(declaredType) & 4096 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 4096 /* Undefined */); + getFalsyFlags(declaredType) & 8192 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 8192 /* Undefined */); return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072 /* NEUndefined */) : declaredType; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 184 /* PropertyAccessExpression */ || - parent.kind === 186 /* CallExpression */ && parent.expression === node || - parent.kind === 185 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 181 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 185 /* PropertyAccessExpression */ || + parent.kind === 187 /* CallExpression */ && parent.expression === node || + parent.kind === 186 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 182 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { - return type.flags & 7372800 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 12288 /* Nullable */); + return type.flags & 14745600 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, 24576 /* Nullable */); } function getConstraintForLocation(type, node) { // When a node is the left hand expression of a property access, element access, or call expression, @@ -39680,7 +39870,7 @@ var ts; function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { - return unknownType; + return errorType; } // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. // Although in down-level emit of arrow function, we emit it using function expression which means that @@ -39691,7 +39881,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 192 /* ArrowFunction */) { + if (container.kind === 193 /* 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.hasModifier(container, 256 /* Async */)) { @@ -39712,7 +39902,7 @@ var ts; // 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 === 234 /* ClassDeclaration */ + if (declaration.kind === 235 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -39724,14 +39914,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 204 /* ClassExpression */) { + else if (declaration.kind === 205 /* 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 !== undefined) { + while (container.kind !== 274 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 151 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 152 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -39748,11 +39938,11 @@ var ts; if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(ts.isInJavaScriptFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol)); - return unknownType; + return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, symbolToString(symbol)); - return unknownType; + return errorType; } } var isAlias = localOrExportSymbol.flags & 2097152 /* Alias */; @@ -39775,7 +39965,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 148 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 149 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -39783,8 +39973,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 === 191 /* FunctionExpression */ || - flowContainer.kind === 192 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 192 /* FunctionExpression */ || + flowContainer.kind === 193 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -39792,10 +39982,10 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAsignmentTarget || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 251 /* ExportSpecifier */) || - node.parent.kind === 208 /* NonNullExpression */ || - declaration.kind === 231 /* VariableDeclaration */ && declaration.exclamationToken || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || + isInTypeQuery(node) || node.parent.kind === 252 /* ExportSpecifier */) || + node.parent.kind === 209 /* NonNullExpression */ || + declaration.kind === 232 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 4194304 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : @@ -39813,7 +40003,7 @@ var ts; return convertAutoToAny(flowType); } } - else if (!assumeInitialized && !(getFalsyFlags(type) & 4096 /* Undefined */) && getFalsyFlags(flowType) & 4096 /* Undefined */) { + else if (!assumeInitialized && !(getFalsyFlags(type) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); // Return the declared type to reduce follow-on errors return type; @@ -39826,7 +40016,7 @@ var ts; function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 268 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 269 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -39851,8 +40041,8 @@ var ts; } // 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 (container.kind === 219 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 232 /* VariableDeclarationList */).parent === container && + if (container.kind === 220 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 233 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -39866,7 +40056,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 190 /* ParenthesizedExpression */) { + while (current.parent.kind === 191 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -39874,7 +40064,7 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 197 /* PrefixUnaryExpression */ || current.parent.kind === 198 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 198 /* PrefixUnaryExpression */ || current.parent.kind === 199 /* PostfixUnaryExpression */)) { var expr = current.parent; isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* MinusMinusToken */; } @@ -39887,7 +40077,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 151 /* PropertyDeclaration */ || container.kind === 154 /* Constructor */) { + if (container.kind === 152 /* PropertyDeclaration */ || container.kind === 155 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -39955,38 +40145,38 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 154 /* Constructor */) { + if (container.kind === 155 /* 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 === 192 /* ArrowFunction */) { + if (container.kind === 193 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES2015 */); } switch (container.kind) { - case 238 /* ModuleDeclaration */: + case 239 /* 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 237 /* EnumDeclaration */: + case 238 /* 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 154 /* Constructor */: + case 155 /* 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 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { 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 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -40007,8 +40197,8 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } - if (container.kind === 191 /* FunctionExpression */ && - container.parent.kind === 199 /* BinaryExpression */ && + if (container.kind === 192 /* FunctionExpression */ && + container.parent.kind === 200 /* BinaryExpression */ && ts.getSpecialPropertyAssignmentKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') var className = container.parent // x.prototype.y = f @@ -40032,14 +40222,14 @@ var ts; } if (ts.isInJavaScriptFile(node)) { var type = getTypeForThisExpressionFromJSDoc(container); - if (type && type !== unknownType) { + if (type && type !== errorType) { return getFlowTypeOfReference(node, type); } } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 283 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 284 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -40049,15 +40239,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 148 /* Parameter */; }); + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 149 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 186 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 187 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); 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 === 192 /* ArrowFunction */) { + while (container && container.kind === 193 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -40070,22 +40260,22 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 146 /* ComputedPropertyName */; }); - if (current && current.kind === 146 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 147 /* ComputedPropertyName */; }); + if (current && current.kind === 147 /* 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 === 183 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 184 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class); } - return unknownType; + return errorType; } - if (!isCallExpression && container.kind === 154 /* Constructor */) { + if (!isCallExpression && container.kind === 155 /* 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.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -40151,7 +40341,7 @@ var ts; // This helper creates an object with a "value" property that wraps the `super` property or indexed access for both get and set. // This is required for destructuring assignments, as a call expression cannot be used as the target of a destructuring assignment // while a property access can. - if (container.kind === 153 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 154 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -40165,10 +40355,10 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 183 /* ObjectLiteralExpression */) { + if (container.parent.kind === 184 /* 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 unknownType; + return errorType; } else { // for object literal assume that type of 'super' is 'any' @@ -40179,17 +40369,17 @@ var ts; var classLikeDeclaration = container.parent; if (!ts.getClassExtendsHeritageClauseElement(classLikeDeclaration)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class); - return unknownType; + return errorType; } var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classLikeDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; if (!baseClassType) { - return unknownType; + return errorType; } - if (container.kind === 154 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 155 /* 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 unknownType; + return errorType; } return nodeCheckFlag === 512 /* SuperStatic */ ? getBaseConstructorTypeOfClass(classType) @@ -40201,7 +40391,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 === 154 /* Constructor */; + return container.kind === 155 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -40209,21 +40399,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 === 183 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 184 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 153 /* MethodDeclaration */ || - container.kind === 152 /* MethodSignature */ || - container.kind === 155 /* GetAccessor */ || - container.kind === 156 /* SetAccessor */; + return container.kind === 154 /* MethodDeclaration */ || + container.kind === 153 /* MethodSignature */ || + container.kind === 156 /* GetAccessor */ || + container.kind === 157 /* SetAccessor */; } else { - return container.kind === 153 /* MethodDeclaration */ || - container.kind === 152 /* MethodSignature */ || - container.kind === 155 /* GetAccessor */ || - container.kind === 156 /* SetAccessor */ || - container.kind === 151 /* PropertyDeclaration */ || - container.kind === 150 /* PropertySignature */ || - container.kind === 154 /* Constructor */; + return container.kind === 154 /* MethodDeclaration */ || + container.kind === 153 /* MethodSignature */ || + container.kind === 156 /* GetAccessor */ || + container.kind === 157 /* SetAccessor */ || + container.kind === 152 /* PropertyDeclaration */ || + container.kind === 151 /* PropertySignature */ || + container.kind === 155 /* Constructor */; } } } @@ -40231,10 +40421,10 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 153 /* MethodDeclaration */ || - func.kind === 155 /* GetAccessor */ || - func.kind === 156 /* SetAccessor */) && func.parent.kind === 183 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 191 /* FunctionExpression */ && func.parent.kind === 269 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 154 /* MethodDeclaration */ || + func.kind === 156 /* GetAccessor */ || + func.kind === 157 /* SetAccessor */) && func.parent.kind === 184 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 192 /* FunctionExpression */ && func.parent.kind === 270 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { @@ -40242,11 +40432,11 @@ var ts; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 262144 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 524288 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 192 /* ArrowFunction */) { + if (func.kind === 193 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -40273,7 +40463,7 @@ var ts; if (thisType) { return instantiateType(thisType, getContextualMapper(containingLiteral)); } - if (literal.parent.kind !== 269 /* PropertyAssignment */) { + if (literal.parent.kind !== 270 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -40287,9 +40477,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 199 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + if (parent.kind === 200 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { var target = parent.left; - if (target.kind === 184 /* PropertyAccessExpression */ || target.kind === 185 /* ElementAccessExpression */) { + if (target.kind === 185 /* PropertyAccessExpression */ || target.kind === 186 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -40345,7 +40535,7 @@ var ts; if (funcHasRestParameters && indexOfParameter === (func.parameters.length - 1) && isRestParameterIndex(contextualSignature, func.parameters.length - 1)) { - return getTypeOfSymbol(ts.lastOrUndefined(contextualSignature.parameters)); + return getTypeOfSymbol(ts.last(contextualSignature.parameters)); } } } @@ -40364,7 +40554,7 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 148 /* Parameter */) { + if (declaration.kind === 149 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -40376,7 +40566,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (parentDeclaration.kind !== 181 /* BindingElement */) { + if (parentDeclaration.kind !== 182 /* BindingElement */) { var parentTypeNode = ts.getEffectiveTypeAnnotationNode(parentDeclaration); if (parentTypeNode && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -40432,7 +40622,7 @@ var ts; function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed - if (functionDecl.kind === 154 /* Constructor */ || + if (functionDecl.kind === 155 /* Constructor */ || ts.getEffectiveReturnTypeNode(functionDecl) || isGetAccessorWithAnnotatedSetAccessor(functionDecl)) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); @@ -40447,7 +40637,7 @@ var ts; } // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. function getContextualTypeForArgument(callTarget, arg) { - var args = getEffectiveCallArguments(callTarget); + var args = getEffectiveCallArguments(callTarget); // TODO: GH#18217 var argIndex = args.indexOf(arg); // -1 for e.g. the expression of a CallExpression, or the tag of a TaggedTemplateExpression return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex); } @@ -40458,7 +40648,7 @@ var ts; return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 188 /* TaggedTemplateExpression */) { + if (template.parent.kind === 189 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -40474,7 +40664,7 @@ var ts; // expression has no contextual type, the right operand is contextually typed by the type of the left operand, // except for the special case of Javascript declarations of the form `namespace.prop = namespace.prop || {}` var type = getContextualType(binaryExpression); - return !type && node === right && !ts.getDeclaredJavascriptInitializer(binaryExpression.parent) && !ts.getAssignedJavascriptInitializer(binaryExpression) ? + return !type && node === right && !ts.isDefaultedJavascriptInitializer(binaryExpression) ? getTypeOfExpression(left) : type; case 53 /* AmpersandAmpersandToken */: case 26 /* CommaToken */: @@ -40501,12 +40691,12 @@ var ts; case 6 /* Prototype */: return false; default: - ts.Debug.assertNever(kind); + return ts.Debug.assertNever(kind); } } function getTypeOfPropertyOfContextualType(type, name) { return mapType(type, function (t) { - var prop = t.flags & 458752 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; + var prop = t.flags & 917504 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }, /*noReductions*/ true); } @@ -40515,7 +40705,7 @@ var ts; } // Return true if the given contextual type is a tuple-like type function contextualTypeIsTupleLikeType(type) { - return !!(type.flags & 131072 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); + return !!(type.flags & 262144 /* Union */ ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one @@ -40590,12 +40780,31 @@ var ts; return getContextualType(attribute.parent); } } + // Return true if the given expression is possibly a discriminant value. We limit the kinds of + // expressions we check to those that don't depend on their contextual type in order not to cause + // recursive (and possibly infinite) invocations of getContextualType. + function isPossiblyDiscriminantValue(node) { + switch (node.kind) { + case 9 /* StringLiteral */: + case 8 /* NumericLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: + case 95 /* NullKeyword */: + case 71 /* Identifier */: + return true; + case 185 /* PropertyAccessExpression */: + case 191 /* ParenthesizedExpression */: + return isPossiblyDiscriminantValue(node.expression); + } + return false; + } // 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. function getApparentTypeOfContextualType(node) { var contextualType = getContextualType(node); contextualType = contextualType && mapType(contextualType, getApparentType); - if (!(contextualType && contextualType.flags & 131072 /* Union */ && ts.isObjectLiteralExpression(node))) { + if (!(contextualType && contextualType.flags & 262144 /* Union */ && ts.isObjectLiteralExpression(node))) { return contextualType; } // Keep the below up-to-date with the work done within `isRelatedTo` by `findMatchingDiscriminantType` @@ -40604,10 +40813,10 @@ var ts; var prop = _a[_i]; if (!prop.symbol) continue; - if (prop.kind !== 269 /* PropertyAssignment */) + if (prop.kind !== 270 /* PropertyAssignment */) continue; - if (isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { - var discriminatingType = getTypeOfNode(prop.initializer); + if (isPossiblyDiscriminantValue(prop.initializer) && isDiscriminantProperty(contextualType, prop.symbol.escapedName)) { + var discriminatingType = checkExpression(prop.initializer); for (var _b = 0, _c = contextualType.types; _b < _c.length; _b++) { var type = _c[_b]; var targetType = getTypeOfPropertyOfType(type, prop.symbol.escapedName); @@ -40652,59 +40861,59 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 181 /* BindingElement */: + case 232 /* VariableDeclaration */: + case 149 /* Parameter */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 182 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 192 /* ArrowFunction */: - case 224 /* ReturnStatement */: + case 193 /* ArrowFunction */: + case 225 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 182 /* ArrayLiteralExpression */: { + case 183 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 210 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 201 /* TemplateExpression */); + case 211 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 202 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 190 /* ParenthesizedExpression */: { + case 191 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); } - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 261 /* JsxAttribute */: - case 263 /* JsxSpreadAttribute */: + case 262 /* JsxAttribute */: + case 264 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 256 /* JsxOpeningElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; } function getContextualMapper(node) { - node = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); - return node ? node.contextualMapper : identityMapper; + var ancestor = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); + return ancestor ? ancestor.contextualMapper : identityMapper; } function getContextualJsxElementAttributesType(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { @@ -40720,16 +40929,16 @@ var ts; } function getJsxSignaturesParameterTypes(valueType, isJs, context) { // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - if (valueType.flags & 2 /* String */) { + if (valueType.flags & 4 /* String */) { return anyType; } - else if (valueType.flags & 32 /* StringLiteral */) { + else if (valueType.flags & 64 /* StringLiteral */) { // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type // For example: // var CustomTag: "h1" = "h1"; // Hello World var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, context); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { var stringLiteralTypeName = valueType.value; var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); if (intrinsicProp) { @@ -40751,7 +40960,7 @@ var ts; ctor = false; if (signatures.length === 0) { // We found no signatures at all, which is an error - return unknownType; + return errorType; } } var links = getNodeLinks(context); @@ -40772,7 +40981,7 @@ var ts; function getJsxPropsTypeFromCallSignature(sig, context) { var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, emptyObjectType); var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); - if (intrinsicAttribs !== unknownType) { + if (intrinsicAttribs !== errorType) { propsType = intersectTypes(intrinsicAttribs, propsType); } return propsType; @@ -40806,7 +41015,7 @@ var ts; // Normal case -- add in IntrinsicClassElements and IntrinsicElements var apparentAttributesType = attributesType; var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context); - if (intrinsicClassAttribs !== unknownType) { + if (intrinsicClassAttribs !== errorType) { var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol); var hostClassType = getReturnTypeOfSignature(sig); apparentAttributesType = intersectTypes(typeParams @@ -40814,7 +41023,7 @@ var ts; : intrinsicClassAttribs, apparentAttributesType); } var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context); - if (intrinsicAttribs !== unknownType) { + if (intrinsicAttribs !== errorType) { apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType); } return apparentAttributesType; @@ -40847,7 +41056,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 191 /* FunctionExpression */ || node.kind === 192 /* ArrowFunction */; + return node.kind === 192 /* FunctionExpression */ || node.kind === 193 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -40866,7 +41075,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 !== 153 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type; if (ts.isInJavaScriptFile(node)) { var jsdoc = ts.getJSDocType(node); @@ -40880,7 +41089,7 @@ var ts; if (!type) { return undefined; } - if (!(type.flags & 131072 /* Union */)) { + if (!(type.flags & 262144 /* Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -40919,8 +41128,8 @@ var ts; return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterables*/ false); } function hasDefaultValue(node) { - return (node.kind === 181 /* BindingElement */ && !!node.initializer) || - (node.kind === 199 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); + return (node.kind === 182 /* BindingElement */ && !!node.initializer) || + (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); } function checkArrayLiteral(node, checkMode) { var elements = node.elements; @@ -40930,7 +41139,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); for (var index = 0; index < elements.length; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 203 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 204 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -40955,7 +41164,7 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 203 /* SpreadElement */; + hasSpreadElement = hasSpreadElement || e.kind === 204 /* SpreadElement */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -40969,7 +41178,7 @@ var ts; var pattern = contextualType.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. - if (pattern && (pattern.kind === 180 /* ArrayBindingPattern */ || pattern.kind === 182 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 181 /* ArrayBindingPattern */ || pattern.kind === 183 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -40977,7 +41186,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 205 /* OmittedExpression */) { + if (patternElement.kind !== 206 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(strictNullChecks ? implicitNeverType : undefinedWideningType); @@ -40995,7 +41204,7 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return isNumericComputedName(name); case 71 /* Identifier */: return isNumericLiteralName(name.escapedText); @@ -41009,7 +41218,7 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAssignableToKind(checkComputedPropertyName(name), 84 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 168 /* NumberLike */); } function isInfinityOrNaNString(name) { return name === "Infinity" || name === "-Infinity" || name === "NaN"; @@ -41044,8 +41253,8 @@ var ts; links.resolvedType = checkExpression(node.expression); // 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 & 12288 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 34 /* StringLike */ | 84 /* NumberLike */ | 1536 /* ESSymbolLike */) && + if (links.resolvedType.flags & 24576 /* Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 68 /* StringLike */ | 168 /* NumberLike */ | 3072 /* ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -41072,23 +41281,26 @@ var ts; var propertiesTable; var propertiesArray = []; var spread = emptyObjectType; - var propagatedFlags = 8388608 /* FreshLiteral */; + var propagatedFlags = 33554432 /* FreshLiteral */; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 179 /* ObjectBindingPattern */ || contextualType.pattern.kind === 183 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 180 /* ObjectBindingPattern */ || contextualType.pattern.kind === 184 /* ObjectLiteralExpression */); var isInJSFile = ts.isInJavaScriptFile(node) && !ts.isInJsonFile(node); var isJSObjectLiteral = !contextualType && isInJSFile; var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; var hasComputedNumberProperty = false; - if (isInJSFile && node.properties.length === 0) { - // an empty JS object literal that nonetheless has members is a JS namespace - var symbol = getSymbolOfNode(node); - if (symbol.exports) { - propertiesTable = symbol.exports; - symbol.exports.forEach(function (symbol) { return propertiesArray.push(getMergedSymbol(symbol)); }); - return createObjectLiteralType(); + if (isInJSFile) { + var decl = ts.getDeclarationOfJSInitializer(node); + if (decl) { + // a JS object literal whose declaration's symbol has exports is a JS namespace + var symbol = getMergedSymbol(decl.symbol); + if (symbol && ts.hasEntries(symbol.exports)) { + propertiesTable = symbol.exports; + symbol.exports.forEach(function (symbol) { return propertiesArray.push(getMergedSymbol(symbol)); }); + return createObjectLiteralType(); + } } } propertiesTable = ts.createSymbolTable(); @@ -41096,13 +41308,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 146 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 147 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 269 /* PropertyAssignment */ || - memberDecl.kind === 270 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 270 /* PropertyAssignment */ || + memberDecl.kind === 271 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 269 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 270 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 270 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 271 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJSFile) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -41112,7 +41324,7 @@ var ts; } } typeFlags |= type.flags; - var nameType = computedNameType && computedNameType.flags & 1120 /* StringOrNumberLiteralOrUnique */ ? + var nameType = computedNameType && computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */ ? computedNameType : undefined; var prop = nameType ? createSymbol(4 /* Property */ | member.flags, getLateBoundNameFromType(nameType), 1024 /* Late */) : @@ -41123,8 +41335,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 === 269 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 270 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 270 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 271 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -41149,7 +41361,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 271 /* SpreadAssignment */) { + else if (memberDecl.kind === 272 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -41164,7 +41376,7 @@ var ts; var type = checkExpression(memberDecl.expression); if (!isValidSpreadType(type)) { error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); - return unknownType; + return errorType; } spread = getSpreadType(spread, type, node.symbol, propagatedFlags, /*objectFlags*/ 0); offset = i + 1; @@ -41176,10 +41388,10 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 155 /* GetAccessor */ || memberDecl.kind === 156 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 156 /* GetAccessor */ || memberDecl.kind === 157 /* SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 1120 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 2240 /* StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -41222,8 +41434,8 @@ var ts; var stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0 /* String */) : undefined; var numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8388608 /* FreshLiteral */; - result.flags |= 33554432 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 117440512 /* PropagatingFlags */); + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 33554432 /* FreshLiteral */; + result.flags |= 268435456 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 939524096 /* PropagatingFlags */); result.objectFlags |= 128 /* ObjectLiteral */; if (patternWithComputedProperties) { result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; @@ -41231,17 +41443,17 @@ var ts; if (inDestructuringPattern) { result.pattern = node; } - if (!(result.flags & 12288 /* Nullable */)) { - propagatedFlags |= (result.flags & 117440512 /* PropagatingFlags */); + if (!(result.flags & 24576 /* Nullable */)) { + propagatedFlags |= (result.flags & 939524096 /* PropagatingFlags */); } return result; } } function isValidSpreadType(type) { - return !!(type.flags & (1 /* Any */ | 134217728 /* NonPrimitive */) || - getFalsyFlags(type) & 14560 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || - type.flags & 65536 /* Object */ && !isGenericMappedType(type) || - type.flags & 393216 /* UnionOrIntersection */ && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); + return !!(type.flags & (3 /* AnyOrUnknown */ | 16777216 /* NonPrimitive */) || + getFalsyFlags(type) & 29120 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || + type.flags & 131072 /* Object */ && !isGenericMappedType(type) || + type.flags & 786432 /* UnionOrIntersection */ && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } function checkJsxSelfClosingElement(node, checkMode) { checkJsxOpeningLikeElementOrOpeningFragment(node, checkMode); @@ -41281,13 +41493,13 @@ var ts; function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment switch (tagName.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: case 99 /* ThisKeyword */: return false; case 71 /* Identifier */: return ts.isIntrinsicJsxName(tagName.escapedText); default: - ts.Debug.fail(); + return ts.Debug.fail(); } } function checkJsxAttribute(node, checkMode) { @@ -41331,7 +41543,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 263 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 264 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, /*typeFlags*/ 0, 4096 /* JsxAttributes */); attributesTable = ts.createSymbolTable(); @@ -41354,7 +41566,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 254 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 255 /* 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); @@ -41389,7 +41601,7 @@ var ts; */ function createJsxAttributesType() { var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.flags |= 33554432 /* ContainsObjectLiteral */; + result.flags |= 268435456 /* ContainsObjectLiteral */; result.objectFlags |= 128 /* ObjectLiteral */ | 4096 /* JsxAttributes */; return result; } @@ -41423,7 +41635,7 @@ var ts; var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); var typeSymbol = exports && getSymbol(exports, name, 67901928 /* Type */); - return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : unknownType; + return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** * Looks up an intrinsic tag name and returns a symbol that either points to an intrinsic @@ -41435,7 +41647,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { // Property case if (!ts.isIdentifier(node.tagName)) return ts.Debug.fail(); @@ -41501,6 +41713,7 @@ var ts; return instantiatedSignatures; } function getJsxSignatureTypeArgumentInstantiation(signature, node, isJavascript, reportErrors) { + if (reportErrors === void 0) { reportErrors = false; } if (!node.typeArguments) { return; } @@ -41523,7 +41736,7 @@ var ts; } } // JSX global fallback - return getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined); + return getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined); // TODO: GH#18217 } /** * Look into JSX namespace and then look for container with matching name as nameOfAttribPropContainer. @@ -41571,7 +41784,7 @@ var ts; if (!propsType) { return undefined; } - if (propsType.flags & 262144 /* Intersection */) { + if (propsType.flags & 524288 /* Intersection */) { var propsApparentType = []; for (var _i = 0, _a = propsType.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -41592,7 +41805,7 @@ var ts; * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global */ function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 131072 /* Union */)); + ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); if (jsxStatelessElementType) { @@ -41605,7 +41818,7 @@ var ts; if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { // Intersect in JSX.IntrinsicAttributes if it exists var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== unknownType) { + if (intrinsicAttributes !== errorType) { paramType = intersectTypes(intrinsicAttributes, paramType); } return paramType; @@ -41626,7 +41839,7 @@ var ts; * @param elementClassType a JSX-ElementClass type. This is a result of looking up ElementClass interface in the JSX global */ function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { - ts.Debug.assert(!(elementType.flags & 131072 /* Union */)); + ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type var jsxStatelessElementType = getJsxStatelessElementTypeAt(openingLikeElement); @@ -41639,6 +41852,7 @@ var ts; for (var _i = 0, candidatesOutArray_1 = candidatesOutArray; _i < candidatesOutArray_1.length; _i++) { var candidate = candidatesOutArray_1[_i]; var callReturnType = getReturnTypeOfSignature(candidate); + // TODO: GH#18217: callReturnType should always be defined... var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); paramType = getApparentTypeOfJsxPropsType(paramType); if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { @@ -41647,7 +41861,7 @@ var ts; var attribute = _b[_a]; if (ts.isJsxAttribute(attribute) && isUnhyphenatedJsxName(attribute.name.escapedText) && - !getPropertyOfType(paramType, attribute.name.escapedText)) { + !getPropertyOfType(paramType, attribute.name.escapedText)) { // TODO: GH#18217 shouldBeCandidate = false; break; } @@ -41664,7 +41878,7 @@ var ts; } // Intersect in JSX.IntrinsicAttributes if it exists var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, openingLikeElement); - if (intrinsicAttributes !== unknownType) { + if (intrinsicAttributes !== errorType) { result = intersectTypes(intrinsicAttributes, result); } return result; @@ -41722,7 +41936,7 @@ var ts; * emptyObjectType if there is no "prop" in the element instance type */ function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { - if (elementType.flags & 131072 /* Union */) { + if (elementType.flags & 262144 /* Union */) { var types = elementType.types; return getUnionType(types.map(function (type) { return resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, type, elementClassType); @@ -41733,16 +41947,16 @@ var ts; return elementType; } // If the elemType is a string type, we have to return anyType to prevent an error downstream as we will try to find construct or call signature of the type - else if (elementType.flags & 2 /* String */) { + else if (elementType.flags & 4 /* String */) { return anyType; } - else if (elementType.flags & 32 /* StringLiteral */) { + else if (elementType.flags & 64 /* StringLiteral */) { // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type // For example: // var CustomTag: "h1" = "h1"; // Hello World var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, openingLikeElement); - if (intrinsicElementsType !== unknownType) { + if (intrinsicElementsType !== errorType) { var stringLiteralTypeName = elementType.value; var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName)); if (intrinsicProp) { @@ -41760,9 +41974,9 @@ var ts; // Get the element instance type (the result of newing or invoking this tag) var instantiatedSignatures = getInstantiatedJsxSignatures(openingLikeElement, elementType, /*reportErrors*/ true); if (!ts.length(instantiatedSignatures)) { - return unknownType; + return errorType; } - var elemInstanceType = getUnionType(ts.map(instantiatedSignatures, getReturnTypeOfSignature), 2 /* Subtype */); + var elemInstanceType = getUnionType(instantiatedSignatures.map(getReturnTypeOfSignature), 2 /* Subtype */); // If we should include all stateless attributes type, then get all attributes type from all stateless function signature. // Otherwise get only attributes type from the signature picked by choose-overload logic. var statelessAttributesType = shouldIncludeAllStatelessAttributesType ? @@ -41776,7 +41990,7 @@ var ts; checkTypeRelatedTo(elemInstanceType, elementClassType, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); } var isJs = ts.isInJavaScriptFile(openingLikeElement); - return getUnionType(ts.map(instantiatedSignatures, function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, /*reportErrors*/ true); })); + return getUnionType(instantiatedSignatures.map(function (sig) { return getJsxPropsTypeFromClassType(sig, isJs, openingLikeElement, /*reportErrors*/ true); })); } /** * Get attributes type of the given intrinsic opening-like Jsx element by resolving the tag name. @@ -41795,7 +42009,7 @@ var ts; return links.resolvedJsxElementAttributesType = getIndexInfoOfSymbol(symbol, 0 /* String */).type; } else { - return links.resolvedJsxElementAttributesType = unknownType; + return links.resolvedJsxElementAttributesType = errorType; } } return links.resolvedJsxElementAttributesType; @@ -41849,7 +42063,7 @@ var ts; } function getJsxElementClassTypeAt(location) { var type = getJsxType(JsxNames.ElementClass, location); - if (type === unknownType) + if (type === errorType) return undefined; return type; } @@ -41922,7 +42136,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 65536 /* Object */) { + if (targetType.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(targetType); if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || @@ -41932,7 +42146,7 @@ var ts; return true; } } - else if (targetType.flags & 393216 /* UnionOrIntersection */) { + else if (targetType.flags & 786432 /* UnionOrIntersection */) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -42018,13 +42232,13 @@ var ts; return type; } else { - return unknownType; + return errorType; } } // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 151 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 152 /* PropertyDeclaration */; } function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; @@ -42053,9 +42267,9 @@ var ts; */ function checkPropertyAccessibility(node, left, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 184 /* PropertyAccessExpression */ || node.kind === 231 /* VariableDeclaration */ ? + var errorNode = node.kind === 185 /* PropertyAccessExpression */ || node.kind === 232 /* VariableDeclaration */ ? node.name : - node.kind === 178 /* ImportType */ ? + node.kind === 179 /* ImportType */ ? node : node.right; if (ts.getCheckFlags(prop) & 256 /* ContainsPrivate */) { @@ -42090,7 +42304,7 @@ var ts; if ((flags & 128 /* Abstract */) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeWithinConstructorOfClass(node, declaringClassDeclaration)) { - error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name)); + 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; } } @@ -42128,9 +42342,9 @@ var ts; if (flags & 32 /* Static */) { return true; } - if (type.flags & 32768 /* TypeParameter */) { + if (type.flags & 65536 /* TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type - type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + 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)); @@ -42141,21 +42355,25 @@ var ts; function symbolHasNonMethodDeclaration(symbol) { return forEachProperty(symbol, function (prop) { var propKind = getDeclarationKindFromSymbol(prop); - return propKind !== 153 /* MethodDeclaration */ && propKind !== 152 /* MethodSignature */; + return propKind !== 154 /* MethodDeclaration */ && propKind !== 153 /* MethodSignature */; }); } function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); } function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 12288 /* Nullable */; + if (type.flags & 2 /* Unknown */) { + error(node, ts.Diagnostics.Object_is_of_type_unknown); + return errorType; + } + var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 24576 /* Nullable */; if (kind) { - error(node, kind & 4096 /* Undefined */ ? kind & 8192 /* Null */ ? + error(node, kind & 8192 /* Undefined */ ? kind & 16384 /* Null */ ? (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); var t = getNonNullableType(type); - return t.flags & (12288 /* Nullable */ | 16384 /* Never */) ? unknownType : t; + return t.flags & (24576 /* Nullable */ | 32768 /* Never */) ? errorType : t; } return type; } @@ -42185,9 +42403,9 @@ var ts; var indexInfo = getIndexInfoOfType(apparentType, 0 /* String */); if (!(indexInfo && indexInfo.type)) { if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistentProperty(right, leftType.flags & 32768 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); + reportNonexistentProperty(right, leftType.flags & 65536 /* TypeParameter */ && leftType.isThisType ? apparentType : leftType); } - return unknownType; + return errorType; } if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) { error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType)); @@ -42202,7 +42420,7 @@ var ts; if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, ts.idText(right)); - return unknownType; + return errorType; } } propType = getConstraintForLocation(getTypeOfSymbol(prop), node); @@ -42210,9 +42428,9 @@ var ts; // 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. - if (node.kind !== 184 /* PropertyAccessExpression */ || + if (node.kind !== 185 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || - prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 131072 /* Union */)) { + prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 262144 /* Union */)) { return propType; } // If strict null checks and strict property initialization checks are enabled, if we have @@ -42224,14 +42442,14 @@ var ts; var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 154 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 155 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } } var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType); - if (assumeUninitialized && !(getFalsyFlags(propType) & 4096 /* Undefined */) && getFalsyFlags(flowType) & 4096 /* Undefined */) { - error(right, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); + if (assumeUninitialized && !(getFalsyFlags(propType) & 8192 /* Undefined */) && getFalsyFlags(flowType) & 8192 /* Undefined */) { + error(right, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop)); // TODO: GH#18217 // Return the declared type to reduce follow-on errors return propType; } @@ -42247,8 +42465,8 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.idText(right)); } - else if (valueDeclaration.kind === 234 /* ClassDeclaration */ && - node.parent.kind !== 161 /* TypeReference */ && + else if (valueDeclaration.kind === 235 /* ClassDeclaration */ && + node.parent.kind !== 162 /* TypeReference */ && !(valueDeclaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.idText(right)); @@ -42257,9 +42475,9 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return true; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. return false; default: @@ -42296,7 +42514,7 @@ var ts; } function reportNonexistentProperty(propNode, containingType) { var errorInfo; - if (containingType.flags & 131072 /* Union */ && !(containingType.flags & 16382 /* Primitive */)) { + if (containingType.flags & 262144 /* Union */ && !(containingType.flags & 32764 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText)) { @@ -42453,20 +42671,20 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return isValidPropertyAccessWithType(node, node.expression, propertyName, getWidenedType(checkExpression(node.expression))); - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return isValidPropertyAccessWithType(node, node.left, propertyName, getWidenedType(checkExpression(node.left))); - case 178 /* ImportType */: + case 179 /* ImportType */: return isValidPropertyAccessWithType(node, node, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 178 /* ImportType */ ? node : node.expression, property.escapedName, type) + return isValidPropertyAccessWithType(node, node.kind === 179 /* ImportType */ ? node : node.expression, property.escapedName, type) && (!(property.flags & 8192 /* Method */) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method, actualThisType) { - var propType = getTypeOfFuncClassEnumModule(method); + var propType = getTypeOfPropertyOfType(actualThisType, method.escapedName); var signatures = getSignaturesOfType(getNonNullableType(propType), 0 /* Call */); ts.Debug.assert(signatures.length !== 0); return signatures.some(function (sig) { @@ -42483,20 +42701,20 @@ var ts; return instantiateType(signatureThisType, createSignatureTypeMapper(sig, getInferredTypes(context))); } function isValidPropertyAccessWithType(node, left, propertyName, type) { - if (type === unknownType || isTypeAny(type)) { + if (type === errorType || isTypeAny(type)) { return true; } var prop = getPropertyOfType(type, propertyName); return prop ? checkPropertyAccessibility(node, left, type, prop) // In js files properties of unions are allowed in completion - : ts.isInJavaScriptFile(node) && (type.flags & 131072 /* Union */) && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, left, propertyName, elementType); }); + : ts.isInJavaScriptFile(node) && (type.flags & 262144 /* Union */) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, left, propertyName, elementType); }); } /** * Return the symbol of the for-in variable declared or referenced by the given for-in statement. */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 232 /* VariableDeclarationList */) { + if (initializer.kind === 233 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); @@ -42525,7 +42743,7 @@ var ts; var child = expr; var node = expr.parent; while (node) { - if (node.kind === 220 /* ForInStatement */ && + if (node.kind === 221 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -42543,7 +42761,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 187 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 188 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -42553,20 +42771,20 @@ var ts; var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); } - return unknownType; + return errorType; } var indexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : checkExpression(indexExpression); - if (objectType === unknownType || objectType === silentNeverType) { + if (objectType === errorType || objectType === silentNeverType) { return objectType; } if (isConstEnumObjectType(objectType) && indexExpression.kind !== 9 /* StringLiteral */) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); - return unknownType; + return errorType; } return checkIndexedAccessIndexType(getIndexedAccessType(objectType, indexType, node), node); } function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) { - if (expressionType === unknownType) { + if (expressionType === errorType) { // There is already an error, so no need to report one. return false; } @@ -42574,7 +42792,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 1536 /* ESSymbolLike */) === 0) { + if ((expressionType.flags & 3072 /* ESSymbolLike */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -42610,10 +42828,10 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 188 /* TaggedTemplateExpression */) { + if (node.kind === 189 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 149 /* Decorator */) { + else if (node.kind !== 150 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -42646,7 +42864,7 @@ var ts; var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { if (lastParent && parent === lastParent) { - index++; + index = index + 1; } else { lastParent = parent; @@ -42679,7 +42897,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 203 /* SpreadElement */) { + if (arg && arg.kind === 204 /* SpreadElement */) { return i; } } @@ -42689,22 +42907,21 @@ var ts; if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } var argCount; // Apparent number of arguments we will have in this call var typeArguments; // Type arguments (undefined if none) - var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments + var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var spreadArgIndex = -1; if (ts.isJsxOpeningLikeElement(node)) { // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". return true; } - if (node.kind === 188 /* TaggedTemplateExpression */) { + if (node.kind === 189 /* TaggedTemplateExpression */) { // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length argCount = args.length; - typeArguments = undefined; - if (node.template.kind === 201 /* TemplateExpression */) { + typeArguments = node.typeArguments; + if (node.template.kind === 202 /* 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.lastOrUndefined(node.template.templateSpans); - ts.Debug.assert(lastSpan !== undefined); // we should always have at least one span. + var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; } else { @@ -42716,14 +42933,14 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 149 /* Decorator */) { + else if (node.kind === 150 /* Decorator */) { typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); } else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 187 /* NewExpression */); + ts.Debug.assert(node.kind === 188 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -42758,7 +42975,7 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - if (type.flags & 65536 /* Object */) { + if (type.flags & 131072 /* Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { @@ -42806,7 +43023,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 !== 149 /* Decorator */) { + if (node.kind !== 150 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the contextual mapper to avoid disturbing a resolution in progress for an @@ -42841,7 +43058,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 205 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 206 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -42882,7 +43099,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (!constraint) continue; - var errorInfo = reportErrors && headMessage && (function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }); + var errorInfo = reportErrors && headMessage ? (function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }) : undefined; var typeArgumentHeadMessage = headMessage || ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1; if (!mapper) { mapper = createTypeMapper(typeParameters, typeArgumentTypes); @@ -42931,7 +43148,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 187 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 188 /* 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. @@ -42939,7 +43156,7 @@ var ts; var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; 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, getThisTypeOfSignature(signature), relation, errorNode, headMessage_1)) { + if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1)) { return false; } } @@ -42948,7 +43165,7 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 205 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 206 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); // If the effective argument type is undefined, there is no synthetic type for the argument. @@ -42972,9 +43189,9 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 186 /* CallExpression */) { + if (node.kind === 187 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 184 /* PropertyAccessExpression */ || callee.kind === 185 /* ElementAccessExpression */) { + if (callee.kind === 185 /* PropertyAccessExpression */ || callee.kind === 186 /* ElementAccessExpression */) { return callee.expression; } } @@ -42989,17 +43206,17 @@ var ts; * will be supplied from calls to `getEffectiveArgumentCount` and `getEffectiveArgumentType`. */ function getEffectiveCallArguments(node) { - if (node.kind === 188 /* TaggedTemplateExpression */) { + if (node.kind === 189 /* TaggedTemplateExpression */) { var template = node.template; - var args_4 = [undefined]; - if (template.kind === 201 /* TemplateExpression */) { + var args_4 = [undefined]; // TODO: GH#18217 + if (template.kind === 202 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_4.push(span.expression); }); } return args_4; } - else if (node.kind === 149 /* Decorator */) { + else if (node.kind === 150 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -43026,19 +43243,19 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 149 /* Decorator */) { + if (node.kind === 150 /* Decorator */) { switch (node.parent.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* 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. @@ -43048,10 +43265,12 @@ var ts; // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 148 /* Parameter */: + case 149 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; + default: + return ts.Debug.fail(); } } else { @@ -43072,25 +43291,25 @@ var ts; */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 234 /* ClassDeclaration */) { + if (node.kind === 235 /* ClassDeclaration */) { // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 154 /* Constructor */) { + if (node.kind === 155 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 151 /* PropertyDeclaration */ || - node.kind === 153 /* MethodDeclaration */ || - node.kind === 155 /* GetAccessor */ || - node.kind === 156 /* SetAccessor */) { + if (node.kind === 152 /* PropertyDeclaration */ || + node.kind === 154 /* MethodDeclaration */ || + node.kind === 156 /* GetAccessor */ || + node.kind === 157 /* SetAccessor */) { // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is // declared "static"; otherwise, it is the "instance"-side type of the @@ -43098,7 +43317,7 @@ var ts; return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } /** * Returns the effective type for the second argument to a decorator. @@ -43117,37 +43336,38 @@ var ts; */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 234 /* ClassDeclaration */) { + if (node.kind === 235 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* Parameter */) { node = node.parent; - if (node.kind === 154 /* Constructor */) { + if (node.kind === 155 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. } - if (node.kind === 151 /* PropertyDeclaration */ || - node.kind === 153 /* MethodDeclaration */ || - node.kind === 155 /* GetAccessor */ || - node.kind === 156 /* SetAccessor */) { + if (node.kind === 152 /* PropertyDeclaration */ || + node.kind === 154 /* MethodDeclaration */ || + node.kind === 156 /* GetAccessor */ || + node.kind === 157 /* SetAccessor */) { // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; - switch (element.name.kind) { + var name = element.name; + switch (name.kind) { case 71 /* Identifier */: - return getLiteralType(ts.idText(element.name)); + return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - return getLiteralType(element.name.text); - case 146 /* ComputedPropertyName */: - var nameType = checkComputedPropertyName(element.name); - if (isTypeAssignableToKind(nameType, 1536 /* ESSymbolLike */)) { + return getLiteralType(name.text); + case 147 /* ComputedPropertyName */: + var nameType = checkComputedPropertyName(name); + if (isTypeAssignableToKind(nameType, 3072 /* ESSymbolLike */)) { return nameType; } else { @@ -43155,11 +43375,11 @@ var ts; } default: ts.Debug.fail("Unsupported property name."); - return unknownType; + return errorType; } } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } /** * Returns the effective argument type for the third argument to a decorator. @@ -43171,28 +43391,28 @@ var ts; function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 234 /* ClassDeclaration */) { + if (node.kind === 235 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 151 /* PropertyDeclaration */) { + if (node.kind === 152 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); - return unknownType; + return errorType; } - if (node.kind === 153 /* MethodDeclaration */ || - node.kind === 155 /* GetAccessor */ || - node.kind === 156 /* SetAccessor */) { + if (node.kind === 154 /* MethodDeclaration */ || + node.kind === 156 /* GetAccessor */ || + node.kind === 157 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. - var propertyType = getTypeOfNode(node); + var propertyType = getTypeOfNode(node); // TODO: GH#18217 return createTypedPropertyDescriptorType(propertyType); } ts.Debug.fail("Unsupported decorator target."); - return unknownType; + return errorType; } /** * Returns the effective argument type for the provided argument to a decorator. @@ -43208,7 +43428,7 @@ var ts; return getEffectiveDecoratorThirdArgumentType(node.parent); } ts.Debug.fail("Decorators should not have a fourth synthetic argument."); - return unknownType; + return errorType; } /** * Gets the effective argument type for an argument in a call expression. @@ -43217,10 +43437,10 @@ var ts; // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 149 /* Decorator */) { + if (node.kind === 150 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 188 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -43232,8 +43452,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 149 /* Decorator */ || - (argIndex === 0 && node.kind === 188 /* TaggedTemplateExpression */)) { + if (node.kind === 150 /* Decorator */ || + (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -43242,11 +43462,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 149 /* Decorator */) { + if (node.kind === 150 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 188 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 189 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -43266,8 +43486,8 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, paramCount, typeArguments.length); } function resolveCall(node, signatures, candidatesOutArray, fallbackError) { - var isTaggedTemplate = node.kind === 188 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 149 /* Decorator */; + var isTaggedTemplate = node.kind === 189 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 150 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; if (!isDecorator) { @@ -43341,7 +43561,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 = candidatesOutArray && node.kind === 186 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 187 /* 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 @@ -43423,7 +43643,7 @@ var ts; var candidate = candidates[bestIndex]; var typeParameters = candidate.typeParameters; if (typeParameters && callLikeExpressionMayHaveTypeArguments(node) && node.typeArguments) { - var typeArguments_1 = node.typeArguments.map(getTypeOfNode); + var typeArguments_1 = node.typeArguments.map(getTypeOfNode); // TODO: GH#18217 while (typeArguments_1.length > typeParameters.length) { typeArguments_1.pop(); } @@ -43520,9 +43740,10 @@ var ts; if (node.expression.kind === 97 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { + ts.forEach(node.arguments, checkExpression); // Still visit arguments so they get marked for visibility, etc return anySignature; } - if (superType !== unknownType) { + if (superType !== errorType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated // with the type arguments specified in the extends clause. var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -43538,7 +43759,7 @@ var ts; return silentNeverSignature; } var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { + if (apparentType === errorType) { // Another error has already been reported return resolveErrorCall(node); } @@ -43554,7 +43775,7 @@ var ts; if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, constructSignatures.length)) { // The unknownType indicates that an error already occurred (and was reported). No // need to report another error in this case. - if (funcType !== unknownType && node.typeArguments) { + if (funcType !== errorType && node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); } return resolveUntypedCall(node); @@ -43580,8 +43801,8 @@ 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 & 32768 /* TypeParameter */ || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (131072 /* Union */ | 16384 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && funcType.flags & 65536 /* TypeParameter */ || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (262144 /* Union */ | 32768 /* Never */)) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray) { if (node.arguments && languageVersion < 1 /* ES5 */) { @@ -43600,7 +43821,7 @@ var ts; // signatures for overload resolution. The result type of the function call becomes // the result type of the operation. expressionType = getApparentType(expressionType); - if (expressionType === unknownType) { + if (expressionType === errorType) { // Another error has already been reported return resolveErrorCall(node); } @@ -43711,7 +43932,7 @@ var ts; function resolveTaggedTemplateExpression(node, candidatesOutArray) { var tagType = checkExpression(node.tag); var apparentType = getApparentType(tagType); - if (apparentType === unknownType) { + if (apparentType === errorType) { // Another error has already been reported return resolveErrorCall(node); } @@ -43731,17 +43952,19 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 148 /* Parameter */: + case 149 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; + default: + return ts.Debug.fail(); } } /** @@ -43750,7 +43973,7 @@ var ts; function resolveDecorator(node, candidatesOutArray) { var funcType = checkExpression(node.expression); var apparentType = getApparentType(funcType); - if (apparentType === unknownType) { + if (apparentType === errorType) { return resolveErrorCall(node); } var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); @@ -43765,8 +43988,7 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorInfo = void 0; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); + var errorInfo = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); errorInfo = ts.chainDiagnosticMessages(errorInfo, headMessage); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); invocationErrorRecovery(apparentType, 0 /* Call */); @@ -43797,7 +44019,7 @@ var ts; * the function will fill it up with appropriate candidate signatures */ function getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray) { - ts.Debug.assert(!(elementType.flags & 131072 /* Union */)); + ts.Debug.assert(!(elementType.flags & 262144 /* Union */)); var callSignatures = elementType && getSignaturesOfType(elementType, 0 /* Call */); if (callSignatures && callSignatures.length > 0) { return resolveCall(openingLikeElement, callSignatures, candidatesOutArray); @@ -43806,16 +44028,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 186 /* CallExpression */: + case 187 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 149 /* Decorator */: + case 150 /* Decorator */: return resolveDecorator(node, candidatesOutArray); - case 256 /* JsxOpeningElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: // This code-path is called by language service var exprTypes = checkExpression(node.tagName); return forEachType(exprTypes, function (exprType) { @@ -43830,7 +44052,7 @@ var ts; return ts.length(sigs) ? sigs[0] : unknownSignature; }) || unknownSignature; } - ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); + throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } /** * Resolve a signature of a given call-like expression. @@ -43870,15 +44092,11 @@ var ts; var symbol = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? getSymbolOfNode(node) : ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : undefined; - return symbol && symbol.members !== undefined; + return !!symbol && symbol.members !== undefined; } return false; } function getJavaScriptClassType(symbol) { - var initializer = ts.getDeclaredJavascriptInitializer(symbol.valueDeclaration); - if (initializer) { - symbol = getSymbolOfNode(initializer); - } var inferred; if (isJavaScriptConstructor(symbol.valueDeclaration)) { inferred = getInferredClassType(symbol); @@ -43909,7 +44127,7 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 184 /* PropertyAccessExpression */) { + while (parent && parent.kind === 185 /* PropertyAccessExpression */) { parent = parent.parent; } if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 58 /* EqualsToken */) { @@ -43941,12 +44159,12 @@ var ts; if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; } - if (node.kind === 187 /* NewExpression */) { + if (node.kind === 188 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 154 /* Constructor */ && - declaration.kind !== 158 /* ConstructSignature */ && - declaration.kind !== 163 /* ConstructorType */ && + declaration.kind !== 155 /* Constructor */ && + declaration.kind !== 159 /* ConstructSignature */ && + declaration.kind !== 164 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any, unless // the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations @@ -43974,10 +44192,20 @@ var ts; var returnType = getReturnTypeOfSignature(signature); // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property // as a fresh unique symbol literal type. - if (returnType.flags & 1536 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 3072 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - return returnType; + var jsAssignmentType; + if (ts.isInJavaScriptFile(node)) { + var decl = ts.getDeclarationOfJSInitializer(node); + if (decl) { + var jsSymbol = getSymbolOfNode(decl); + if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { + jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, jsObjectLiteralIndexInfo, undefined); + } + } + } + return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -44009,7 +44237,7 @@ var ts; for (var i = 1; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 4096 /* Undefined */ || specifierType.flags & 8192 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 8192 /* Undefined */ || specifierType.flags & 16384 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -44023,7 +44251,7 @@ var ts; return createPromiseReturnType(node, anyType); } function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) { - if (allowSyntheticDefaultImports && type && type !== unknownType) { + if (allowSyntheticDefaultImports && type && type !== errorType) { var synthType = type; if (!synthType.syntheticType) { var file_4 = ts.find(originalSymbol.declarations, ts.isSourceFile); @@ -44053,7 +44281,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67216319 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 67216319 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } @@ -44062,9 +44290,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 233 /* FunctionDeclaration */ + ? 234 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 231 /* VariableDeclaration */ + ? 232 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -44087,7 +44315,7 @@ var ts; var exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(checkExpression(expression, checkMode))); checkSourceElement(type); var targetType = getTypeFromTypeNode(type); - if (produceDiagnostics && targetType !== unknownType) { + if (produceDiagnostics && targetType !== errorType) { var widenedType = getWidenedType(exprType); if (!isTypeComparableTo(targetType, widenedType)) { checkTypeComparableTo(exprType, targetType, errNode, ts.Diagnostics.Type_0_cannot_be_converted_to_type_1); @@ -44106,14 +44334,15 @@ var ts; if (node.keywordToken === 91 /* ImportKeyword */) { return checkImportMetaProperty(node); } + return ts.Debug.assertNever(node.keywordToken); } function checkNewTargetMetaProperty(node) { var container = ts.getNewTargetContainer(node); if (!container) { error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); - return unknownType; + return errorType; } - else if (container.kind === 154 /* Constructor */) { + else if (container.kind === 155 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -44129,7 +44358,7 @@ var ts; var file = ts.getSourceFileOfNode(node); ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); - return node.name.escapedText === "meta" ? getGlobalImportMetaType() : unknownType; + return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { var type = getTypeOfSymbol(symbol); @@ -44185,9 +44414,9 @@ var ts; } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { // parameter might be a transient symbol generated by use of `arguments` in the function body. - var parameter = ts.lastOrUndefined(signature.parameters); + var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { - var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); + var contextualParameterType = getTypeOfSymbol(ts.last(context.parameters)); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } @@ -44237,7 +44466,7 @@ var ts; error(func, ts.isImportCall(func) ? ts.Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option : ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); - return unknownType; + return errorType; } else if (!getGlobalPromiseConstructorSymbol(/*reportErrors*/ true)) { error(func, ts.isImportCall(func) ? @@ -44248,11 +44477,11 @@ var ts; } function getReturnTypeFromBody(func, checkMode) { if (!func.body) { - return unknownType; + return errorType; } var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 212 /* Block */) { + if (func.body.kind !== 213 /* Block */) { type = checkExpressionCached(func.body, checkMode); if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any @@ -44366,7 +44595,7 @@ var ts; if (!(func.flags & 128 /* HasImplicitReturn */)) { return false; } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 226 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { + if (ts.some(func.body.statements, function (statement) { return statement.kind === 227 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { return false; } return true; @@ -44388,7 +44617,7 @@ var ts; // the native Promise type by the caller. type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - if (type.flags & 16384 /* Never */) { + if (type.flags & 32768 /* Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -44409,11 +44638,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return true; - case 153 /* MethodDeclaration */: - return func.parent.kind === 183 /* ObjectLiteralExpression */; + case 154 /* MethodDeclaration */: + return func.parent.kind === 184 /* ObjectLiteralExpression */; default: return false; } @@ -44432,16 +44661,16 @@ var ts; return; } // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (returnType && maybeTypeOfKind(returnType, 1 /* Any */ | 2048 /* Void */)) { + if (returnType && maybeTypeOfKind(returnType, 3 /* AnyOrUnknown */ | 4096 /* Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 152 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 212 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 153 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 213 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; - if (returnType && returnType.flags & 16384 /* Never */) { + if (returnType && returnType.flags & 32768 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (returnType && !hasExplicitReturn) { @@ -44470,14 +44699,14 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 153 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode === 1 /* SkipContextSensitive */ && isContextSensitive(node)) { return anyFunctionType; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 191 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 192 /* FunctionExpression */) { checkGrammarForGenerator(node); } var links = getNodeLinks(node); @@ -44518,7 +44747,7 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 153 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 154 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnTypeNode = ts.getEffectiveReturnTypeNode(node); var returnOrPromisedType = returnTypeNode && @@ -44538,7 +44767,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 212 /* Block */) { + if (node.body.kind === 213 /* Block */) { checkSourceElement(node.body); } else { @@ -44561,7 +44790,7 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!isTypeAssignableToKind(type, 84 /* NumberLike */)) { + if (!isTypeAssignableToKind(type, 168 /* NumberLike */)) { error(operand, diagnostic); return false; } @@ -44584,11 +44813,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 184 /* PropertyAccessExpression */ || expr.kind === 185 /* ElementAccessExpression */) && + (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) && expr.expression.kind === 99 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 154 /* Constructor */)) { + if (!(func && func.kind === 155 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -44601,13 +44830,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 184 /* PropertyAccessExpression */ || expr.kind === 185 /* ElementAccessExpression */) { + if (expr.kind === 185 /* PropertyAccessExpression */ || expr.kind === 186 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); if (node.kind === 71 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 245 /* NamespaceImport */; + return !!declaration && declaration.kind === 246 /* NamespaceImport */; } } } @@ -44616,7 +44845,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 71 /* Identifier */ && node.kind !== 184 /* PropertyAccessExpression */ && node.kind !== 185 /* ElementAccessExpression */) { + if (node.kind !== 71 /* Identifier */ && node.kind !== 185 /* PropertyAccessExpression */ && node.kind !== 186 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -44625,7 +44854,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 184 /* PropertyAccessExpression */ && expr.kind !== 185 /* ElementAccessExpression */) { + if (expr.kind !== 185 /* PropertyAccessExpression */ && expr.kind !== 186 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -44675,7 +44904,7 @@ var ts; case 38 /* MinusToken */: case 52 /* TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKind(operandType, 1536 /* ESSymbolLike */)) { + if (maybeTypeOfKind(operandType, 3072 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; @@ -44693,7 +44922,7 @@ var ts; } return numberType; } - return unknownType; + return errorType; } function checkPostfixUnaryExpression(node) { var operandType = checkExpression(node.operand); @@ -44710,10 +44939,10 @@ var ts; // Return true if type might be of the given kind. A union or intersection type might be of a given // kind if at least one constituent type is of the given kind. function maybeTypeOfKind(type, kind) { - if (type.flags & kind || kind & 536870912 /* GenericMappedType */ && isGenericMappedType(type)) { + if (type.flags & kind & ~134217728 /* GenericMappedType */ || kind & 134217728 /* GenericMappedType */ && isGenericMappedType(type)) { return true; } - if (type.flags & 393216 /* UnionOrIntersection */) { + if (type.flags & 786432 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; @@ -44728,26 +44957,26 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (1 /* Any */ | 2048 /* Void */ | 4096 /* Undefined */ | 8192 /* Null */)) { + if (strict && source.flags & (3 /* AnyOrUnknown */ | 4096 /* Void */ | 8192 /* Undefined */ | 16384 /* Null */)) { return false; } - return (kind & 84 /* NumberLike */ && isTypeAssignableTo(source, numberType)) || - (kind & 34 /* StringLike */ && isTypeAssignableTo(source, stringType)) || - (kind & 136 /* BooleanLike */ && isTypeAssignableTo(source, booleanType)) || - (kind & 2048 /* Void */ && isTypeAssignableTo(source, voidType)) || - (kind & 16384 /* Never */ && isTypeAssignableTo(source, neverType)) || - (kind & 8192 /* Null */ && isTypeAssignableTo(source, nullType)) || - (kind & 4096 /* Undefined */ && isTypeAssignableTo(source, undefinedType)) || - (kind & 512 /* ESSymbol */ && isTypeAssignableTo(source, esSymbolType)) || - (kind & 134217728 /* NonPrimitive */ && isTypeAssignableTo(source, nonPrimitiveType)); + return !!(kind & 168 /* NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 68 /* StringLike */) && isTypeAssignableTo(source, stringType) || + !!(kind & 272 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || + !!(kind & 4096 /* Void */) && isTypeAssignableTo(source, voidType) || + !!(kind & 32768 /* Never */) && isTypeAssignableTo(source, neverType) || + !!(kind & 16384 /* Null */) && isTypeAssignableTo(source, nullType) || + !!(kind & 8192 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 1024 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 16777216 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 131072 /* Union */ ? + return source.flags & 262144 /* Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { return (symbol.flags & 128 /* ConstEnum */) !== 0; @@ -44762,7 +44991,7 @@ var ts; // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 16382 /* Primitive */)) { + allTypesAssignableToKind(leftType, 32764 /* Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -44781,10 +45010,10 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 84 /* NumberLike */ | 1536 /* ESSymbolLike */))) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeAssignableToKind(leftType, 168 /* NumberLike */ | 3072 /* ESSymbolLike */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAssignableToKind(rightType, 134217728 /* NonPrimitive */ | 7372800 /* InstantiableNonPrimitive */)) { + if (!isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 14745600 /* 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); } return booleanType; @@ -44803,9 +45032,9 @@ var ts; } /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 269 /* PropertyAssignment */ || property.kind === 270 /* ShorthandPropertyAssignment */) { + if (property.kind === 270 /* PropertyAssignment */ || property.kind === 271 /* ShorthandPropertyAssignment */) { var name = property.name; - if (name.kind === 146 /* ComputedPropertyName */) { + if (name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -44818,7 +45047,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 270 /* ShorthandPropertyAssignment */) { + if (property.kind === 271 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -44830,7 +45059,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 271 /* SpreadAssignment */) { + else if (property.kind === 272 /* SpreadAssignment */) { if (languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -44856,7 +45085,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType; + var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; for (var i = 0; i < elements.length; i++) { checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); } @@ -44865,8 +45094,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 205 /* OmittedExpression */) { - if (element.kind !== 203 /* SpreadElement */) { + if (element.kind !== 206 /* OmittedExpression */) { + if (element.kind !== 204 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -44894,7 +45123,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 199 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { + if (restExpression.kind === 200 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -44907,13 +45136,13 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 270 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 271 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. if (strictNullChecks && - !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 4096 /* Undefined */)) { + !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 8192 /* Undefined */)) { sourceType = getTypeWithFacts(sourceType, 131072 /* NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); @@ -44923,21 +45152,21 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 199 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + if (target.kind === 200 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 183 /* ObjectLiteralExpression */) { + if (target.kind === 184 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 182 /* ArrayLiteralExpression */) { + if (target.kind === 183 /* 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 === 271 /* SpreadAssignment */ ? + var error = target.parent.kind === 272 /* 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; if (checkReferenceExpression(target, error)) { @@ -44959,35 +45188,35 @@ var ts; case 71 /* Identifier */: case 9 /* StringLiteral */: case 12 /* RegularExpressionLiteral */: - case 188 /* TaggedTemplateExpression */: - case 201 /* TemplateExpression */: + case 189 /* TaggedTemplateExpression */: + case 202 /* TemplateExpression */: case 13 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: case 86 /* FalseKeyword */: case 95 /* NullKeyword */: case 140 /* UndefinedKeyword */: - case 191 /* FunctionExpression */: - case 204 /* ClassExpression */: - case 192 /* ArrowFunction */: - case 182 /* ArrayLiteralExpression */: - case 183 /* ObjectLiteralExpression */: - case 194 /* TypeOfExpression */: - case 208 /* NonNullExpression */: - case 255 /* JsxSelfClosingElement */: - case 254 /* JsxElement */: + case 192 /* FunctionExpression */: + case 205 /* ClassExpression */: + case 193 /* ArrowFunction */: + case 183 /* ArrayLiteralExpression */: + case 184 /* ObjectLiteralExpression */: + case 195 /* TypeOfExpression */: + case 209 /* NonNullExpression */: + case 256 /* JsxSelfClosingElement */: + case 255 /* JsxElement */: return true; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { @@ -44999,15 +45228,15 @@ var ts; } return false; // Some forms listed here for clarity - case 195 /* VoidExpression */: // Explicit opt-out - case 189 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 207 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 196 /* VoidExpression */: // Explicit opt-out + case 190 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 208 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 12288 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 24576 /* Nullable */) !== 0 || isTypeComparableTo(source, target); } function checkBinaryExpression(node, checkMode) { if (ts.isInJavaScriptFile(node) && ts.getAssignedJavascriptInitializer(node)) { @@ -45017,7 +45246,7 @@ var ts; } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 58 /* EqualsToken */ && (left.kind === 183 /* ObjectLiteralExpression */ || left.kind === 182 /* ArrayLiteralExpression */)) { + if (operator === 58 /* EqualsToken */ && (left.kind === 184 /* ObjectLiteralExpression */ || left.kind === 183 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } var leftType = checkExpression(left, checkMode); @@ -45053,8 +45282,8 @@ var ts; var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion - if ((leftType.flags & 136 /* BooleanLike */) && - (rightType.flags & 136 /* BooleanLike */) && + if ((leftType.flags & 272 /* BooleanLike */) && + (rightType.flags & 272 /* BooleanLike */) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); } @@ -45072,24 +45301,24 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 34 /* StringLike */) && !isTypeAssignableToKind(rightType, 34 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 68 /* StringLike */) && !isTypeAssignableToKind(rightType, 68 /* StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 84 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 84 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 168 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 168 /* NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 34 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 34 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 68 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 68 /* StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } else if (isTypeAny(leftType) || isTypeAny(rightType)) { // Otherwise, the result is of type Any. // NOTE: unknown type here denotes error type. Old compiler treated this case as any type so do we. - resultType = leftType === unknownType || rightType === unknownType ? unknownType : anyType; + resultType = leftType === errorType || rightType === errorType ? errorType : anyType; } // Symbols are not allowed at all in arithmetic expressions if (resultType && !checkForDisallowedESSymbolOperand(operator)) { @@ -45150,6 +45379,8 @@ var ts; error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } return rightType; + default: + return ts.Debug.fail(); } function checkSpecialAssignment(left, right) { var special = ts.getSpecialPropertyAssignmentKind(left.parent); @@ -45161,7 +45392,7 @@ var ts; if (propType.symbol && propType.symbol.flags & 32 /* Class */) { var name = prop.escapedName; var symbol = resolveName(prop.valueDeclaration, name, 67901928 /* Type */, undefined, name, /*isUse*/ false); - if (symbol) { + if (symbol && symbol.declarations.some(function (d) { return d.kind === 297 /* JSDocTypedefTag */; })) { grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); } @@ -45174,8 +45405,8 @@ var ts; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKind(leftType, 1536 /* ESSymbolLike */) ? left : - maybeTypeOfKind(rightType, 1536 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKind(leftType, 3072 /* ESSymbolLike */) ? left : + maybeTypeOfKind(rightType, 3072 /* ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -45243,7 +45474,9 @@ var ts; } } var func = ts.getContainingFunction(node); - var functionFlags = func ? ts.getFunctionFlags(func) : 0 /* Normal */; + if (!func) + return anyType; + var functionFlags = ts.getFunctionFlags(func); if (!(functionFlags & 1 /* Generator */)) { // If the user's code is syntactically correct, the func should always have a star. After all, we are in a yield context. return anyType; @@ -45262,7 +45495,7 @@ var ts; } } var isAsync = (functionFlags & 2 /* Async */) !== 0; - var yieldedType = getYieldedTypeOfYieldExpression(node, isAsync); + var yieldedType = getYieldedTypeOfYieldExpression(node, isAsync); // TODO: GH#18217 // There is no point in doing an assignability check if the function // has no explicit return type because the return type is directly computed // from the yield expressions. @@ -45287,14 +45520,14 @@ var ts; // A place where we actually *are* concerned with the expressions' types are // in tagged templates. ts.forEach(node.templateSpans, function (templateSpan) { - if (maybeTypeOfKind(checkExpression(templateSpan.expression), 1536 /* ESSymbolLike */)) { + if (maybeTypeOfKind(checkExpression(templateSpan.expression), 3072 /* ESSymbolLike */)) { error(templateSpan.expression, ts.Diagnostics.Type_0_cannot_be_converted_to_type_1, typeToString(esSymbolType), typeToString(stringType)); } }); return stringType; } function getContextNode(node) { - if (node.kind === 262 /* JsxAttributes */) { + if (node.kind === 263 /* JsxAttributes */) { 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; @@ -45330,17 +45563,16 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 189 /* TypeAssertionExpression */ || node.kind === 207 /* AsExpression */; + return node.kind === 190 /* TypeAssertionExpression */ || node.kind === 208 /* AsExpression */; } function checkDeclarationInitializer(declaration) { - var inJs = ts.isInJavaScriptFile(declaration); - var initializer = inJs && ts.getDeclaredJavascriptInitializer(declaration) || declaration.initializer; + var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || (ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration)) || isTypeAssertion(initializer) ? type : getWidenedLiteralType(type); - if (inJs) { - if (widened.flags & 12288 /* Nullable */) { + if (ts.isInJavaScriptFile(declaration)) { + if (widened.flags & 24576 /* Nullable */) { if (noImplicitAny) { reportImplicitAnyError(declaration, anyType); } @@ -45355,38 +45587,28 @@ var ts; } return widened; } - function isTypeParameterWithKeyofConstraint(type) { - if (type.flags & 32768 /* TypeParameter */) { - var constraintDeclaration = getConstraintDeclaration(type); - return constraintDeclaration && constraintDeclaration.kind === 174 /* TypeOperator */ && - constraintDeclaration.operator === 128 /* KeyOfKeyword */; - } - return false; - } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 393216 /* UnionOrIntersection */) { + if (contextualType.flags & 786432 /* UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 7372800 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 14745600 /* InstantiableNonPrimitive */) { // If the contextual type is a type variable constrained to a primitive type, consider // this a literal context for literals of that primitive type. For example, given a // type parameter 'T extends string', infer string literal types for T. var constraint = getBaseConstraintOfType(contextualType) || emptyObjectType; - return isTypeParameterWithKeyofConstraint(contextualType) && maybeTypeOfKind(candidateType, 32 /* StringLiteral */ | 64 /* NumberLiteral */ | 1024 /* UniqueESSymbol */) || - constraint.flags & 2 /* String */ && maybeTypeOfKind(candidateType, 32 /* StringLiteral */) || - constraint.flags & 4 /* Number */ && maybeTypeOfKind(candidateType, 64 /* NumberLiteral */) || - constraint.flags & 8 /* Boolean */ && maybeTypeOfKind(candidateType, 128 /* BooleanLiteral */) || - constraint.flags & 512 /* ESSymbol */ && maybeTypeOfKind(candidateType, 1024 /* UniqueESSymbol */) || + return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || + maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || + maybeTypeOfKind(constraint, 1024 /* ESSymbol */) && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint); } // If the contextual type is a literal of a particular primitive type, we consider this a // literal context for all literals of that primitive type. - return contextualType.flags & (32 /* StringLiteral */ | 524288 /* Index */) && maybeTypeOfKind(candidateType, 32 /* StringLiteral */) || - contextualType.flags & 64 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 64 /* NumberLiteral */) || - contextualType.flags & 128 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 128 /* BooleanLiteral */) || - contextualType.flags & 1024 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 1024 /* UniqueESSymbol */); + return !!(contextualType.flags & (64 /* StringLiteral */ | 1048576 /* Index */) && maybeTypeOfKind(candidateType, 64 /* StringLiteral */) || + contextualType.flags & 128 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 128 /* NumberLiteral */) || + contextualType.flags & 256 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 256 /* BooleanLiteral */) || + contextualType.flags & 2048 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 2048 /* UniqueESSymbol */)); } return false; } @@ -45402,7 +45624,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 === 146 /* ComputedPropertyName */) { + if (node.name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -45413,7 +45635,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 === 146 /* ComputedPropertyName */) { + if (node.name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -45443,7 +45665,7 @@ var ts; function getTypeOfExpression(node, cache) { // 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 (node.kind === 186 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { + if (node.kind === 187 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(node)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -45478,7 +45700,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, checkMode) { var type; - if (node.kind === 145 /* QualifiedName */) { + if (node.kind === 146 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -45490,10 +45712,10 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 185 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 71 /* Identifier */ || node.kind === 145 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 164 /* TypeQuery */ && node.parent.exprName === node)); + var ok = (node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 186 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 71 /* Identifier */ || node.kind === 146 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 165 /* TypeQuery */ && node.parent.exprName === node)); 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); } @@ -45527,77 +45749,77 @@ var ts; return trueType; case 86 /* FalseKeyword */: return falseType; - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* RegularExpressionLiteral */: return globalRegExpType; - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (node.expression.kind === 91 /* ImportKeyword */) { return checkImportCallExpression(node); } /* falls through */ - case 187 /* NewExpression */: + case 188 /* NewExpression */: return checkCallExpression(node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return checkClassExpression(node); - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 194 /* TypeOfExpression */: + case 195 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: return checkAssertion(node); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: return checkNonNullAssertion(node); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return checkMetaProperty(node); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return checkDeleteExpression(node); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return checkVoidExpression(node); - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return checkAwaitExpression(node); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 205 /* OmittedExpression */: + case 206 /* OmittedExpression */: return undefinedWideningType; - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return checkYieldExpression(node); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 254 /* JsxElement */: + case 255 /* JsxElement */: return checkJsxElement(node, checkMode); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return checkJsxFragment(node, checkMode); - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 256 /* JsxOpeningElement */: + case 257 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } - return unknownType; + return errorType; } // DECLARATION AND STATEMENT TYPE CHECKING function checkTypeParameter(node) { @@ -45632,7 +45854,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 154 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 155 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -45643,7 +45865,7 @@ 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 === 154 /* Constructor */ || func.kind === 158 /* ConstructSignature */ || func.kind === 163 /* ConstructorType */) { + if (func.kind === 155 /* Constructor */ || func.kind === 159 /* ConstructSignature */ || func.kind === 164 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -45687,7 +45909,8 @@ var ts; } else { var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), node.type, + checkTypeAssignableTo(typePredicate.type, getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), // TODO: GH#18217 + node.type, /*headMessage*/ undefined, leadingError); } } @@ -45709,13 +45932,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 192 /* ArrowFunction */: - case 157 /* CallSignature */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 162 /* FunctionType */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 193 /* ArrowFunction */: + case 158 /* CallSignature */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 163 /* FunctionType */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -45733,7 +45956,7 @@ var ts; error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 180 /* ArrayBindingPattern */ || name.kind === 179 /* ObjectBindingPattern */) { + else if (name.kind === 181 /* ArrayBindingPattern */ || name.kind === 180 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -45742,13 +45965,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 159 /* IndexSignature */) { + if (node.kind === 160 /* 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 === 162 /* FunctionType */ || node.kind === 233 /* FunctionDeclaration */ || node.kind === 163 /* ConstructorType */ || - node.kind === 157 /* CallSignature */ || node.kind === 154 /* Constructor */ || - node.kind === 158 /* ConstructSignature */) { + else if (node.kind === 163 /* FunctionType */ || node.kind === 234 /* FunctionDeclaration */ || node.kind === 164 /* ConstructorType */ || + node.kind === 158 /* CallSignature */ || node.kind === 155 /* Constructor */ || + node.kind === 159 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -45778,10 +46001,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 157 /* CallSignature */: + case 158 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -45811,7 +46034,7 @@ var ts; checkAsyncFunctionReturnType(node); } } - if (node.kind !== 159 /* IndexSignature */ && node.kind !== 283 /* JSDocFunctionType */) { + if (node.kind !== 160 /* IndexSignature */ && node.kind !== 284 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -45828,7 +46051,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* Constructor */) { + if (member.kind === 155 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param) && !ts.isBindingPattern(param.name)) { @@ -45839,20 +46062,21 @@ var ts; else { var isStatic = ts.hasModifier(member, 32 /* Static */); var names = isStatic ? staticNames : instanceNames; - var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); - if (memberName) { + var name = member.name; + var memberName = name && ts.getPropertyNameForPropertyNameNode(name); + if (name && memberName) { switch (member.kind) { - case 155 /* GetAccessor */: - addName(names, member.name, memberName, 1 /* Getter */); + case 156 /* GetAccessor */: + addName(names, name, memberName, 1 /* Getter */); break; - case 156 /* SetAccessor */: - addName(names, member.name, memberName, 2 /* Setter */); + case 157 /* SetAccessor */: + addName(names, name, memberName, 2 /* Setter */); break; - case 151 /* PropertyDeclaration */: - addName(names, member.name, memberName, 3 /* Property */); + case 152 /* PropertyDeclaration */: + addName(names, name, memberName, 3 /* Property */); break; - case 153 /* MethodDeclaration */: - addName(names, member.name, memberName, 4 /* Method */); + case 154 /* MethodDeclaration */: + addName(names, name, memberName, 4 /* Method */); break; } } @@ -45914,15 +46138,16 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 /* PropertySignature */) { + if (member.kind === 151 /* PropertySignature */) { var memberName = void 0; - switch (member.name.kind) { + var name = member.name; + switch (name.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - memberName = member.name.text; + memberName = name.text; break; case 71 /* Identifier */: - memberName = ts.idText(member.name); + memberName = ts.idText(name); break; default: continue; @@ -45938,7 +46163,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 235 /* InterfaceDeclaration */) { + if (node.kind === 236 /* 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 @@ -45993,7 +46218,7 @@ var ts; 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.hasModifier(node, 128 /* Abstract */) && node.kind === 153 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 154 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -46018,7 +46243,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 151 /* PropertyDeclaration */ && + return n.kind === 152 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -46048,7 +46273,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { var statement = statements_2[_i]; - if (statement.kind === 215 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -46073,7 +46298,7 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 155 /* GetAccessor */) { + if (node.kind === 156 /* GetAccessor */) { if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -46083,13 +46308,13 @@ 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 === 146 /* ComputedPropertyName */) { + if (node.name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(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 === 155 /* GetAccessor */ ? 156 /* SetAccessor */ : 155 /* GetAccessor */; + var otherKind = node.kind === 156 /* GetAccessor */ ? 157 /* SetAccessor */ : 156 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -46107,7 +46332,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 155 /* GetAccessor */) { + if (node.kind === 156 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -46144,7 +46369,7 @@ var ts; } function getTypeParametersForTypeReference(node) { var type = getTypeFromTypeReference(node); - if (type !== unknownType) { + if (type !== errorType) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters || @@ -46155,11 +46380,11 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 161 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 162 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJavaScriptFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } var type = getTypeFromTypeReference(node); - if (type !== unknownType) { + if (type !== errorType) { if (node.typeArguments) { // Do type argument local checks only if referenced type is successfully resolved ts.forEach(node.typeArguments, checkSourceElement); @@ -46170,7 +46395,7 @@ var ts; } } } - if (type.flags & 16 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { + if (type.flags & 32 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -46179,7 +46404,7 @@ var ts; var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType); if (!typeReferenceNode) return undefined; - var typeParameters = getTypeParametersForTypeReference(typeReferenceNode); + var typeParameters = getTypeParametersForTypeReference(typeReferenceNode); // TODO: GH#18217 var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]); return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters))); } @@ -46210,14 +46435,14 @@ var ts; ts.forEach(node.types, checkSourceElement); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 1048576 /* IndexedAccess */)) { + if (!(type.flags & 2097152 /* IndexedAccess */)) { return type; } // Check if the index type is assignable to 'keyof T' for the object type. var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 185 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 186 /* 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)); } @@ -46225,7 +46450,7 @@ var ts; } // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. - if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 84 /* NumberLike */)) { + if (getIndexInfoOfType(getApparentType(objectType), 1 /* Number */) && isTypeAssignableToKind(indexType, 168 /* NumberLike */)) { return type; } error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); @@ -46254,7 +46479,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 170 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 171 /* 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); @@ -46270,9 +46495,9 @@ var ts; 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 !== 235 /* InterfaceDeclaration */ && - n.parent.kind !== 234 /* ClassDeclaration */ && - n.parent.kind !== 204 /* ClassExpression */ && + if (n.parent.kind !== 236 /* InterfaceDeclaration */ && + n.parent.kind !== 235 /* ClassDeclaration */ && + n.parent.kind !== 205 /* ClassExpression */ && n.flags & 4194304 /* 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 @@ -46363,7 +46588,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 153 /* MethodDeclaration */ || node.kind === 152 /* MethodSignature */) && + var reportError = (node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -46402,7 +46627,7 @@ var ts; var current = declarations_4[_i]; var node = current; var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 235 /* InterfaceDeclaration */ || node.parent.kind === 165 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 236 /* InterfaceDeclaration */ || node.parent.kind === 166 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -46413,7 +46638,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 233 /* FunctionDeclaration */ || node.kind === 153 /* MethodDeclaration */ || node.kind === 152 /* MethodSignature */ || node.kind === 154 /* Constructor */) { + if (node.kind === 234 /* FunctionDeclaration */ || node.kind === 154 /* MethodDeclaration */ || node.kind === 153 /* MethodSignature */ || node.kind === 155 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -46542,22 +46767,22 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: return 2 /* ExportType */; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 273 /* SourceFile */: + case 274 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; @@ -46565,20 +46790,20 @@ var ts; d = d.expression; /* falls through */ // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 242 /* ImportEqualsDeclaration */: - case 245 /* NamespaceImport */: - case 244 /* ImportClause */: + case 243 /* ImportEqualsDeclaration */: + case 246 /* NamespaceImport */: + case 245 /* ImportClause */: var result_3 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); return result_3; - case 231 /* VariableDeclaration */: - case 181 /* BindingElement */: - case 233 /* FunctionDeclaration */: - case 247 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 232 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 234 /* FunctionDeclaration */: + case 248 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: - ts.Debug.fail(ts.Debug.showSyntaxKind(d)); + return ts.Debug.fail(ts.Debug.showSyntaxKind(d)); } } } @@ -46611,7 +46836,7 @@ var ts; if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; } - var thenFunction = getTypeOfPropertyOfType(promise, "then"); + var thenFunction = getTypeOfPropertyOfType(promise, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; } @@ -46643,7 +46868,7 @@ var ts; * The runtime behavior of the `await` keyword. */ function checkAwaitedType(type, errorNode, diagnosticMessage) { - return getAwaitedType(type, errorNode, diagnosticMessage) || unknownType; + return getAwaitedType(type, errorNode, diagnosticMessage) || errorType; } function getAwaitedType(type, errorNode, diagnosticMessage) { var typeAsAwaitable = type; @@ -46653,7 +46878,7 @@ var ts; if (isTypeAny(type)) { return typeAsAwaitable.awaitedTypeOfType = type; } - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { var types = void 0; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var constituentType = _a[_i]; @@ -46732,7 +46957,8 @@ var ts; var thenFunction = getTypeOfPropertyOfType(type, "then"); if (thenFunction && getSignaturesOfType(thenFunction, 0 /* Call */).length > 0) { if (errorNode) { - ts.Debug.assert(!!diagnosticMessage); + if (!diagnosticMessage) + return ts.Debug.fail(); error(errorNode, diagnosticMessage); } return undefined; @@ -46777,58 +47003,58 @@ var ts; // then(...): Promise; // } // - var returnTypeNode = ts.getEffectiveReturnTypeNode(node); + var returnTypeNode = ts.getEffectiveReturnTypeNode(node); // TODO: GH#18217 var returnType = getTypeFromTypeNode(returnTypeNode); if (languageVersion >= 2 /* ES2015 */) { - if (returnType === unknownType) { - return unknownType; + if (returnType === errorType) { + return errorType; } var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true); if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { // The promise type was not a valid type reference to the global promise type, so we // report an error and return the unknown type. error(returnTypeNode, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); - return unknownType; + return errorType; } } else { // Always mark the type node as referenced if it points to a value markTypeNodeAsReferenced(returnTypeNode); - if (returnType === unknownType) { - return unknownType; + if (returnType === errorType) { + return errorType; } var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode); if (promiseConstructorName === undefined) { error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); - return unknownType; + return errorType; } var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 67216319 /* Value */, /*ignoreErrors*/ true); - var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; - if (promiseConstructorType === unknownType) { + var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; + if (promiseConstructorType === errorType) { if (promiseConstructorName.kind === 71 /* 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 { error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); } - return unknownType; + return errorType; } var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(/*reportErrors*/ true); if (globalPromiseConstructorLikeType === emptyObjectType) { // If we couldn't resolve the global PromiseConstructorLike type we cannot verify // compatibility with __awaiter. error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); - return unknownType; + return errorType; } if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value)) { - return unknownType; + return errorType; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 67216319 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); - return unknownType; + return errorType; } } // Get and return the awaited type of the return type. @@ -46845,26 +47071,30 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 148 /* Parameter */: + case 149 /* Parameter */: expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); + errorInfo = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: expectedReturnType = voidType; - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); + errorInfo = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - var methodType = getTypeOfNode(node.parent); + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + var methodType = getTypeOfNode(node.parent); // TODO: GH#18217 var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); break; + default: + return ts.Debug.fail(); } checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; }); } @@ -46904,12 +47134,12 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 169 /* IntersectionType */: - case 168 /* UnionType */: + case 170 /* IntersectionType */: + case 169 /* UnionType */: var commonEntityName = void 0; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 172 /* ParenthesizedType */) { + while (typeNode.kind === 173 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -46941,9 +47171,9 @@ var ts; } } return commonEntityName; - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return node.typeName; } } @@ -46967,14 +47197,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 148 /* Parameter */) { + if (node.kind === 149 /* 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 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -46983,19 +47213,19 @@ var ts; } } break; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 148 /* Parameter */: + case 149 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -47038,12 +47268,12 @@ var ts; return; } if (!containsArgumentsReference(decl)) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name.kind === 145 /* 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, ts.idText(node.name.kind === 146 /* QualifiedName */ ? node.name.right : node.name)); } 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 === 145 /* 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 === 146 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -47072,7 +47302,7 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -47085,7 +47315,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 146 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 147 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -47114,7 +47344,7 @@ var ts; } } } - var body = node.kind === 152 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 153 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if ((functionFlags & 1 /* Generator */) === 0) { // Async function or normal function @@ -47155,41 +47385,41 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 273 /* SourceFile */: - case 238 /* ModuleDeclaration */: - case 212 /* Block */: - case 240 /* CaseBlock */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 274 /* SourceFile */: + case 239 /* ModuleDeclaration */: + case 213 /* Block */: + case 241 /* CaseBlock */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 154 /* Constructor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 155 /* Constructor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 236 /* TypeAliasDeclaration */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 237 /* TypeAliasDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; default: @@ -47199,15 +47429,8 @@ var ts; } function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; - if (isIdentifierThatStartsWithUnderScore(node)) { - var declaration_2 = ts.getRootDeclaration(node.parent); - if ((declaration_2.kind === 231 /* VariableDeclaration */ && ts.isForInOrOfStatement(declaration_2.parent.parent)) || - declaration_2.kind === 147 /* TypeParameter */) { - return; - } - } var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(0 /* Local */, ts.createDiagnosticForNodeSpan(ts.getSourceFileOfNode(declaration), declaration, node, message, name)); + addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(node, message, name)); } function parameterNameStartsWithUnderscore(parameterName) { return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); @@ -47220,11 +47443,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 153 /* MethodDeclaration */: - case 151 /* PropertyDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - if (member.kind === 156 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 154 /* MethodDeclaration */: + case 152 /* PropertyDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + if (member.kind === 157 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -47233,7 +47456,7 @@ var ts; addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 154 /* Constructor */: + case 155 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -47241,8 +47464,8 @@ var ts; } } break; - case 159 /* IndexSignature */: - case 211 /* SemicolonClassElement */: + case 160 /* IndexSignature */: + case 212 /* SemicolonClassElement */: // Can't be private break; default: @@ -47283,6 +47506,7 @@ var ts; // Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value. var unusedImports = ts.createMap(); var unusedDestructures = ts.createMap(); + var unusedVariables = ts.createMap(); nodeWithLocals.locals.forEach(function (local) { // If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`. // If it's a type parameter merged with a parameter, check if the parameter-side is used. @@ -47303,6 +47527,11 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } } + else if (ts.isVariableDeclaration(declaration)) { + if (!isIdentifierThatStartsWithUnderScore(declaration.name) || !ts.isForInOrOfStatement(declaration.parent.parent)) { + addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); + } + } else { var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); if (parameter) { @@ -47320,50 +47549,77 @@ var ts; unusedImports.forEach(function (_a) { var importClause = _a[0], unuseds = _a[1]; var importDecl = importClause.parent; - if (forEachImportedDeclaration(importClause, function (d) { return !ts.contains(unuseds, d); })) { + var nDeclarations = (importClause.name ? 1 : 0) + + (importClause.namedBindings ? + (importClause.namedBindings.kind === 246 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + : 0); + if (nDeclarations === unuseds.length) { + addDiagnostic(0 /* Local */, unuseds.length === 1 + ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) + : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); + } + else { for (var _i = 0, unuseds_1 = unuseds; _i < unuseds_1.length; _i++) { var unused = unuseds_1[_i]; errorUnusedLocal(unused, ts.idText(unused.name), addDiagnostic); } } - else if (unuseds.length === 1) { - addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name))); - } - else { - addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); - } }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; - if (!bindingPattern.elements.every(function (e) { return ts.contains(bindingElements, e); })) { + if (bindingPattern.elements.length === bindingElements.length) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 232 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 233 /* VariableDeclarationList */) { + addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); + } + else { + addDiagnostic(kind, bindingElements.length === 1 + ? ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(ts.first(bindingElements).name, ts.isIdentifier))) + : ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused)); + } + } + else { for (var _i = 0, bindingElements_1 = bindingElements; _i < bindingElements_1.length; _i++) { var e = bindingElements_1[_i]; addDiagnostic(kind, ts.createDiagnosticForNode(e, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(e.name, ts.isIdentifier)))); } } - else if (bindingElements.length === 1) { - addDiagnostic(kind, ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(ts.first(bindingElements).name, ts.isIdentifier)))); + }); + unusedVariables.forEach(function (_a) { + var declarationList = _a[0], declarations = _a[1]; + if (declarationList.declarations.length === declarations.length) { + addDiagnostic(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 === 214 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { - addDiagnostic(kind, ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused)); + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var decl = declarations_5[_i]; + addDiagnostic(0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.cast(decl.name, ts.isIdentifier)))); + } } }); } + function bindingNameText(name) { + switch (name.kind) { + case 71 /* Identifier */: + return ts.idText(name); + case 181 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); + default: + return ts.Debug.assertNever(name); + } + } function isImportedDeclaration(node) { - return node.kind === 244 /* ImportClause */ || node.kind === 247 /* ImportSpecifier */ || node.kind === 245 /* NamespaceImport */; + return node.kind === 245 /* ImportClause */ || node.kind === 248 /* ImportSpecifier */ || node.kind === 246 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 244 /* ImportClause */ ? decl : decl.kind === 245 /* NamespaceImport */ ? decl.parent : decl.parent.parent; - } - function forEachImportedDeclaration(importClause, cb) { - var defaultName = importClause.name, namedBindings = importClause.namedBindings; - return (defaultName && cb(importClause)) || - namedBindings && (namedBindings.kind === 245 /* NamespaceImport */ ? cb(namedBindings) : ts.forEach(namedBindings.elements, cb)); + return decl.kind === 245 /* ImportClause */ ? decl : decl.kind === 246 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 212 /* Block */) { + if (node.kind === 213 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -47393,12 +47649,12 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 151 /* PropertyDeclaration */ || - node.kind === 150 /* PropertySignature */ || - node.kind === 153 /* MethodDeclaration */ || - node.kind === 152 /* MethodSignature */ || - node.kind === 155 /* GetAccessor */ || - node.kind === 156 /* SetAccessor */) { + if (node.kind === 152 /* PropertyDeclaration */ || + node.kind === 151 /* PropertySignature */ || + node.kind === 154 /* MethodDeclaration */ || + node.kind === 153 /* MethodSignature */ || + node.kind === 156 /* GetAccessor */ || + node.kind === 157 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -47407,7 +47663,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 148 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 149 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -47426,6 +47682,7 @@ var ts; } return true; } + return false; }); } function checkIfNewTargetIsCapturedInEnclosingScope(node) { @@ -47440,6 +47697,7 @@ var ts; } return true; } + return false; }); } function checkCollisionWithRequireExportsInGeneratedCode(node, name) { @@ -47456,7 +47714,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 === 273 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -47471,7 +47729,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 === 273 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 274 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(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)); } @@ -47506,7 +47764,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 === 231 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 232 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -47518,17 +47776,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 232 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 213 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 233 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 214 /* 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 === 212 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 239 /* ModuleBlock */ || - container.kind === 238 /* ModuleDeclaration */ || - container.kind === 273 /* SourceFile */); + (container.kind === 213 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 240 /* ModuleBlock */ || + container.kind === 239 /* ModuleDeclaration */ || + container.kind === 274 /* 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 @@ -47543,7 +47801,7 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 148 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 149 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -47554,7 +47812,7 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 184 /* PropertyAccessExpression */) { + if (n.kind === 185 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } @@ -47573,8 +47831,8 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 148 /* Parameter */ || - symbol.valueDeclaration.kind === 181 /* BindingElement */) { + if (symbol.valueDeclaration.kind === 149 /* Parameter */ || + symbol.valueDeclaration.kind === 182 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { @@ -47588,7 +47846,7 @@ var ts; return ts.isFunctionLike(current.parent) || // computed property names/initializers in instance property declaration of class like entities // are executed in constructor and thus deferred - (current.parent.kind === 151 /* PropertyDeclaration */ && + (current.parent.kind === 152 /* PropertyDeclaration */ && !(ts.hasModifier(current.parent, 32 /* Static */)) && ts.isClassLike(current.parent.parent)); })) { @@ -47621,18 +47879,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 === 146 /* ComputedPropertyName */) { + if (node.name.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 181 /* BindingElement */) { - if (node.parent.kind === 179 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { + if (node.kind === 182 /* BindingElement */) { + if (node.parent.kind === 180 /* ObjectBindingPattern */ && languageVersion < 6 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 146 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 147 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -47640,7 +47898,7 @@ var ts; var parentType = getTypeForBindingElementParent(parent); var name = node.propertyName || node.name; if (!ts.isBindingPattern(name)) { - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); // TODO: GH#18217 markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. if (parent.initializer && property) { checkPropertyAccessibility(parent, parent.initializer, parentType, property); @@ -47649,20 +47907,20 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 180 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 181 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 148 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 149 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 220 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 221 /* ForInStatement */) { var initializerType = checkExpressionCached(node.initializer); if (strictNullChecks && node.name.elements.length === 0) { checkNonNullType(initializerType, node); @@ -47679,8 +47937,8 @@ var ts; if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - if (node.initializer && node.parent.parent.kind !== 220 /* ForInStatement */) { - var initializer = ts.isInJavaScriptFile(node) && ts.getDeclaredJavascriptInitializer(node) || node.initializer; + var initializer = ts.getEffectiveInitializer(node); + if (initializer && node.parent.parent.kind !== 221 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -47689,7 +47947,7 @@ var ts; // Node is a secondary declaration, check that type is identical to primary declaration and check that // initializer is consistent with type associated with the node var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); - if (type !== unknownType && declarationType !== unknownType && + if (type !== errorType && declarationType !== errorType && !isTypeIdenticalTo(type, declarationType) && !(symbol.flags & 67108864 /* JSContainer */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(type, node, declarationType); @@ -47702,10 +47960,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 151 /* PropertyDeclaration */ && node.kind !== 150 /* PropertySignature */) { + if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 231 /* VariableDeclaration */ || node.kind === 181 /* BindingElement */) { + if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -47714,14 +47972,14 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 151 /* PropertyDeclaration */ || nextDeclaration.kind === 150 /* PropertySignature */ + var message = nextDeclaration.kind === 152 /* PropertyDeclaration */ || nextDeclaration.kind === 151 /* 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; error(nextDeclarationName, message, ts.declarationNameToString(nextDeclarationName), typeToString(firstType), typeToString(nextType)); } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 148 /* Parameter */ && right.kind === 231 /* VariableDeclaration */) || - (left.kind === 231 /* VariableDeclaration */ && right.kind === 148 /* Parameter */)) { + if ((left.kind === 149 /* Parameter */ && right.kind === 232 /* VariableDeclaration */) || + (left.kind === 232 /* VariableDeclaration */ && right.kind === 149 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -47760,7 +48018,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 214 /* EmptyStatement */) { + if (node.thenStatement.kind === 215 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -47780,12 +48038,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 232 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 233 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 232 /* VariableDeclarationList */) { + if (node.initializer.kind === 233 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -47819,18 +48077,18 @@ 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 === 232 /* VariableDeclarationList */) { + if (node.initializer.kind === 233 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 182 /* ArrayLiteralExpression */ || varExpr.kind === 183 /* ObjectLiteralExpression */) { + if (varExpr.kind === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* 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. - checkDestructuringAssignment(varExpr, iteratedType || unknownType); + checkDestructuringAssignment(varExpr, iteratedType || errorType); } else { var leftType = checkExpression(varExpr); @@ -47858,7 +48116,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 === 232 /* VariableDeclarationList */) { + if (node.initializer.kind === 233 /* 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); @@ -47872,7 +48130,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 === 182 /* ArrayLiteralExpression */ || varExpr.kind === 183 /* ObjectLiteralExpression */) { + if (varExpr.kind === 183 /* ArrayLiteralExpression */ || varExpr.kind === 184 /* 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)) { @@ -47885,7 +48143,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (rightType === neverType || !isTypeAssignableToKind(rightType, 134217728 /* NonPrimitive */ | 7372800 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 16777216 /* NonPrimitive */ | 14745600 /* InstantiableNonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -47918,7 +48176,7 @@ var ts; */ function getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterables, checkAssignability) { if (inputType === neverType) { - reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); + reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); // TODO: GH#18217 return undefined; } var uplevelIteration = languageVersion >= 2 /* ES2015 */; @@ -47940,16 +48198,16 @@ var ts; // This allows us to find other non-string element types from an array unioned with // a string. if (allowStringInput) { - if (arrayType.flags & 131072 /* Union */) { + if (arrayType.flags & 262144 /* Union */) { // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the result of filter is a new array. var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 34 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 68 /* StringLike */); }); if (filteredTypes !== arrayTypes) { arrayType = getUnionType(filteredTypes, 2 /* Subtype */); } } - else if (arrayType.flags & 34 /* StringLike */) { + else if (arrayType.flags & 68 /* StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; @@ -47962,7 +48220,7 @@ var ts; } // Now that we've removed all the StringLike types, if no constituents remain, then the entire // arrayOrStringType was a string. - if (arrayType.flags & 16384 /* Never */) { + if (arrayType.flags & 32768 /* Never */) { return stringType; } } @@ -47993,7 +48251,7 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 34 /* StringLike */) { + if (arrayElementType.flags & 68 /* StringLike */) { return stringType; } return getUnionType([arrayElementType, stringType], 2 /* Subtype */); @@ -48068,11 +48326,11 @@ var ts; } } var asyncMethodType = allowAsyncIterables && getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); - var methodType = asyncMethodType || (allowSyncIterables && getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator"))); + var methodType = asyncMethodType || (allowSyncIterables ? getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")) : undefined); if (isTypeAny(methodType)) { return undefined; } - var signatures = methodType && getSignaturesOfType(methodType, 0 /* Call */); + var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined; if (!ts.some(signatures)) { if (errorNode) { // only report on the first error @@ -48198,14 +48456,14 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return node.kind === 155 /* GetAccessor */ - && ts.getEffectiveSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 156 /* SetAccessor */)) !== undefined; + return node.kind === 156 /* GetAccessor */ + && ts.getEffectiveSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 157 /* SetAccessor */)) !== undefined; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = (ts.getFunctionFlags(func) & 3 /* AsyncGenerator */) === 2 /* Async */ ? getPromisedTypeOfPromise(returnType) // Async function : returnType; // AsyncGenerator function, Generator function, or normal function - return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 2048 /* Void */ | 1 /* Any */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 4096 /* Void */ | 3 /* AnyOrUnknown */); } function checkReturnStatement(node) { // Grammar checking @@ -48221,7 +48479,7 @@ var ts; var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(func); var isGenerator = functionFlags & 1 /* Generator */; - if (strictNullChecks || node.expression || returnType.flags & 16384 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 32768 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; if (isGenerator) { // AsyncGenerator function or Generator function // A generator does not need its return expressions checked against its return type. @@ -48230,12 +48488,12 @@ var ts; // for generators. return; } - else if (func.kind === 156 /* SetAccessor */) { + else if (func.kind === 157 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 154 /* Constructor */) { + else if (func.kind === 155 /* Constructor */) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -48256,7 +48514,7 @@ var ts; } } } - else if (func.kind !== 154 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { + else if (func.kind !== 155 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType) && !isGenerator) { // 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); } @@ -48285,7 +48543,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 === 266 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 267 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -48297,7 +48555,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 265 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 266 /* 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. @@ -48326,10 +48584,11 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 227 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 228 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } + return false; }); } // ensure that label is unique @@ -48389,8 +48648,8 @@ var ts; checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); }); - if (ts.getObjectFlags(type) & 1 /* Class */ && ts.isClassLike(type.symbol.valueDeclaration)) { - var classDeclaration = type.symbol.valueDeclaration; + 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]; // Only process instance properties with computed names here. @@ -48414,7 +48673,7 @@ var ts; errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0]; } } - if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { + if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) { // TODO: GH#18217 error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType)); } function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) { @@ -48431,8 +48690,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 && - (propDeclaration.kind === 199 /* BinaryExpression */ || - ts.getNameOfDeclaration(propDeclaration).kind === 146 /* ComputedPropertyName */ || + (propDeclaration.kind === 200 /* BinaryExpression */ || + ts.getNameOfDeclaration(propDeclaration).kind === 147 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -48459,6 +48718,7 @@ var ts; // The predefined type keywords are reserved and cannot be used as names of user defined types. switch (name.escapedText) { case "any": + case "unknown": case "number": case "boolean": case "string": @@ -48468,6 +48728,15 @@ var ts; error(name, message, name.escapedText); } } + /** + * The name cannot be used as 'Object' of user defined types with special target. + */ + function checkClassNameCollisionWithObject(name) { + if (languageVersion === 1 /* ES5 */ && name.escapedText === "Object" + && moduleKind !== ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.ESNext) { + error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 + } + } /** * Check each type parameter and check that type parameters have no duplicate type parameter declarations */ @@ -48509,8 +48778,8 @@ var ts; if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); - for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { - var declaration = declarations_5[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name); } } @@ -48519,8 +48788,8 @@ var ts; function areTypeParametersIdentical(declarations, targetParameters) { var maxTypeArgumentCount = ts.length(targetParameters); var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters); - for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { - var declaration = declarations_6[_i]; + for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { + var declaration = declarations_7[_i]; // If this declaration has too few or too many type parameters, we report an error var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration); var numTypeParameters = sourceParameters.length; @@ -48580,6 +48849,9 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); + if (!(node.flags & 4194304 /* Ambient */)) { + checkClassNameCollisionWithObject(node.name); + } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); checkExportsOnMergedDeclarations(node); @@ -48619,10 +48891,10 @@ var ts; issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); } checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseConstructorType.flags & 1081344 /* TypeVariable */ && !isMixinConstructorType(staticType)) { + if (baseConstructorType.flags & 2162688 /* TypeVariable */ && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 1081344 /* TypeVariable */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 2162688 /* TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. We can simply compare the type // references (as opposed to checking the structure of the types) because elsewhere we have already checked @@ -48645,7 +48917,7 @@ var ts; checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { var t = getTypeFromTypeNode(typeRefNode); - if (t !== unknownType) { + if (t !== errorType) { if (isValidBaseType(t)) { var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : @@ -48716,7 +48988,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 234 /* ClassDeclaration */ || d.kind === 235 /* InterfaceDeclaration */; + return d.kind === 235 /* ClassDeclaration */ || d.kind === 236 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -48741,7 +49013,7 @@ var ts; if (base.flags & 4194304 /* Prototype */) { continue; } - var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); + var derived = getTargetSymbol(getPropertyOfObjectType(type, base.escapedName)); // TODO: GH#18217 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base); ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { @@ -48755,7 +49027,7 @@ var ts; // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasModifier(derivedClassDecl, 128 /* Abstract */))) { - if (derivedClassDecl.kind === 204 /* ClassExpression */) { + if (derivedClassDecl.kind === 205 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -48770,7 +49042,7 @@ var ts; // either base or derived property is private - not override, skip it continue; } - if (isPrototypeProperty(base) && isPrototypeProperty(derived) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { + if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { // method is overridden with method or property/accessor is overridden with property/accessor - correct case continue; } @@ -48837,7 +49109,7 @@ var ts; var propName = member.name; if (ts.isIdentifier(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 1 /* Any */ || getFalsyFlags(type) & 4096 /* Undefined */)) { + if (!(type.flags & 3 /* AnyOrUnknown */ || getFalsyFlags(type) & 8192 /* Undefined */)) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -48847,7 +49119,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 151 /* PropertyDeclaration */ && + return node.kind === 152 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -48856,7 +49128,7 @@ var ts; var reference = ts.createPropertyAccess(ts.createThis(), propName); reference.flowNode = constructor.returnFlowNode; var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType)); - return !(getFalsyFlags(flowType) & 4096 /* Undefined */); + return !(getFalsyFlags(flowType) & 8192 /* Undefined */); } function checkInterfaceDeclaration(node) { // Grammar checking @@ -48869,7 +49141,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 235 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 236 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -48974,7 +49246,7 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { @@ -48984,7 +49256,7 @@ var ts; } } break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { @@ -49012,18 +49284,22 @@ var ts; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return evaluate(expr.expression); case 71 /* Identifier */: - return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), expr.escapedText); - case 185 /* ElementAccessExpression */: - case 184 /* PropertyAccessExpression */: + var identifier = expr; + if (isInfinityOrNaNString(identifier.escapedText)) { + return +(identifier.escapedText); + } + return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); + case 186 /* ElementAccessExpression */: + case 185 /* 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 === 184 /* PropertyAccessExpression */) { + if (ex.kind === 185 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { @@ -49055,8 +49331,8 @@ var ts; } function isConstantMemberAccess(node) { return node.kind === 71 /* Identifier */ || - node.kind === 184 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 185 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + node.kind === 185 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 186 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && node.argumentExpression.kind === 9 /* StringLiteral */; } function checkEnumDeclaration(node) { @@ -49094,7 +49370,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 !== 237 /* EnumDeclaration */) { + if (declaration.kind !== 238 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -49115,10 +49391,10 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { - var declaration = declarations_7[_i]; - if ((declaration.kind === 234 /* ClassDeclaration */ || - (declaration.kind === 233 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; + if ((declaration.kind === 235 /* ClassDeclaration */ || + (declaration.kind === 234 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !(declaration.flags & 4194304 /* Ambient */)) { return declaration; } @@ -49169,7 +49445,7 @@ var ts; if (symbol.flags & 512 /* ValueModule */ && symbol.declarations.length > 1 && !inAmbientContext - && isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules)) { + && isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules)) { var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (firstNonAmbientClassOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) { @@ -49181,7 +49457,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, 234 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 235 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -49231,23 +49507,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* 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]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 248 /* ExportAssignment */: - case 249 /* ExportDeclaration */: + case 249 /* ExportAssignment */: + case 250 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 242 /* ImportEqualsDeclaration */: - case 243 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 181 /* BindingElement */: - case 231 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 232 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -49258,12 +49534,12 @@ var ts; break; } // falls through - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: - case 233 /* FunctionDeclaration */: - case 235 /* InterfaceDeclaration */: - case 238 /* ModuleDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 234 /* FunctionDeclaration */: + case 236 /* InterfaceDeclaration */: + case 239 /* ModuleDeclaration */: + case 237 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -49286,12 +49562,12 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return node; - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: do { node = node.left; } while (node.kind !== 71 /* Identifier */); return node; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: do { node = node.expression; } while (node.kind !== 71 /* Identifier */); @@ -49300,7 +49576,7 @@ var ts; } function checkExternalImportOrExportDeclaration(node) { var moduleName = ts.getExternalModuleName(node); - if (ts.nodeIsMissing(moduleName)) { + if (!moduleName || ts.nodeIsMissing(moduleName)) { // Should be a parse error. return false; } @@ -49308,9 +49584,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 239 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 273 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 249 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 250 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -49343,14 +49619,14 @@ var ts; (symbol.flags & 67901928 /* Type */ ? 67901928 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 251 /* ExportSpecifier */ ? + var message = node.kind === 252 /* 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 === 251 /* ExportSpecifier */ + && node.kind === 252 /* ExportSpecifier */ && !(target.flags & 67216319 /* Value */) && !(node.flags & 4194304 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); @@ -49377,7 +49653,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 245 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -49401,7 +49677,7 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 253 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 254 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 67216319 /* Value */) { @@ -49437,10 +49713,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 239 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 239 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 240 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 240 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 273 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 274 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -49457,7 +49733,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 273 /* SourceFile */ || node.parent.kind === 239 /* ModuleBlock */ || node.parent.kind === 238 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 274 /* SourceFile */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 239 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -49486,8 +49762,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 273 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 238 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -49558,8 +49834,8 @@ var ts; return; } if (exportedDeclarationsCount > 1) { - for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { - var declaration = declarations_8[_i]; + 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))); } @@ -49575,168 +49851,168 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 233 /* FunctionDeclaration */ && declaration.kind !== 153 /* MethodDeclaration */) || + return (declaration.kind !== 234 /* FunctionDeclaration */ && declaration.kind !== 154 /* MethodDeclaration */) || !!declaration.body; } function checkSourceElement(node) { if (!node) { return; } - if (ts.isInJavaScriptFile(node) && node.jsDoc) { - for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { - var tags = _a[_i].tags; - ts.forEach(tags, checkSourceElement); - } + if (ts.isInJavaScriptFile(node)) { + ts.forEach(node.jsDoc, function (_a) { + var tags = _a.tags; + return ts.forEach(tags, checkSourceElement); + }); } var kind = node.kind; if (cancellationToken) { // 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 238 /* ModuleDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 233 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 234 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return checkTypeParameter(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return checkParameter(node); - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return checkPropertyDeclaration(node); - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 159 /* IndexSignature */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 160 /* IndexSignature */: return checkSignatureDeclaration(node); - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: return checkMethodDeclaration(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return checkConstructorDeclaration(node); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return checkAccessorDeclaration(node); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return checkTypeReferenceNode(node); - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return checkTypePredicate(node); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return checkTypeQuery(node); - case 165 /* TypeLiteral */: + case 166 /* TypeLiteral */: return checkTypeLiteral(node); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return checkArrayType(node); - case 167 /* TupleType */: + case 168 /* TupleType */: return checkTupleType(node); - case 168 /* UnionType */: - case 169 /* IntersectionType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return checkSourceElement(node.type); - case 174 /* TypeOperator */: + case 175 /* TypeOperator */: return checkTypeOperator(node); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return checkConditionalType(node); - case 171 /* InferType */: + case 172 /* InferType */: return checkInferType(node); - case 178 /* ImportType */: + case 179 /* ImportType */: return checkImportType(node); - case 289 /* JSDocAugmentsTag */: + case 290 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: return checkJSDocTypeAliasTag(node); - case 292 /* JSDocParameterTag */: + case 293 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: checkSignatureDeclaration(node); // falls through - case 281 /* JSDocNonNullableType */: - case 280 /* JSDocNullableType */: - case 278 /* JSDocAllType */: - case 279 /* JSDocUnknownType */: - case 286 /* JSDocTypeLiteral */: + case 282 /* JSDocNonNullableType */: + case 281 /* JSDocNullableType */: + case 279 /* JSDocAllType */: + case 280 /* JSDocUnknownType */: + case 287 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 277 /* JSDocTypeExpression */: + case 278 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 176 /* MappedType */: + case 177 /* MappedType */: return checkMappedType(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 212 /* Block */: - case 239 /* ModuleBlock */: + case 213 /* Block */: + case 240 /* ModuleBlock */: return checkBlock(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return checkVariableStatement(node); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return checkExpressionStatement(node); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return checkIfStatement(node); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return checkDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return checkWhileStatement(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return checkForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return checkForInStatement(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return checkForOfStatement(node); - case 222 /* ContinueStatement */: - case 223 /* BreakStatement */: + case 223 /* ContinueStatement */: + case 224 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return checkReturnStatement(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return checkWithStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return checkSwitchStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return checkLabeledStatement(node); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return checkThrowStatement(node); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return checkTryStatement(node); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return checkBindingElement(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return checkClassDeclaration(node); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return checkImportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return checkExportDeclaration(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return checkExportAssignment(node); - case 214 /* EmptyStatement */: - case 230 /* DebuggerStatement */: + case 215 /* EmptyStatement */: + case 231 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 252 /* MissingDeclaration */: + case 253 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -49759,7 +50035,7 @@ var ts; if (!ts.isJSDocTypeExpression(parent)) { error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature); } - var paramTag = parent.parent; + var paramTag = node.parent.parent; if (!ts.isJSDocParameterTag(paramTag)) { error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature); return; @@ -49777,8 +50053,8 @@ var ts; function getTypeFromJSDocVariadicType(node) { var type = getTypeFromTypeNode(node.type); var parent = node.parent; - var paramTag = parent.parent; - if (ts.isJSDocTypeExpression(parent) && ts.isJSDocParameterTag(paramTag)) { + var paramTag = node.parent.parent; + 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) { @@ -49817,20 +50093,20 @@ var ts; } } function checkDeferredNodes() { - for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { - var node = deferredNodes_1[_i]; + for (var _i = 0, _a = deferredNodes; _i < _a.length; _i++) { + var node = _a[_i]; switch (node.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -49845,9 +50121,9 @@ var ts; function unusedIsError(kind) { switch (kind) { case 0 /* Local */: - return compilerOptions.noUnusedLocals; + return !!compilerOptions.noUnusedLocals; case 1 /* Parameter */: - return compilerOptions.noUnusedParameters; + return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); } @@ -49963,13 +50239,13 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -49977,8 +50253,8 @@ var ts; // falls through // 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 - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* 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. @@ -49987,7 +50263,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 67901928 /* Type */); } break; - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -50035,28 +50311,28 @@ var ts; } function isTypeDeclaration(node) { switch (node.kind) { - case 147 /* TypeParameter */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 237 /* EnumDeclaration */: + case 148 /* TypeParameter */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 238 /* EnumDeclaration */: return true; + default: + return false; } } // True if the given identifier is part of a type reference - function isTypeReferenceIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 145 /* QualifiedName */) { + function isTypeReferenceIdentifier(node) { + while (node.parent.kind === 146 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 161 /* TypeReference */; + return node.parent.kind === 162 /* TypeReference */; } - function isHeritageClauseElementIdentifier(entityName) { - var node = entityName; - while (node.parent && node.parent.kind === 184 /* PropertyAccessExpression */) { + function isHeritageClauseElementIdentifier(node) { + while (node.parent.kind === 185 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 206 /* ExpressionWithTypeArguments */; + return node.parent.kind === 207 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -50084,14 +50360,14 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 145 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 146 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 242 /* ImportEqualsDeclaration */) { - return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; + if (nodeOnRightSide.parent.kind === 243 /* ImportEqualsDeclaration */) { + return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 248 /* ExportAssignment */) { - return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; + if (nodeOnRightSide.parent.kind === 249 /* ExportAssignment */) { + return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; } @@ -50116,7 +50392,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 178 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 179 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -50126,7 +50402,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJavaScriptFile(entityName) && - entityName.parent.kind === 184 /* PropertyAccessExpression */ && + entityName.parent.kind === 185 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -50134,7 +50410,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 248 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 249 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 67216319 /* Value */ | 67901928 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -50144,7 +50420,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 242 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 243 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -50162,7 +50438,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 206 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 207 /* ExpressionWithTypeArguments */) { meaning = 67901928 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -50178,10 +50454,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 292 /* JSDocParameterTag */) { + if (entityName.parent.kind === 293 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 147 /* TypeParameter */ && entityName.parent.parent.kind === 295 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 148 /* TypeParameter */ && entityName.parent.parent.kind === 296 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJavaScriptFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -50198,12 +50474,12 @@ var ts; } return resolveEntityName(entityName, 67216319 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 184 /* PropertyAccessExpression */ || entityName.kind === 145 /* QualifiedName */) { + else if (entityName.kind === 185 /* PropertyAccessExpression */ || entityName.kind === 146 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 184 /* PropertyAccessExpression */) { + if (entityName.kind === 185 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -50213,41 +50489,43 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 161 /* TypeReference */ ? 67901928 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 162 /* TypeReference */ ? 67901928 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 261 /* JsxAttribute */) { + else if (entityName.parent.kind === 262 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 160 /* TypePredicate */) { + if (entityName.parent.kind === 161 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } + var parent = node.parent; + var grandParent = parent.parent; if (node.flags & 8388608 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } if (isDeclarationNameOrImportPropertyName(node)) { // This is a declaration, call getSymbolOfNode - return getSymbolOfNode(node.parent); + return getSymbolOfNode(parent); } else if (ts.isLiteralComputedPropertyDeclarationName(node)) { - return getSymbolOfNode(node.parent.parent); + return getSymbolOfNode(parent.parent); } if (node.kind === 71 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 181 /* BindingElement */ && - node.parent.parent.kind === 179 /* ObjectBindingPattern */ && - node === node.parent.propertyName) { - var typeOfPattern = getTypeOfNode(node.parent.parent); + else if (parent.kind === 182 /* BindingElement */ && + grandParent.kind === 180 /* ObjectBindingPattern */ && + node === parent.propertyName) { + var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.escapedText); if (propertyDeclaration) { return propertyDeclaration; @@ -50256,8 +50534,8 @@ var ts; } switch (node.kind) { case 71 /* Identifier */: - case 184 /* PropertyAccessExpression */: - case 145 /* QualifiedName */: + case 185 /* PropertyAccessExpression */: + case 146 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); case 99 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); @@ -50271,14 +50549,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 173 /* ThisType */: + case 174 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; case 97 /* SuperKeyword */: return checkExpression(node).symbol; case 123 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 154 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 155 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -50289,7 +50567,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 === 243 /* ImportDeclaration */ || node.parent.kind === 249 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 244 /* ImportDeclaration */ || node.parent.kind === 250 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJavaScriptFile(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); @@ -50297,24 +50575,24 @@ var ts; // falls through case 8 /* NumericLiteral */: // index access - var objectType = ts.isElementAccessExpression(node.parent) - ? node.parent.argumentExpression === node ? getTypeOfExpression(node.parent.expression) : undefined - : ts.isLiteralTypeNode(node.parent) && ts.isIndexedAccessTypeNode(node.parent.parent) - ? getTypeFromTypeNode(node.parent.parent.objectType) + var objectType = ts.isElementAccessExpression(parent) + ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined + : ts.isLiteralTypeNode(parent) && ts.isIndexedAccessTypeNode(grandParent) + ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); case 79 /* DefaultKeyword */: case 89 /* FunctionKeyword */: case 36 /* EqualsGreaterThanToken */: return getSymbolOfNode(node.parent); - case 178 /* ImportType */: + case 179 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 270 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 271 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 67216319 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -50328,7 +50606,7 @@ var ts; function getTypeOfNode(node) { if (node.flags & 8388608 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further - return unknownType; + return errorType; } if (ts.isPartOfTypeNode(node)) { var typeFromTypeNode = getTypeFromTypeNode(node); @@ -50375,10 +50653,10 @@ var ts; var symbol = getSymbolAtLocation(node); if (symbol) { var declaredType = getDeclaredTypeOfSymbol(symbol); - return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol); + return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol); } } - return unknownType; + return errorType; } // Gets the type of object literal or array literal of destructuring assignment. // { a } from @@ -50387,32 +50665,32 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 183 /* ObjectLiteralExpression */ || expr.kind === 182 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 184 /* ObjectLiteralExpression */ || expr.kind === 183 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 221 /* ForOfStatement */) { + if (expr.parent.kind === 222 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); - return checkDestructuringAssignment(expr, iteratedType || unknownType); + return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 199 /* BinaryExpression */) { + if (expr.parent.kind === 200 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); - return checkDestructuringAssignment(expr, iteratedType || unknownType); + 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 === 269 /* PropertyAssignment */) { + if (expr.parent.kind === 270 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); - return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || errorType, expr.parent); // TODO: GH#18217 } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 182 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 183 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); - var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || unknownType; - return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || unknownType); + var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || errorType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterables*/ false) || errorType; + return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, expr.parent.elements.indexOf(expr), elementType || errorType); // TODO: GH#18217 } // Gets the property symbol corresponding to the property in destructuring assignment // 'property1' from @@ -50483,11 +50761,11 @@ var ts; return target; } // Emitter support - function isArgumentsLocalBinding(node) { - if (!ts.isGeneratedIdentifier(node)) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function isArgumentsLocalBinding(nodeIn) { + if (!ts.isGeneratedIdentifier(nodeIn)) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -50518,13 +50796,12 @@ var ts; } } function isNameOfModuleOrEnumDeclaration(node) { - var parent = node.parent; - return parent && ts.isModuleOrEnumDeclaration(parent) && node === parent.name; + return ts.isModuleOrEnumDeclaration(node.parent) && node === node.parent.name; } // 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(node, prefixLocals) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedExportContainer(nodeIn, prefixLocals) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { // When resolving the export container for the name of a module or enum // declaration, we need to start resolution at the declaration's container. @@ -50544,7 +50821,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 273 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 274 /* 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. @@ -50558,8 +50835,8 @@ var ts; } // When resolved as an expression identifier, if the given node references an import, return the declaration of // that import. Otherwise, return undefined. - function getReferencedImportDeclaration(node) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedImportDeclaration(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value @@ -50599,7 +50876,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 212 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 213 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -50614,9 +50891,9 @@ var ts; // When resolved as an expression identifier, if the given node references a nested block scoped entity with // a name that either hides an existing name or might hide it when compiled downlevel, // return the declaration of that entity. Otherwise, return undefined. - function getReferencedDeclarationWithCollidingName(node) { - if (!ts.isGeneratedIdentifier(node)) { - node = ts.getParseTreeNode(node, ts.isIdentifier); + function getReferencedDeclarationWithCollidingName(nodeIn) { + if (!ts.isGeneratedIdentifier(nodeIn)) { + var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { var symbol = getReferencedValueSymbol(node); if (symbol && isSymbolOfDeclarationWithCollidingName(symbol)) { @@ -50628,8 +50905,8 @@ var ts; } // Return true if the given node is a declaration of a nested block scoped entity with a name that either hides an // existing name or might hide a name when compiled downlevel - function isDeclarationWithCollidingName(node) { - node = ts.getParseTreeNode(node, ts.isDeclaration); + function isDeclarationWithCollidingName(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); if (node) { var symbol = getSymbolOfNode(node); if (symbol) { @@ -50640,16 +50917,16 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: - case 244 /* ImportClause */: - case 245 /* NamespaceImport */: - case 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 243 /* ImportEqualsDeclaration */: + case 245 /* ImportClause */: + case 246 /* NamespaceImport */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: var exportClause = node.exportClause; - return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 248 /* ExportAssignment */: + return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); + case 249 /* ExportAssignment */: return node.expression && node.expression.kind === 71 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) @@ -50657,9 +50934,9 @@ var ts; } return false; } - function isTopLevelValueImportEqualsWithEntityName(node) { - node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 273 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + function isTopLevelValueImportEqualsWithEntityName(nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); + if (node === undefined || node.parent.kind !== 274 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -50673,11 +50950,11 @@ 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 & 67216319 /* Value */ && + return !!(target.flags & 67216319 /* Value */) && (compilerOptions.preserveConstEnums || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { - return isConstEnumSymbol(s) || s.constEnumOnlyModule; + return isConstEnumSymbol(s) || !!s.constEnumOnlyModule; } function isReferencedAliasDeclaration(node, checkChildren) { if (ts.isAliasSymbolDeclaration(node)) { @@ -50685,14 +50962,14 @@ var ts; if (symbol && getSymbolLinks(symbol).referenced) { return true; } - var target = getSymbolLinks(symbol).target; + var target = getSymbolLinks(symbol).target; // TODO: GH#18217 if (target && ts.getModifierFlags(node) & 1 /* Export */ && target.flags & 67216319 /* Value */) { // An `export import ... =` of a value symbol is always considered referenced return true; } } if (checkChildren) { - return ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); + return !!ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); }); } return false; } @@ -50719,10 +50996,10 @@ var ts; return false; } function isRequiredInitializedParameter(parameter) { - return strictNullChecks && + return !!strictNullChecks && !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && - parameter.initializer && + !!parameter.initializer && !ts.hasModifier(parameter, 92 /* ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { @@ -50732,7 +51009,7 @@ var ts; ts.hasModifier(parameter, 92 /* ParameterPropertyModifier */); } function getNodeCheckFlags(node) { - return getNodeLinks(node).flags; + return getNodeLinks(node).flags || 0; } function getEnumMemberValue(node) { computeEnumMemberValues(node.parent); @@ -50740,15 +51017,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 272 /* EnumMember */: - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: + case 273 /* EnumMember */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 272 /* EnumMember */) { + if (node.kind === 273 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -50761,11 +51038,11 @@ var ts; return undefined; } function isFunctionType(type) { - return type.flags & 65536 /* Object */ && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 131072 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; } - function getTypeReferenceSerializationKind(typeName, location) { + function getTypeReferenceSerializationKind(typeNameIn, location) { // ensure both `typeName` and `location` are parse tree nodes. - typeName = ts.getParseTreeNode(typeName, ts.isEntityName); + var typeName = ts.getParseTreeNode(typeNameIn, ts.isEntityName); if (!typeName) return ts.TypeReferenceSerializationKind.Unknown; if (location) { @@ -50789,31 +51066,31 @@ var ts; } // We might not be able to resolve type symbol so use unknown type in that case (eg error case) if (!typeSymbol) { - return ts.TypeReferenceSerializationKind.ObjectType; - } - var type = getDeclaredTypeOfSymbol(typeSymbol); - if (type === unknownType) { return ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 1 /* Any */) { + var type = getDeclaredTypeOfSymbol(typeSymbol); + if (type === errorType) { + return ts.TypeReferenceSerializationKind.Unknown; + } + else if (type.flags & 3 /* AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 2048 /* Void */ | 12288 /* Nullable */ | 16384 /* Never */)) { + else if (isTypeAssignableToKind(type, 4096 /* Void */ | 24576 /* Nullable */ | 32768 /* Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 136 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 272 /* BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 84 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 168 /* NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 34 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 68 /* StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 1536 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 3072 /* ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -50826,8 +51103,8 @@ var ts; return ts.TypeReferenceSerializationKind.ObjectType; } } - function createTypeOfDeclaration(declaration, enclosingDeclaration, flags, tracker, addUndefined) { - declaration = ts.getParseTreeNode(declaration, ts.isVariableLikeOrAccessor); + function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { + var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { return ts.createToken(119 /* AnyKeyword */); } @@ -50835,8 +51112,8 @@ var ts; var symbol = getSymbolOfNode(declaration); var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) - : unknownType; - if (type.flags & 1024 /* UniqueESSymbol */ && + : errorType; + if (type.flags & 2048 /* UniqueESSymbol */ && type.symbol === symbol) { flags |= 1048576 /* AllowUniqueESSymbolType */; } @@ -50845,16 +51122,16 @@ var ts; } return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); } - function createReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, tracker) { - signatureDeclaration = ts.getParseTreeNode(signatureDeclaration, ts.isFunctionLike); + function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { + var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { return ts.createToken(119 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); } - function createTypeOfExpression(expr, enclosingDeclaration, flags, tracker) { - expr = ts.getParseTreeNode(expr, ts.isExpression); + function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { + var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { return ts.createToken(119 /* AnyKeyword */); } @@ -50880,9 +51157,9 @@ var ts; } return resolveName(location, reference.escapedText, 67216319 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } - function getReferencedValueDeclaration(reference) { - if (!ts.isGeneratedIdentifier(reference)) { - reference = ts.getParseTreeNode(reference, ts.isIdentifier); + function getReferencedValueDeclaration(referenceIn) { + if (!ts.isGeneratedIdentifier(referenceIn)) { + var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier); if (reference) { var symbol = getReferencedValueSymbol(reference); if (symbol) { @@ -50895,7 +51172,7 @@ var ts; function isLiteralConstDeclaration(node) { if (ts.isConst(node)) { var type = getTypeOfSymbol(getSymbolOfNode(node)); - return !!(type.flags & 96 /* StringOrNumberLiteral */ && type.flags & 8388608 /* FreshLiteral */); + return !!(type.flags & 192 /* StringOrNumberLiteral */ && type.flags & 33554432 /* FreshLiteral */); } return false; } @@ -50940,7 +51217,7 @@ var ts; }, getNodeCheckFlags: function (node) { node = ts.getParseTreeNode(node); - return node ? getNodeCheckFlags(node) : undefined; + return node ? getNodeCheckFlags(node) : 0; }, isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, @@ -50953,8 +51230,8 @@ var ts; createLiteralConstValue: createLiteralConstValue, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, - getConstantValue: function (node) { - node = ts.getParseTreeNode(node, canHaveConstantValue); + getConstantValue: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue); return node ? getConstantValue(node) : undefined; }, collectLinkedAliases: collectLinkedAliases, @@ -50967,20 +51244,20 @@ var ts; getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName, getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol, isLiteralConstDeclaration: isLiteralConstDeclaration, - isLateBound: function (node) { - node = ts.getParseTreeNode(node, ts.isDeclaration); + isLateBound: function (nodeIn) { + var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); return !!(symbol && ts.getCheckFlags(symbol) & 1024 /* Late */); }, getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { - accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); - var otherKind = accessor.kind === 156 /* SetAccessor */ ? 155 /* GetAccessor */ : 156 /* SetAccessor */; + accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 + var otherKind = accessor.kind === 157 /* SetAccessor */ ? 156 /* GetAccessor */ : 157 /* 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 === 156 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 155 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 157 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 156 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -50990,7 +51267,7 @@ var ts; } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 206 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 267 /* HeritageClause */; + return node.parent && node.parent.kind === 207 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 268 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -51002,7 +51279,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 = 67901928 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 184 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 71 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 185 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 67216319 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -51053,7 +51330,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 273 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 274 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -51068,12 +51345,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 238 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); - var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); + var specifier = declaration.kind === 239 /* 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, 273 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 274 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -51104,7 +51381,7 @@ var ts; }); } } - // We do global augmentations seperately from module augmentations (and before creating global types) because they + // We do global augmentations separately from module augmentations (and before creating global types) because they // 1. Affect global types. We won't have the correct global types until global augmentations are merged. Also, // 2. Module augmentation instantiation requires creating the type of a module, which, in turn, can require // checking for an export or property on the module (if export=) which, in turn, can fall back to the @@ -51127,7 +51404,7 @@ var ts; addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); - getSymbolLinks(unknownSymbol).type = unknownType; + getSymbolLinks(unknownSymbol).type = errorType; // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); @@ -51199,7 +51476,7 @@ var ts; case 16384 /* AsyncValues */: return "__asyncValues"; case 32768 /* ExportStar */: return "__exportStar"; case 65536 /* MakeTemplateObject */: return "__makeTemplateObject"; - default: ts.Debug.fail("Unrecognized helper"); + default: return ts.Debug.fail("Unrecognized helper"); } } function resolveHelpersModule(node, errorNode) { @@ -51217,14 +51494,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 153 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 154 /* 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 === 155 /* GetAccessor */ || node.kind === 156 /* SetAccessor */) { + else if (node.kind === 156 /* GetAccessor */ || node.kind === 157 /* 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); @@ -51242,16 +51519,16 @@ var ts; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (modifier.kind !== 132 /* ReadonlyKeyword */) { - if (node.kind === 150 /* PropertySignature */ || node.kind === 152 /* MethodSignature */) { + if (node.kind === 151 /* PropertySignature */ || node.kind === 153 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 159 /* IndexSignature */) { + if (node.kind === 160 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { case 76 /* ConstKeyword */: - if (node.kind !== 237 /* EnumDeclaration */ && node.parent.kind === 234 /* ClassDeclaration */) { + if (node.kind !== 238 /* EnumDeclaration */ && node.parent.kind === 235 /* ClassDeclaration */) { return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); } break; @@ -51271,7 +51548,7 @@ 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 === 239 /* ModuleBlock */ || node.parent.kind === 273 /* SourceFile */) { + else if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { @@ -51294,10 +51571,10 @@ 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 === 239 /* ModuleBlock */ || node.parent.kind === 273 /* SourceFile */) { + else if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 148 /* Parameter */) { + else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -51310,7 +51587,7 @@ var ts; if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 151 /* PropertyDeclaration */ && node.kind !== 150 /* PropertySignature */ && node.kind !== 159 /* IndexSignature */ && node.kind !== 148 /* Parameter */) { + else if (node.kind !== 152 /* PropertyDeclaration */ && node.kind !== 151 /* PropertySignature */ && node.kind !== 160 /* IndexSignature */ && node.kind !== 149 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report 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); } @@ -51330,17 +51607,17 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 148 /* Parameter */) { + else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; case 79 /* DefaultKeyword */: - var container = node.parent.kind === 273 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 238 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 274 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 239 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; @@ -51352,13 +51629,13 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 148 /* Parameter */) { + else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 239 /* ModuleBlock */) { + else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 240 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; @@ -51368,14 +51645,14 @@ var ts; if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 234 /* ClassDeclaration */) { - if (node.kind !== 153 /* MethodDeclaration */ && - node.kind !== 151 /* PropertyDeclaration */ && - node.kind !== 155 /* GetAccessor */ && - node.kind !== 156 /* SetAccessor */) { + if (node.kind !== 235 /* ClassDeclaration */) { + if (node.kind !== 154 /* MethodDeclaration */ && + node.kind !== 152 /* PropertyDeclaration */ && + node.kind !== 156 /* GetAccessor */ && + node.kind !== 157 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 234 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 235 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -51394,7 +51671,7 @@ var ts; else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 148 /* Parameter */) { + else if (node.kind === 149 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -51402,12 +51679,12 @@ var ts; break; } } - if (node.kind === 154 /* Constructor */) { + if (node.kind === 155 /* 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"); + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217 } else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); @@ -51415,20 +51692,21 @@ var ts; else if (flags & 64 /* Readonly */) { return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly"); } - return; + return false; } - else if ((node.kind === 243 /* ImportDeclaration */ || node.kind === 242 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 244 /* ImportDeclaration */ || node.kind === 243 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 148 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 149 /* Parameter */ && (flags & 92 /* 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 === 148 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 149 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { return checkGrammarAsyncModifier(node, lastAsync); } + return false; } /** * true | false: Early return this value from checkGrammarModifiers. @@ -51443,37 +51721,37 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 154 /* Constructor */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 159 /* IndexSignature */: - case 238 /* ModuleDeclaration */: - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 249 /* ExportDeclaration */: - case 248 /* ExportAssignment */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 148 /* Parameter */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 155 /* Constructor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 160 /* IndexSignature */: + case 239 /* ModuleDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 250 /* ExportDeclaration */: + case 249 /* ExportAssignment */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 149 /* Parameter */: return false; default: - if (node.parent.kind === 239 /* ModuleBlock */ || node.parent.kind === 273 /* SourceFile */) { + if (node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { return false; } switch (node.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); - case 235 /* InterfaceDeclaration */: - case 213 /* VariableStatement */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 214 /* VariableStatement */: + case 237 /* TypeAliasDeclaration */: return true; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); default: ts.Debug.fail(); @@ -51486,10 +51764,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 153 /* MethodDeclaration */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -51499,6 +51777,7 @@ var ts; if (list && list.hasTrailingComma) { return grammarErrorAtPos(list[0], list.end - ",".length, ",".length, diag); } + return false; } function checkGrammarTypeParameterList(typeParameters, file) { if (typeParameters && typeParameters.length === 0) { @@ -51506,6 +51785,7 @@ var ts; var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length; return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty); } + return false; } function checkGrammarParameterList(parameters) { var seenOptionalParameter = false; @@ -51586,10 +51866,10 @@ var ts; } if (parameter.type.kind !== 137 /* StringKeyword */ && parameter.type.kind !== 134 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); - if (type.flags & 2 /* String */ || type.flags & 4 /* Number */) { + 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(getTypeFromTypeNode(node.type))); } - if (type.flags & 131072 /* Union */ && allTypesAssignableToKind(type, 32 /* StringLiteral */, /*strict*/ true)) { + if (type.flags & 262144 /* Union */ && allTypesAssignableToKind(type, 64 /* StringLiteral */, /*strict*/ true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); @@ -51597,6 +51877,7 @@ var ts; if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); } + return false; } function checkGrammarIndexSignature(node) { // Prevent cascading error by short-circuit @@ -51609,6 +51890,7 @@ var ts; var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length; return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty); } + return false; } function checkGrammarTypeArguments(node, typeArguments) { return checkGrammarForDisallowedTrailingComma(typeArguments) || @@ -51618,11 +51900,12 @@ var ts; if (args) { for (var _i = 0, args_5 = args; _i < args_5.length; _i++) { var arg = args_5[_i]; - if (arg.kind === 205 /* OmittedExpression */) { + if (arg.kind === 206 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } + return false; } function checkGrammarArguments(args) { return checkGrammarForOmittedArgument(args); @@ -51636,7 +51919,7 @@ var ts; var listType = ts.tokenToString(node.token); return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType); } - return ts.forEach(types, checkGrammarExpressionWithTypeArguments); + return ts.some(types, checkGrammarExpressionWithTypeArguments); } function checkGrammarExpressionWithTypeArguments(node) { return checkGrammarTypeArguments(node, node.typeArguments); @@ -51694,19 +51977,20 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 146 /* ComputedPropertyName */) { + if (node.kind !== 147 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 199 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* CommaToken */) { + if (computedPropertyName.expression.kind === 200 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* 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 === 233 /* FunctionDeclaration */ || - node.kind === 191 /* FunctionExpression */ || - node.kind === 153 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 234 /* FunctionDeclaration */ || + node.kind === 192 /* FunctionExpression */ || + node.kind === 154 /* MethodDeclaration */); if (node.flags & 4194304 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -51716,9 +52000,7 @@ var ts; } } function checkGrammarForInvalidQuestionMark(questionToken, message) { - if (questionToken) { - return grammarErrorOnNode(questionToken, message); - } + return !!questionToken && grammarErrorOnNode(questionToken, message); } function checkGrammarObjectLiteralExpression(node, inDestructuring) { var Flags; @@ -51731,24 +52013,24 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 271 /* SpreadAssignment */) { + if (prop.kind === 272 /* SpreadAssignment */) { continue; } var name = prop.name; - if (name.kind === 146 /* ComputedPropertyName */) { + if (name.kind === 147 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 270 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 271 /* 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.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { - for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { + for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 120 /* AsyncKeyword */ || prop.kind !== 153 /* MethodDeclaration */) { + if (mod.kind !== 120 /* AsyncKeyword */ || prop.kind !== 154 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -51763,25 +52045,25 @@ 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 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { checkGrammarNumericLiteral(name); } // falls through - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: currentKind = 1 /* Property */; break; - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: currentKind = 2 /* GetAccessor */; break; - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: currentKind = 4 /* SetAccessor */; break; default: - ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); + throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); } var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { @@ -51814,7 +52096,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 263 /* JsxSpreadAttribute */) { + if (attr.kind === 264 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -51824,7 +52106,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 264 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 265 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -51833,12 +52115,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 221 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (forInOrOfStatement.kind === 222 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); } } - if (forInOrOfStatement.initializer.kind === 232 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 233 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -51853,20 +52135,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 220 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 221 /* 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 === 220 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 221 /* 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 === 220 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 221 /* 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); @@ -51893,11 +52175,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 155 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 156 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 156 /* SetAccessor */) { + else if (kind === 157 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -51914,16 +52196,17 @@ var ts; } } } + return false; } /** Does the accessor have the right number of parameters? * A get accessor has no parameters or a single `this` parameter. * 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 === 155 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 156 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 155 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 156 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -51934,7 +52217,7 @@ var ts; } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: var decl = parent; if (decl.name.kind !== 71 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); @@ -51946,13 +52229,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(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 150 /* PropertySignature */: + case 151 /* PropertySignature */: if (!ts.hasModifier(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); } @@ -51971,8 +52254,8 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 153 /* MethodDeclaration */) { - if (node.parent.kind === 183 /* ObjectLiteralExpression */) { + if (node.kind === 154 /* MethodDeclaration */) { + if (node.parent.kind === 184 /* 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 === 120 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); @@ -51997,14 +52280,14 @@ var ts; if (node.flags & 4194304 /* 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 === 153 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 154 /* 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 === 235 /* InterfaceDeclaration */) { + else if (node.parent.kind === 236 /* 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 === 165 /* TypeLiteral */) { + else if (node.parent.kind === 166 /* 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); } } @@ -52015,11 +52298,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 227 /* LabeledStatement */: + case 228 /* 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 === 222 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 223 /* 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); @@ -52027,8 +52310,8 @@ var ts; return false; } break; - case 226 /* SwitchStatement */: - if (node.kind === 223 /* BreakStatement */ && !node.label) { + case 227 /* SwitchStatement */: + if (node.kind === 224 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -52043,13 +52326,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 223 /* BreakStatement */ + var message = node.kind === 224 /* 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 === 223 /* BreakStatement */ + var message = node.kind === 224 /* 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); @@ -52062,7 +52345,7 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); - if (node.name.kind === 180 /* ArrayBindingPattern */ || node.name.kind === 179 /* ObjectBindingPattern */) { + if (node.name.kind === 181 /* ArrayBindingPattern */ || node.name.kind === 180 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.propertyName) { @@ -52076,11 +52359,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 197 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && + expr.kind === 198 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 220 /* ForInStatement */ && node.parent.parent.kind !== 221 /* ForOfStatement */) { + if (node.parent.parent.kind !== 221 /* ForInStatement */ && node.parent.parent.kind !== 222 /* ForOfStatement */) { if (node.flags & 4194304 /* Ambient */) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -52109,7 +52392,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 213 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 214 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && @@ -52140,6 +52423,7 @@ var ts; } } } + return false; } function checkGrammarNameInLetOrConstDeclarations(name) { if (name.kind === 71 /* Identifier */) { @@ -52156,6 +52440,7 @@ var ts; } } } + return false; } function checkGrammarVariableDeclarationList(declarationList) { var declarations = declarationList.declarations; @@ -52165,18 +52450,19 @@ var ts; if (!declarationList.declarations.length) { return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty); } + return false; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 216 /* IfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 225 /* WithStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 217 /* IfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 226 /* WithStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: return false; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -52216,6 +52502,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2)); return true; } + return false; } function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile); @@ -52223,6 +52510,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2)); return true; } + return false; } function grammarErrorOnNode(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); @@ -52230,11 +52518,12 @@ var ts; diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2)); return true; } + return false; } function checkGrammarConstructorTypeParameters(node) { - var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - if (ts.isNodeArray(typeParameters)) { - var pos = typeParameters.pos, end = typeParameters.end; + var jsdocTypeParameters = ts.isInJavaScriptFile(node) && ts.getJSDocTypeParameterDeclarations(node); + if (node.typeParameters || jsdocTypeParameters && jsdocTypeParameters.length) { + var _a = node.typeParameters || jsdocTypeParameters && jsdocTypeParameters[0] || node, pos = _a.pos, end = _a.end; return grammarErrorAtPos(node, pos, end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); } } @@ -52250,7 +52539,7 @@ var ts; return true; } } - else if (node.parent.kind === 235 /* InterfaceDeclaration */) { + else if (node.parent.kind === 236 /* 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; } @@ -52258,7 +52547,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 165 /* TypeLiteral */) { + else if (node.parent.kind === 166 /* 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; } @@ -52287,13 +52576,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 235 /* InterfaceDeclaration */ || - node.kind === 236 /* TypeAliasDeclaration */ || - node.kind === 243 /* ImportDeclaration */ || - node.kind === 242 /* ImportEqualsDeclaration */ || - node.kind === 249 /* ExportDeclaration */ || - node.kind === 248 /* ExportAssignment */ || - node.kind === 241 /* NamespaceExportDeclaration */ || + if (node.kind === 236 /* InterfaceDeclaration */ || + node.kind === 237 /* TypeAliasDeclaration */ || + node.kind === 244 /* ImportDeclaration */ || + node.kind === 243 /* ImportEqualsDeclaration */ || + node.kind === 250 /* ExportDeclaration */ || + node.kind === 249 /* ExportAssignment */ || + node.kind === 242 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -52302,12 +52591,13 @@ 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 === 213 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 214 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } } } + return false; } function checkGrammarSourceFile(node) { return !!(node.flags & 4194304 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); @@ -52328,7 +52618,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 === 212 /* Block */ || node.parent.kind === 239 /* ModuleBlock */ || node.parent.kind === 273 /* SourceFile */) { + if (node.parent.kind === 213 /* Block */ || node.parent.kind === 240 /* ModuleBlock */ || node.parent.kind === 274 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -52341,6 +52631,7 @@ var ts; // Debug.assert(isStatement(node.parent)); } } + return false; } function checkGrammarNumericLiteral(node) { // Grammar checking @@ -52349,10 +52640,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, 177 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 178 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 272 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 273 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { @@ -52361,6 +52652,7 @@ var ts; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + return false; } function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) { var sourceFile = ts.getSourceFileOfNode(node); @@ -52369,6 +52661,7 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), /*length*/ 0, message, arg0, arg1, arg2)); return true; } + return false; } function getAmbientModules() { if (!ambientModulesCache) { @@ -52398,14 +52691,15 @@ var ts; if (ts.isSpreadElement(nodeArguments[0])) { return grammarErrorOnNode(nodeArguments[0], ts.Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element); } + return false; } } ts.createTypeChecker = createTypeChecker; /** 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 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -52413,14 +52707,14 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 244 /* ImportClause */: // For default import - case 242 /* ImportEqualsDeclaration */: - case 245 /* NamespaceImport */: - case 247 /* ImportSpecifier */: // For rename import `x as y` + case 245 /* ImportClause */: // For default import + case 243 /* ImportEqualsDeclaration */: + case 246 /* NamespaceImport */: + case 248 /* ImportSpecifier */: // For rename import `x as y` return true; case 71 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 247 /* ImportSpecifier */; + return decl.parent.kind === 248 /* ImportSpecifier */; default: return false; } @@ -52482,7 +52776,7 @@ var ts; // the original node. We also need to exclude specific properties and only include own- // properties (to skip members already defined on the shared prototype). if (node === undefined) { - return undefined; + return node; } var clone = createSynthesizedNode(node.kind); clone.flags |= node.flags; @@ -52587,7 +52881,6 @@ var ts; return name; } ts.createUniqueName = createUniqueName; - /** Create a unique name based on the supplied text. */ function createOptimisticUniqueName(text) { var name = createIdentifier(text); name.autoGenerateFlags = 3 /* Unique */ | 16 /* Optimistic */; @@ -52683,7 +52976,7 @@ var ts; ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(145 /* QualifiedName */); + var node = createSynthesizedNode(146 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -52698,12 +52991,12 @@ var ts; ts.updateQualifiedName = updateQualifiedName; function parenthesizeForComputedName(expression) { return (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 26 /* CommaToken */) || - expression.kind === 301 /* CommaListExpression */ ? + expression.kind === 302 /* CommaListExpression */ ? createParen(expression) : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(146 /* ComputedPropertyName */); + var node = createSynthesizedNode(147 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -52716,7 +53009,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(147 /* TypeParameter */); + var node = createSynthesizedNode(148 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -52732,7 +53025,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(148 /* Parameter */); + var node = createSynthesizedNode(149 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -52756,7 +53049,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(149 /* Decorator */); + var node = createSynthesizedNode(150 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -52769,7 +53062,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(150 /* PropertySignature */); + var node = createSynthesizedNode(151 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -52789,7 +53082,7 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(151 /* PropertyDeclaration */); + var node = createSynthesizedNode(152 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -52813,7 +53106,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(152 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(153 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -52830,7 +53123,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(153 /* MethodDeclaration */); + var node = createSynthesizedNode(154 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -52858,7 +53151,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(154 /* Constructor */); + var node = createSynthesizedNode(155 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -52878,7 +53171,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(155 /* GetAccessor */); + var node = createSynthesizedNode(156 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -52901,7 +53194,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(156 /* SetAccessor */); + var node = createSynthesizedNode(157 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -52922,7 +53215,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(157 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(158 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -52930,7 +53223,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(158 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(159 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -52938,7 +53231,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(159 /* IndexSignature */); + var node = createSynthesizedNode(160 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -52978,7 +53271,7 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(160 /* TypePredicate */); + var node = createSynthesizedNode(161 /* TypePredicate */); node.parameterName = asName(parameterName); node.type = type; return node; @@ -52992,7 +53285,7 @@ var ts; } ts.updateTypePredicateNode = updateTypePredicateNode; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(161 /* TypeReference */); + var node = createSynthesizedNode(162 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -53006,7 +53299,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(163 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -53014,7 +53307,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(163 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(164 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -53022,7 +53315,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(164 /* TypeQuery */); + var node = createSynthesizedNode(165 /* TypeQuery */); node.exprName = exprName; return node; } @@ -53034,7 +53327,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(165 /* TypeLiteral */); + var node = createSynthesizedNode(166 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -53046,7 +53339,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(166 /* ArrayType */); + var node = createSynthesizedNode(167 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -53058,7 +53351,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(167 /* TupleType */); + var node = createSynthesizedNode(168 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -53070,7 +53363,7 @@ var ts; } ts.updateTypleTypeNode = updateTypleTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(168 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(169 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -53078,7 +53371,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(169 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(170 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -53097,7 +53390,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(170 /* ConditionalType */); + var node = createSynthesizedNode(171 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -53115,7 +53408,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(171 /* InferType */); + var node = createSynthesizedNode(172 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -53127,7 +53420,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(178 /* ImportType */); + var node = createSynthesizedNode(179 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = asNodeArray(typeArguments); @@ -53145,7 +53438,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(172 /* ParenthesizedType */); + var node = createSynthesizedNode(173 /* ParenthesizedType */); node.type = type; return node; } @@ -53157,11 +53450,11 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(173 /* ThisType */); + return createSynthesizedNode(174 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(174 /* TypeOperator */); + var node = createSynthesizedNode(175 /* TypeOperator */); node.operator = typeof operatorOrType === "number" ? operatorOrType : 128 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; @@ -53172,7 +53465,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(175 /* IndexedAccessType */); + var node = createSynthesizedNode(176 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -53186,7 +53479,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(176 /* MappedType */); + var node = createSynthesizedNode(177 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -53204,7 +53497,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(177 /* LiteralType */); + var node = createSynthesizedNode(178 /* LiteralType */); node.literal = literal; return node; } @@ -53217,7 +53510,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(179 /* ObjectBindingPattern */); + var node = createSynthesizedNode(180 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -53229,7 +53522,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(180 /* ArrayBindingPattern */); + var node = createSynthesizedNode(181 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -53241,7 +53534,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(181 /* BindingElement */); + var node = createSynthesizedNode(182 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -53260,7 +53553,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(182 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(183 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -53274,7 +53567,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(183 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(184 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -53288,9 +53581,9 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(184 /* PropertyAccessExpression */); + var node = createSynthesizedNode(185 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); - node.name = asName(name); + node.name = asName(name); // TODO: GH#18217 setEmitFlags(node, 131072 /* NoIndentation */); return node; } @@ -53305,7 +53598,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(185 /* ElementAccessExpression */); + var node = createSynthesizedNode(186 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -53319,7 +53612,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(186 /* CallExpression */); + var node = createSynthesizedNode(187 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -53335,7 +53628,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(187 /* NewExpression */); + var node = createSynthesizedNode(188 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -53351,7 +53644,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(188 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(189 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -53374,7 +53667,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(189 /* TypeAssertionExpression */); + var node = createSynthesizedNode(190 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -53388,7 +53681,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(190 /* ParenthesizedExpression */); + var node = createSynthesizedNode(191 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -53400,7 +53693,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(191 /* FunctionExpression */); + var node = createSynthesizedNode(192 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -53424,7 +53717,7 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(192 /* ArrowFunction */); + var node = createSynthesizedNode(193 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); @@ -53458,7 +53751,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(193 /* DeleteExpression */); + var node = createSynthesizedNode(194 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53470,7 +53763,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(194 /* TypeOfExpression */); + var node = createSynthesizedNode(195 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53482,7 +53775,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(195 /* VoidExpression */); + var node = createSynthesizedNode(196 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53494,7 +53787,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(196 /* AwaitExpression */); + var node = createSynthesizedNode(197 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53506,7 +53799,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(197 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(198 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -53519,7 +53812,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(198 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(199 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -53532,7 +53825,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(199 /* BinaryExpression */); + var node = createSynthesizedNode(200 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -53549,7 +53842,7 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(200 /* ConditionalExpression */); + var node = createSynthesizedNode(201 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); @@ -53579,7 +53872,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(201 /* TemplateExpression */); + var node = createSynthesizedNode(202 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -53617,7 +53910,7 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(202 /* YieldExpression */); + var node = createSynthesizedNode(203 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; @@ -53631,7 +53924,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(203 /* SpreadElement */); + var node = createSynthesizedNode(204 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -53643,7 +53936,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(204 /* ClassExpression */); + var node = createSynthesizedNode(205 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -53664,11 +53957,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(205 /* OmittedExpression */); + return createSynthesizedNode(206 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(206 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(207 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -53682,7 +53975,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(207 /* AsExpression */); + var node = createSynthesizedNode(208 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -53696,7 +53989,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(208 /* NonNullExpression */); + var node = createSynthesizedNode(209 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -53708,7 +54001,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(209 /* MetaProperty */); + var node = createSynthesizedNode(210 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -53722,7 +54015,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(210 /* TemplateSpan */); + var node = createSynthesizedNode(211 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -53736,12 +54029,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(211 /* SemicolonClassElement */); + return createSynthesizedNode(212 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(212 /* Block */); + var block = createSynthesizedNode(213 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -53750,7 +54043,7 @@ var ts; ts.createBlock = createBlock; /* @internal */ function createExpressionStatement(expression) { - var node = createSynthesizedNode(215 /* ExpressionStatement */); + var node = createSynthesizedNode(216 /* ExpressionStatement */); node.expression = expression; return node; } @@ -53762,7 +54055,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(213 /* VariableStatement */); + var node = createSynthesizedNode(214 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -53777,7 +54070,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(214 /* EmptyStatement */); + return createSynthesizedNode(215 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression) { @@ -53791,7 +54084,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(216 /* IfStatement */); + var node = createSynthesizedNode(217 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -53807,7 +54100,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(217 /* DoStatement */); + var node = createSynthesizedNode(218 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -53821,7 +54114,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(218 /* WhileStatement */); + var node = createSynthesizedNode(219 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -53835,7 +54128,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(219 /* ForStatement */); + var node = createSynthesizedNode(220 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -53853,7 +54146,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(220 /* ForInStatement */); + var node = createSynthesizedNode(221 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -53869,7 +54162,7 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(221 /* ForOfStatement */); + var node = createSynthesizedNode(222 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; @@ -53887,7 +54180,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(222 /* ContinueStatement */); + var node = createSynthesizedNode(223 /* ContinueStatement */); node.label = asName(label); return node; } @@ -53899,7 +54192,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(223 /* BreakStatement */); + var node = createSynthesizedNode(224 /* BreakStatement */); node.label = asName(label); return node; } @@ -53911,7 +54204,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(224 /* ReturnStatement */); + var node = createSynthesizedNode(225 /* ReturnStatement */); node.expression = expression; return node; } @@ -53923,7 +54216,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(225 /* WithStatement */); + var node = createSynthesizedNode(226 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -53937,7 +54230,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(226 /* SwitchStatement */); + var node = createSynthesizedNode(227 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -53951,7 +54244,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(227 /* LabeledStatement */); + var node = createSynthesizedNode(228 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -53965,7 +54258,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(228 /* ThrowStatement */); + var node = createSynthesizedNode(229 /* ThrowStatement */); node.expression = expression; return node; } @@ -53977,7 +54270,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(229 /* TryStatement */); + var node = createSynthesizedNode(230 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -53993,11 +54286,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(230 /* DebuggerStatement */); + return createSynthesizedNode(231 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(231 /* VariableDeclaration */); + var node = createSynthesizedNode(232 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -54013,7 +54306,8 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { - var node = createSynthesizedNode(232 /* VariableDeclarationList */); + if (flags === void 0) { flags = 0 /* None */; } + var node = createSynthesizedNode(233 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -54026,7 +54320,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(233 /* FunctionDeclaration */); + var node = createSynthesizedNode(234 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -54052,7 +54346,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(234 /* ClassDeclaration */); + var node = createSynthesizedNode(235 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54074,7 +54368,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(235 /* InterfaceDeclaration */); + var node = createSynthesizedNode(236 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54096,7 +54390,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(236 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(237 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54116,7 +54410,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(237 /* EnumDeclaration */); + var node = createSynthesizedNode(238 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54134,7 +54428,8 @@ var ts; } ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { - var node = createSynthesizedNode(238 /* ModuleDeclaration */); + if (flags === void 0) { flags = 0 /* None */; } + var node = createSynthesizedNode(239 /* ModuleDeclaration */); node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -54153,7 +54448,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(239 /* ModuleBlock */); + var node = createSynthesizedNode(240 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -54165,7 +54460,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(240 /* CaseBlock */); + var node = createSynthesizedNode(241 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -54177,7 +54472,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(241 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(242 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -54189,7 +54484,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(242 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(243 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54207,7 +54502,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(243 /* ImportDeclaration */); + var node = createSynthesizedNode(244 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -54225,7 +54520,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(244 /* ImportClause */); + var node = createSynthesizedNode(245 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -54239,7 +54534,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(245 /* NamespaceImport */); + var node = createSynthesizedNode(246 /* NamespaceImport */); node.name = name; return node; } @@ -54251,7 +54546,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(246 /* NamedImports */); + var node = createSynthesizedNode(247 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -54263,7 +54558,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(247 /* ImportSpecifier */); + var node = createSynthesizedNode(248 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -54277,7 +54572,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(248 /* ExportAssignment */); + var node = createSynthesizedNode(249 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -54294,7 +54589,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(249 /* ExportDeclaration */); + var node = createSynthesizedNode(250 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -54312,7 +54607,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(250 /* NamedExports */); + var node = createSynthesizedNode(251 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -54324,7 +54619,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(251 /* ExportSpecifier */); + var node = createSynthesizedNode(252 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -54339,7 +54634,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(253 /* ExternalModuleReference */); + var node = createSynthesizedNode(254 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -54352,7 +54647,7 @@ var ts; ts.updateExternalModuleReference = updateExternalModuleReference; // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(254 /* JsxElement */); + var node = createSynthesizedNode(255 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -54368,7 +54663,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(255 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(256 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -54384,7 +54679,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(256 /* JsxOpeningElement */); + var node = createSynthesizedNode(257 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = typeArguments && createNodeArray(typeArguments); node.attributes = attributes; @@ -54400,7 +54695,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(257 /* JsxClosingElement */); + var node = createSynthesizedNode(258 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -54412,7 +54707,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(258 /* JsxFragment */); + var node = createSynthesizedNode(259 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -54428,7 +54723,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(261 /* JsxAttribute */); + var node = createSynthesizedNode(262 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -54442,7 +54737,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(262 /* JsxAttributes */); + var node = createSynthesizedNode(263 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -54454,7 +54749,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(263 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(264 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -54466,7 +54761,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(264 /* JsxExpression */); + var node = createSynthesizedNode(265 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -54480,7 +54775,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(265 /* CaseClause */); + var node = createSynthesizedNode(266 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -54494,7 +54789,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(266 /* DefaultClause */); + var node = createSynthesizedNode(267 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -54506,7 +54801,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(267 /* HeritageClause */); + var node = createSynthesizedNode(268 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -54519,7 +54814,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(268 /* CatchClause */); + var node = createSynthesizedNode(269 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -54534,7 +54829,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(269 /* PropertyAssignment */); + var node = createSynthesizedNode(270 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -54549,7 +54844,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(270 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(271 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -54563,8 +54858,8 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(271 /* SpreadAssignment */); - node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; + var node = createSynthesizedNode(272 /* SpreadAssignment */); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; // TODO: GH#18217 return node; } ts.createSpreadAssignment = createSpreadAssignment; @@ -54576,7 +54871,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(272 /* EnumMember */); + var node = createSynthesizedNode(273 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -54596,7 +54891,7 @@ var ts; (referencedFiles !== undefined && node.referencedFiles !== referencedFiles) || (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(273 /* SourceFile */); + var updated = createSynthesizedNode(274 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -54635,6 +54930,8 @@ var ts; updated.parseDiagnostics = node.parseDiagnostics; if (node.bindDiagnostics !== undefined) updated.bindDiagnostics = node.bindDiagnostics; + if (node.bindSuggestionDiagnostics !== undefined) + updated.bindSuggestionDiagnostics = node.bindSuggestionDiagnostics; if (node.lineMap !== undefined) updated.lineMap = node.lineMap; if (node.classifiableNames !== undefined) @@ -54677,7 +54974,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(299 /* NotEmittedStatement */); + var node = createSynthesizedNode(300 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -54689,7 +54986,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(303 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(304 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -54701,7 +54998,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(302 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(303 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -54716,7 +55013,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(300 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(301 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -54732,7 +55029,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 301 /* CommaListExpression */) { + if (node.kind === 302 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { @@ -54742,7 +55039,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(301 /* CommaListExpression */); + var node = createSynthesizedNode(302 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -54755,20 +55052,20 @@ var ts; ts.updateCommaList = updateCommaList; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(274 /* Bundle */); + var node = ts.createNode(275 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; } ts.createBundle = createBundle; function createUnparsedSourceFile(text) { - var node = ts.createNode(275 /* UnparsedSource */); + var node = ts.createNode(276 /* UnparsedSource */); node.text = text; return node; } ts.createUnparsedSourceFile = createUnparsedSourceFile; function createInputFiles(javascript, declaration) { - var node = ts.createNode(276 /* InputFiles */); + var node = ts.createNode(277 /* InputFiles */); node.javascriptText = javascript; node.declarationText = declaration; return node; @@ -54861,6 +55158,7 @@ var ts; return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(/*propertyName*/ undefined, exportName)])); } ts.createExternalModuleExport = createExternalModuleExport; + // Utilities function asName(name) { return ts.isString(name) ? createIdentifier(name) : name; } @@ -54906,7 +55204,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 === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -55391,7 +55689,7 @@ var ts; // Utilities function createForOfBindingStatement(node, boundValue) { if (ts.isVariableDeclarationList(node)) { - var firstDeclaration = ts.firstOrUndefined(node.declarations); + var firstDeclaration = ts.first(node.declarations); var updatedDeclaration = ts.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, /*typeNode*/ undefined, boundValue); return ts.setTextRange(ts.createVariableStatement( @@ -55417,7 +55715,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 227 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 228 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -55435,19 +55733,20 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; } } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { + if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } var callee = skipOuterExpressions(expression, 7 /* All */); var thisArg; var target; @@ -55467,7 +55766,7 @@ var ts; } else { switch (callee.kind) { - case 184 /* PropertyAccessExpression */: { + case 185 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -55480,7 +55779,7 @@ var ts; } break; } - case 185 /* ElementAccessExpression */: { + case 186 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -55537,14 +55836,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 269 /* PropertyAssignment */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); + case 270 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -55558,7 +55857,8 @@ var ts; /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, getAccessor.parameters, - /*type*/ undefined, getAccessor.body); + /*type*/ undefined, getAccessor.body // TODO: GH#18217 + ); ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); @@ -55569,7 +55869,8 @@ var ts; /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, setAccessor.parameters, - /*type*/ undefined, setAccessor.body); + /*type*/ undefined, setAccessor.body // TODO: GH#18217 + ); ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); @@ -55600,7 +55901,8 @@ var ts; return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, /*location*/ method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, /*name*/ undefined, /*typeParameters*/ undefined, method.parameters, - /*type*/ undefined, method.body), + /*type*/ undefined, method.body // TODO: GH#18217 + ), /*location*/ method), /*original*/ method)), /*location*/ method), @@ -55683,6 +55985,7 @@ var ts; } ts.getDeclarationName = getDeclarationName; function getName(node, allowComments, allowSourceMaps, emitFlags) { + if (emitFlags === void 0) { emitFlags = 0; } var nodeName = ts.getNameOfDeclaration(node); if (nodeName && ts.isIdentifier(nodeName) && !ts.isGeneratedIdentifier(nodeName)) { var name = ts.getMutableClone(nodeName); @@ -55726,7 +56029,7 @@ var ts; function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) { var qualifiedName = ts.createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : ts.getSynthesizedClone(name)); ts.setTextRange(qualifiedName, name); - var emitFlags; + var emitFlags = 0; if (!allowSourceMaps) emitFlags |= 48 /* NoSourceMap */; if (!allowComments) @@ -55741,7 +56044,8 @@ var ts; } ts.convertToFunctionBody = convertToFunctionBody; function convertFunctionDeclarationToExpression(node) { - ts.Debug.assert(!!node.body); + if (!node.body) + return ts.Debug.fail(); var updated = ts.createFunctionExpression(node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body); ts.setOriginalNode(updated, node); ts.setTextRange(updated, node); @@ -55801,15 +56105,9 @@ var ts; return statementOffset; } ts.addStandardPrologue = addStandardPrologue; - /** - * Add just the custom prologue-directives into target statement-array. - * The function needs to be called during each transformation step. - * This function needs to be called whenever we transform the statement - * list of a source file, namespace, or function-like body. - */ function addCustomPrologue(target, source, statementOffset, visitor) { var numStatements = source.length; - while (statementOffset < numStatements) { + while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); @@ -55868,7 +56166,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 === 190 /* ParenthesizedExpression */) { + if (skipped.kind === 191 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -55902,8 +56200,8 @@ 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(199 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(199 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(200 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(200 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -55912,7 +56210,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 202 /* YieldExpression */) { + && operand.kind === 203 /* YieldExpression */) { return false; } return true; @@ -56000,7 +56298,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 199 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { + if (node.kind === 200 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -56015,7 +56313,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(200 /* ConditionalExpression */, 55 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(201 /* ConditionalExpression */, 55 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -56029,8 +56327,8 @@ var ts; // so in case when comma expression is introduced as a part of previous transformations // if should be wrapped in parens since comma operator has the lowest precedence var emittedExpression = ts.skipPartiallyEmittedExpressions(e); - return emittedExpression.kind === 199 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ || - emittedExpression.kind === 301 /* CommaListExpression */ + return emittedExpression.kind === 200 /* BinaryExpression */ && emittedExpression.operatorToken.kind === 26 /* CommaToken */ || + emittedExpression.kind === 302 /* CommaListExpression */ ? ts.createParen(e) : e; } @@ -56048,9 +56346,9 @@ var ts; */ function parenthesizeDefaultExpression(e) { var check = ts.skipPartiallyEmittedExpressions(e); - return (check.kind === 204 /* ClassExpression */ || - check.kind === 191 /* FunctionExpression */ || - check.kind === 301 /* CommaListExpression */ || + return (check.kind === 205 /* ClassExpression */ || + check.kind === 192 /* FunctionExpression */ || + check.kind === 302 /* CommaListExpression */ || ts.isBinaryExpression(check) && check.operatorToken.kind === 26 /* CommaToken */) ? ts.createParen(e) : e; @@ -56065,9 +56363,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 186 /* CallExpression */: + case 187 /* CallExpression */: return ts.createParen(expression); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -56090,7 +56388,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 187 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 188 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -56128,7 +56426,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(199 /* BinaryExpression */, 26 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(200 /* BinaryExpression */, 26 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -56139,29 +56437,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 191 /* FunctionExpression */ || kind === 192 /* ArrowFunction */) { + if (kind === 192 /* FunctionExpression */ || kind === 193 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 183 /* ObjectLiteralExpression */ || leftmostExpressionKind === 191 /* FunctionExpression */) { + if (leftmostExpressionKind === 184 /* ObjectLiteralExpression */ || leftmostExpressionKind === 192 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 170 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 171 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 168 /* UnionType */: - case 169 /* IntersectionType */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -56169,9 +56467,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 164 /* TypeQuery */: - case 174 /* TypeOperator */: - case 171 /* InferType */: + case 165 /* TypeQuery */: + case 175 /* TypeOperator */: + case 172 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -56197,25 +56495,25 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: node = node.operand; continue; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: node = node.left; continue; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: node = node.condition; continue; - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 185 /* ElementAccessExpression */: - case 184 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: + case 185 /* PropertyAccessExpression */: node = node.expression; continue; - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -56223,7 +56521,7 @@ var ts; } } function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 183 /* ObjectLiteralExpression */) { + if (!ts.isBlock(body) && getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 184 /* ObjectLiteralExpression */) { return ts.setTextRange(ts.createParen(body), body); } return body; @@ -56239,13 +56537,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: - case 208 /* NonNullExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: + case 209 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -56270,7 +56568,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 208 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 209 /* NonNullExpression */) { node = node.expression; } return node; @@ -56278,11 +56576,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 190 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 189 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 207 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 208 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 300 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 191 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 190 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 208 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 209 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 301 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -56300,7 +56598,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 190 /* ParenthesizedExpression */ + return node.kind === 191 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -56365,10 +56663,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 243 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 244 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 249 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 250 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -56383,7 +56681,7 @@ var ts; * Otherwise, a new StringLiteral node representing the module name will be returned. */ function getExternalModuleNameLiteral(importNode, sourceFile, host, resolver, compilerOptions) { - var moduleName = ts.getExternalModuleName(importNode); + var moduleName = ts.getExternalModuleName(importNode); // TODO: GH#18217 if (moduleName.kind === 9 /* StringLiteral */) { return tryGetModuleNameFromDeclaration(importNode, host, resolver, compilerOptions) || tryRenameExternalModule(moduleName, sourceFile) @@ -56441,8 +56739,9 @@ var ts; // `1` in `({ a: b = 1 } = ...)` // `1` in `({ a: {b} = 1 } = ...)` // `1` in `({ a: [b] = 1 } = ...)` - return ts.isAssignmentExpression(bindingElement.initializer, /*excludeCompoundAssignment*/ true) - ? bindingElement.initializer.right + var initializer = bindingElement.initializer; + return ts.isAssignmentExpression(initializer, /*excludeCompoundAssignment*/ true) + ? initializer.right : undefined; } if (ts.isShorthandPropertyAssignment(bindingElement)) { @@ -56486,7 +56785,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -56498,11 +56797,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -56534,12 +56833,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 148 /* Parameter */: - case 181 /* BindingElement */: + case 149 /* Parameter */: + case 182 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 203 /* SpreadElement */: - case 271 /* SpreadAssignment */: + case 204 /* SpreadElement */: + case 272 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -56551,7 +56850,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 181 /* BindingElement */: + case 182 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -56563,7 +56862,7 @@ var ts; : propertyName; } break; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -56575,7 +56874,7 @@ var ts; : propertyName; } break; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -56593,13 +56892,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: - case 182 /* ArrayLiteralExpression */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: + case 183 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -56639,11 +56938,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 180 /* ArrayBindingPattern */: - case 182 /* ArrayLiteralExpression */: + case 181 /* ArrayBindingPattern */: + case 183 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 179 /* ObjectBindingPattern */: - case 183 /* ObjectLiteralExpression */: + case 180 /* ObjectBindingPattern */: + case 184 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -56804,272 +57103,272 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 144 /* LastToken */) || kind === 173 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */) || kind === 174 /* ThisType */) { return node; } switch (kind) { // Names case 71 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 148 /* Parameter */: + case 149 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 149 /* Decorator */: + case 150 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 150 /* PropertySignature */: + case 151 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 152 /* MethodSignature */: + case 153 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 154 /* Constructor */: + case 155 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 157 /* CallSignature */: + case 158 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 162 /* FunctionType */: + case 163 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* ConstructorType */: + case 164 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 165 /* TypeLiteral */: + case 166 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 167 /* TupleType */: + case 168 /* TupleType */: return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 168 /* UnionType */: + case 169 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 169 /* IntersectionType */: + case 170 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 171 /* InferType */: + case 172 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 178 /* ImportType */: + case 179 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* TypeOperator */: + case 175 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 176 /* MappedType */: + case 177 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 177 /* LiteralType */: + case 178 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 194 /* TypeOfExpression */: + case 195 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 207 /* AsExpression */: + case 208 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 212 /* Block */: + case 213 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 222 /* ContinueStatement */: + case 223 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 223 /* BreakStatement */: + case 224 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 246 /* NamedImports */: + case 247 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 250 /* NamedExports */: + case 251 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 251 /* ExportSpecifier */: + case 252 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 254 /* JsxElement */: + case 255 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 256 /* JsxOpeningElement */: + case 257 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 263 /* JsxSpreadAttribute */: + case 264 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 265 /* CaseClause */: + case 266 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 272 /* EnumMember */: + case 273 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 273 /* SourceFile */: + case 274 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -57111,58 +57410,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 144 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 145 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 160 /* TypePredicate */ && kind <= 177 /* LiteralType */)) { + if ((kind >= 161 /* TypePredicate */ && kind <= 178 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 211 /* SemicolonClassElement */: - case 214 /* EmptyStatement */: - case 205 /* OmittedExpression */: - case 230 /* DebuggerStatement */: - case 299 /* NotEmittedStatement */: + case 212 /* SemicolonClassElement */: + case 215 /* EmptyStatement */: + case 206 /* OmittedExpression */: + case 231 /* DebuggerStatement */: + case 300 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 148 /* Parameter */: + case 149 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 149 /* Decorator */: + case 150 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 150 /* PropertySignature */: + case 151 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57171,12 +57470,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 154 /* Constructor */: + case 155 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57184,7 +57483,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57192,49 +57491,49 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 181 /* BindingElement */: + case 182 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 186 /* CallExpression */: + case 187 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 187 /* NewExpression */: + case 188 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNode(node.template, cbNode, result); break; - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -57242,123 +57541,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 190 /* ParenthesizedExpression */: - case 193 /* DeleteExpression */: - case 194 /* TypeOfExpression */: - case 195 /* VoidExpression */: - case 196 /* AwaitExpression */: - case 202 /* YieldExpression */: - case 203 /* SpreadElement */: - case 208 /* NonNullExpression */: + case 191 /* ParenthesizedExpression */: + case 194 /* DeleteExpression */: + case 195 /* TypeOfExpression */: + case 196 /* VoidExpression */: + case 197 /* AwaitExpression */: + case 203 /* YieldExpression */: + case 204 /* SpreadElement */: + case 209 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 207 /* AsExpression */: + case 208 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 212 /* Block */: + case 213 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 216 /* IfStatement */: + case 217 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 217 /* DoStatement */: + case 218 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 218 /* WhileStatement */: - case 225 /* WithStatement */: + case 219 /* WhileStatement */: + case 226 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 219 /* ForStatement */: + case 220 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 224 /* ReturnStatement */: - case 228 /* ThrowStatement */: + case 225 /* ReturnStatement */: + case 229 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 229 /* TryStatement */: + case 230 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57367,7 +57666,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57375,139 +57674,139 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 244 /* ImportClause */: + case 245 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 246 /* NamedImports */: - case 250 /* NamedExports */: + case 247 /* NamedImports */: + case 251 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 247 /* ImportSpecifier */: - case 251 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 252 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 254 /* JsxElement */: + case 255 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 255 /* JsxSelfClosingElement */: - case 256 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 263 /* JsxSpreadAttribute */: + case 264 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 265 /* CaseClause */: + case 266 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 268 /* CatchClause */: + case 269 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 272 /* EnumMember */: + case 273 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 273 /* SourceFile */: + case 274 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -57521,8 +57820,8 @@ var ts; return statements; } return ts.isNodeArray(statements) - ? ts.setTextRange(ts.createNodeArray(ts.concatenate(declarations, statements)), statements) - : ts.prependRange(statements, declarations); + ? ts.setTextRange(ts.createNodeArray(ts.prependStatements(statements.slice(), declarations)), statements) + : ts.prependStatements(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; /** @@ -57580,7 +57879,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 206 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 207 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -57630,7 +57929,7 @@ var ts; }); Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, { __debugFlags: { get: function () { return ts.formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 65536 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 131072 /* Object */ ? ts.formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { return this.checker.typeToString(this); } }, }); var nodeConstructors = [ @@ -57680,12 +57979,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName && e.propertyName.escapedText === "default" /* Default */; + return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* Default */; } function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 273 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 274 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -57715,7 +58014,7 @@ var ts; ts.getImportNeedsImportStarHelper = getImportNeedsImportStarHelper; function getImportNeedsImportDefaultHelper(node) { // Import default is needed if there's a default import or a default ref and no other refs (meaning an import star helper wasn't requested) - return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings))); + return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (!!node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings))); // TODO: GH#18217 } ts.getImportNeedsImportDefaultHelper = getImportNeedsImportDefaultHelper; function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { @@ -57731,7 +58030,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -57739,13 +58038,13 @@ var ts; externalImports.push(node); hasImportStarOrImportDefault = hasImportStarOrImportDefault || getImportNeedsImportStarHelper(node) || getImportNeedsImportDefaultHelper(node); break; - case 242 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 253 /* ExternalModuleReference */) { + case 243 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 254 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -57775,13 +58074,13 @@ var ts; } } break; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -57789,7 +58088,7 @@ var ts; } } break; - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -57809,7 +58108,7 @@ var ts; } } break; - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -57942,7 +58241,7 @@ var ts; var flattenContext = { context: context, level: level, - downlevelIteration: context.getCompilerOptions().downlevelIteration, + downlevelIteration: !!context.getCompilerOptions().downlevelIteration, hoistTempVariables: true, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -58003,7 +58302,7 @@ var ts; } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; function bindingOrAssignmentElementAssignsToName(element, escapedName) { - var target = ts.getTargetOfBindingOrAssignmentElement(element); + var target = ts.getTargetOfBindingOrAssignmentElement(element); // TODO: GH#18217 if (ts.isBindingOrAssignmentPattern(target)) { return bindingOrAssignmentPatternAssignsToName(target, escapedName); } @@ -58034,13 +58333,14 @@ var ts; * @param level Indicates the extent to which flattening should occur. */ function flattenDestructuringBinding(node, visitor, context, level, rval, hoistTempVariables, skipInitializer) { + if (hoistTempVariables === void 0) { hoistTempVariables = false; } var pendingExpressions; var pendingDeclarations = []; var declarations = []; var flattenContext = { context: context, level: level, - downlevelIteration: context.getCompilerOptions().downlevelIteration, + downlevelIteration: !!context.getCompilerOptions().downlevelIteration, hoistTempVariables: hoistTempVariables, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -58068,7 +58368,7 @@ var ts; } else { context.hoistVariableDeclaration(temp); - var pendingDeclaration = ts.lastOrUndefined(pendingDeclarations); + var pendingDeclaration = ts.last(pendingDeclarations); pendingDeclaration.pendingExpressions = ts.append(pendingDeclaration.pendingExpressions, ts.createAssignment(temp, pendingDeclaration.value)); ts.addRange(pendingDeclaration.pendingExpressions, pendingExpressions); pendingDeclaration.value = temp; @@ -58122,7 +58422,7 @@ var ts; value = ts.createVoidZero(); } } - var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element); + var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element); // TODO: GH#18217 if (ts.isObjectBindingOrAssignmentPattern(bindingTarget)) { flattenObjectBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location); } @@ -58130,7 +58430,7 @@ var ts; flattenArrayBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location); } else { - flattenContext.emitBindingOrAssignment(bindingTarget, value, location, /*original*/ element); + flattenContext.emitBindingOrAssignment(bindingTarget, value, location, /*original*/ element); // TODO: GH#18217 } } /** @@ -58182,7 +58482,7 @@ var ts; flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern); bindingElements = undefined; } - var rhsValue = createRestCall(flattenContext.context, value, elements, computedTempVariables, pattern); + var rhsValue = createRestCall(flattenContext.context, value, elements, computedTempVariables, pattern); // TODO: GH#18217 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element); } } @@ -58424,8 +58724,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(184 /* PropertyAccessExpression */); - context.enableSubstitution(185 /* ElementAccessExpression */); + context.enableSubstitution(185 /* PropertyAccessExpression */); + context.enableSubstitution(186 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -58454,14 +58754,14 @@ var ts; var pendingExpressions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 274 /* Bundle */) { + if (node.kind === 275 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 276 /* InputFiles */) { + if (prepend.kind === 277 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.javascriptText); } return prepend; @@ -58508,15 +58808,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 273 /* SourceFile */: - case 240 /* CaseBlock */: - case 239 /* ModuleBlock */: - case 212 /* Block */: + case 274 /* SourceFile */: + case 241 /* CaseBlock */: + case 240 /* ModuleBlock */: + case 213 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 234 /* ClassDeclaration */: - case 233 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 234 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -58528,7 +58828,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 === 234 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 235 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } break; } @@ -58572,10 +58872,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 248 /* ExportAssignment */: - case 249 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 249 /* ExportAssignment */: + case 250 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -58596,13 +58896,13 @@ var ts; return node; } switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return visitImportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitExportAssignment(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -58622,11 +58922,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 249 /* ExportDeclaration */ || - node.kind === 243 /* ImportDeclaration */ || - node.kind === 244 /* ImportClause */ || - (node.kind === 242 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 253 /* ExternalModuleReference */)) { + if (node.kind === 250 /* ExportDeclaration */ || + node.kind === 244 /* ImportDeclaration */ || + node.kind === 245 /* ImportClause */ || + (node.kind === 243 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 254 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -58656,19 +58956,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 154 /* Constructor */: + case 155 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 151 /* PropertyDeclaration */: - case 159 /* IndexSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 153 /* MethodDeclaration */: + case 152 /* PropertyDeclaration */: + case 160 /* IndexSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 154 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 211 /* SemicolonClassElement */: + case 212 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -58707,52 +59007,53 @@ var ts; case 124 /* DeclareKeyword */: case 132 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 166 /* ArrayType */: - case 167 /* TupleType */: - case 165 /* TypeLiteral */: - case 160 /* TypePredicate */: - case 147 /* TypeParameter */: + case 167 /* ArrayType */: + case 168 /* TupleType */: + case 166 /* TypeLiteral */: + case 161 /* TypePredicate */: + case 148 /* TypeParameter */: case 119 /* AnyKeyword */: + case 142 /* UnknownKeyword */: case 122 /* BooleanKeyword */: case 137 /* StringKeyword */: case 134 /* NumberKeyword */: case 131 /* NeverKeyword */: case 105 /* VoidKeyword */: case 138 /* SymbolKeyword */: - case 163 /* ConstructorType */: - case 162 /* FunctionType */: - case 164 /* TypeQuery */: - case 161 /* TypeReference */: - case 168 /* UnionType */: - case 169 /* IntersectionType */: - case 170 /* ConditionalType */: - case 172 /* ParenthesizedType */: - case 173 /* ThisType */: - case 174 /* TypeOperator */: - case 175 /* IndexedAccessType */: - case 176 /* MappedType */: - case 177 /* LiteralType */: + case 164 /* ConstructorType */: + case 163 /* FunctionType */: + case 165 /* TypeQuery */: + case 162 /* TypeReference */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: + case 171 /* ConditionalType */: + case 173 /* ParenthesizedType */: + case 174 /* ThisType */: + case 175 /* TypeOperator */: + case 176 /* IndexedAccessType */: + case 177 /* MappedType */: + case 178 /* LiteralType */: // TypeScript type nodes are elided. - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: // TypeScript index signatures are elided. - case 149 /* Decorator */: + case 150 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 151 /* PropertyDeclaration */: + case 152 /* 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 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 154 /* Constructor */: + case 155 /* Constructor */: return visitConstructor(node); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -58763,7 +59064,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -58774,35 +59075,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 148 /* Parameter */: + case 149 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -58812,35 +59113,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 189 /* TypeAssertionExpression */: - case 207 /* AsExpression */: + case 190 /* TypeAssertionExpression */: + case 208 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return visitCallExpression(node); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return visitNewExpression(node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -58849,7 +59150,8 @@ var ts; } function visitSourceFile(node) { var alwaysStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") && - !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015); + !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015) && + !ts.isJsonSourceFile(node); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); } /** @@ -58956,7 +59258,7 @@ var ts; statement.pos = closingBraceLocation.pos; ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); statements.push(statement); - ts.prependRange(statements, context.endLexicalEnvironment()); + ts.prependStatements(statements, context.endLexicalEnvironment()); var iife = ts.createImmediatelyInvokedArrowFunction(statements); ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); var varStatement = ts.createVariableStatement( @@ -59321,7 +59623,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 215 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -59392,7 +59694,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 151 /* PropertyDeclaration */ + return member.kind === 152 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -59530,12 +59832,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -59688,7 +59990,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 151 /* PropertyDeclaration */ + ? member.kind === 152 /* 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`. ? ts.createVoidZero() @@ -59811,10 +60113,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */ - || kind === 151 /* PropertyDeclaration */; + return kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */ + || kind === 152 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -59824,7 +60126,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 153 /* MethodDeclaration */; + return node.kind === 154 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -59835,12 +60137,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return true; } return false; @@ -59852,15 +60154,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 151 /* PropertyDeclaration */: - case 148 /* Parameter */: - case 155 /* GetAccessor */: + case 152 /* PropertyDeclaration */: + case 149 /* Parameter */: + case 156 /* GetAccessor */: return serializeTypeNode(node.type); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 153 /* MethodDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 154 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -59897,7 +60199,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 155 /* GetAccessor */) { + if (container && node.kind === 156 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -59947,22 +60249,22 @@ var ts; case 95 /* NullKeyword */: case 131 /* NeverKeyword */: return ts.createVoidZero(); - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 162 /* FunctionType */: - case 163 /* ConstructorType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: return ts.createIdentifier("Function"); - case 166 /* ArrayType */: - case 167 /* TupleType */: + case 167 /* ArrayType */: + case 168 /* TupleType */: return ts.createIdentifier("Array"); - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: case 122 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); case 137 /* StringKeyword */: return ts.createIdentifier("String"); case 135 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 177 /* LiteralType */: + case 178 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); @@ -59980,18 +60282,19 @@ var ts; return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return serializeTypeReferenceNode(node); - case 169 /* IntersectionType */: - case 168 /* UnionType */: + case 170 /* IntersectionType */: + case 169 /* UnionType */: return serializeUnionOrIntersectionType(node); - case 164 /* TypeQuery */: - case 174 /* TypeOperator */: - case 175 /* IndexedAccessType */: - case 176 /* MappedType */: - case 165 /* TypeLiteral */: + case 165 /* TypeQuery */: + case 175 /* TypeOperator */: + case 176 /* IndexedAccessType */: + case 177 /* MappedType */: + case 166 /* TypeLiteral */: case 119 /* AnyKeyword */: - case 173 /* ThisType */: + case 142 /* UnknownKeyword */: + case 174 /* ThisType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -60004,7 +60307,7 @@ var ts; var serializedUnion; for (var _i = 0, _a = node.types; _i < _a.length; _i++) { var typeNode = _a[_i]; - while (typeNode.kind === 172 /* ParenthesizedType */) { + while (typeNode.kind === 173 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } if (typeNode.kind === 131 /* NeverKeyword */) { @@ -60043,7 +60346,8 @@ var ts; * @param node The type reference node. */ function serializeTypeReferenceNode(node) { - switch (resolver.getTypeReferenceSerializationKind(node.typeName, currentScope)) { + var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentScope); + switch (kind) { case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, /*useFallback*/ true); var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -60069,8 +60373,9 @@ var ts; case ts.TypeReferenceSerializationKind.Promise: return ts.createIdentifier("Promise"); case ts.TypeReferenceSerializationKind.ObjectType: - default: return ts.createIdentifier("Object"); + default: + return ts.Debug.assertNever(kind); } } /** @@ -60093,7 +60398,7 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } return name; - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -60579,7 +60884,7 @@ var ts; var statements = []; startLexicalEnvironment(); var members = ts.map(node.members, transformEnumMember); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); ts.addRange(statements, members); currentNamespaceContainerName = savedCurrentNamespaceLocalName; return ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ node.members), @@ -60628,7 +60933,7 @@ var ts; * @param node The module declaration node. */ function shouldEmitModuleDeclaration(node) { - return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); + return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules); } /** * Determines whether an exported declaration will have a qualified export name (e.g. `f.x` @@ -60678,12 +60983,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentScope.kind === 273 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentScope.kind === 274 /* 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 === 237 /* EnumDeclaration */) { + if (node.kind === 238 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -60802,7 +61107,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 239 /* ModuleBlock */) { + if (body.kind === 240 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -60820,7 +61125,7 @@ var ts; var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; statementsLocation = ts.moveRangePos(moduleBlock.statements, -1); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; @@ -60848,13 +61153,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 (body.kind !== 239 /* ModuleBlock */) { + if (body.kind !== 240 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 238 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -60895,7 +61200,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 245 /* NamespaceImport */) { + if (node.kind === 246 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -61127,16 +61432,16 @@ var ts; // 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(71 /* Identifier */); - context.enableSubstitution(270 /* ShorthandPropertyAssignment */); + context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(238 /* ModuleDeclaration */); + context.enableEmitNotification(239 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 238 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 239 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 237 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 238 /* EnumDeclaration */; } /** * Hook for node emit. @@ -61197,9 +61502,9 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -61219,7 +61524,7 @@ var ts; // constructor references in static property initializers. var declaration = resolver.getReferencedValueDeclaration(node); if (declaration) { - var classAlias = classAliases[declaration.id]; + var classAlias = classAliases[declaration.id]; // TODO: GH#18217 if (classAlias) { var clone_1 = ts.getSynthesizedClone(classAlias); ts.setSourceMapRange(clone_1, node); @@ -61237,9 +61542,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 !== 273 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 238 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 237 /* EnumDeclaration */); + if (container && container.kind !== 274 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 239 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 238 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -61374,15 +61679,15 @@ var ts; case 120 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return visitAwaitExpression(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return visitArrowFunction(node); default: return ts.visitEachChild(node, visitor, context); @@ -61391,27 +61696,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 212 /* Block */: - case 226 /* SwitchStatement */: - case 240 /* CaseBlock */: - case 265 /* CaseClause */: - case 266 /* DefaultClause */: - case 229 /* TryStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 216 /* IfStatement */: - case 225 /* WithStatement */: - case 227 /* LabeledStatement */: + case 213 /* Block */: + case 227 /* SwitchStatement */: + case 241 /* CaseBlock */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: + case 230 /* TryStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 217 /* IfStatement */: + case 226 /* WithStatement */: + case 228 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -61421,7 +61726,7 @@ var ts; } function visitCatchClauseInAsyncBody(node) { var catchClauseNames = ts.createUnderscoreEscapedMap(); - recordDeclarationName(node.variableDeclaration, catchClauseNames); + recordDeclarationName(node.variableDeclaration, catchClauseNames); // TODO: GH#18217 // names declared in a catch variable are block scoped var catchClauseUnshadowedNames; catchClauseNames.forEach(function (_, escapedName) { @@ -61461,8 +61766,9 @@ var ts; : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, ts.liftToBlock)); } function visitForStatementInAsyncBody(node) { - return ts.updateFor(node, isVariableDeclarationListWithCollidingName(node.initializer) - ? visitVariableDeclarationListWithCollidingNames(node.initializer, /*hasReceiver*/ false) + var initializer = node.initializer; // TODO: GH#18217 + return ts.updateFor(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, ts.liftToBlock)); } /** @@ -61554,10 +61860,10 @@ var ts; } } function isVariableDeclarationListWithCollidingName(node) { - return node + return !!node && ts.isVariableDeclarationList(node) && !(node.flags & 3 /* BlockScoped */) - && ts.forEach(node.declarations, collidesWithParameterName); + && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { hoistVariableDeclarationList(node); @@ -61611,7 +61917,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 === 192 /* ArrowFunction */; + var isArrowFunction = node.kind === 193 /* 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 @@ -61629,7 +61935,7 @@ var ts; var statements = []; var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset)))); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.createBlock(statements, /*multiLine*/ true); ts.setTextRange(block, node.body); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. @@ -61684,15 +61990,15 @@ 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(186 /* CallExpression */); - context.enableSubstitution(184 /* PropertyAccessExpression */); - context.enableSubstitution(185 /* ElementAccessExpression */); + context.enableSubstitution(187 /* CallExpression */); + context.enableSubstitution(185 /* PropertyAccessExpression */); + context.enableSubstitution(186 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(234 /* ClassDeclaration */); - context.enableEmitNotification(153 /* MethodDeclaration */); - context.enableEmitNotification(155 /* GetAccessor */); - context.enableEmitNotification(156 /* SetAccessor */); - context.enableEmitNotification(154 /* Constructor */); + context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(154 /* MethodDeclaration */); + context.enableEmitNotification(156 /* GetAccessor */); + context.enableEmitNotification(157 /* SetAccessor */); + context.enableEmitNotification(155 /* Constructor */); } } /** @@ -61732,11 +62038,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -61768,11 +62074,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 234 /* ClassDeclaration */ - || kind === 154 /* Constructor */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */; + return kind === 235 /* ClassDeclaration */ + || kind === 155 /* Constructor */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */; } function createSuperAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -61867,45 +62173,47 @@ var ts; return node; } switch (node.kind) { - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return visitAwaitExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return visitYieldExpression(node); - case 227 /* LabeledStatement */: + case 225 /* ReturnStatement */: + return visitReturnStatement(node); + case 228 /* LabeledStatement */: return visitLabeledStatement(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return visitVoidExpression(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return visitConstructorDeclaration(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: return visitGetAccessorDeclaration(node); - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return visitArrowFunction(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return visitParameter(node); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return visitExpressionStatement(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -61930,10 +62238,16 @@ var ts; } return ts.visitEachChild(node, visitor, context); } + function visitReturnStatement(node) { + if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + return ts.updateReturn(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : ts.createVoidZero())); + } + return ts.visitEachChild(node, visitor, context); + } function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 221 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 222 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -61945,7 +62259,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 === 271 /* SpreadAssignment */) { + if (e.kind === 272 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -61954,7 +62268,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 269 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 270 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -61972,7 +62286,7 @@ var ts; // If the first element is a spread element, then the first argument to __assign is {}: // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 183 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 184 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -62106,7 +62420,7 @@ var ts; ]), node.expression), 2097152 /* NoHoisting */), /*condition*/ ts.createComma(ts.createAssignment(result, createDownlevelAwait(callNext)), ts.createLogicalNot(getDone)), /*incrementor*/ undefined, - /*statement*/ convertForOfStatementHead(node, createDownlevelAwait(getValue))), + /*statement*/ convertForOfStatementHead(node, getValue)), /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); return ts.createTry(ts.createBlock([ ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) @@ -62228,7 +62542,7 @@ var ts; /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset)))))); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.updateBlock(node.body, statements); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. @@ -62256,7 +62570,7 @@ var ts; var leadingStatements = endLexicalEnvironment(); if (statementOffset > 0 || ts.some(statements) || ts.some(leadingStatements)) { var block = ts.convertToFunctionBody(body, /*multiLine*/ true); - ts.prependRange(statements, leadingStatements); + ts.prependStatements(statements, leadingStatements); ts.addRange(statements, block.statements.slice(statementOffset)); return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(statements), block.statements)); } @@ -62285,15 +62599,15 @@ 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(186 /* CallExpression */); - context.enableSubstitution(184 /* PropertyAccessExpression */); - context.enableSubstitution(185 /* ElementAccessExpression */); + context.enableSubstitution(187 /* CallExpression */); + context.enableSubstitution(185 /* PropertyAccessExpression */); + context.enableSubstitution(186 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(234 /* ClassDeclaration */); - context.enableEmitNotification(153 /* MethodDeclaration */); - context.enableEmitNotification(155 /* GetAccessor */); - context.enableEmitNotification(156 /* SetAccessor */); - context.enableEmitNotification(154 /* Constructor */); + context.enableEmitNotification(235 /* ClassDeclaration */); + context.enableEmitNotification(154 /* MethodDeclaration */); + context.enableEmitNotification(156 /* GetAccessor */); + context.enableEmitNotification(157 /* SetAccessor */); + context.enableEmitNotification(155 /* Constructor */); } } /** @@ -62333,11 +62647,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return substituteCallExpression(node); } return node; @@ -62369,11 +62683,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 234 /* ClassDeclaration */ - || kind === 154 /* Constructor */ - || kind === 153 /* MethodDeclaration */ - || kind === 155 /* GetAccessor */ - || kind === 156 /* SetAccessor */; + return kind === 235 /* ClassDeclaration */ + || kind === 155 /* Constructor */ + || kind === 154 /* MethodDeclaration */ + || kind === 156 /* GetAccessor */ + || kind === 157 /* SetAccessor */; } function createSuperAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -62482,13 +62796,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 254 /* JsxElement */: + case 255 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -62498,13 +62812,13 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return visitJsxExpression(node); - case 254 /* JsxElement */: + case 255 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -62545,14 +62859,16 @@ var ts; objectProperties = ts.createAssignHelper(context, segments); } } - var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location); + var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217 + tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), node, location); if (isChild) { ts.startOnNewLine(element); } return element; } function visitJsxOpeningFragment(node, children, isChild, location) { - var element = ts.createExpressionForJsxFragment(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, ts.mapDefined(children, transformJsxChildToExpression), node, location); + var element = ts.createExpressionForJsxFragment(context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217 + ts.mapDefined(children, transformJsxChildToExpression), node, location); if (isChild) { ts.startOnNewLine(element); } @@ -62577,7 +62893,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 264 /* JsxExpression */) { + else if (node.kind === 265 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -62671,7 +62987,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 254 /* JsxElement */) { + if (node.kind === 255 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -62977,7 +63293,7 @@ var ts; return node; } switch (node.kind) { - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -63209,14 +63525,14 @@ var ts; hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ - && node.kind === 224 /* ReturnStatement */ + return (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */) !== 0 + && node.kind === 225 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 212 /* Block */))) + || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 213 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -63244,63 +63560,63 @@ var ts; switch (node.kind) { case 115 /* StaticKeyword */: return undefined; // elide static keyword - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return visitClassDeclaration(node); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return visitClassExpression(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return visitParameter(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return visitArrowFunction(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return visitVariableDeclaration(node); case 71 /* Identifier */: return visitIdentifier(node); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return visitSwitchStatement(node); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return visitCaseBlock(node); - case 212 /* Block */: + case 213 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return visitLabeledStatement(node); - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return visitExpressionStatement(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitCatchClause(node); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return visitCallExpression(node); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return visitNewExpression(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 13 /* NoSubstitutionTemplateLiteral */: case 14 /* TemplateHead */: @@ -63311,28 +63627,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return visitTemplateExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return visitYieldExpression(node); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return visitSpreadElement(node); case 97 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); case 99 /* ThisKeyword */: return visitThisKeyword(node); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return visitMetaProperty(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -63349,7 +63665,7 @@ var ts; if (taggedTemplateStringDeclarations) { statements.push(ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList(taggedTemplateStringDeclarations))); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); } @@ -63419,13 +63735,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 === 223 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 224 /* 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; - if (!node.label) { - if (node.kind === 223 /* BreakStatement */) { + var label = node.label; + if (!label) { + if (node.kind === 224 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -63436,13 +63753,13 @@ var ts; } } else { - if (node.kind === 223 /* BreakStatement */) { - labelMarker = "break-" + node.label.escapedText; - setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(node.label), labelMarker); + if (node.kind === 224 /* BreakStatement */) { + labelMarker = "break-" + label.escapedText; + setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + node.label.escapedText; - setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(node.label), labelMarker); + labelMarker = "continue-" + label.escapedText; + setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(label), labelMarker); } } var returnExpression = ts.createLiteral(labelMarker); @@ -63603,7 +63920,7 @@ var ts; statement.pos = closingBraceLocation.pos; ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); statements.push(statement); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); ts.setEmitFlags(block, 1536 /* NoComments */); return block; @@ -63661,7 +63978,7 @@ var ts; // `super` call. // If this is the case, we do not include the synthetic `...args` parameter and // will instead use the `arguments` object in ES5/3. - return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) + return ts.visitParameterList(constructor && !hasSynthesizedSuper ? constructor.parameters : undefined, visitor, context) || []; } /** @@ -63697,7 +64014,7 @@ var ts; } // 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 !== 95 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { @@ -63716,7 +64033,7 @@ var ts; && !(constructor && isSufficientlyCoveredByReturnStatements(constructor.body))) { statements.push(ts.createReturn(ts.createFileLevelUniqueName("_this"))); } - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); if (constructor) { prependCaptureNewTargetIfNeeded(statements, constructor, /*copyOnWrite*/ false); } @@ -63736,11 +64053,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 224 /* ReturnStatement */) { + if (statement.kind === 225 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 216 /* IfStatement */) { + else if (statement.kind === 217 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -63748,7 +64065,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 212 /* Block */) { + else if (statement.kind === 213 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -63806,7 +64123,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 215 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 216 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -63816,8 +64133,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 199 /* BinaryExpression */ - || superCallExpression.left.kind !== 186 /* CallExpression */) { + if (superCallExpression.kind !== 200 /* BinaryExpression */ + || superCallExpression.left.kind !== 187 /* CallExpression */) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } // Shift comments from the original super call to the return statement. @@ -64014,7 +64331,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 192 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 193 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -64034,22 +64351,22 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return statements; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 154 /* Constructor */: + case 155 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 192 /* 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 = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 93 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); @@ -64080,20 +64397,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 211 /* SemicolonClassElement */: + case 212 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 154 /* Constructor */: + case 155 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -64163,7 +64480,7 @@ var ts; // arguments are both mapped contiguously to the accessor name. var target = ts.getMutableClone(receiver); ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); - ts.setSourceMapRange(target, firstAccessor.name); + ts.setSourceMapRange(target, firstAccessor.name); // TODO: GH#18217 var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 16 /* NoLeadingSourceMap */); ts.setSourceMapRange(propertyName, firstAccessor.name); @@ -64285,7 +64602,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 === 233 /* FunctionDeclaration */ || node.kind === 191 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 234 /* FunctionDeclaration */ || node.kind === 192 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -64333,7 +64650,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 192 /* ArrowFunction */); + ts.Debug.assert(node.kind === 193 /* 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 @@ -64359,7 +64676,7 @@ var ts; closeBraceLocation = body; } var lexicalEnvironment = context.endLexicalEnvironment(); - ts.prependRange(statements, lexicalEnvironment); + ts.prependStatements(statements, lexicalEnvironment); prependCaptureNewTargetIfNeeded(statements, node, /*copyOnWrite*/ false); // If we added any final generated statements, this must be a multi-line block if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { @@ -64401,9 +64718,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -64422,9 +64739,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -64497,13 +64814,12 @@ var ts; ts.setTextRange(declarationList, node); ts.setCommentRange(declarationList, node); if (node.transformFlags & 8388608 /* ContainsBindingPattern */ - && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { + && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. var firstDeclaration = ts.firstOrUndefined(declarations); if (firstDeclaration) { - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, ts.last(declarations).end)); } } return declarationList; @@ -64626,14 +64942,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -64657,11 +64973,12 @@ var ts; } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; - if (ts.isVariableDeclarationList(node.initializer)) { + var initializer = node.initializer; + if (ts.isVariableDeclarationList(initializer)) { if (node.initializer.flags & 3 /* BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } - var firstOriginalDeclaration = ts.firstOrUndefined(node.initializer.declarations); + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. @@ -64670,9 +64987,7 @@ var ts; ts.setOriginalNode(declarationList, node.initializer); // Adjust the source map range for the first declaration to align with the old // emitter. - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + ts.setSourceMapRange(declarationList, ts.createRange(declarations[0].pos, ts.last(declarations).end)); statements.push(ts.createVariableStatement( /*modifiers*/ undefined, declarationList)); } @@ -64683,20 +64998,20 @@ var ts; /*modifiers*/ undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), /*type*/ undefined, boundValue) - ]), ts.moveRangePos(node.initializer, -1)), node.initializer)), ts.moveRangeEnd(node.initializer, -1))); + ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); } } else { // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. - var assignment = ts.createAssignment(node.initializer, boundValue); + var assignment = ts.createAssignment(initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { ts.aggregateTransformFlags(assignment); statements.push(ts.createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); } else { - assignment.end = node.initializer.end; - statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(node.initializer, -1))); + assignment.end = initializer.end; + statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1))); } } if (convertedLoopBodyStatements) { @@ -64818,7 +65133,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 146 /* ComputedPropertyName */) { + if (property.name.kind === 147 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -64890,11 +65205,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 232 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 233 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -64940,7 +65255,7 @@ var ts; if (loopOutParameters.length) { copyOutParameters(loopOutParameters, 1 /* ToOutParameter */, statements_4); } - ts.prependRange(statements_4, lexicalEnvironment); + ts.prependStatements(statements_4, lexicalEnvironment); loopBody = ts.createBlock(statements_4, /*multiline*/ true); } if (ts.isBlock(loopBody)) { @@ -65174,20 +65489,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { - expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); + expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -65298,7 +65613,7 @@ var ts; var body = node.transformFlags & (32768 /* ContainsCapturedLexicalThis */ | 128 /* ContainsES2015 */) ? transformFunctionBody(node) : visitFunctionBodyDownLevel(node); - if (node.kind === 155 /* GetAccessor */) { + if (node.kind === 156 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -65340,7 +65655,7 @@ var ts; function visitArrayLiteralExpression(node) { if (node.transformFlags & 64 /* ES2015 */) { // We are here because we contain a SpreadElementExpression. - return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, node.multiLine, /*hasTrailingComma*/ node.elements.hasTrailingComma); + return transformAndSpreadElements(node.elements, /*needsUniqueCopy*/ true, !!node.multiLine, /*hasTrailingComma*/ !!node.elements.hasTrailingComma); } return ts.visitEachChild(node, visitor, context); } @@ -65395,11 +65710,11 @@ var ts; var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock); // The class statements are the statements generated by visiting the first statement with initializer of the // body (1), while all other statements are added to remainingStatements (2) - var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.firstOrUndefined(stmt.declarationList.declarations).initializer; }; + var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.first(stmt.declarationList.declarations).initializer; }; var bodyStatements = ts.visitNodes(body.statements, visitor, ts.isStatement); var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer); var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); }); - var varStatement = ts.cast(ts.firstOrUndefined(classStatements), ts.isVariableStatement); + var varStatement = ts.cast(ts.first(classStatements), ts.isVariableStatement); // We know there is only one variable declaration here as we verified this in an // earlier call to isTypeScriptClassWrapper var variable = varStatement.declarationList.declarations[0]; @@ -65576,7 +65891,7 @@ var ts; else { if (segments.length === 1) { var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 182 /* ArrayLiteralExpression */ + return needsUniqueCopy && ts.isSpreadElement(firstElement) && firstElement.expression.kind !== 183 /* ArrayLiteralExpression */ ? ts.createArraySlice(segments[0]) : segments[0]; } @@ -65839,13 +66154,13 @@ var ts; if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; context.enableSubstitution(99 /* ThisKeyword */); - context.enableEmitNotification(154 /* Constructor */); - context.enableEmitNotification(153 /* MethodDeclaration */); - context.enableEmitNotification(155 /* GetAccessor */); - context.enableEmitNotification(156 /* SetAccessor */); - context.enableEmitNotification(192 /* ArrowFunction */); - context.enableEmitNotification(191 /* FunctionExpression */); - context.enableEmitNotification(233 /* FunctionDeclaration */); + context.enableEmitNotification(155 /* Constructor */); + context.enableEmitNotification(154 /* MethodDeclaration */); + context.enableEmitNotification(156 /* GetAccessor */); + context.enableEmitNotification(157 /* SetAccessor */); + context.enableEmitNotification(193 /* ArrowFunction */); + context.enableEmitNotification(192 /* FunctionExpression */); + context.enableEmitNotification(234 /* FunctionDeclaration */); } } /** @@ -65885,14 +66200,13 @@ var ts; * @param node An original source tree node. */ function isNameOfDeclarationWithCollidingName(node) { - var parent = node.parent; - switch (parent.kind) { - case 181 /* BindingElement */: - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: - case 231 /* VariableDeclaration */: - return parent.name === node - && resolver.isDeclarationWithCollidingName(parent); + switch (node.parent.kind) { + case 182 /* BindingElement */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 232 /* VariableDeclaration */: + return node.parent.name === node + && resolver.isDeclarationWithCollidingName(node.parent); } return false; } @@ -65972,11 +66286,11 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 215 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 216 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 186 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 187 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; @@ -65984,7 +66298,7 @@ var ts; return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 203 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 204 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -66037,15 +66351,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(256 /* JsxOpeningElement */); - context.enableEmitNotification(257 /* JsxClosingElement */); - context.enableEmitNotification(255 /* JsxSelfClosingElement */); + context.enableEmitNotification(257 /* JsxOpeningElement */); + context.enableEmitNotification(258 /* JsxClosingElement */); + context.enableEmitNotification(256 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(184 /* PropertyAccessExpression */); - context.enableSubstitution(269 /* PropertyAssignment */); + context.enableSubstitution(185 /* PropertyAccessExpression */); + context.enableSubstitution(270 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -66064,9 +66378,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 256 /* JsxOpeningElement */: - case 257 /* JsxClosingElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 258 /* JsxClosingElement */: + case 256 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -66123,7 +66437,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */) { + if (token !== undefined && token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -66308,6 +66622,7 @@ var ts; case 4 /* Yield */: return "yield"; case 5 /* YieldStar */: return "yield*"; case 7 /* Endfinally */: return "endfinally"; + default: return undefined; // TODO: GH#18217 } } function transformGenerators(context) { @@ -66397,13 +66712,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 217 /* DoStatement */: + case 218 /* DoStatement */: return visitDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return visitWhileStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return visitSwitchStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -66416,24 +66731,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return visitAccessorDeclaration(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatement(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatement(node); - case 223 /* BreakStatement */: + case 224 /* BreakStatement */: return visitBreakStatement(node); - case 222 /* ContinueStatement */: + case 223 /* ContinueStatement */: return visitContinueStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -66454,21 +66769,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return visitBinaryExpression(node); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return visitConditionalExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return visitYieldExpression(node); - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return visitCallExpression(node); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -66481,9 +66796,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -66615,7 +66930,7 @@ var ts; var statementOffset = ts.addPrologue(statements, body.statements, /*ensureUseStrict*/ false, visitor); transformAndEmitStatements(body.statements, statementOffset); var buildResult = build(); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); statements.push(ts.createReturn(buildResult)); // Restore previous generator state inGeneratorFunctionBody = savedInGeneratorFunctionBody; @@ -66671,13 +66986,14 @@ var ts; * @param node The node to visit. */ function visitBinaryExpression(node) { - switch (ts.getExpressionAssociativity(node)) { + var assoc = ts.getExpressionAssociativity(node); + switch (assoc) { case 0 /* Left */: return visitLeftAssociativeBinaryExpression(node); case 1 /* Right */: return visitRightAssociativeBinaryExpression(node); default: - ts.Debug.fail("Unknown associativity."); + return ts.Debug.assertNever(assoc); } } function isCompoundAssignment(kind) { @@ -66710,7 +67026,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -66722,7 +67038,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -67098,35 +67414,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 212 /* Block */: + case 213 /* Block */: return transformAndEmitBlock(node); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return transformAndEmitIfStatement(node); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return transformAndEmitDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return transformAndEmitForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 222 /* ContinueStatement */: + case 223 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 223 /* BreakStatement */: + case 224 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return transformAndEmitWithStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -67556,7 +67872,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 266 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 267 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -67569,7 +67885,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 265 /* CaseClause */) { + if (clause.kind === 266 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -67685,7 +68001,7 @@ var ts; beginExceptionBlock(); transformAndEmitEmbeddedStatement(node.tryBlock); if (node.catchClause) { - beginCatchBlock(node.catchClause.variableDeclaration); + beginCatchBlock(node.catchClause.variableDeclaration); // TODO: GH#18217 transformAndEmitEmbeddedStatement(node.catchClause.block); } if (node.finallyBlock) { @@ -67699,7 +68015,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 16777216 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 16777216 /* ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -67800,7 +68116,8 @@ var ts; */ function endBlock() { var block = peekBlock(); - ts.Debug.assert(block !== undefined, "beginBlock was never called."); + if (block === undefined) + return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; blockActions[index] = 1 /* Close */; blockOffsets[index] = operations ? operations.length : 0; @@ -68133,7 +68450,7 @@ var ts; * @param label A label. */ function createLabel(label) { - if (label > 0) { + if (label !== undefined && label > 0) { if (labelExpressions === undefined) { labelExpressions = []; } @@ -68772,7 +69089,7 @@ var ts; name: "typescript:generator", scoped: false, priority: 6, - text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" + text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; })(ts || (ts = {})); /*@internal*/ @@ -68797,11 +69114,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(199 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(197 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(198 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(270 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(273 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(200 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(198 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(199 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(274 /* 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. @@ -68851,7 +69168,7 @@ var ts; ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { // If we have any `export * from ...` declarations @@ -69045,7 +69362,7 @@ var ts; if (ts.isImportEqualsDeclaration(node) || ts.isExportDeclaration(node) || !ts.getExternalModuleNameLiteral(node, currentSourceFile, host, resolver, compilerOptions)) { return undefined; } - var name = ts.getLocalNameForExternalImport(node, currentSourceFile); + var name = ts.getLocalNameForExternalImport(node, currentSourceFile); // TODO: GH#18217 var expr = getHelperExpressionForImport(node, name); if (expr === name) { return undefined; @@ -69074,7 +69391,7 @@ var ts; addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); // End the lexical environment for the module body // and merge any new lexical declarations. - ts.prependRange(statements, endLexicalEnvironment()); + ts.prependStatements(statements, endLexicalEnvironment()); var body = ts.createBlock(statements, /*multiLine*/ true); if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { // If we have any `export * from ...` declarations @@ -69123,23 +69440,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return visitImportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return visitExportDeclaration(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitExportAssignment(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatement(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return visitClassDeclaration(node); - case 302 /* MergeDeclarationMarker */: + case 303 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 303 /* EndOfDeclarationMarker */: + case 304 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -69166,24 +69483,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -69658,7 +69975,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 213 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -69713,10 +70030,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 246 /* NamedImports */: + case 247 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -69915,7 +70232,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -69979,10 +70296,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return substituteBinaryExpression(node); - case 198 /* PostfixUnaryExpression */: - case 197 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -70003,7 +70320,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 273 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -70078,7 +70395,7 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 198 /* PostfixUnaryExpression */ + var expression = node.kind === 199 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; @@ -70154,11 +70471,11 @@ var ts; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(270 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(199 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(197 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(198 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(273 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(271 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(200 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(198 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(199 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(274 /* 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. @@ -70343,8 +70660,8 @@ var ts; // We emit hoisted variables early to align roughly with our previous emit output. // Two key differences in this approach are: // - Temporary variables will appear at the top rather than at the bottom of the file - ts.prependRange(statements, endLexicalEnvironment()); - var exportStarFunction = addExportStarIfNeeded(statements); + ts.prependStatements(statements, endLexicalEnvironment()); + var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217 var moduleObject = ts.createObjectLiteral([ ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), ts.createPropertyAssignment("execute", ts.createFunctionExpression( @@ -70379,7 +70696,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 249 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 250 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -70404,7 +70721,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 249 /* ExportDeclaration */) { + if (externalImport.kind !== 250 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -70480,21 +70797,21 @@ var ts; var statements = []; for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; - var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); + var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -70544,15 +70861,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return visitImportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -70566,7 +70883,7 @@ var ts; function visitImportDeclaration(node) { var statements; if (node.importClause) { - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); // TODO: GH#18217 } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -70586,7 +70903,7 @@ var ts; function visitImportEqualsDeclaration(node) { ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); var statements; - hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); + hoistVariableDeclaration(ts.getLocalNameForExternalImport(node, currentSourceFile)); // TODO: GH#18217 if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node var id = ts.getOriginalNodeId(node); @@ -70728,7 +71045,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 === 273 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 274 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -70792,7 +71109,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 === 213 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 214 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -70854,10 +71171,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 246 /* NamedImports */: + case 247 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -71037,43 +71354,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return visitVariableStatement(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return visitClassDeclaration(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return visitForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return visitForInStatement(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return visitForOfStatement(node); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return visitDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return visitWhileStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return visitLabeledStatement(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return visitWithStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return visitSwitchStatement(node); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return visitCaseBlock(node); - case 265 /* CaseClause */: + case 266 /* CaseClause */: return visitCaseClause(node); - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: return visitDefaultClause(node); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return visitTryStatement(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return visitCatchClause(node); - case 212 /* Block */: + case 213 /* Block */: return visitBlock(node); - case 302 /* MergeDeclarationMarker */: + case 303 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 303 /* EndOfDeclarationMarker */: + case 304 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -71087,7 +71404,7 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateFor(node, 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 = ts.updateFor(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)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -71131,9 +71448,6 @@ var ts; * @param node The node to visit. */ function visitForInitializer(node) { - if (!node) { - return node; - } if (shouldHoistForInitializer(node)) { var expressions = void 0; for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { @@ -71259,7 +71573,7 @@ var ts; */ function destructuringAndImportCallVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 199 /* BinaryExpression */) { + && node.kind === 200 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (ts.isImportCall(node)) { @@ -71324,7 +71638,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 273 /* SourceFile */; + return container !== undefined && container.kind === 274 /* SourceFile */; } else { return false; @@ -71357,7 +71671,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -71405,7 +71719,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -71441,10 +71755,10 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return substituteBinaryExpression(node); - case 197 /* PrefixUnaryExpression */: - case 198 /* PostfixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -71537,14 +71851,14 @@ var ts; && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 198 /* PostfixUnaryExpression */ + var expression = node.kind === 199 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(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 === 198 /* PostfixUnaryExpression */) { + if (node.kind === 199 /* PostfixUnaryExpression */) { expression = node.operator === 43 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); @@ -71566,7 +71880,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 273 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 274 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -71605,7 +71919,7 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(273 /* SourceFile */); + context.enableEmitNotification(274 /* SourceFile */); context.enableSubstitution(71 /* Identifier */); var currentSourceFile; return ts.chainBundle(transformSourceFile); @@ -71634,10 +71948,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -71744,7 +72058,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 === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* 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 : @@ -71773,7 +72087,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 === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* 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 : @@ -71817,10 +72131,10 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); + 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 === 231 /* VariableDeclaration */ || node.kind === 181 /* BindingElement */) { + if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* 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 : @@ -71829,8 +72143,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 === 151 /* PropertyDeclaration */ || node.kind === 150 /* PropertySignature */ || - (node.kind === 148 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 152 /* PropertyDeclaration */ || node.kind === 151 /* PropertySignature */ || + (node.kind === 149 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -71839,7 +72153,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 === 234 /* ClassDeclaration */ || node.kind === 148 /* Parameter */) { + else if (node.parent.kind === 235 /* ClassDeclaration */ || node.kind === 149 /* 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 : @@ -71864,7 +72178,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 156 /* SetAccessor */) { + if (node.kind === 157 /* 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.hasModifier(node, 32 /* Static */)) { @@ -71903,26 +72217,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 158 /* ConstructSignature */: + case 159 /* 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 157 /* CallSignature */: + case 158 /* 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 159 /* IndexSignature */: + case 160 /* 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 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -71930,7 +72244,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 === 234 /* ClassDeclaration */) { + else if (node.parent.kind === 235 /* 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 : @@ -71944,7 +72258,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 233 /* FunctionDeclaration */: + case 234 /* 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 : @@ -71952,7 +72266,7 @@ var ts; ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; break; default: - ts.Debug.fail("This is unknown kind for signature: " + node.kind); + return ts.Debug.fail("This is unknown kind for signature: " + node.kind); } return { diagnosticMessage: diagnosticMessage, @@ -71969,30 +72283,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 154 /* Constructor */: + case 155 /* 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 158 /* ConstructSignature */: - case 163 /* ConstructorType */: + case 159 /* ConstructSignature */: + case 164 /* 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 157 /* CallSignature */: + case 158 /* 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 159 /* IndexSignature */: + case 160 /* 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 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -72000,7 +72314,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 === 234 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 235 /* 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 : @@ -72013,53 +72327,53 @@ 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 233 /* FunctionDeclaration */: - case 162 /* FunctionType */: + case 234 /* FunctionDeclaration */: + case 163 /* 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; default: - ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* CallSignature */: + case 158 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.hasModifier(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 === 234 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 235 /* 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 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: - ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); + return ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); } return { diagnosticMessage: diagnosticMessage, @@ -72070,7 +72384,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 234 /* ClassDeclaration */) { + if (node.parent.parent.kind === 235 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = node.parent.token === 108 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -72222,16 +72536,16 @@ var ts; } } function transformRoot(node) { - if (node.kind === 273 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { + if (node.kind === 274 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJavaScript(node))) { return node; } - if (node.kind === 274 /* Bundle */) { + if (node.kind === 275 /* Bundle */) { isBundledEmit = true; var refs_1 = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { if (sourceFile.isDeclarationFile || ts.isSourceFileJavaScript(sourceFile)) - return; // Omit declaration files from bundle results, too + return undefined; // Omit declaration files from bundle results, too // TODO: GH#18217 hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; enclosingDeclaration = sourceFile; @@ -72253,7 +72567,7 @@ var ts; var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 276 /* InputFiles */) { + if (prepend.kind === 277 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend.declarationText); } })); @@ -72351,7 +72665,7 @@ var ts; return name; } else { - if (name.kind === 180 /* ArrayBindingPattern */) { + if (name.kind === 181 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -72359,7 +72673,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 205 /* OmittedExpression */) { + if (elem.kind === 206 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -72397,7 +72711,7 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 148 /* Parameter */ && + var shouldUseResolverType = node.kind === 149 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { @@ -72406,7 +72720,7 @@ var ts; if (!ts.getParseTreeNode(node)) { return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(119 /* AnyKeyword */); } - if (node.kind === 156 /* SetAccessor */) { + if (node.kind === 157 /* 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 ts.createKeywordTypeNode(119 /* AnyKeyword */); @@ -72417,12 +72731,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 231 /* VariableDeclaration */ || node.kind === 181 /* BindingElement */) { + if (node.kind === 232 /* VariableDeclaration */ || node.kind === 182 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 148 /* Parameter */ - || node.kind === 151 /* PropertyDeclaration */ - || node.kind === 150 /* PropertySignature */) { + if (node.kind === 149 /* Parameter */ + || node.kind === 152 /* PropertyDeclaration */ + || node.kind === 151 /* 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)); @@ -72439,20 +72753,20 @@ var ts; function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 238 /* ModuleDeclaration */: - case 235 /* InterfaceDeclaration */: - case 234 /* ClassDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 237 /* EnumDeclaration */: + case 234 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 236 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 238 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 242 /* ImportEqualsDeclaration */: - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: - case 248 /* ExportAssignment */: + case 243 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: + case 249 /* ExportAssignment */: return false; } return false; @@ -72463,7 +72777,7 @@ var ts; } if (ts.isBindingPattern(elem.name)) { // If any child binding pattern element has been marked visible (usually by collect linked aliases), then this is visible - return ts.forEach(elem.name.elements, getBindingNameVisible); + return ts.some(elem.name.elements, getBindingNameVisible); } else { return resolver.isDeclarationVisible(elem); @@ -72471,11 +72785,11 @@ var ts; } function updateParamsList(node, params, modifierMask) { if (ts.hasModifier(node, 8 /* Private */)) { - return undefined; + return undefined; // TODO: GH#18217 } var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); }); if (!newParams) { - return undefined; + return undefined; // TODO: GH#18217 } return ts.createNodeArray(newParams, params.hasTrailingComma); } @@ -72505,8 +72819,8 @@ var ts; } function rewriteModuleSpecifier(parent, input) { if (!input) - return; - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 238 /* ModuleDeclaration */ && parent.kind !== 178 /* ImportType */); + return undefined; // TODO: GH#18217 + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 239 /* ModuleDeclaration */ && parent.kind !== 179 /* ImportType */); if (input.kind === 9 /* StringLiteral */ && isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); if (newName) { @@ -72518,7 +72832,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 253 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 254 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -72545,7 +72859,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 245 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 246 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -72650,66 +72964,68 @@ var ts; checkEntityNameVisibility(input.exprName, enclosingDeclaration); } var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 165 /* TypeLiteral */ || input.kind === 176 /* MappedType */) && input.parent.kind !== 236 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 166 /* TypeLiteral */ || input.kind === 177 /* MappedType */) && input.parent.kind !== 237 /* TypeAliasDeclaration */); if (shouldEnterSuppressNewDiagnosticsContextContext) { // We stop making new diagnostic contexts within object literal types. Unless it's an object type on the RHS of a type alias declaration. Then we do. suppressNewDiagnosticContexts = true; } if (isProcessedComponent(input)) { switch (input.kind) { - case 206 /* ExpressionWithTypeArguments */: { + case 207 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 161 /* TypeReference */: { + case 162 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 154 /* Constructor */: { + case 155 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(154 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), + var ctor = ts.createSignatureDeclaration(155 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + // TODO: GH#18217 + isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 153 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(152 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 154 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(153 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 155 /* GetAccessor */: { + case 156 /* GetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 156 /* SetAccessor */: { + case 157 /* SetAccessor */: { var newNode = ensureAccessor(input); return cleanup(newNode); } - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 150 /* PropertySignature */: + case 151 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 152 /* MethodSignature */: { + case 153 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 157 /* CallSignature */: { + case 158 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 159 /* IndexSignature */: { + case 160 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(119 /* AnyKeyword */))); } - case 231 /* VariableDeclaration */: { + case 232 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -72717,13 +73033,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(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 147 /* TypeParameter */: { + case 148 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 170 /* ConditionalType */: { + case 171 /* 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); @@ -72735,13 +73051,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 162 /* FunctionType */: { + case 163 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 163 /* ConstructorType */: { + case 164 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 178 /* ImportType */: { + case 179 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -72770,7 +73086,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 153 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 154 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -72780,7 +73096,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ExportDeclaration */: { + case 250 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; resultHasScopeMarker = true; @@ -72789,7 +73105,7 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 248 /* ExportAssignment */: { + case 249 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; @@ -72819,10 +73135,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 242 /* ImportEqualsDeclaration */: { + case 243 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 243 /* ImportDeclaration */: { + case 244 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -72843,24 +73159,24 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 236 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 237 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 235 /* InterfaceDeclaration */: { + case 236 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 233 /* FunctionDeclaration */: { + case 234 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type return cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input, isPrivate), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), /*body*/ undefined)); } - case 238 /* ModuleDeclaration */: { + case 239 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 239 /* ModuleBlock */) { + if (inner && inner.kind === 240 /* ModuleBlock */) { var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var body = ts.updateModuleBlock(inner, transformAndReplaceLatePaintedStatements(statements)); needsDeclare = previousNeedsDeclare; @@ -72874,14 +73190,14 @@ var ts; needsDeclare = false; ts.visitNode(inner, visitDeclarationStatements); // eagerly transform nested namespaces (the nesting doesn't need any elision or painting done) - var id = "" + ts.getOriginalNodeId(inner); + var id = "" + ts.getOriginalNodeId(inner); // TODO: GH#18217 var body = lateStatementReplacementMap.get(id); lateStatementReplacementMap.delete(id); return cleanup(ts.updateModuleDeclaration(input, /*decorators*/ undefined, mods, input.name, body)); } } - case 234 /* ClassDeclaration */: { + case 235 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input, isPrivate)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -72924,7 +73240,7 @@ var ts; var extendsClause_1 = ts.getClassExtendsHeritageClauseElement(input); if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 95 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression - var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); + var newId_1 = ts.createOptimisticUniqueName(ts.unescapeLeadingUnderscores(input.name.escapedText) + "_base"); // TODO: GH#18217 getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, @@ -72943,7 +73259,7 @@ var ts; return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 95 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, - /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; + /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 } else { var heritageClauses = transformHeritageClauses(input.heritageClauses); @@ -72951,10 +73267,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 213 /* VariableStatement */: { + case 214 /* VariableStatement */: { return cleanup(transformVariableStatement(input, isPrivate)); } - case 237 /* EnumDeclaration */: { + case 238 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input, isPrivate)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -72973,7 +73289,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 238 /* ModuleDeclaration */) { + if (input.kind === 239 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -72994,7 +73310,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 205 /* OmittedExpression */) { + if (e.kind === 206 /* OmittedExpression */) { return; } if (e.name) { @@ -73048,7 +73364,7 @@ var ts; function ensureModifierFlags(node, privateDeclaration) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 273 /* SourceFile */; + var parentIsFile = node.parent.kind === 274 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= ((privateDeclaration || (isBundledEmit && parentIsFile) ? 0 : 1 /* Export */) | 512 /* Default */ | 2 /* Ambient */); additions = 0 /* None */; @@ -73096,7 +73412,7 @@ var ts; } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 235 /* InterfaceDeclaration */) { + if (node.kind === 236 /* InterfaceDeclaration */) { return true; } return false; @@ -73116,7 +73432,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 155 /* GetAccessor */ + return accessor.kind === 156 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -73125,51 +73441,51 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 231 /* VariableDeclaration */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 148 /* Parameter */: + case 232 /* VariableDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 149 /* Parameter */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 238 /* ModuleDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 235 /* InterfaceDeclaration */: - case 234 /* ClassDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 237 /* EnumDeclaration */: - case 213 /* VariableStatement */: - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: - case 248 /* ExportAssignment */: + case 234 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 236 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 238 /* EnumDeclaration */: + case 214 /* VariableStatement */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: + case 249 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 158 /* ConstructSignature */: - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 159 /* IndexSignature */: - case 231 /* VariableDeclaration */: - case 147 /* TypeParameter */: - case 206 /* ExpressionWithTypeArguments */: - case 161 /* TypeReference */: - case 170 /* ConditionalType */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 178 /* ImportType */: + case 159 /* ConstructSignature */: + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 160 /* IndexSignature */: + case 232 /* VariableDeclaration */: + case 148 /* TypeParameter */: + case 207 /* ExpressionWithTypeArguments */: + case 162 /* TypeReference */: + case 171 /* ConditionalType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 179 /* ImportType */: return true; } return false; @@ -73245,7 +73561,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(304 /* Count */); + var enabledSyntaxKindFeatures = new Array(305 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -73554,7 +73870,7 @@ var ts; * @param sourceFileOrBundle The input source file or bundle for the program. */ function initialize(filePath, sourceMapFilePath, sourceFileOrBundle, outputSourceMapDataList) { - if (disabled) { + if (disabled || ts.fileExtensionIs(filePath, ".json" /* Json */)) { return; } if (sourceMapData) { @@ -73590,7 +73906,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 273 /* SourceFile */) { // emitting single module file + if (sourceFileOrBundle.kind === 274 /* SourceFile */) { // emitting single module file // For modules or multiple emit files the mapRoot will have directory structure like the sources // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); @@ -73677,7 +73993,7 @@ var ts; * @param pos The position. */ function emitPos(pos) { - if (disabled || ts.positionIsSynthesized(pos)) { + if (disabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(currentSource)) { return; } if (extendedDiagnostics) { @@ -73726,12 +74042,12 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithSourceMap(hint, node, emitCallback) { - if (disabled) { + if (disabled || ts.isInJsonFile(node)) { return emitCallback(hint, node); } if (node) { var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0 /* None */; var range = emitNode && emitNode.sourceMapRange; var _a = range || node, pos = _a.pos, end = _a.end; var source = range && range.source; @@ -73740,7 +74056,7 @@ var ts; source = undefined; if (source) setSourceFile(source); - if (node.kind !== 299 /* NotEmittedStatement */ + if (node.kind !== 300 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(skipSourceTrivia(pos)); @@ -73757,7 +74073,7 @@ var ts; } if (source) setSourceFile(source); - if (node.kind !== 299 /* NotEmittedStatement */ + if (node.kind !== 300 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -73775,11 +74091,11 @@ var ts; * @param emitCallback The callback used to emit the token. */ function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) { - if (disabled) { + if (disabled || ts.isInJsonFile(node)) { return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0 /* None */; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; tokenPos = skipSourceTrivia(range ? range.pos : tokenPos); if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { @@ -73793,6 +74109,9 @@ var ts; } return tokenPos; } + function isJsonSourceMapSource(sourceFile) { + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + } /** * Set the current source file. * @@ -73804,6 +74123,9 @@ var ts; } currentSource = sourceFile; currentSourceText = currentSource.text; + if (isJsonSourceMapSource(sourceFile)) { + return; + } // Add the file to tsFilePaths // If sourceroot option: Use the relative path corresponding to the common directory path // otherwise source locations relative to map file location @@ -73825,8 +74147,8 @@ var ts; * Gets the text for the source map. */ function getText() { - if (disabled) { - return; + if (disabled || isJsonSourceMapSource(currentSource)) { + return undefined; // TODO: GH#18217 } encodeLastRecordedSourceMapSpan(); return JSON.stringify({ @@ -73843,8 +74165,8 @@ var ts; * Gets the SourceMappingURL for the source map. */ function getSourceMappingURL() { - if (disabled) { - return; + if (disabled || isJsonSourceMapSource(currentSource)) { + return undefined; // TODO: GH#18217 } if (compilerOptions.inlineSourceMap) { // Encode the sourceMap into the sourceMap url @@ -73905,7 +74227,7 @@ var ts; var currentLineMap; var detachedCommentsInfo; var hasWrittenComment = false; - var disabled = printerOptions.removeComments; + var disabled = !!printerOptions.removeComments; return { reset: reset, setWriter: setWriter, @@ -73923,7 +74245,7 @@ var ts; if (node) { hasWrittenComment = false; var emitNode = node.emitNode; - var emitFlags = emitNode && emitNode.flags; + var emitFlags = emitNode && emitNode.flags || 0; var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; if ((pos < 0 && end < 0) || (pos === end)) { // Both pos and end are synthesized, so just emit the node without comments. @@ -73933,7 +74255,7 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 299 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 300 /* 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 === 10 /* JsxText */; @@ -73954,7 +74276,7 @@ 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 === 232 /* VariableDeclarationList */) { + if (node.kind === 233 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -74211,11 +74533,11 @@ var ts; detachedCommentsInfo = undefined; } function hasDetachedComments(pos) { - return detachedCommentsInfo !== undefined && ts.lastOrUndefined(detachedCommentsInfo).nodePos === pos; + return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos; } function forEachLeadingCommentWithoutDetachedComments(cb) { // get the leading comments from detachedPos - var pos = ts.lastOrUndefined(detachedCommentsInfo).detachedCommentEndPos; + var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos; if (detachedCommentsInfo.length - 1) { detachedCommentsInfo.pop(); } @@ -74270,6 +74592,7 @@ var ts; * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles) { + if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { @@ -74295,17 +74618,17 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 274 /* Bundle */) { + if (sourceFile.kind === 275 /* Bundle */) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || options.declaration) ? ts.removeFileExtension(jsFilePath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var bundleInfoPath = options.references && jsFilePath && (ts.removeFileExtension(jsFilePath) + infoExtension); + var bundleInfoPath = options.references && jsFilePath ? (ts.removeFileExtension(jsFilePath) + infoExtension) : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, bundleInfoPath: bundleInfoPath }; } else { var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, getOutputExtension(sourceFile, options)); - var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); + var sourceMapFilePath = ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error var isJs = ts.isSourceFileJavaScript(sourceFile); var declarationFilePath = ((forceDtsPaths || options.declaration) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile, host) : undefined; @@ -74371,7 +74694,7 @@ var ts; emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), emittedFiles: emittedFilesList, - sourceMaps: sourceMapDataList + sourceMaps: sourceMapDataList, }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, bundleInfoPath = _a.bundleInfoPath; @@ -74458,8 +74781,8 @@ var ts; declarationTransform.dispose(); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, bundleInfoPath, printer, mapRecorder) { - var bundle = sourceFileOrBundle.kind === 274 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 273 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 275 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 274 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; mapRecorder.initialize(jsFilePath, sourceMapFilePath || "", sourceFileOrBundle, sourceMapDataList); if (bundle) { @@ -74478,7 +74801,7 @@ var ts; ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, mapRecorder.getText(), /*writeByteOrderMark*/ false, sourceFiles); } // Write the output file - ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); + ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles); // Write bundled offset information if applicable if (bundleInfoPath) { bundleInfo.totalLength = writer.getTextPos(); @@ -74559,9 +74882,9 @@ var ts; break; } switch (node.kind) { - case 273 /* SourceFile */: return printFile(node); - case 274 /* Bundle */: return printBundle(node); - case 275 /* UnparsedSource */: return printUnparsedSource(node); + case 274 /* SourceFile */: return printFile(node); + case 275 /* Bundle */: return printBundle(node); + case 276 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -74662,7 +74985,7 @@ var ts; } } function setWriter(output) { - writer = output; + writer = output; // TODO: GH#18217 comments.setWriter(output); } function reset() { @@ -74720,8 +75043,7 @@ var ts; return getPipelinePhase(currentPhase + 1, hint); } function pipelineEmitWithNotification(hint, node) { - ts.Debug.assertDefined(onEmitNode); - onEmitNode(hint, node, getNextPipelinePhase(0 /* Notification */, hint)); + ts.Debug.assertDefined(onEmitNode)(hint, node, getNextPipelinePhase(0 /* Notification */, hint)); } function pipelineEmitWithComments(hint, node) { ts.Debug.assertDefined(emitNodeWithComments); @@ -74733,9 +75055,8 @@ var ts; pipelinePhase(hint, trySubstituteNode(hint, node)); } function pipelineEmitWithSourceMap(hint, node) { - ts.Debug.assertDefined(onEmitSourceMapOfNode); ts.Debug.assert(hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */); - onEmitSourceMapOfNode(hint, node, pipelineEmitWithHint); + ts.Debug.assertDefined(onEmitSourceMapOfNode)(hint, node, pipelineEmitWithHint); } function pipelineEmitWithHint(hint, node) { if (hint === 0 /* SourceFile */) @@ -74753,235 +75074,235 @@ var ts; case 15 /* TemplateMiddle */: case 16 /* TemplateTail */: return emitLiteral(node); - case 275 /* UnparsedSource */: + case 276 /* UnparsedSource */: return emitUnparsedSource(node); // Identifiers case 71 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: return emitQualifiedName(node); - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return emitTypeParameter(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return emitParameter(node); - case 149 /* Decorator */: + case 150 /* Decorator */: return emitDecorator(node); // Type members - case 150 /* PropertySignature */: + case 151 /* PropertySignature */: return emitPropertySignature(node); - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 152 /* MethodSignature */: + case 153 /* MethodSignature */: return emitMethodSignature(node); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return emitConstructor(node); - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return emitAccessorDeclaration(node); - case 157 /* CallSignature */: + case 158 /* CallSignature */: return emitCallSignature(node); - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: return emitConstructSignature(node); - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: return emitIndexSignature(node); // Types - case 160 /* TypePredicate */: + case 161 /* TypePredicate */: return emitTypePredicate(node); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return emitTypeReference(node); - case 162 /* FunctionType */: + case 163 /* FunctionType */: return emitFunctionType(node); - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 163 /* ConstructorType */: + case 164 /* ConstructorType */: return emitConstructorType(node); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return emitTypeQuery(node); - case 165 /* TypeLiteral */: + case 166 /* TypeLiteral */: return emitTypeLiteral(node); - case 166 /* ArrayType */: + case 167 /* ArrayType */: return emitArrayType(node); - case 167 /* TupleType */: + case 168 /* TupleType */: return emitTupleType(node); - case 168 /* UnionType */: + case 169 /* UnionType */: return emitUnionType(node); - case 169 /* IntersectionType */: + case 170 /* IntersectionType */: return emitIntersectionType(node); - case 170 /* ConditionalType */: + case 171 /* ConditionalType */: return emitConditionalType(node); - case 171 /* InferType */: + case 172 /* InferType */: return emitInferType(node); - case 172 /* ParenthesizedType */: + case 173 /* ParenthesizedType */: return emitParenthesizedType(node); - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 173 /* ThisType */: + case 174 /* ThisType */: return emitThisType(); - case 174 /* TypeOperator */: + case 175 /* TypeOperator */: return emitTypeOperator(node); - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 176 /* MappedType */: + case 177 /* MappedType */: return emitMappedType(node); - case 177 /* LiteralType */: + case 178 /* LiteralType */: return emitLiteralType(node); - case 178 /* ImportType */: + case 179 /* ImportType */: return emitImportTypeNode(node); - case 278 /* JSDocAllType */: + case 279 /* JSDocAllType */: write("*"); return; - case 279 /* JSDocUnknownType */: + case 280 /* JSDocUnknownType */: write("?"); return; - case 280 /* JSDocNullableType */: + case 281 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 281 /* JSDocNonNullableType */: + case 282 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 282 /* JSDocOptionalType */: + case 283 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: return emitJSDocVariadicType(node); // Binding patterns - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return emitBindingElement(node); // Misc - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return emitTemplateSpan(node); - case 211 /* SemicolonClassElement */: + case 212 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 212 /* Block */: + case 213 /* Block */: return emitBlock(node); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return emitVariableStatement(node); - case 214 /* EmptyStatement */: + case 215 /* EmptyStatement */: return emitEmptyStatement(); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return emitExpressionStatement(node); - case 216 /* IfStatement */: + case 217 /* IfStatement */: return emitIfStatement(node); - case 217 /* DoStatement */: + case 218 /* DoStatement */: return emitDoStatement(node); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: return emitWhileStatement(node); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return emitForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: return emitForInStatement(node); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: return emitForOfStatement(node); - case 222 /* ContinueStatement */: + case 223 /* ContinueStatement */: return emitContinueStatement(node); - case 223 /* BreakStatement */: + case 224 /* BreakStatement */: return emitBreakStatement(node); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: return emitReturnStatement(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: return emitWithStatement(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return emitSwitchStatement(node); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: return emitLabeledStatement(node); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: return emitThrowStatement(node); - case 229 /* TryStatement */: + case 230 /* TryStatement */: return emitTryStatement(node); - case 230 /* DebuggerStatement */: + case 231 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return emitClassDeclaration(node); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return emitModuleBlock(node); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return emitCaseBlock(node); - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return emitImportDeclaration(node); - case 244 /* ImportClause */: + case 245 /* ImportClause */: return emitImportClause(node); - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: return emitNamespaceImport(node); - case 246 /* NamedImports */: + case 247 /* NamedImports */: return emitNamedImports(node); - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: return emitImportSpecifier(node); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: return emitExportAssignment(node); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: return emitExportDeclaration(node); - case 250 /* NamedExports */: + case 251 /* NamedExports */: return emitNamedExports(node); - case 251 /* ExportSpecifier */: + case 252 /* ExportSpecifier */: return emitExportSpecifier(node); - case 252 /* MissingDeclaration */: + case 253 /* MissingDeclaration */: return; // Module references - case 253 /* ExternalModuleReference */: + case 254 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 256 /* JsxOpeningElement */: - case 259 /* JsxOpeningFragment */: + case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 257 /* JsxClosingElement */: - case 260 /* JsxClosingFragment */: + case 258 /* JsxClosingElement */: + case 261 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return emitJsxAttribute(node); - case 262 /* JsxAttributes */: + case 263 /* JsxAttributes */: return emitJsxAttributes(node); - case 263 /* JsxSpreadAttribute */: + case 264 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 264 /* JsxExpression */: + case 265 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 265 /* CaseClause */: + case 266 /* CaseClause */: return emitCaseClause(node); - case 266 /* DefaultClause */: + case 267 /* DefaultClause */: return emitDefaultClause(node); - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: return emitHeritageClause(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 270 /* ShorthandPropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 271 /* SpreadAssignment */: + case 272 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 272 /* EnumMember */: + case 273 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (ignored) // Transformation nodes (ignored) @@ -75016,71 +75337,71 @@ var ts; writeTokenNode(node, writeKeyword); return; // Expressions - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 186 /* CallExpression */: + case 187 /* CallExpression */: return emitCallExpression(node); - case 187 /* NewExpression */: + case 188 /* NewExpression */: return emitNewExpression(node); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return emitFunctionExpression(node); - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return emitArrowFunction(node); - case 193 /* DeleteExpression */: + case 194 /* DeleteExpression */: return emitDeleteExpression(node); - case 194 /* TypeOfExpression */: + case 195 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 195 /* VoidExpression */: + case 196 /* VoidExpression */: return emitVoidExpression(node); - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: return emitAwaitExpression(node); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return emitBinaryExpression(node); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return emitConditionalExpression(node); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: return emitTemplateExpression(node); - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: return emitYieldExpression(node); - case 203 /* SpreadElement */: + case 204 /* SpreadElement */: return emitSpreadExpression(node); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return emitClassExpression(node); - case 205 /* OmittedExpression */: + case 206 /* OmittedExpression */: return; - case 207 /* AsExpression */: + case 208 /* AsExpression */: return emitAsExpression(node); - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: return emitNonNullExpression(node); - case 209 /* MetaProperty */: + case 210 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 254 /* JsxElement */: + case 255 /* JsxElement */: return emitJsxElement(node); - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 258 /* JsxFragment */: + case 259 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 300 /* PartiallyEmittedExpression */: + case 301 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 301 /* CommaListExpression */: + case 302 /* CommaListExpression */: return emitCommaList(node); } } @@ -75097,7 +75418,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 274 /* Bundle */ ? node : undefined; + var bundle = node.kind === 275 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -75223,7 +75544,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 283 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 284 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -75285,7 +75606,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 155 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 156 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -75542,7 +75863,7 @@ var ts; increaseIndent(); } var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ ? 32 /* AllowTrailingComma */ : 0 /* None */; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 32 /* AllowTrailingComma */ : 0 /* None */; emitList(node, node.properties, 263122 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); @@ -75682,7 +76003,7 @@ 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 === 197 /* PrefixUnaryExpression */ + return operand.kind === 198 /* PrefixUnaryExpression */ && ((node.operator === 37 /* PlusToken */ && (operand.operator === 37 /* PlusToken */ || operand.operator === 43 /* PlusPlusToken */)) || (node.operator === 38 /* MinusToken */ && (operand.operator === 38 /* MinusToken */ || operand.operator === 44 /* MinusMinusToken */))); } @@ -75802,7 +76123,7 @@ var ts; if (node.elseStatement) { writeLineOrSpace(node); emitTokenWithComment(82 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 216 /* IfStatement */) { + if (node.elseStatement.kind === 217 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -75865,7 +76186,7 @@ var ts; emitTokenWithComment(19 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(144 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(145 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(20 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -75873,7 +76194,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 232 /* VariableDeclarationList */) { + if (node.kind === 233 /* VariableDeclarationList */) { emit(node); } else { @@ -75988,7 +76309,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); + emitIdentifierName(node.name); // TODO: GH#18217 emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -76168,7 +76489,7 @@ var ts; var body = node.body; if (!body) return writeSemicolon(); - while (body.kind === 238 /* ModuleDeclaration */) { + while (body.kind === 239 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -76213,7 +76534,7 @@ var ts; if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(142 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(143 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -76265,7 +76586,7 @@ var ts; if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(142 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(143 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -76357,7 +76678,7 @@ var ts; } function emitJsxAttribute(node) { emit(node.name); - emitNodeWithPrefix("=", writePunctuation, node.initializer, emit); + emitNodeWithPrefix("=", writePunctuation, node.initializer, emit); // TODO: GH#18217 } function emitJsxSpreadAttribute(node) { writePunctuation("{..."); @@ -76491,7 +76812,7 @@ var ts; emitSourceFileWorker(node); } function emitSyntheticTripleSlashReferencesIfNeeded(node) { - emitTripleSlashDirectives(node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || []); + emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || []); } function emitTripleSlashDirectivesIfNeeded(node) { if (node.isDeclarationFile) @@ -76719,7 +77040,7 @@ var ts; emitNodeList(emit, parentNode, children, format, start, count); } function emitExpressionList(parentNode, children, format, start, count) { - emitNodeList(emitExpression, parentNode, children, format, start, count); + emitNodeList(emitExpression, parentNode, children, format, start, count); // TODO: GH#18217 } function writeDelimiter(format) { switch (format & 28 /* DelimitersMask */) { @@ -76745,7 +77066,7 @@ var ts; if (isUndefined && format & 8192 /* OptionalIfUndefined */) { return; } - var isEmpty = isUndefined || start >= children.length || count === 0; + var isEmpty = children === undefined || start >= children.length || count === 0; if (isEmpty && format & 16384 /* OptionalIfEmpty */) { if (onBeforeEmitNodeArray) { onBeforeEmitNodeArray(children); @@ -76758,6 +77079,7 @@ var ts; if (format & 7680 /* BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && !isUndefined) { + // TODO: GH#18217 emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists } } @@ -76777,7 +77099,7 @@ var ts; // Write the opening line terminator or leading whitespace. var mayEmitInterveningComments = (format & 131072 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; - if (shouldWriteLeadingLineTerminator(parentNode, children, format)) { + if (shouldWriteLeadingLineTerminator(parentNode, children, format)) { // TODO: GH#18217 writeLine(); shouldEmitInterveningComments = false; } @@ -76790,7 +77112,7 @@ var ts; } // Emit each child. var previousSibling = void 0; - var shouldDecreaseIndentAfterEmit = void 0; + var shouldDecreaseIndentAfterEmit = false; for (var i = 0; i < count; i++) { var child = children[start + i]; // Write the delimiter if this is not the first node. @@ -76868,6 +77190,7 @@ var ts; } if (format & 7680 /* BracketsMask */) { if (isEmpty && !isUndefined) { + // TODO: GH#18217 emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } writePunctuation(getClosingBracket(format)); @@ -77091,7 +77414,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 190 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 191 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -77156,81 +77479,81 @@ var ts; if (!node) return; switch (node.kind) { - case 212 /* Block */: + case 213 /* Block */: ts.forEach(node.statements, generateNames); break; - case 227 /* LabeledStatement */: - case 225 /* WithStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 228 /* LabeledStatement */: + case 226 /* WithStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: generateNames(node.statement); break; - case 216 /* IfStatement */: + case 217 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 219 /* ForStatement */: - case 221 /* ForOfStatement */: - case 220 /* ForInStatement */: + case 220 /* ForStatement */: + case 222 /* ForOfStatement */: + case 221 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 229 /* TryStatement */: + case 230 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 268 /* CatchClause */: + case 269 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: generateNames(node.declarationList); break; - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: - case 181 /* BindingElement */: - case 234 /* ClassDeclaration */: + case 232 /* VariableDeclaration */: + case 149 /* Parameter */: + case 182 /* BindingElement */: + case 235 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: generateNames(node.importClause); break; - case 244 /* ImportClause */: + case 245 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 246 /* NamedImports */: + case 247 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -77239,12 +77562,12 @@ var ts; if (!node) return; switch (node.kind) { - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -77396,7 +77719,7 @@ var ts; * Generates a unique name for an ImportDeclaration or ExportDeclaration. */ function generateNameForImportOrExportDeclaration(node) { - var expr = ts.getExternalModuleName(node); + var expr = ts.getExternalModuleName(node); // TODO: GH#18217 var baseName = ts.isStringLiteral(expr) ? ts.makeIdentifierFromModuleName(expr.text) : "module"; return makeUniqueName(baseName); @@ -77426,21 +77749,21 @@ var ts; switch (node.kind) { case 71 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - case 248 /* ExportAssignment */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 249 /* ExportAssignment */: return generateNameForExportDefault(); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: return generateNameForClassExpression(); - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); @@ -77458,7 +77781,7 @@ var ts; case 3 /* Unique */: return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* Optimistic */), !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); } - ts.Debug.fail("Unsupported GeneratedIdentifierKind."); + return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } /** * Gets the node from which a name should be generated. @@ -77921,8 +78244,8 @@ var ts; if (!outputFingerprints) { outputFingerprints = ts.createMap(); } - var hash = ts.sys.createHash(data); - var mtimeBefore = ts.sys.getModifiedTime(fileName); + var hash = ts.sys.createHash(data); // TODO: GH#18217 + var mtimeBefore = ts.sys.getModifiedTime(fileName); // TODO: GH#18217 if (mtimeBefore) { var fingerprint = outputFingerprints.get(fileName); // If output has not been changed, and the file has no external modification @@ -77934,7 +78257,7 @@ var ts; } } ts.sys.writeFile(fileName, data, writeByteOrderMark); - var mtimeAfter = ts.sys.getModifiedTime(fileName); + var mtimeAfter = ts.sys.getModifiedTime(fileName); // TODO: GH#18217 outputFingerprints.set(fileName, { hash: hash, byteOrderMark: writeByteOrderMark, @@ -78005,7 +78328,7 @@ var ts; function formatDiagnostic(diagnostic, host) { var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); if (diagnostic.file) { - var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; + var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; // TODO: GH#18217 var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; @@ -78052,7 +78375,7 @@ var ts; var context_2 = ""; if (diagnostic.file) { var start = diagnostic.start, length_4 = diagnostic.length, file_9 = diagnostic.file; - var _a = ts.getLineAndCharacterOfPosition(file_9, start), firstLine = _a.line, firstLineChar = _a.character; + var _a = ts.getLineAndCharacterOfPosition(file_9, start), firstLine = _a.line, firstLineChar = _a.character; // TODO: GH#18217 var _b = ts.getLineAndCharacterOfPosition(file_9, start + length_4), lastLine = _b.line, lastLineChar = _b.character; var lastLineInFile = ts.getLineAndCharacterOfPosition(file_9, file_9.text.length).line; var relativeFileName = host ? ts.convertToRelativePath(file_9.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file_9.fileName; @@ -78196,8 +78519,7 @@ var ts; } ts.isProgramUptoDate = isProgramUptoDate; function getConfigFileParsingDiagnostics(configFileParseResult) { - return configFileParseResult.options.configFile ? - configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : + return configFileParseResult.options.configFile ? configFileParseResult.options.configFile.parseDiagnostics.concat(configFileParseResult.errors) : configFileParseResult.errors; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; @@ -78228,9 +78550,9 @@ var ts; }; } function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) { - var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; + var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; - var host = createProgramOptions.host, oldProgram = createProgramOptions.oldProgram; + var oldProgram = createProgramOptions.oldProgram; var program; var files = []; var commonSourceDirectory; @@ -78257,7 +78579,7 @@ var ts; // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. var sourceFilesFoundSearchingNodeModules = ts.createMap(); ts.performance.mark("beforeProgram"); - host = host || createCompilerHost(options); + var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHost(host); var skipDefaultLib = options.noLib; var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); }); @@ -78285,7 +78607,7 @@ var ts; } else { moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }); - var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; + var loader_1 = function (moduleName, containingFile) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache).resolvedModule; }; // TODO: GH#18217 resolveModuleNamesWorker = function (moduleNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, loader_1); }; } var resolveTypeReferenceDirectiveNamesWorker; @@ -78293,7 +78615,7 @@ var ts; resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile); }; } else { - var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; + var loader_2 = function (typesRef, containingFile) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host).resolvedTypeReferenceDirective; }; // TODO: GH#18217 resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, loader_2); }; } // Map from a stringified PackageId to the source file with that id. @@ -78384,6 +78706,7 @@ var ts; getOptionsDiagnostics: getOptionsDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, getSemanticDiagnostics: getSemanticDiagnostics, + getSuggestionDiagnostics: getSuggestionDiagnostics, getDeclarationDiagnostics: getDeclarationDiagnostics, getTypeChecker: getTypeChecker, getClassifiableNames: getClassifiableNames, @@ -78427,7 +78750,7 @@ var ts; } else if (options.composite) { // Project compilations never infer their root from the input source paths - commonSourceDirectory = ts.getDirectoryPath(ts.normalizeSlashes(options.configFilePath)); + commonSourceDirectory = ts.getDirectoryPath(ts.normalizeSlashes(options.configFilePath)); // TODO: GH#18217 checkSourceFilesBelongToPath(emittedFiles, commonSourceDirectory); } else { @@ -78548,7 +78871,7 @@ var ts; // `result[i]` is either a `ResolvedModuleFull` or a marker. // If it is the former, we can leave it as is. if (result[i] === predictedToResolveToAmbientModuleMarker) { - result[i] = undefined; + result[i] = undefined; // TODO: GH#18217 } } else { @@ -78561,7 +78884,7 @@ var ts; // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState) { - var resolutionToFile = ts.getResolvedModule(oldProgramState.oldSourceFile, moduleName); + var resolutionToFile = ts.getResolvedModule(oldProgramState.oldSourceFile, moduleName); // TODO: GH#18217 var resolvedFile = resolutionToFile && oldProgramState.program && oldProgramState.program.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile && !resolvedFile.externalModuleIndicator) { // In the old program, we resolved to an ambient module that was in the same @@ -78657,7 +78980,7 @@ var ts; var oldSourceFile = oldSourceFiles_2[_i]; var newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.path, options.target, /*onError*/ undefined, shouldCreateNewSourceFile) - : host.getSourceFile(oldSourceFile.fileName, options.target, /*onError*/ undefined, shouldCreateNewSourceFile); + : host.getSourceFile(oldSourceFile.fileName, options.target, /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 if (!newSourceFile) { return oldProgram.structureIsReused = 0 /* Not */; } @@ -78843,7 +79166,7 @@ var ts; return nodes; } function isSourceFileFromExternalLibrary(file) { - return sourceFilesFoundSearchingNodeModules.get(file.path); + return !!sourceFilesFoundSearchingNodeModules.get(file.path); } function isSourceFileDefaultLibrary(file) { if (file.hasNoDefaultLib) { @@ -78859,7 +79182,7 @@ var ts; return equalityComparer(file.fileName, getDefaultLibraryFileName()); } else { - return ts.forEach(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); }); + return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); }); } } function getDiagnosticsProducingTypeChecker() { @@ -78912,7 +79235,8 @@ var ts; var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(options, customTransformers); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, // TODO: GH#18217 + emitOnlyDtsFiles, transformers, customTransformers && customTransformers.afterDeclarations); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -79003,11 +79327,24 @@ var ts; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); - if (isCheckJs) { - diagnostics = ts.concatenate(diagnostics, sourceFile.jsDocDiagnostics); + var diagnostics; + for (var _i = 0, _a = [bindDiagnostics, checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile, isCheckJs ? sourceFile.jsDocDiagnostics : undefined]; _i < _a.length; _i++) { + var diags = _a[_i]; + if (diags) { + for (var _b = 0, diags_1 = diags; _b < diags_1.length; _b++) { + var diag = diags_1[_b]; + if (shouldReportDiagnostic(diag)) { + diagnostics = ts.append(diagnostics, diag); + } + } + } } - return ts.filter(diagnostics, shouldReportDiagnostic); + return diagnostics; + }); + } + function getSuggestionDiagnostics(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken); }); } /** @@ -79017,7 +79354,7 @@ var ts; var file = diagnostic.file, start = diagnostic.start; if (file) { var lineStarts = ts.getLineStarts(file); - var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line; + var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line; // TODO: GH#18217 while (line > 0) { var previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]); var result = ignoreDiagnosticCommentRegEx.exec(previousLineText); @@ -79044,22 +79381,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 148 /* Parameter */: - case 151 /* PropertyDeclaration */: + case 149 /* Parameter */: + case 152 /* PropertyDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: - case 231 /* VariableDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: + case 232 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -79067,41 +79404,41 @@ var ts; } } switch (node.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 267 /* HeritageClause */: + case 268 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 108 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 208 /* NonNullExpression */: + case 209 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 207 /* AsExpression */: + case 208 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -79114,28 +79451,28 @@ 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_to_remove_this_warning)); } switch (parent.kind) { - case 234 /* ClassDeclaration */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: + case 235 /* ClassDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 213 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 214 /* VariableStatement */); } break; - case 151 /* PropertyDeclaration */: + case 152 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { @@ -79147,18 +79484,18 @@ var ts; return; } break; - case 148 /* Parameter */: + case 149 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 206 /* ExpressionWithTypeArguments */: - case 255 /* JsxSelfClosingElement */: - case 256 /* JsxOpeningElement */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 207 /* ExpressionWithTypeArguments */: + case 256 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -79224,7 +79561,7 @@ var ts; if (cachedResult) { return cachedResult; } - var result = getDiagnostics(sourceFile, cancellationToken) || ts.emptyArray; + var result = getDiagnostics(sourceFile, cancellationToken) || ts.emptyArray; // TODO: GH#18217 if (sourceFile) { if (!cache.perFile) { cache.perFile = ts.createMap(); @@ -79404,7 +79741,8 @@ var ts; } /** This has side effects through `findSourceFile`. */ function processSourceFile(fileName, isDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId); }, function (diagnostic) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; @@ -79496,7 +79834,7 @@ var ts; if (fileFromPackageId) { // Some other SourceFile already exists with this package name and version. // Instead of creating a duplicate, just redirect to the existing one. - var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path); + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path); // TODO: GH#18217 redirectTargetsSet.set(fileFromPackageId.path, true); filesByName.set(path, dupFile); sourceFileToPackageName.set(path, packageId.name); @@ -79591,7 +79929,7 @@ var ts; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -79601,7 +79939,8 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 + ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -79614,7 +79953,7 @@ var ts; } } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); + fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -79718,7 +80057,7 @@ var ts; } function parseProjectReferenceConfigFile(ref) { // The actual filename (i.e. add "/tsconfig.json" if necessary) - var refPath = resolveProjectReferencePath(host, ref); + var refPath = resolveProjectReferencePath(host, ref); // TODO: GH#18217 // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); var sourceFile = host.getSourceFile(refPath, 100 /* JSON */); @@ -79729,13 +80068,13 @@ var ts; return { commandLine: commandLine, sourceFile: sourceFile }; } function addProjectReferenceRedirects(referencedProject, target) { - var rootDir = ts.normalizePath(referencedProject.options.rootDir || ts.getDirectoryPath(referencedProject.options.configFilePath)); + var rootDir = ts.normalizePath(referencedProject.options.rootDir || ts.getDirectoryPath(referencedProject.options.configFilePath)); // TODO: GH#18217 target.set(rootDir, getDeclarationOutputDirectory(referencedProject)); } function getDeclarationOutputDirectory(proj) { return proj.options.declarationDir || proj.options.outDir || - ts.getDirectoryPath(proj.options.configFilePath); + ts.getDirectoryPath(proj.options.configFilePath); // TODO: GH#18217 } function verifyCompilerOptions() { if (options.strictPropertyInitialization && !options.strictNullChecks) { @@ -79990,9 +80329,9 @@ var ts; if (ts.isObjectLiteralExpression(pathProp.initializer)) { for (var _a = 0, _b = ts.getPropertyAssignment(pathProp.initializer, key); _a < _b.length; _a++) { var keyProps = _b[_a]; - if (ts.isArrayLiteralExpression(keyProps.initializer) && - keyProps.initializer.elements.length > valueIndex) { - programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, keyProps.initializer.elements[valueIndex], message, arg0, arg1, arg2)); + var initializer = keyProps.initializer; + if (ts.isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) { + programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, arg0, arg1, arg2)); needCompilerDiagnostic = false; } } @@ -80053,7 +80392,7 @@ var ts; if (_referencesArrayLiteralSyntax === undefined) { _referencesArrayLiteralSyntax = null; // tslint:disable-line:no-null-keyword if (options.configFile) { - var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); + var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); // TODO: GH#18217 for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "references"); _i < _a.length; _i++) { var prop = _a[_i]; if (ts.isArrayLiteralExpression(prop.initializer)) { @@ -80095,6 +80434,7 @@ var ts; return false; } programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, arrayLiteral.elements[index], message, arg0, arg1, arg2)); + return false; // TODO: GH#18217 This function always returns `false`!` } function blockEmittingOfFile(emitFileName, diag) { hasEmitBlockingDiagnostics.set(toPath(emitFileName), true); @@ -80114,6 +80454,10 @@ var ts; if (out) { return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Dts */); } + // If declarationDir is specified, return if its a file in that directory + if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { + return true; + } // If --outDir, check if file is in that directory if (options.outDir) { return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); @@ -80121,8 +80465,8 @@ var ts; if (ts.fileExtensionIsOneOf(filePath, ts.supportedJavascriptExtensions) || ts.fileExtensionIs(filePath, ".d.ts" /* Dts */)) { // Otherwise just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath(ts.combinePaths(filePathWithoutExtension, ".ts" /* Ts */)) || - !!getSourceFileByPath(ts.combinePaths(filePathWithoutExtension, ".tsx" /* Tsx */)); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Tsx */)); } return false; } @@ -80247,7 +80591,7 @@ var ts; if (!resolvedTypeReferenceDirective) { return; } - var fileName = resolvedTypeReferenceDirective.resolvedFileName; + var fileName = resolvedTypeReferenceDirective.resolvedFileName; // TODO: GH#18217 var typeFilePath = ts.toPath(fileName, sourceFileDirectory, getCanonicalFileName); addReferencedFile(typeFilePath); }); @@ -80279,7 +80623,7 @@ var ts; for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; var version_1 = sourceFile.version; - var oldInfo = useOldState && oldState.fileInfos.get(sourceFile.path); + var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.path) : undefined; if (referencedMap) { var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName); if (newReferences) { @@ -80342,7 +80686,8 @@ var ts; return false; } var info = state.fileInfos.get(sourceFile.path); - ts.Debug.assert(!!info); + if (!info) + return ts.Debug.fail(); var prevSignature = info.signature; var latestSignature; if (sourceFile.isDeclarationFile) { @@ -80354,7 +80699,7 @@ var ts; latestSignature = computeHash(emitOutput.outputFiles[0].text); } else { - latestSignature = prevSignature; + latestSignature = prevSignature; // TODO: GH#18217 } } cacheToUpdateSignature.set(sourceFile.path, latestSignature); @@ -80489,8 +80834,9 @@ var ts; if (!seenFileNamesMap.has(currentPath)) { var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath); seenFileNamesMap.set(currentPath, currentSourceFile); - if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash)) { - queue.push.apply(queue, getReferencedByPaths(state, currentPath)); + if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash)) { // TODO: GH#18217 + queue.push.apply(// TODO: GH#18217 + queue, getReferencedByPaths(state, currentPath)); } } } @@ -80505,7 +80851,7 @@ var ts; (function (ts) { function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps - return map1 === map2 || map1 && map2 && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); + return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); } /** * Create the state so that we can iterate on changedFiles/affected files @@ -80533,7 +80879,7 @@ var ts; } // Update changed files and copy semantic diagnostics if we can var referencedMap = state.referencedMap; - var oldReferencedMap = useOldState && oldState.referencedMap; + var oldReferencedMap = useOldState ? oldState.referencedMap : undefined; state.fileInfos.forEach(function (info, sourceFilePath) { var oldInfo; var newReferences; @@ -80577,7 +80923,7 @@ var ts; var affectedFiles = state.affectedFiles; if (affectedFiles) { var seenAffectedFiles = state.seenAffectedFiles, semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile; - var affectedFilesIndex = state.affectedFilesIndex; + var affectedFilesIndex = state.affectedFilesIndex; // TODO: GH#18217 while (affectedFilesIndex < affectedFiles.length) { var affectedFile = affectedFiles[affectedFilesIndex]; if (!seenAffectedFiles.has(affectedFile.path)) { @@ -80690,7 +81036,7 @@ var ts; // Return same program if underlying program doesnt change var oldState = oldProgram && oldProgram.getState(); if (oldState && newProgram === oldState.program && configFileParsingDiagnostics === newProgram.getConfigFileParsingDiagnostics()) { - newProgram = undefined; + newProgram = undefined; // TODO: GH#18217 oldState = undefined; return oldProgram; } @@ -80704,7 +81050,7 @@ var ts; var computeHash = host.createHash || ts.identity; var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState); // To ensure that we arent storing any references to old program or new program without state - newProgram = undefined; + newProgram = undefined; // TODO: GH#18217 oldProgram = undefined; oldState = undefined; var result = { @@ -80765,7 +81111,7 @@ var ts; if (!targetSourceFile) { // Emit and report any errors we ran into. var sourceMaps = []; - var emitSkipped = void 0; + var emitSkipped = false; var diagnostics = void 0; var emittedFiles = []; var affectedEmitResult = void 0; @@ -80885,7 +81231,7 @@ var ts; var filesWithInvalidatedResolutions; var filesWithInvalidatedNonRelativeUnresolvedImports; var allFilesHaveInvalidatedResolution = false; - var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); + 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. // The key in the map is source file's path. @@ -80906,7 +81252,7 @@ var ts; var customFailedLookupPaths = ts.createMap(); var directoryWatchesOfFailedLookups = ts.createMap(); var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory())); - var rootPath = rootDir && resolutionHost.toPath(rootDir); + var rootPath = (rootDir && resolutionHost.toPath(rootDir)); // TODO: GH#18217 // TypeRoot watches for the types that get added as part of getAutomaticTypeDirectiveNames var typeRootsWatches = ts.createMap(); return { @@ -80964,7 +81310,7 @@ var ts; } // Invalidated if file has unresolved imports var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path); - return value && !!value.length; + return !!value && !!value.length; } function createHasInvalidatedResolution(forceAllFilesAsInvalidated) { if (allFilesHaveInvalidatedResolution || forceAllFilesAsInvalidated) { @@ -80974,7 +81320,7 @@ var ts; } var collected = filesWithInvalidatedResolutions; filesWithInvalidatedResolutions = undefined; - return function (path) { return (collected && collected.has(path)) || + return function (path) { return (!!collected && collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } function clearPerDirectoryResolutions() { @@ -81055,7 +81401,7 @@ var ts; } ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, true); - resolvedModules.push(getResolutionWithResolvedFileName(resolution)); + resolvedModules.push(getResolutionWithResolvedFileName(resolution)); // TODO: GH#18217 } // Stop watching and remove the unused name resolutionsInFile.forEach(function (resolution, name) { @@ -81126,7 +81472,7 @@ var ts; } function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) { if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { - return { dir: rootDir, dirPath: rootPath }; + return { dir: rootDir, dirPath: rootPath }; // TODO: GH#18217 } return getDirectoryToWatchFromFailedLookupLocationDirectory(ts.getDirectoryPath(ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())), ts.getDirectoryPath(failedLookupLocationPath)); } @@ -81141,19 +81487,20 @@ var ts; return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath }, ts.getDirectoryPath(dirPath)); } // Use some ancestor of the root directory - var subDirectory; + var subDirectoryPath, subDirectory; if (rootPath !== undefined) { while (!isInDirectoryPath(dirPath, rootPath)) { var parentPath = ts.getDirectoryPath(dirPath); if (parentPath === dirPath) { break; } - subDirectory = dirPath.slice(parentPath.length + ts.directorySeparator.length); + subDirectoryPath = dirPath; + subDirectory = dir; dirPath = parentPath; dir = ts.getDirectoryPath(dir); } } - return filterFSRootDirectoriesToWatch({ dir: dir, dirPath: dirPath, subDirectory: subDirectory }, dirPath); + return filterFSRootDirectoriesToWatch({ dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath }, dirPath); } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -81173,7 +81520,7 @@ var ts; for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) { var failedLookupLocation = failedLookupLocations_1[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, ignore = _a.ignore, subDirectory = _a.subDirectory; + var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dir = _a.dir, dirPath = _a.dirPath, ignore = _a.ignore; if (!ignore) { // If the failed lookup location path is not one of the supported extensions, // store it in the custom path @@ -81185,27 +81532,21 @@ var ts; setAtRoot = true; } else { - setDirectoryWatcher(dir, dirPath, subDirectory); + setDirectoryWatcher(dir, dirPath); } } } if (setAtRoot) { - setDirectoryWatcher(rootDir, rootPath); + setDirectoryWatcher(rootDir, rootPath); // TODO: GH#18217 } } - function setDirectoryWatcher(dir, dirPath, subDirectory) { + function setDirectoryWatcher(dir, dirPath) { var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); if (dirWatcher) { dirWatcher.refCount++; } else { - dirWatcher = { watcher: createDirectoryWatcher(dir, dirPath), refCount: 1 }; - directoryWatchesOfFailedLookups.set(dirPath, dirWatcher); - } - if (subDirectory) { - var subDirectoryMap = dirWatcher.subDirectoryMap || (dirWatcher.subDirectoryMap = ts.createMap()); - var existing = subDirectoryMap.get(subDirectory) || 0; - subDirectoryMap.set(subDirectory, existing + 1); + directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath), refCount: 1 }); } } function stopWatchFailedLookupLocationOfResolution(resolution) { @@ -81221,7 +81562,7 @@ var ts; for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) { var failedLookupLocation = failedLookupLocations_2[_i]; var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore, subDirectory = _a.subDirectory; + var _a = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath), dirPath = _a.dirPath, ignore = _a.ignore; if (!ignore) { var refCount = customFailedLookupPaths.get(failedLookupLocationPath); if (refCount) { @@ -81237,7 +81578,7 @@ var ts; removeAtRoot = true; } else { - removeDirectoryWatcher(dirPath, subDirectory); + removeDirectoryWatcher(dirPath); } } } @@ -81245,29 +81586,11 @@ var ts; removeDirectoryWatcher(rootPath); } } - function removeDirectoryWatcher(dirPath, subDirectory) { + function removeDirectoryWatcher(dirPath) { var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); - if (subDirectory) { - var existing = dirWatcher.subDirectoryMap.get(subDirectory); - if (existing === 1) { - dirWatcher.subDirectoryMap.delete(subDirectory); - } - else { - dirWatcher.subDirectoryMap.set(subDirectory, existing - 1); - } - } // Do not close the watcher yet since it might be needed by other failed lookup locations. dirWatcher.refCount--; } - function inWatchedSubdirectory(dirPath, fileOrDirectoryPath) { - var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); - if (!dirWatcher || !dirWatcher.subDirectoryMap) - return false; - return ts.forEachKey(dirWatcher.subDirectoryMap, function (subDirectory) { - var fullSubDirectory = dirPath + "/" + subDirectory; - return fullSubDirectory === fileOrDirectoryPath || isInDirectoryPath(fullSubDirectory, fileOrDirectoryPath); - }); - } function createDirectoryWatcher(directory, dirPath) { return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) { var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory); @@ -81275,13 +81598,8 @@ var ts; // Since the file existence changed, update the sourceFiles cache cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } - // If the files are added to project root or node_modules directory, always run through the invalidation process - // Otherwise run through invalidation only if adding to the immediate directory - if (!allFilesHaveInvalidatedResolution && - (dirPath === rootPath || isNodeModulesDirectory(dirPath) || ts.getDirectoryPath(fileOrDirectoryPath) === dirPath || inWatchedSubdirectory(dirPath, fileOrDirectoryPath))) { - if (invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) { - resolutionHost.onInvalidatedResolution(); - } + if (!allFilesHaveInvalidatedResolution && invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) { + resolutionHost.onInvalidatedResolution(); } }, 1 /* Recursive */); } @@ -81339,7 +81657,7 @@ var ts; // Resolution is invalidated if the resulting file name is same as the deleted file path function (resolution, getResolutionWithResolvedFileName) { var result = getResolutionWithResolvedFileName(resolution); - return result && resolutionHost.toPath(result.resolvedFileName) === filePath; + return !!result && resolutionHost.toPath(result.resolvedFileName) === filePath; // TODO: GH#18217 }); } function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) { @@ -81395,7 +81713,7 @@ var ts; return rootPath; } var _a = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath), dirPath = _a.dirPath, ignore = _a.ignore; - return !ignore && directoryWatchesOfFailedLookups.has(dirPath) && dirPath; + return !ignore && directoryWatchesOfFailedLookups.has(dirPath) ? dirPath : undefined; } function createTypeRootsWatch(typeRootPath, typeRoot) { // Create new watch and recursive info @@ -81462,7 +81780,7 @@ var ts; getCurrentDirectory: function () { return ts.sys.getCurrentDirectory(); }, getNewLine: function () { return ts.sys.newLine; }, getCanonicalFileName: ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames) - } : undefined; + } : undefined; // TODO: GH#18217 /** * Create a function that reports error by writing to the system and handles the formating of the diagnostic */ @@ -81479,7 +81797,7 @@ var ts; return function (diagnostic) { diagnostics[0] = diagnostic; system.write(ts.formatDiagnosticsWithColorAndContext(diagnostics, host) + host.getNewLine()); - diagnostics[0] = undefined; + diagnostics[0] = undefined; // TODO: GH#18217 }; } ts.createDiagnosticReporter = createDiagnosticReporter; @@ -81539,7 +81857,7 @@ var ts; var host = system; host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(ts.sys, reportDiagnostic, diagnostic); }; var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host); - host.onUnRecoverableConfigFileDiagnostic = undefined; + host.onUnRecoverableConfigFileDiagnostic = undefined; // TODO: GH#18217 return result; } ts.parseConfigFileWithSystem = parseConfigFileWithSystem; @@ -81669,9 +81987,9 @@ var ts; * Creates the watch compiler host from system for config file in watch mode */ function createWatchCompilerHostOfConfigFile(configFileName, optionsToExtend, system, createProgram, reportDiagnostic, reportWatchStatus) { - reportDiagnostic = reportDiagnostic || createDiagnosticReporter(system); - var host = createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus); - host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; + var diagnosticReporter = reportDiagnostic || createDiagnosticReporter(system); + var host = createWatchCompilerHost(system, createProgram, diagnosticReporter, reportWatchStatus); + host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, diagnosticReporter, diagnostic); }; host.configFileName = configFileName; host.optionsToExtend = optionsToExtend; return host; @@ -81691,7 +82009,7 @@ var ts; (function (ts) { function createWatchCompilerHost(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus) { if (ts.isArray(rootFilesOrConfigFileName)) { - return ts.createWatchCompilerHostOfFilesAndCompilerOptions(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus); + return ts.createWatchCompilerHostOfFilesAndCompilerOptions(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus); // TODO: GH#18217 } else { return ts.createWatchCompilerHostOfConfigFile(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus); @@ -81718,7 +82036,7 @@ var ts; var configFileSpecs; var configFileParsingDiagnostics; var hasChangedConfigFileParsingErrors = false; - var cachedDirectoryStructureHost = configFileName && ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames); + var cachedDirectoryStructureHost = configFileName === undefined ? undefined : ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames); if (cachedDirectoryStructureHost && host.onCachedDirectoryStructureHostCreate) { host.onCachedDirectoryStructureHostCreate(cachedDirectoryStructureHost); } @@ -81748,7 +82066,7 @@ var ts; var trace = host.trace && (function (s) { host.trace(s + newLine); }); var watchLogLevel = trace ? compilerOptions.extendedDiagnostics ? ts.WatchLogLevel.Verbose : compilerOptions.diagnostis ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None; - var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? trace : ts.noop; + var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? trace : ts.noop; // TODO: GH#18217 var _b = ts.getWatchFactory(watchLogLevel, writeLog), watchFile = _b.watchFile, watchFilePath = _b.watchFilePath, watchDirectory = _b.watchDirectory; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); @@ -81770,7 +82088,7 @@ var ts; readFile: readFile, trace: trace, directoryExists: directoryStructureHost.directoryExists && (function (path) { return directoryStructureHost.directoryExists(path); }), - getDirectories: directoryStructureHost.getDirectories && (function (path) { return directoryStructureHost.getDirectories(path); }), + getDirectories: (directoryStructureHost.getDirectories && (function (path) { return directoryStructureHost.getDirectories(path); })), realpath: host.realpath && (function (s) { return host.realpath(s); }), getEnvironmentVariable: host.getEnvironmentVariable ? (function (name) { return host.getEnvironmentVariable(name); }) : (function () { return ""; }), onReleaseOldSourceFile: onReleaseOldSourceFile, @@ -82059,12 +82377,12 @@ var ts; watchConfigFileWildCardDirectories(); } function parseConfigFile() { - setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost)); + setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost)); // TODO: GH#18217 } function setConfigFileParsingResult(configFileParseResult) { rootFileNames = configFileParseResult.fileNames; compilerOptions = configFileParseResult.options; - configFileSpecs = configFileParseResult.configFileSpecs; + configFileSpecs = configFileParseResult.configFileSpecs; // TODO: GH#18217 configFileParsingDiagnostics = ts.getConfigFileParsingDiagnostics(configFileParseResult); hasChangedConfigFileParsingErrors = true; } @@ -82303,6 +82621,7 @@ var ts; "es2018.promise": "lib.es2018.promise.d.ts", "es2018.regexp": "lib.es2018.regexp.d.ts", "esnext.array": "lib.esnext.array.d.ts", + "esnext.symbol": "lib.esnext.symbol.d.ts", "esnext.asynciterable": "lib.esnext.asynciterable.d.ts", }), }, @@ -82948,7 +83267,7 @@ var ts; case "string": return ts.map(values, function (v) { return v || ""; }); default: - return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + return ts.mapDefined(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }); } } ts.parseListTypeOption = parseListTypeOption; @@ -83061,6 +83380,7 @@ var ts; } } ts.parseCommandLine = parseCommandLine; + /** @internal */ function getOptionFromName(optionName, allowShort) { if (allowShort === void 0) { allowShort = false; } optionName = optionName.toLowerCase(); @@ -83074,6 +83394,7 @@ var ts; } return optionNameMap.get(optionName); } + ts.getOptionFromName = getOptionFromName; /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ @@ -83233,7 +83554,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 269 /* PropertyAssignment */) { + if (element.kind !== 270 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -83310,13 +83631,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: if (valueExpression.operator !== 38 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -83333,7 +83654,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -83371,6 +83692,7 @@ var ts; var expectedType = ts.isString(option.type) ? option.type : "string"; return typeof value === expectedType; } + return false; } /** * Generate tsconfig configuration when running command line "--init" @@ -83423,7 +83745,7 @@ var ts; } else { if (optionDefinition.type === "list") { - result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); + result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); })); // TODO: GH#18217 } else { // There is a typeMap associated with this command-line option so use it to map value back to its name @@ -83850,13 +84172,10 @@ var ts; } function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { - return undefined; + return false; } var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption.compileOnSave, basePath, errors); - if (typeof result === "boolean" && result) { - return result; - } - return false; + return typeof result === "boolean" && result; } function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var errors = []; @@ -83885,7 +84204,7 @@ var ts; return options; } function getDefaultTypeAcquisition(configFileName) { - return { enable: configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; + return { enable: !!configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; } function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) { var options = getDefaultTypeAcquisition(configFileName); @@ -84282,7 +84601,7 @@ var ts; if (optionEnumValue === value) { return optionStringValue; } - }); + }); // TODO: GH#18217 } } })(ts || (ts = {})); @@ -84550,36 +84869,36 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 148 /* Parameter */: - case 231 /* VariableDeclaration */: - case 181 /* BindingElement */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 269 /* PropertyAssignment */: - case 270 /* ShorthandPropertyAssignment */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 268 /* CatchClause */: - case 261 /* JsxAttribute */: + case 149 /* Parameter */: + case 232 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 270 /* PropertyAssignment */: + case 271 /* ShorthandPropertyAssignment */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 269 /* CatchClause */: + case 262 /* JsxAttribute */: return 1 /* Value */; - case 147 /* TypeParameter */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 165 /* TypeLiteral */: + case 148 /* TypeParameter */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 166 /* TypeLiteral */: return 2 /* Type */; - case 296 /* JSDocTypedefTag */: + case 297 /* 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 272 /* EnumMember */: - case 234 /* ClassDeclaration */: + case 273 /* EnumMember */: + case 235 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -84589,26 +84908,26 @@ var ts; else { return 4 /* Namespace */; } - case 237 /* EnumDeclaration */: - case 246 /* NamedImports */: - case 247 /* ImportSpecifier */: - case 242 /* ImportEqualsDeclaration */: - case 243 /* ImportDeclaration */: - case 248 /* ExportAssignment */: - case 249 /* ExportDeclaration */: + case 238 /* EnumDeclaration */: + case 247 /* NamedImports */: + case 248 /* ImportSpecifier */: + case 243 /* ImportEqualsDeclaration */: + case 244 /* ImportDeclaration */: + case 249 /* ExportAssignment */: + case 250 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 273 /* SourceFile */: + case 274 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 248 /* ExportAssignment */) { + else if (node.parent.kind === 249 /* ExportAssignment */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -84640,11 +84959,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 145 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 242 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 146 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 243 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 145 /* QualifiedName */) { + while (node.parent.kind === 146 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -84656,27 +84975,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 145 /* QualifiedName */) { - while (root.parent && root.parent.kind === 145 /* QualifiedName */) { + if (root.parent.kind === 146 /* QualifiedName */) { + while (root.parent && root.parent.kind === 146 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 161 /* TypeReference */ && !isLastClause; + return root.parent.kind === 162 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 184 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 184 /* PropertyAccessExpression */) { + if (root.parent.kind === 185 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 185 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 206 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 267 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 207 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 268 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 234 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || - (decl.kind === 235 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); + return (decl.kind === 235 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || + (decl.kind === 236 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); } return false; } @@ -84687,30 +85006,30 @@ var ts; switch (node.kind) { case 99 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 173 /* ThisType */: + case 174 /* ThisType */: return true; } switch (node.parent.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return true; - case 178 /* ImportType */: + case 179 /* ImportType */: return !node.parent.isTypeOf; - case 206 /* ExpressionWithTypeArguments */: + case 207 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 186 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 187 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 187 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 188 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { var target = climbPastPropertyAccess(node); - return target && target.parent && target.parent.kind === kind && target.parent.expression === target; + return !!target && !!target.parent && target.parent.kind === kind && target.parent.expression === target; } function climbPastPropertyAccess(node) { return isRightSideOfPropertyAccess(node) ? node.parent : node; @@ -84718,7 +85037,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 227 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 228 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -84739,15 +85058,15 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 145 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 146 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 184 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 185 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 238 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 239 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { @@ -84757,22 +85076,24 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 269 /* PropertyAssignment */: - case 272 /* EnumMember */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 238 /* ModuleDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 270 /* PropertyAssignment */: + case 273 /* EnumMember */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 239 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 146 /* ComputedPropertyName */: + case 147 /* ComputedPropertyName */: return true; - case 177 /* LiteralType */: - return node.parent.parent.kind === 175 /* IndexedAccessType */; + case 178 /* LiteralType */: + return node.parent.parent.kind === 176 /* IndexedAccessType */; + default: + return false; } } ts.isLiteralNameOfPropertyDeclarationOrIndexAccess = isLiteralNameOfPropertyDeclarationOrIndexAccess; @@ -84794,17 +85115,17 @@ var ts; return undefined; } switch (node.kind) { - case 273 /* SourceFile */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 238 /* ModuleDeclaration */: + case 274 /* SourceFile */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 239 /* ModuleDeclaration */: return node; } } @@ -84812,49 +85133,49 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: return "class" /* classElement */; - case 235 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 236 /* TypeAliasDeclaration */: - case 291 /* JSDocCallbackTag */: - case 296 /* JSDocTypedefTag */: + case 236 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 237 /* TypeAliasDeclaration */: + case 292 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 237 /* EnumDeclaration */: return "enum" /* enumElement */; - case 231 /* VariableDeclaration */: + case 238 /* EnumDeclaration */: return "enum" /* enumElement */; + case 232 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 192 /* ArrowFunction */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: return "function" /* functionElement */; - case 155 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 156 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 156 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 157 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return "property" /* memberVariableElement */; - case 159 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 158 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 157 /* CallSignature */: return "call" /* callSignatureElement */; - case 154 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 147 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 272 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 148 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 242 /* ImportEqualsDeclaration */: - case 247 /* ImportSpecifier */: - case 244 /* ImportClause */: - case 251 /* ExportSpecifier */: - case 245 /* NamespaceImport */: + case 160 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 159 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 158 /* CallSignature */: return "call" /* callSignatureElement */; + case 155 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 148 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 273 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 149 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 243 /* ImportEqualsDeclaration */: + case 248 /* ImportSpecifier */: + case 245 /* ImportClause */: + case 252 /* ExportSpecifier */: + case 246 /* NamespaceImport */: return "alias" /* alias */; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: var kind = ts.getSpecialPropertyAssignmentKind(node); var right = node.right; switch (kind) { @@ -84897,7 +85218,7 @@ var ts; return true; case 71 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 148 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 149 /* Parameter */; default: return false; } @@ -84919,6 +85240,10 @@ var ts; return r.pos <= pos && pos <= r.end; } ts.rangeContainsPosition = rangeContainsPosition; + function rangeContainsPositionExclusive(r, pos) { + return r.pos < pos && pos < r.end; + } + ts.rangeContainsPositionExclusive = rangeContainsPositionExclusive; function startEndContainsRange(start, end, range) { return start <= range.pos && end >= range.end; } @@ -84946,46 +85271,46 @@ var ts; } ts.positionBelongsToNode = positionBelongsToNode; function isCompletedNode(n, sourceFile) { - if (ts.nodeIsMissing(n)) { + if (n === undefined || ts.nodeIsMissing(n)) { return false; } switch (n.kind) { - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 183 /* ObjectLiteralExpression */: - case 179 /* ObjectBindingPattern */: - case 165 /* TypeLiteral */: - case 212 /* Block */: - case 239 /* ModuleBlock */: - case 240 /* CaseBlock */: - case 246 /* NamedImports */: - case 250 /* NamedExports */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 184 /* ObjectLiteralExpression */: + case 180 /* ObjectBindingPattern */: + case 166 /* TypeLiteral */: + case 213 /* Block */: + case 240 /* ModuleBlock */: + case 241 /* CaseBlock */: + case 247 /* NamedImports */: + case 251 /* NamedExports */: return nodeEndsWith(n, 18 /* CloseBraceToken */, sourceFile); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 187 /* NewExpression */: + case 188 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 186 /* CallExpression */: - case 190 /* ParenthesizedExpression */: - case 172 /* ParenthesizedType */: + case 187 /* CallExpression */: + case 191 /* ParenthesizedExpression */: + case 173 /* ParenthesizedType */: return nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile); - case 162 /* FunctionType */: - case 163 /* ConstructorType */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 158 /* ConstructSignature */: - case 157 /* CallSignature */: - case 192 /* ArrowFunction */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 159 /* ConstructSignature */: + case 158 /* CallSignature */: + case 193 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -84995,65 +85320,65 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 20 /* CloseParenToken */, sourceFile); - case 238 /* ModuleDeclaration */: - return n.body && isCompletedNode(n.body, sourceFile); - case 216 /* IfStatement */: + case 239 /* ModuleDeclaration */: + return !!n.body && isCompletedNode(n.body, sourceFile); + case 217 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 25 /* SemicolonToken */, sourceFile); - case 182 /* ArrayLiteralExpression */: - case 180 /* ArrayBindingPattern */: - case 185 /* ElementAccessExpression */: - case 146 /* ComputedPropertyName */: - case 167 /* TupleType */: + case 183 /* ArrayLiteralExpression */: + case 181 /* ArrayBindingPattern */: + case 186 /* ElementAccessExpression */: + case 147 /* ComputedPropertyName */: + case 168 /* TupleType */: return nodeEndsWith(n, 22 /* CloseBracketToken */, sourceFile); - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 218 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 219 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 217 /* DoStatement */: + case 218 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; return hasChildOfKind(n, 106 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 20 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 164 /* TypeQuery */: + case 165 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 194 /* TypeOfExpression */: - case 193 /* DeleteExpression */: - case 195 /* VoidExpression */: - case 202 /* YieldExpression */: - case 203 /* SpreadElement */: + case 195 /* TypeOfExpression */: + case 194 /* DeleteExpression */: + case 196 /* VoidExpression */: + case 203 /* YieldExpression */: + case 204 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 188 /* TaggedTemplateExpression */: + case 189 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 201 /* TemplateExpression */: + case 202 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 210 /* TemplateSpan */: + case 211 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 249 /* ExportDeclaration */: - case 243 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 200 /* ConditionalExpression */: + case 201 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -85066,11 +85391,11 @@ var ts; function nodeEndsWith(n, expectedLastToken, sourceFile) { var children = n.getChildren(sourceFile); if (children.length) { - var last_2 = ts.lastOrUndefined(children); - if (last_2.kind === expectedLastToken) { + var lastChild = ts.last(children); + if (lastChild.kind === expectedLastToken) { return true; } - else if (last_2.kind === 25 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 25 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -85130,6 +85455,7 @@ var ts; ts.getTouchingToken = getTouchingToken; /** Returns a token if position is in [start-of-leading-trivia, end) */ function getTokenAtPosition(sourceFile, position, includeJsDocComment, includeEndPosition) { + if (includeEndPosition === void 0) { includeEndPosition = false; } return getTokenAtPositionWorker(sourceFile, position, /*allowPositionInLeadingTrivia*/ true, /*includePrecedingTokenAtEndPosition*/ undefined, includeEndPosition, includeJsDocComment); } ts.getTokenAtPosition = getTokenAtPosition; @@ -85244,7 +85570,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 273 /* SourceFile */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 274 /* SourceFile */ || 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. @@ -85284,7 +85610,7 @@ var ts; function isInString(sourceFile, position, previousToken) { if (previousToken === void 0) { previousToken = findPrecedingToken(position, sourceFile); } if (previousToken && ts.isStringTextContainingNode(previousToken)) { - var start = previousToken.getStart(); + var start = previousToken.getStart(sourceFile); var end = previousToken.getEnd(); // To be "in" one of these literals, the position has to be: // 1. entirely within the token text. @@ -85316,17 +85642,17 @@ var ts; return true; } //
{ |
or
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 264 /* JsxExpression */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 265 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 264 /* JsxExpression */) { + if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 265 /* JsxExpression */) { return true; } //
|
- if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 257 /* JsxClosingElement */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 258 /* JsxClosingElement */) { return true; } return false; @@ -85344,10 +85670,11 @@ var ts; var tokenKind = token.kind; var remainingMatchingTokens = 0; while (true) { - token = findPrecedingToken(token.getFullStart(), sourceFile); - if (!token) { + var preceding = findPrecedingToken(token.getFullStart(), sourceFile); + if (!preceding) { return undefined; } + token = preceding; if (token.kind === matchingTokenKind) { if (remainingMatchingTokens === 0) { return token; @@ -85360,21 +85687,24 @@ var ts; } } ts.findPrecedingMatchingToken = findPrecedingMatchingToken; - function isPossiblyTypeArgumentPosition(token, sourceFile) { + function isPossiblyTypeArgumentPosition(tokenIn, sourceFile) { + var token = tokenIn; // This function determines if the node could be type argument position // Since during editing, when type argument list is not complete, // the tree could be of any shape depending on the tokens parsed before current node, // scanning of the previous identifier followed by "<" before current node would give us better result // Note that we also balance out the already provided type arguments, arrays, object literals while doing so var remainingLessThanTokens = 0; + var nTypeArguments = 0; while (token) { switch (token.kind) { case 27 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); - var tokenIsIdentifier = token && ts.isIdentifier(token); - if (!remainingLessThanTokens || !tokenIsIdentifier) { - return tokenIsIdentifier; + if (!token || !ts.isIdentifier(token)) + return undefined; + if (!remainingLessThanTokens) { + return { called: token, nTypeArguments: nTypeArguments }; } remainingLessThanTokens--; break; @@ -85392,24 +85722,26 @@ var ts; // Skip until the matching open brace token token = findPrecedingMatchingToken(token, 17 /* OpenBraceToken */, sourceFile); if (!token) - return false; + return undefined; break; case 20 /* CloseParenToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token token = findPrecedingMatchingToken(token, 19 /* OpenParenToken */, sourceFile); if (!token) - return false; + return undefined; break; case 22 /* CloseBracketToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token token = findPrecedingMatchingToken(token, 21 /* OpenBracketToken */, sourceFile); if (!token) - return false; + return undefined; break; // Valid tokens in a type name. Skip. case 26 /* CommaToken */: + nTypeArguments++; + break; case 36 /* EqualsGreaterThanToken */: case 71 /* Identifier */: case 9 /* StringLiteral */: @@ -85429,11 +85761,11 @@ var ts; break; } // Invalid token in type - return false; + return undefined; } token = findPrecedingToken(token.getFullStart(), sourceFile); } - return false; + return undefined; } ts.isPossiblyTypeArgumentPosition = isPossiblyTypeArgumentPosition; /** @@ -85483,10 +85815,10 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 161 /* TypeReference */ || node.kind === 186 /* CallExpression */) { + if (node.kind === 162 /* TypeReference */ || node.kind === 187 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 234 /* ClassDeclaration */ || node.kind === 235 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 235 /* ClassDeclaration */ || node.kind === 236 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -85509,9 +85841,9 @@ var ts; return 17 /* FirstPunctuation */ <= kind && kind <= 70 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; - function isInsideTemplateLiteral(node, position) { + function isInsideTemplateLiteral(node, position, sourceFile) { return ts.isTemplateLiteralKind(node.kind) - && (node.getStart() < position && position < node.getEnd()) || (!!node.isUnterminated && position === node.getEnd()); + && (node.getStart(sourceFile) < position && position < node.end) || (!!node.isUnterminated && position === node.end); } ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { @@ -85531,18 +85863,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 182 /* ArrayLiteralExpression */ || - node.kind === 183 /* ObjectLiteralExpression */) { + if (node.kind === 183 /* ArrayLiteralExpression */ || + node.kind === 184 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 199 /* BinaryExpression */ && + if (node.parent.kind === 200 /* BinaryExpression */ && node.parent.left === node && node.parent.operatorToken.kind === 58 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 221 /* ForOfStatement */ && + if (node.parent.kind === 222 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -85550,7 +85882,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 269 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 270 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -85604,6 +85936,7 @@ var ts; 105 /* VoidKeyword */, 140 /* UndefinedKeyword */, 141 /* UniqueKeyword */, + 142 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -85636,11 +85969,11 @@ var ts; } ts.repeatString = repeatString; function skipConstraint(type) { - return type.isTypeParameter() ? type.getConstraint() : type; + return type.isTypeParameter() ? type.getConstraint() : type; // TODO: GH#18217 } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 146 /* ComputedPropertyName */ + return name.kind === 147 /* ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteral(name.expression) ? name.expression.text : undefined : ts.getTextOfIdentifierOrLiteral(name); @@ -85662,16 +85995,16 @@ var ts; return ts.createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host)); } ts.hostGetCanonicalFileName = hostGetCanonicalFileName; - function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier) { - return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier) : undefined; + function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, preferences) { + return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, preferences) : undefined; } ts.makeImportIfNecessary = makeImportIfNecessary; - function makeImport(defaultImport, namedImports, moduleSpecifier) { + function makeImport(defaultImport, namedImports, moduleSpecifier, preferences) { return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, defaultImport || namedImports ? ts.createImportClause(defaultImport, namedImports && namedImports.length ? ts.createNamedImports(namedImports) : undefined) - : undefined, typeof moduleSpecifier === "string" ? ts.createLiteral(moduleSpecifier) : moduleSpecifier); + : undefined, typeof moduleSpecifier === "string" ? ts.createLiteral(moduleSpecifier, preferences.quotePreference === "single") : moduleSpecifier); } ts.makeImport = makeImport; function symbolNameNoDefault(symbol) { @@ -85700,6 +86033,37 @@ var ts; return propSymbol; } ts.getPropertySymbolFromBindingElement = getPropertySymbolFromBindingElement; + /** + * Find symbol of the given property-name and add the symbol to the given result array + * @param symbol a symbol to start searching for the given propertyName + * @param propertyName a name of property to search for + * @param result an array of symbol of found property symbols + * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. + * The value of previousIterationSymbol is undefined when the function is first called. + */ + function getPropertySymbolsFromBaseTypes(symbol, propertyName, checker, cb) { + var seen = ts.createMap(); + return recur(symbol); + function recur(symbol) { + // Use `addToSeen` to ensure we don't infinitely recurse in this situation: + // interface C extends C { + // /*findRef*/propName: string; + // } + if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) + return; + return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { + var type = checker.getTypeAtLocation(typeReference); + var propertySymbol = type && type.symbol && checker.getPropertyOfType(type, propertyName); + // Visit the typeReference as well to see if it directly or indirectly uses that property + return type && propertySymbol && (ts.firstDefined(checker.getRootSymbols(propertySymbol), cb) || recur(type.symbol)); + }); }); + } + } + ts.getPropertySymbolsFromBaseTypes = getPropertySymbolsFromBaseTypes; + function isMemberSymbolInBaseType(memberSymbol, checker) { + return getPropertySymbolsFromBaseTypes(memberSymbol.parent, memberSymbol.name, checker, function (_) { return true; }) || false; + } + ts.isMemberSymbolInBaseType = isMemberSymbolInBaseType; var NodeSet = /** @class */ (function () { function NodeSet() { this.map = ts.createMap(); @@ -85719,12 +86083,27 @@ var ts; return NodeSet; }()); ts.NodeSet = NodeSet; + function getParentNodeInSpan(node, file, span) { + if (!node) + return undefined; + while (node.parent) { + if (ts.isSourceFile(node.parent) || !spanContainsNode(span, node.parent, file)) { + return node; + } + node = node.parent; + } + } + ts.getParentNodeInSpan = getParentNodeInSpan; + function spanContainsNode(span, node, file) { + return ts.textSpanContainsPosition(span, node.getStart(file)) && + node.getEnd() <= ts.textSpanEnd(span); + } })(ts || (ts = {})); // Display-part writer helpers /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 148 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 149 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -85897,18 +86276,21 @@ var ts; } ts.mapToDisplayParts = mapToDisplayParts; function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { + if (flags === void 0) { flags = 0 /* None */; } return mapToDisplayParts(function (writer) { - typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, writer); + typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.typeToDisplayParts = typeToDisplayParts; function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { + if (flags === void 0) { flags = 0 /* None */; } return mapToDisplayParts(function (writer) { typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { + if (flags === void 0) { flags = 0 /* None */; } flags |= 16384 /* UseAliasDefinedOutsideCurrentScope */ | 1024 /* MultilineObjectLiterals */ | 32 /* WriteTypeArgumentsOfSignature */ | 8192 /* OmitParameterModifiers */; return mapToDisplayParts(function (writer) { typechecker.writeSignature(signature, enclosingDeclaration, flags, /*signatureKind*/ undefined, writer); @@ -85916,8 +86298,8 @@ var ts; } ts.signatureToDisplayParts = signatureToDisplayParts; function isImportOrExportSpecifierName(location) { - return location.parent && - (location.parent.kind === 247 /* ImportSpecifier */ || location.parent.kind === 251 /* ExportSpecifier */) && + return !!location.parent && + (location.parent.kind === 248 /* ImportSpecifier */ || location.parent.kind === 252 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -85944,7 +86326,7 @@ var ts; scriptKinds[_i - 2] = arguments[_i]; } var scriptKind = getScriptKind(fileName, host); - return ts.forEach(scriptKinds, function (k) { return k === scriptKind; }); + return ts.some(scriptKinds, function (k) { return k === scriptKind; }); } ts.scriptKindIs = scriptKindIs; function getScriptKind(fileName, host) { @@ -86037,9 +86419,9 @@ var ts; return node.forEachChild(function (child) { return child; }); } /* @internal */ - function getUniqueName(baseName, fileText) { + function getUniqueName(baseName, sourceFile) { var nameText = baseName; - for (var i = 1; ts.stringContains(fileText, nameText); i++) { + for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { nameText = baseName + "_" + i; } return nameText; @@ -86060,7 +86442,7 @@ var ts; for (var _b = 0, textChanges_1 = textChanges_2; _b < textChanges_1.length; _b++) { var change = textChanges_1[_b]; var span = change.span, newText = change.newText; - var index = newText.indexOf(name); + var index = indexInTextChange(newText, name); if (index !== -1) { lastPos = span.start + delta + index; // If the reference comes first, return immediately. @@ -86077,6 +86459,17 @@ var ts; return lastPos; } ts.getRenameLocation = getRenameLocation; + function indexInTextChange(change, name) { + if (ts.startsWith(change, name)) + return 0; + // Add a " " to avoid references inside words + var idx = change.indexOf(" " + name); + if (idx === -1) + idx = change.indexOf("." + name); + if (idx === -1) + idx = change.indexOf('"' + name); + return idx === -1 ? -1 : idx + 1; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -86356,6 +86749,8 @@ var ts; case 9 /* text */: case 17 /* parameterName */: return ts.TokenClass.Identifier; + default: + return undefined; // TODO: GH#18217 Debug.assertNever(type); } } /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ @@ -86506,10 +86901,10 @@ 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 238 /* ModuleDeclaration */: - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 233 /* FunctionDeclaration */: + case 239 /* ModuleDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 234 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -86603,6 +86998,7 @@ var ts; case 22 /* jsxAttribute */: return "jsx attribute" /* jsxAttribute */; case 23 /* jsxText */: return "jsx text" /* jsxText */; case 24 /* jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* jsxAttributeStringLiteralValue */; + default: return undefined; // TODO: GH#18217 throw Debug.assertNever(type); } } function convertClassificationsToSpans(classifications) { @@ -86720,18 +87116,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 292 /* JSDocParameterTag */: + case 293 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 295 /* JSDocTemplateTag */: + case 296 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 294 /* JSDocTypeTag */: + case 295 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 293 /* JSDocReturnTag */: + case 294 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -86818,22 +87214,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 256 /* JsxOpeningElement */: + case 257 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 255 /* JsxSelfClosingElement */: + case 256 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -86859,19 +87255,20 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { + var parent = token.parent; if (tokenKind === 58 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 231 /* VariableDeclaration */ || - token.parent.kind === 151 /* PropertyDeclaration */ || - token.parent.kind === 148 /* Parameter */ || - token.parent.kind === 261 /* JsxAttribute */) { + if (parent.kind === 232 /* VariableDeclaration */ || + parent.kind === 152 /* PropertyDeclaration */ || + parent.kind === 149 /* Parameter */ || + parent.kind === 262 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 199 /* BinaryExpression */ || - token.parent.kind === 197 /* PrefixUnaryExpression */ || - token.parent.kind === 198 /* PostfixUnaryExpression */ || - token.parent.kind === 200 /* ConditionalExpression */) { + if (parent.kind === 200 /* BinaryExpression */ || + parent.kind === 198 /* PrefixUnaryExpression */ || + parent.kind === 199 /* PostfixUnaryExpression */ || + parent.kind === 201 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -86881,7 +87278,8 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 261 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + // TODO: GH#18217 + return token.parent.kind === 262 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 12 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -86897,32 +87295,32 @@ var ts; else if (tokenKind === 71 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 148 /* Parameter */: + case 149 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -87006,7 +87404,7 @@ var ts; // Determine the path to the directory containing the script relative to the root directory it is contained within var relativeDirectory = ts.firstDefined(rootDirs, function (rootDirectory) { return ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase) ? scriptPath.substr(rootDirectory.length) : undefined; - }); + }); // TODO: GH#18217 // Now find a path for each potential directory that is to be merged with the one containing the script return ts.deduplicate(rootDirs.map(function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); }), ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive); } @@ -87210,8 +87608,8 @@ var ts; // after the last '/' that appears in the fragment because that's where the replacement span // starts if (fragmentDirectory !== undefined) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(fragmentDirectory); - return nonRelativeModuleNames.map(function (nonRelativeModuleName) { return ts.removePrefix(nonRelativeModuleName, moduleNameWithSeperator_1); }); + var moduleNameWithSeparator_1 = ts.ensureTrailingDirectorySeparator(fragmentDirectory); + return nonRelativeModuleNames.map(function (nonRelativeModuleName) { return ts.removePrefix(nonRelativeModuleName, moduleNameWithSeparator_1); }); } return nonRelativeModuleNames; } @@ -87321,7 +87719,7 @@ var ts; } return result; } - // Replace everything after the last directory seperator that appears + // Replace everything after the last directory separator that appears function getDirectoryFragmentTextSpan(text, textStart) { var index = Math.max(text.lastIndexOf(ts.directorySeparator), text.lastIndexOf("\\")); var offset = index !== -1 ? index + 1 : 0; @@ -87366,7 +87764,7 @@ var ts; return ts.directoryProbablyExists(path, host); } catch ( /*ignore*/_a) { /*ignore*/ } - return undefined; + return false; } function tryIOAndConsumeErrors(host, toApply) { var args = []; @@ -87414,7 +87812,7 @@ var ts; } var contextToken = ts.findPrecedingToken(position, sourceFile); if (triggerCharacter && !isValidTrigger(sourceFile, triggerCharacter, contextToken, position)) - return undefined; + return undefined; // TODO: GH#18217 if (ts.isInString(sourceFile, position, contextToken)) { return !contextToken || !ts.isStringLiteralLike(contextToken) ? undefined @@ -87424,7 +87822,7 @@ var ts; && (contextToken.kind === 72 /* BreakKeyword */ || contextToken.kind === 77 /* ContinueKeyword */ || contextToken.kind === 71 /* Identifier */)) { return getLabelCompletionAtPosition(contextToken.parent); } - var completionData = getCompletionData(program, log, sourceFile, position, preferences, /*detailsEntryId*/ undefined); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, preferences, /*detailsEntryId*/ undefined); if (!completionData) { return undefined; } @@ -87494,9 +87892,9 @@ var ts; }] }; } var entries = []; - if (ts.isSourceFileJavaScript(sourceFile)) { + if (isUncheckedFile(sourceFile, compilerOptions)) { var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap); - getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); + getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217 } else { if ((!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { @@ -87514,6 +87912,9 @@ var ts; } return { isGlobalCompletion: isInSnippetScope, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; } + function isUncheckedFile(sourceFile, compilerOptions) { + return ts.isSourceFileJavaScript(sourceFile) && !ts.isCheckJsEnabledForFile(sourceFile, compilerOptions); + } function isMemberCompletionKind(kind) { switch (kind) { case 0 /* ObjectPropertyDeclaration */: @@ -87632,7 +88033,7 @@ var ts; continue; } // Latter case tests whether this is a global variable. - if (!origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }))) { + if (!origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }))) { // TODO: GH#18217 uniques.set(name, true); } entries.push(entry); @@ -87678,11 +88079,11 @@ var ts; })(StringLiteralCompletionKind || (StringLiteralCompletionKind = {})); function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { switch (node.parent.kind) { - case 177 /* LiteralType */: + case 178 /* LiteralType */: switch (node.parent.parent.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(node.parent), typeChecker), isNewIdentifier: false }; - case 175 /* IndexedAccessType */: + case 176 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -87690,12 +88091,12 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(node.parent.parent.objectType)); - case 178 /* ImportType */: + case 179 /* ImportType */: return { kind: 0 /* Paths */, paths: Completions.PathCompletions.getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; default: return undefined; } - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(node.parent.parent) && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -87712,7 +88113,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(node.parent.parent)); } return fromContextualType(); - case 185 /* ElementAccessExpression */: { + case 186 /* ElementAccessExpression */: { var _a = node.parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -87725,19 +88126,19 @@ var ts; } return undefined; } - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: if (!ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(node.parent)) { - var argumentInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(node, position, sourceFile); + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 243 /* ImportDeclaration */: - case 249 /* ExportDeclaration */: - case 253 /* ExternalModuleReference */: + case 244 /* ImportDeclaration */: + case 250 /* ExportDeclaration */: + case 254 /* 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*/"); @@ -87763,7 +88164,7 @@ var ts; if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) return; var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); - isNewIdentifier = isNewIdentifier || !!(type.flags & 2 /* String */); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); return getStringLiteralTypes(type, checker, uniques); }); return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; @@ -87778,12 +88179,13 @@ var ts; type = ts.skipConstraint(type); return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, typeChecker, uniques); }) - : type.isStringLiteral() && !(type.flags & 256 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) + : type.isStringLiteral() && !(type.flags & 512 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { - var completionData = getCompletionData(program, log, sourceFile, position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); + var compilerOptions = program.getCompilerOptions(); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); if (!completionData) { return { type: "none" }; } @@ -87797,7 +88199,7 @@ var ts; // completion entry. return ts.firstDefined(symbols, function (symbol) { var origin = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; - var info = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, origin, completionKind); + var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target, origin, completionKind); return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source ? { type: "symbol", symbol: symbol, location: location, symbolToOriginInfoMap: symbolToOriginInfoMap, previousToken: previousToken, isJsxInitializer: isJsxInitializer } : undefined; @@ -87819,7 +88221,7 @@ var ts; var stringLiteralCompletions = !contextToken || !ts.isStringLiteralLike(contextToken) ? undefined : getStringLiteralCompletionEntries(sourceFile, contextToken, position, typeChecker, compilerOptions, host); - return stringLiteralCompletions && stringLiteralCompletionDetails(name, contextToken, stringLiteralCompletions, sourceFile, typeChecker, cancellationToken); + return stringLiteralCompletions && stringLiteralCompletionDetails(name, contextToken, stringLiteralCompletions, sourceFile, typeChecker, cancellationToken); // TODO: GH#18217 } // Compute all the completion symbols again. var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); @@ -87840,7 +88242,7 @@ var ts; 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, previousToken, formatContext, getCanonicalFileName, program.getSourceFiles(), preferences), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay; - return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); + return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217 } case "none": // Didn't find a symbol with this name. See if we can find a keyword instead. @@ -87879,7 +88281,7 @@ var ts; return { codeActions: undefined, sourceDisplay: undefined }; } var moduleSymbol = symbolOriginInfo.moduleSymbol; - var exportedSymbol = ts.skipAlias(symbol.exportSymbol || symbol, checker); + var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, checker, compilerOptions, allSourceFiles, formatContext, getCanonicalFileName, previousToken, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } @@ -87905,12 +88307,15 @@ var ts; CompletionKind[CompletionKind["None"] = 5] = "None"; })(CompletionKind || (CompletionKind = {})); function getRecommendedCompletion(currentToken, position, sourceFile, checker) { - var ty = getContextualType(currentToken, position, sourceFile, checker); - var symbol = ty && ty.symbol; - // Don't include make a recommended completion for an abstract class - return symbol && (symbol.flags & 384 /* Enum */ || symbol.flags & 32 /* Class */ && !ts.isAbstractConstructorSymbol(symbol)) - ? getFirstSymbolInChain(symbol, currentToken, checker) - : undefined; + var contextualType = getContextualType(currentToken, position, sourceFile, checker); + // For a union, return the first one with a recommended completion. + return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { + var symbol = type && type.symbol; + // Don't include make a recommended completion for an abstract class + return symbol && (symbol.flags & (8 /* EnumMember */ | 384 /* Enum */ | 32 /* Class */) && !ts.isAbstractConstructorSymbol(symbol)) + ? getFirstSymbolInChain(symbol, currentToken, checker) + : undefined; + }); } function getContextualType(currentToken, position, sourceFile, checker) { var parent = currentToken.parent; @@ -87919,11 +88324,11 @@ var ts; return getContextualTypeFromParent(currentToken, checker); case 58 /* EqualsToken */: switch (parent.kind) { - case 231 /* VariableDeclaration */: - return checker.getContextualType(parent.initializer); - case 199 /* BinaryExpression */: + case 232 /* VariableDeclaration */: + return checker.getContextualType(parent.initializer); // TODO: GH#18217 + case 200 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; @@ -87933,9 +88338,9 @@ var ts; case 73 /* CaseKeyword */: return getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 17 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 254 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 255 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: - var argInfo = ts.SignatureHelp.getImmediatelyContainingArgumentInfo(currentToken, position, sourceFile); + var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(currentToken, position, sourceFile); return argInfo // At `,`, treat this as the next argument after the comma. ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (currentToken.kind === 26 /* CommaToken */ ? 1 : 0)) @@ -87948,15 +88353,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 187 /* NewExpression */: + case 188 /* NewExpression */: return checker.getContextualType(parent); - case 199 /* BinaryExpression */: { + case 200 /* 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 265 /* CaseClause */: + case 266 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -87972,9 +88377,9 @@ 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 === 273 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 274 /* SourceFile */; }); } - function getCompletionData(program, log, sourceFile, position, preferences, detailsEntryId) { + function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); // TODO: GH#15853 @@ -88024,11 +88429,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 277 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 278 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ true); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 297 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 298 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -88046,7 +88451,7 @@ var ts; } } start = ts.timestamp(); - var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); + var previousToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 log("getCompletionData: Get previous token 1: " + (ts.timestamp() - start)); // The decision to provide completion depends on the contextToken, which is determined through the previousToken. // Note: 'previousToken' (and thus 'contextToken') can be undefined if we are the beginning of the file @@ -88055,7 +88460,7 @@ var ts; // Skip this partial identifier and adjust the contextToken to the token that precedes it. if (contextToken && position <= contextToken.end && (ts.isIdentifier(contextToken) || ts.isKeyword(contextToken.kind))) { var start_4 = ts.timestamp(); - contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); + contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile, /*startNode*/ undefined, insideJsDocTagTypeExpression); // TODO: GH#18217 log("getCompletionData: Get previous token 2: " + (ts.timestamp() - start_4)); } // Find the node where completion is requested on. @@ -88078,14 +88483,15 @@ var ts; if (contextToken.kind === 23 /* DotToken */) { isRightOfDot = true; switch (parent.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; break; - case 145 /* QualifiedName */: + case 146 /* QualifiedName */: node = parent.left; break; - case 178 /* ImportType */: + case 179 /* ImportType */: + case 210 /* MetaProperty */: node = parent; break; default: @@ -88098,7 +88504,7 @@ var ts; // // 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 === 184 /* PropertyAccessExpression */) { + if (parent && parent.kind === 185 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } @@ -88106,39 +88512,39 @@ var ts; if (currentToken.parent === location) { switch (currentToken.kind) { case 29 /* GreaterThanToken */: - if (currentToken.parent.kind === 254 /* JsxElement */ || currentToken.parent.kind === 256 /* JsxOpeningElement */) { + if (currentToken.parent.kind === 255 /* JsxElement */ || currentToken.parent.kind === 257 /* JsxOpeningElement */) { location = currentToken; } break; case 41 /* SlashToken */: - if (currentToken.parent.kind === 255 /* JsxSelfClosingElement */) { + if (currentToken.parent.kind === 256 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 257 /* JsxClosingElement */: + case 258 /* JsxClosingElement */: if (contextToken.kind === 41 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (!(parent.left.flags & 32768 /* ThisNodeHasError */)) { // It has a left-hand side, so we're not in an opening JSX tag. break; } // falls through - case 255 /* JsxSelfClosingElement */: - case 254 /* JsxElement */: - case 256 /* JsxOpeningElement */: + case 256 /* JsxSelfClosingElement */: + case 255 /* JsxElement */: + case 257 /* JsxOpeningElement */: if (contextToken.kind === 27 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: switch (previousToken.kind) { case 58 /* EqualsToken */: isJsxInitializer = true; @@ -88189,12 +88595,14 @@ var ts; return { kind: 0 /* Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, propertyAccessToConvert: propertyAccessToConvert, isNewIdentifierLocation: isNewIdentifierLocation, location: location, keywordFilters: keywordFilters, symbolToOriginInfoMap: symbolToOriginInfoMap, recommendedCompletion: recommendedCompletion, previousToken: previousToken, isJsxInitializer: isJsxInitializer }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 292 /* JSDocParameterTag */: - case 297 /* JSDocPropertyTag */: - case 293 /* JSDocReturnTag */: - case 294 /* JSDocTypeTag */: - case 296 /* JSDocTypedefTag */: + case 293 /* JSDocParameterTag */: + case 298 /* JSDocPropertyTag */: + case 294 /* JSDocReturnTag */: + case 295 /* JSDocTypeTag */: + case 297 /* JSDocTypedefTag */: return true; + default: + return false; } } function getTypeScriptMemberSymbols() { @@ -88225,20 +88633,25 @@ 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.some(function (d) { return d.kind !== 273 /* SourceFile */ && d.kind !== 238 /* ModuleDeclaration */ && d.kind !== 237 /* EnumDeclaration */; })) { + if (!isTypeLocation && symbol.declarations.some(function (d) { return d.kind !== 274 /* SourceFile */ && d.kind !== 239 /* ModuleDeclaration */ && d.kind !== 238 /* EnumDeclaration */; })) { addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); } return; } } } + if (ts.isMetaProperty(node) && (node.keywordToken === 94 /* NewKeyword */ || node.keywordToken === 91 /* ImportKeyword */)) { + var completion = (node.keywordToken === 94 /* NewKeyword */) ? "target" : "meta"; + symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); + return; + } if (!isTypeLocation) { addTypeProperties(typeChecker.getTypeAtLocation(node)); } } function addTypeProperties(type) { isNewIdentifierLocation = hasIndexSignature(type); - if (ts.isSourceFileJavaScript(sourceFile)) { + 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 // each individual type has. This is because we're going to add all identifiers @@ -88249,7 +88662,7 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 178 /* ImportType */ ? node : node.parent, type, symbol)) { + if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 179 /* ImportType */ ? node : node.parent, type, symbol)) { addPropertySymbol(symbol); } } @@ -88259,7 +88672,7 @@ var ts; // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. var symbolSymbol = ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - var leftName = name.kind === 146 /* ComputedPropertyName */ ? getLeftMostName(name.expression) : undefined; + var leftName = name.kind === 147 /* ComputedPropertyName */ ? getLeftMostName(name.expression) : undefined; return leftName && typeChecker.getSymbolAtLocation(leftName); }); if (symbolSymbol) { @@ -88348,7 +88761,7 @@ var ts; var symbolMeanings = 67901928 /* Type */ | 67216319 /* Value */ | 1920 /* Namespace */ | 2097152 /* Alias */; symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 273 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 274 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode); if (thisType) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker, /*isForAccess*/ true); _i < _a.length; _i++) { @@ -88377,17 +88790,17 @@ var ts; if (ts.programContainsEs6Modules(program)) return true; // For JS, stay on the safe side. - if (ts.isSourceFileJavaScript(sourceFile)) + if (isUncheckedFile) return false; // If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK. return ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions()); } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 273 /* SourceFile */: - case 201 /* TemplateExpression */: - case 264 /* JsxExpression */: - case 212 /* Block */: + case 274 /* SourceFile */: + case 202 /* TemplateExpression */: + case 265 /* JsxExpression */: + case 213 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -88424,22 +88837,22 @@ var ts; function isContextTokenValueLocation(contextToken) { return contextToken && contextToken.kind === 103 /* TypeOfKeyword */ && - (contextToken.parent.kind === 164 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + (contextToken.parent.kind === 165 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { case 56 /* ColonToken */: - return parentKind === 151 /* PropertyDeclaration */ || - parentKind === 150 /* PropertySignature */ || - parentKind === 148 /* Parameter */ || - parentKind === 231 /* VariableDeclaration */ || + return parentKind === 152 /* PropertyDeclaration */ || + parentKind === 151 /* PropertySignature */ || + parentKind === 149 /* Parameter */ || + parentKind === 232 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); case 58 /* EqualsToken */: - return parentKind === 236 /* TypeAliasDeclaration */; + return parentKind === 237 /* TypeAliasDeclaration */; case 118 /* AsKeyword */: - return parentKind === 207 /* AsExpression */; + return parentKind === 208 /* AsExpression */; } } return false; @@ -88457,14 +88870,21 @@ var ts; // symbol can be referenced at locations where type is allowed return exportedSymbols.some(symbolCanBeReferencedAtTypeLocation); } + return false; } function getSymbolsFromOtherSourceFileExports(symbols, tokenText, target) { var tokenTextLowerCase = tokenText.toLowerCase(); + var seenResolvedModules = ts.createMap(); ts.codefix.forEachExternalModuleToImportFrom(typeChecker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { // Perf -- ignore other modules if this is a request for details if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { return; } + 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))) { + return; + } for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) { var symbol = _a[_i]; // Don't add a completion for a re-export, only for the original. @@ -88473,7 +88893,7 @@ var ts; // // If `symbol.parent !== ...`, this comes from an `export * from "foo"` re-export. Those don't create new symbols. // If `some(...)`, this comes from an `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). - if (typeChecker.getMergedSymbol(symbol.parent) !== typeChecker.resolveExternalModuleSymbol(moduleSymbol) + if (typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.parent.parent.moduleSpecifier; })) { continue; } @@ -88535,11 +88955,11 @@ var ts; return true; } if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 256 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 257 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 257 /* JsxClosingElement */ || contextToken.parent.kind === 255 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 254 /* JsxElement */; + if (contextToken.parent.kind === 258 /* JsxClosingElement */ || contextToken.parent.kind === 256 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 255 /* JsxElement */; } } return false; @@ -88549,40 +88969,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 186 /* CallExpression */ // func( a, | - || containingNodeKind === 154 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 187 /* NewExpression */ // new C(a, | - || containingNodeKind === 182 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 199 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 162 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 187 /* CallExpression */ // func( a, | + || containingNodeKind === 155 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 188 /* NewExpression */ // new C(a, | + || containingNodeKind === 183 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 200 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 163 /* FunctionType */; // var x: (s: string, list| case 19 /* OpenParenToken */: - return containingNodeKind === 186 /* CallExpression */ // func( | - || containingNodeKind === 154 /* Constructor */ // constructor( | - || containingNodeKind === 187 /* NewExpression */ // new C(a| - || containingNodeKind === 190 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 172 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 187 /* CallExpression */ // func( | + || containingNodeKind === 155 /* Constructor */ // constructor( | + || containingNodeKind === 188 /* NewExpression */ // new C(a| + || containingNodeKind === 191 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 173 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 21 /* OpenBracketToken */: - return containingNodeKind === 182 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 159 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 146 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + return containingNodeKind === 183 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 160 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 147 /* ComputedPropertyName */; // [ | /* this can become an index signature */ case 129 /* ModuleKeyword */: // module | case 130 /* NamespaceKeyword */: // namespace | return true; case 23 /* DotToken */: - return containingNodeKind === 238 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 239 /* ModuleDeclaration */; // module A.| case 17 /* OpenBraceToken */: - return containingNodeKind === 234 /* ClassDeclaration */; // class A{ | + return containingNodeKind === 235 /* ClassDeclaration */; // class A{ | case 58 /* EqualsToken */: - return containingNodeKind === 231 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 199 /* BinaryExpression */; // x = a| + return containingNodeKind === 232 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 200 /* BinaryExpression */; // x = a| case 14 /* TemplateHead */: - return containingNodeKind === 201 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 202 /* TemplateExpression */; // `aa ${| case 15 /* TemplateMiddle */: - return containingNodeKind === 210 /* TemplateSpan */; // `aa ${10} dd ${| + return containingNodeKind === 211 /* TemplateSpan */; // `aa ${10} dd ${| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: - return containingNodeKind === 151 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 152 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { @@ -88595,24 +89015,12 @@ var ts; return false; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { - if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 12 /* RegularExpressionLiteral */ - || ts.isTemplateLiteralKind(contextToken.kind)) { - var start_5 = contextToken.getStart(); - var end = contextToken.getEnd(); - // To be "in" one of these literals, the position has to be: - // 1. entirely within the token text. - // 2. at the end position of an unterminated token. - // 3. at the end of a regular expression (due to trailing flags like '/foo/g'). - if (start_5 < position && position < end) { - return true; - } - if (position === end) { - return !!contextToken.isUnterminated - || contextToken.kind === 12 /* RegularExpressionLiteral */; - } - } - return false; + // To be "in" one of these literals, the position has to be: + // 1. entirely within the token text. + // 2. at the end position of an unterminated token. + // 3. at the end of a regular expression (due to trailing flags like '/foo/g'). + return (ts.isRegularExpressionLiteral(contextToken) || ts.isStringTextContainingNode(contextToken)) && (ts.rangeContainsPositionExclusive(ts.createTextRangeFromSpan(ts.createTextSpanFromNode(contextToken)), position) || + position === contextToken.end && (!!contextToken.isUnterminated || ts.isRegularExpressionLiteral(contextToken))); } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. @@ -88628,7 +89036,7 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 183 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 184 /* ObjectLiteralExpression */) { var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return 2 /* Fail */; @@ -88637,7 +89045,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 179 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 180 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -88648,12 +89056,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 === 221 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 148 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 222 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 149 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 153 /* MethodDeclaration */ || rootDeclaration.parent.kind === 156 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 154 /* MethodDeclaration */ || rootDeclaration.parent.kind === 157 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -88695,8 +89103,8 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 246 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); + var moduleSpecifier = (namedImportsOrExports.kind === 247 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; completionKind = 3 /* MemberLike */; @@ -88723,7 +89131,7 @@ var ts; if (!ts.isClassLike(decl)) return 1 /* Success */; var classElement = contextToken.parent; - var classElementModifierFlags = ts.isClassElement(classElement) && ts.getModifierFlags(classElement); + var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(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 === 71 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { @@ -88739,7 +89147,7 @@ var ts; 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 type = typeChecker.getTypeAtLocation(baseTypeNode); + var type = typeChecker.getTypeAtLocation(baseTypeNode); // TODO: GH#18217 return typeChecker.getPropertiesOfType(classElementModifierFlags & 32 /* Static */ ? typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl) : type); }); symbols = filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags); @@ -88774,13 +89182,14 @@ var ts; */ function tryGetConstructorLikeCompletionContainer(contextToken) { if (contextToken) { + var parent = contextToken.parent; switch (contextToken.kind) { case 19 /* OpenParenToken */: case 26 /* CommaToken */: - return ts.isConstructorDeclaration(contextToken.parent) && contextToken.parent; + return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { - return contextToken.parent.parent; + return parent.parent; } } } @@ -88797,6 +89206,7 @@ var ts; return true; } prev_1 = node; + return false; }); return container && container; } @@ -88808,14 +89218,14 @@ var ts; case 28 /* LessThanSlashToken */: case 41 /* SlashToken */: case 71 /* Identifier */: - case 184 /* PropertyAccessExpression */: - case 262 /* JsxAttributes */: - case 261 /* JsxAttribute */: - case 263 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 255 /* JsxSelfClosingElement */ || parent.kind === 256 /* JsxOpeningElement */)) { + case 185 /* PropertyAccessExpression */: + case 263 /* JsxAttributes */: + case 262 /* JsxAttribute */: + case 264 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 256 /* JsxSelfClosingElement */ || parent.kind === 257 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 261 /* JsxAttribute */) { + else if (parent.kind === 262 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -88827,7 +89237,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent && ((parent.kind === 261 /* JsxAttribute */) || (parent.kind === 263 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 262 /* JsxAttribute */) || (parent.kind === 264 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -88837,8 +89247,8 @@ var ts; break; case 18 /* CloseBraceToken */: if (parent && - parent.kind === 264 /* JsxExpression */ && - parent.parent && parent.parent.kind === 261 /* JsxAttribute */) { + parent.kind === 265 /* JsxExpression */ && + parent.parent && parent.parent.kind === 262 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -88846,7 +89256,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 263 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 264 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -88862,53 +89272,53 @@ var ts; * @returns true if we are certain that the currently edited location must define a new location; false otherwise. */ function isSolelyIdentifierDefinitionLocation(contextToken) { - var containingNodeKind = contextToken.parent.kind; + var parent = contextToken.parent; + var containingNodeKind = parent.kind; switch (contextToken.kind) { case 26 /* CommaToken */: - return containingNodeKind === 231 /* VariableDeclaration */ || - containingNodeKind === 232 /* VariableDeclarationList */ || - containingNodeKind === 213 /* VariableStatement */ || - containingNodeKind === 237 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 232 /* VariableDeclaration */ || + containingNodeKind === 233 /* VariableDeclarationList */ || + containingNodeKind === 214 /* VariableStatement */ || + containingNodeKind === 238 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 235 /* InterfaceDeclaration */ || // interface A= contextToken.pos); + (ts.isClassLike(parent) && + !!parent.typeParameters && + parent.typeParameters.end >= contextToken.pos); case 23 /* DotToken */: - return containingNodeKind === 180 /* ArrayBindingPattern */; // var [.| + return containingNodeKind === 181 /* ArrayBindingPattern */; // var [.| case 56 /* ColonToken */: - return containingNodeKind === 181 /* BindingElement */; // var {x :html| + return containingNodeKind === 182 /* BindingElement */; // var {x :html| case 21 /* OpenBracketToken */: - return containingNodeKind === 180 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 181 /* ArrayBindingPattern */; // var [x| case 19 /* OpenParenToken */: - return containingNodeKind === 268 /* CatchClause */ || + return containingNodeKind === 269 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 17 /* OpenBraceToken */: - return containingNodeKind === 237 /* EnumDeclaration */; // enum a { | + return containingNodeKind === 238 /* EnumDeclaration */; // enum a { | case 27 /* LessThanToken */: - return containingNodeKind === 234 /* ClassDeclaration */ || // class A< | - containingNodeKind === 204 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 235 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 236 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 235 /* ClassDeclaration */ || // class A< | + containingNodeKind === 205 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 236 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 237 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); case 115 /* StaticKeyword */: - return containingNodeKind === 151 /* PropertyDeclaration */ && !ts.isClassLike(contextToken.parent.parent); + return containingNodeKind === 152 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 24 /* DotDotDotToken */: - return containingNodeKind === 148 /* Parameter */ || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 180 /* ArrayBindingPattern */); // var [...z| + return containingNodeKind === 149 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 181 /* ArrayBindingPattern */); // var [...z| case 114 /* PublicKeyword */: case 112 /* PrivateKeyword */: case 113 /* ProtectedKeyword */: - return containingNodeKind === 148 /* Parameter */ && !ts.isConstructorDeclaration(contextToken.parent.parent); + return containingNodeKind === 149 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); case 118 /* AsKeyword */: - return containingNodeKind === 247 /* ImportSpecifier */ || - containingNodeKind === 251 /* ExportSpecifier */ || - containingNodeKind === 245 /* NamespaceImport */; + return containingNodeKind === 248 /* ImportSpecifier */ || + containingNodeKind === 252 /* ExportSpecifier */ || + containingNodeKind === 246 /* NamespaceImport */; case 125 /* GetKeyword */: case 136 /* SetKeyword */: if (isFromObjectTypeDeclaration(contextToken)) { @@ -88969,7 +89379,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 154 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 155 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -88992,12 +89402,12 @@ 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 !== 269 /* PropertyAssignment */ && - m.kind !== 270 /* ShorthandPropertyAssignment */ && - m.kind !== 181 /* BindingElement */ && - m.kind !== 153 /* MethodDeclaration */ && - m.kind !== 155 /* GetAccessor */ && - m.kind !== 156 /* SetAccessor */) { + if (m.kind !== 270 /* PropertyAssignment */ && + m.kind !== 271 /* ShorthandPropertyAssignment */ && + m.kind !== 182 /* BindingElement */ && + m.kind !== 154 /* MethodDeclaration */ && + m.kind !== 156 /* GetAccessor */ && + m.kind !== 157 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -89005,7 +89415,7 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 181 /* BindingElement */ && m.propertyName) { + if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list if (m.propertyName.kind === 71 /* Identifier */) { existingName = m.propertyName.escapedText; @@ -89018,7 +89428,7 @@ var ts; var name = ts.getNameOfDeclaration(m); existingName = ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } - existingMemberNames.set(existingName, true); + existingMemberNames.set(existingName, true); // TODO: GH#18217 } return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); } @@ -89032,10 +89442,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 !== 151 /* PropertyDeclaration */ && - m.kind !== 153 /* MethodDeclaration */ && - m.kind !== 155 /* GetAccessor */ && - m.kind !== 156 /* SetAccessor */) { + if (m.kind !== 152 /* PropertyDeclaration */ && + m.kind !== 154 /* MethodDeclaration */ && + m.kind !== 156 /* GetAccessor */ && + m.kind !== 157 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -89075,7 +89485,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 261 /* JsxAttribute */) { + if (attr.kind === 262 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } } @@ -89119,7 +89529,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 72 /* FirstKeyword */; i <= 144 /* LastKeyword */; i++) { + for (var i = 72 /* FirstKeyword */; i <= 145 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -89220,7 +89630,7 @@ var ts; } // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals. var filteredTypes = isForAccess ? type.types : type.types.filter(function (memberType) { - return !(memberType.flags & 16382 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker)); + return !(memberType.flags & 32764 /* Primitive */ || checker.isArrayLikeType(memberType) || ts.typeHasCallOrConstructSignatures(memberType, checker)); }); return ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(filteredTypes), "getAllPossiblePropertiesOfTypes() should all be defined"); } @@ -89231,7 +89641,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location) { // class c { method() { } | method2() { } } switch (location.kind) { - case 298 /* SyntaxList */: + case 299 /* 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); @@ -89255,7 +89665,7 @@ var ts; if (!isFromObjectTypeDeclaration(contextToken)) return undefined; var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) + return (isValidKeyword(contextToken.kind) || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -89278,7 +89688,7 @@ var ts; return isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return contextToken.kind === 27 /* LessThanToken */ && contextToken.parent.kind !== 199 /* BinaryExpression */; + return contextToken.kind === 27 /* LessThanToken */ && contextToken.parent.kind !== 200 /* BinaryExpression */; case "/": return ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) @@ -89291,8 +89701,8 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 13 /* NoSubstitutionTemplateLiteral */: - case 201 /* TemplateExpression */: - case 188 /* TaggedTemplateExpression */: + case 202 /* TemplateExpression */: + case 189 /* TaggedTemplateExpression */: return true; default: return false; @@ -89337,7 +89747,7 @@ var ts; if (!sourceFilesSet.has(fileName)) { ts.Debug.assert(program.redirectTargetsSet.has(fileName)); var redirectTarget_1 = program.getSourceFile(fileName); - var redirect = ts.find(sourceFilesToSearch, function (f) { return f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget_1; }); + var redirect = ts.find(sourceFilesToSearch, function (f) { return !!f.redirectInfo && f.redirectInfo.redirectTarget === redirectTarget_1; }); fileName = redirect.fileName; ts.Debug.assert(sourceFilesSet.has(fileName)); } @@ -89383,6 +89793,8 @@ var ts; return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); case 120 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); + case 116 /* YieldKeyword */: + return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) ? highlightSpans(getModifierOccurrences(node.kind, node.parent)) @@ -89410,7 +89822,7 @@ var ts; } else if (ts.isTryStatement(node)) { // Exceptions thrown within a try block lacking a catch clause are "owned" in the current context. - return ts.concatenate(node.catchClause ? aggregateOwnedThrowStatements(node.catchClause) : node.tryBlock && aggregateOwnedThrowStatements(node.tryBlock), aggregateOwnedThrowStatements(node.finallyBlock)); + return ts.concatenate(node.catchClause ? aggregateOwnedThrowStatements(node.catchClause) : node.tryBlock && aggregateOwnedThrowStatements(node.tryBlock), node.finallyBlock && aggregateOwnedThrowStatements(node.finallyBlock)); } // Do not cross function boundaries. return ts.isFunctionLike(node) ? undefined : flatMapChildren(node, aggregateOwnedThrowStatements); @@ -89424,7 +89836,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 273 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 274 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -89451,26 +89863,26 @@ var ts; } function ownsBreakOrContinueStatement(owner, statement) { var actualOwner = getBreakOrContinueOwner(statement); - return actualOwner && actualOwner === owner; + return !!actualOwner && actualOwner === owner; } function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 226 /* SwitchStatement */: - if (statement.kind === 222 /* ContinueStatement */) { + case 227 /* SwitchStatement */: + if (statement.kind === 223 /* ContinueStatement */) { return false; } // falls through - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 218 /* WhileStatement */: - case 217 /* DoStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 219 /* WhileStatement */: + case 218 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. // TODO: GH#20090 - return (ts.isFunctionLike(node) && "quit"); + return ts.isFunctionLike(node) && "quit"; } }); } @@ -89488,11 +89900,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 239 /* ModuleBlock */: - case 273 /* SourceFile */: - case 212 /* Block */: - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 240 /* ModuleBlock */: + case 274 /* SourceFile */: + case 213 /* Block */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return declaration.members.concat([declaration]); @@ -89500,13 +89912,12 @@ var ts; else { return container.statements; } - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 233 /* FunctionDeclaration */: { + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 234 /* FunctionDeclaration */: return container.parameters.concat((ts.isClassLike(container.parent) ? container.parent.members : [])); - } - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: 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. @@ -89539,7 +89950,7 @@ var ts; var keywords = []; if (pushKeywordIf(keywords, loopNode.getFirstToken(), 88 /* ForKeyword */, 106 /* WhileKeyword */, 81 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 217 /* DoStatement */) { + if (loopNode.kind === 218 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { @@ -89559,13 +89970,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 217 /* DoStatement */: - case 218 /* WhileStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 218 /* DoStatement */: + case 219 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -89641,16 +90052,35 @@ var ts; pushKeywordIf(keywords, modifier, 120 /* AsyncKeyword */); }); } - ts.forEachChild(func, aggregate); + ts.forEachChild(func, function (child) { + traverseWithoutCrossingFunction(child, function (node) { + if (ts.isAwaitExpression(node)) { + pushKeywordIf(keywords, node.getFirstToken(), 121 /* AwaitKeyword */); + } + }); + }); return keywords; - function aggregate(node) { - if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 121 /* AwaitKeyword */); - } - // Do not cross function boundaries. - if (!ts.isFunctionLike(node) && !ts.isClassLike(node) && !ts.isInterfaceDeclaration(node) && !ts.isModuleDeclaration(node) && !ts.isTypeAliasDeclaration(node) && !ts.isTypeNode(node)) { - ts.forEachChild(node, aggregate); - } + } + function getYieldOccurrences(node) { + var func = ts.getContainingFunction(node); + if (!func) { + return undefined; + } + var keywords = []; + ts.forEachChild(func, function (child) { + traverseWithoutCrossingFunction(child, function (node) { + if (ts.isYieldExpression(node)) { + pushKeywordIf(keywords, node.getFirstToken(), 116 /* YieldKeyword */); + } + }); + }); + return keywords; + } + // Do not cross function/class/interface/module/type boundaries. + function traverseWithoutCrossingFunction(node, cb) { + cb(node); + if (!ts.isFunctionLike(node) && !ts.isClassLike(node) && !ts.isInterfaceDeclaration(node) && !ts.isModuleDeclaration(node) && !ts.isTypeAliasDeclaration(node) && !ts.isTypeNode(node)) { + ts.forEachChild(node, function (child) { return traverseWithoutCrossingFunction(child, cb); }); } } function getIfElseOccurrences(ifStatement, sourceFile) { @@ -89720,6 +90150,11 @@ var ts; var ts; (function (ts) { function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { + return createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory); + } + ts.createDocumentRegistry = createDocumentRegistry; + /*@internal*/ + function createDocumentRegistryInternal(useCaseSensitiveFileNames, currentDirectory, externalCache) { if (currentDirectory === void 0) { currentDirectory = ""; } // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. @@ -89733,7 +90168,7 @@ var ts; if (!bucket && createIfMissing) { buckets.set(key, bucket = ts.createMap()); } - return bucket; + return bucket; // TODO: GH#18217 } function reportStats() { var bucketInfoArray = ts.arrayFrom(buckets.keys()).filter(function (name) { return name && name.charAt(0) === "_"; }).map(function (name) { @@ -89742,8 +90177,7 @@ var ts; entries.forEach(function (entry, name) { sourceFiles.push({ name: name, - refCount: entry.languageServiceRefCount, - references: entry.owners.slice(0) + refCount: entry.languageServiceRefCount }); }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); @@ -89774,13 +90208,26 @@ var ts; var bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ true); var entry = bucket.get(path); var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : compilationSettings.target; + if (!entry && externalCache) { + var sourceFile = externalCache.getDocument(key, path); + if (sourceFile) { + ts.Debug.assert(acquiring); + entry = { + sourceFile: sourceFile, + languageServiceRefCount: 0 + }; + bucket.set(path, entry); + } + } if (!entry) { // Have never seen this file with these settings. Create a new source file for it. - var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, /*setNodeParents*/ false, scriptKind); + var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, /*setNodeParents*/ false, scriptKind); // TODO: GH#18217 + if (externalCache) { + externalCache.setDocument(key, path, sourceFile); + } entry = { sourceFile: sourceFile, languageServiceRefCount: 1, - owners: [] }; bucket.set(path, entry); } @@ -89789,7 +90236,10 @@ var ts; // the script snapshot. If so, update it appropriately. Otherwise, we can just // return it as is. if (entry.sourceFile.version !== version) { - entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); + entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); // TODO: GH#18217 + if (externalCache) { + externalCache.setDocument(key, path, entry.sourceFile); + } } // If we're acquiring, then this is the first time this LS is asking for this document. // Increase our ref count so we know there's another LS using the document. If we're @@ -89800,6 +90250,7 @@ var ts; entry.languageServiceRefCount++; } } + ts.Debug.assert(entry.languageServiceRefCount !== 0); return entry.sourceFile; } function releaseDocument(fileName, compilationSettings) { @@ -89817,6 +90268,13 @@ var ts; bucket.delete(path); } } + function getLanguageServiceRefCounts(path) { + return ts.arrayFrom(buckets.entries(), function (_a) { + var key = _a[0], bucket = _a[1]; + var entry = bucket.get(path); + return [key, entry && entry.languageServiceRefCount]; + }); + } return { acquireDocument: acquireDocument, acquireDocumentWithKey: acquireDocumentWithKey, @@ -89824,11 +90282,12 @@ var ts; updateDocumentWithKey: updateDocumentWithKey, releaseDocument: releaseDocument, releaseDocumentWithKey: releaseDocumentWithKey, + getLanguageServiceRefCounts: getLanguageServiceRefCounts, reportStats: reportStats, getKeyForCompilationSettings: getKeyForCompilationSettings }; } - ts.createDocumentRegistry = createDocumentRegistry; + ts.createDocumentRegistryInternal = createDocumentRegistryInternal; })(ts || (ts = {})); /* Code for finding imports of an exported symbol. Used only by FindAllReferences. */ /* @internal */ @@ -89891,10 +90350,10 @@ var ts; } cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 231 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 232 /* VariableDeclaration */) { var name = parent.name; if (name.kind === 71 /* Identifier */) { directImports.push(name); @@ -89907,12 +90366,12 @@ var ts; break; case 71 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */)); break; - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 245 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 246 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name); } else if (ts.isDefaultImport(direct)) { @@ -89926,7 +90385,7 @@ var ts; directImports.push(direct); } break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -89936,7 +90395,7 @@ var ts; directImports.push(direct); } break; - case 178 /* ImportType */: + case 179 /* ImportType */: directImports.push(direct); break; default: @@ -89952,7 +90411,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 273 /* SourceFile */ || sourceFileLike.kind === 238 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 274 /* SourceFile */ || sourceFileLike.kind === 239 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -89965,7 +90424,7 @@ var ts; ts.Debug.assert(!isAvailableThroughGlobal); var isNew = markSeenIndirectUser(sourceFileLike); if (isNew) { - indirectUserDeclarations.push(sourceFileLike); + indirectUserDeclarations.push(sourceFileLike); // TODO: GH#18217 } return isNew; } @@ -90007,7 +90466,7 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 242 /* ImportEqualsDeclaration */) { + if (decl.kind === 243 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } @@ -90017,7 +90476,7 @@ var ts; handleNamespaceImportLike(decl); return; } - if (decl.kind === 178 /* ImportType */) { + if (decl.kind === 179 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -90032,7 +90491,7 @@ var ts; if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { return; } - if (decl.kind === 249 /* ExportDeclaration */) { + if (decl.kind === 250 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } @@ -90041,12 +90500,12 @@ var ts; return; } var namedBindings = importClause.namedBindings; - if (namedBindings && namedBindings.kind === 245 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 246 /* NamespaceImport */) { handleNamespaceImportLike(namedBindings.name); return; } if (exportKind === 0 /* Named */) { - searchForNamedImport(namedBindings); + searchForNamedImport(namedBindings); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) } else { // `export =` might be imported by a default import if `--allowSyntheticDefaultImports` is on, so this handles both ExportKind.Default and ExportKind.ExportEquals @@ -90095,7 +90554,7 @@ var ts; } } else { - var localSymbol = element.kind === 251 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 252 /* 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); @@ -90110,7 +90569,7 @@ var ts; /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ function findNamespaceReExports(sourceFileLike, name, checker) { var namespaceImportSymbol = checker.getSymbolAtLocation(name); - return forEachPossibleImportOrExportStatement(sourceFileLike, function (statement) { + return !!forEachPossibleImportOrExportStatement(sourceFileLike, function (statement) { if (!ts.isExportDeclaration(statement)) return; var exportClause = statement.exportClause, moduleSpecifier = statement.moduleSpecifier; @@ -90124,7 +90583,7 @@ var ts; for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { var referencingFile = sourceFiles_5[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 273 /* SourceFile */) { + if (searchSourceFile.kind === 274 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -90171,7 +90630,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 === 273 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 274 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -90186,15 +90645,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 249 /* ExportDeclaration */: - case 243 /* ImportDeclaration */: { + case 250 /* ExportDeclaration */: + case 244 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 242 /* ImportEqualsDeclaration */: { + case 243 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -90216,12 +90675,13 @@ var ts; return comingFromExport ? getExport() : getExport() || getImport(); function getExport() { var parent = node.parent; + var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 184 /* PropertyAccessExpression */) { + if (parent.kind === 185 /* 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(parent.parent) - ? getSpecialPropertyExport(parent.parent, /*useLhsSymbol*/ false) + return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) + ? getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ false) : undefined; } else { @@ -90248,15 +90708,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(parent.parent)) { - return getExportAssignmentExport(parent.parent); + 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(parent.parent)) { - return getSpecialPropertyExport(parent.parent, /*useLhsSymbol*/ true); + else if (ts.isBinaryExpression(grandParent)) { + return getSpecialPropertyExport(grandParent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { return exportInfo(symbol, 0 /* Named */); @@ -90331,15 +90791,18 @@ var ts; else if (ts.isBinaryExpression(decl)) { // `module.exports = class {}` return ts.Debug.assertDefined(decl.right.symbol); } + else if (ts.isSourceFile(decl)) { // json module + return ts.Debug.assertDefined(decl.symbol); + } return ts.Debug.fail(); } // If a reference is a class expression, the exported node would be its parent. // If a reference is a variable declaration, the exported node would be the variable statement. function getExportNode(parent, node) { - if (parent.kind === 231 /* VariableDeclaration */) { + if (parent.kind === 232 /* VariableDeclaration */) { var p = parent; return p.name !== node ? undefined : - p.parent.kind === 268 /* CatchClause */ ? undefined : p.parent.parent.kind === 213 /* VariableStatement */ ? p.parent.parent : undefined; + p.parent.kind === 269 /* CatchClause */ ? undefined : p.parent.parent.kind === 214 /* VariableStatement */ ? p.parent.parent : undefined; } else { return parent; @@ -90348,15 +90811,15 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent) ? { isNamedImport: false } : undefined; - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return parent.propertyName ? undefined : { isNamedImport: true }; - case 244 /* ImportClause */: - case 245 /* NamespaceImport */: + case 245 /* ImportClause */: + case 246 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return { isNamedImport: false }; default: @@ -90389,21 +90852,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 186 /* CallExpression */) { + if (node.kind === 187 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 273 /* SourceFile */) { + if (parent.kind === 274 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 239 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 240 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 238 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + return node.kind === 239 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 253 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; + return eq.moduleReference.kind === 254 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 9 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -90413,7 +90876,7 @@ var ts; var FindAllReferences; (function (FindAllReferences) { function nodeEntry(node, isInString) { - return { type: "node", node: node, isInString: isInString }; + return { type: "node", node: node.name || node, isInString: isInString }; } FindAllReferences.nodeEntry = nodeEntry; function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position) { @@ -90439,13 +90902,13 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 273 /* SourceFile */) { + if (node.kind === 274 /* 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 === 270 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 271 /* ShorthandPropertyAssignment */) { var result_5 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_5.push(nodeEntry(node)); }); return result_5; @@ -90549,13 +91012,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 183 /* ObjectLiteralExpression */) { + else if (node.kind === 184 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] }; } - else if (node.kind === 204 /* ClassExpression */) { + else if (node.kind === 205 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] @@ -90626,6 +91089,7 @@ var ts; } var moduleReferences = ts.emptyArray; var moduleSourceFile = isModuleSymbol(symbol); + var referencedNode = node; if (moduleSourceFile) { var exportEquals = symbol.exports.get("export=" /* ExportEquals */); // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. @@ -90634,13 +91098,13 @@ var ts; return moduleReferences; // Continue to get references to 'export ='. symbol = ts.skipAlias(exportEquals, checker); - node = undefined; + referencedNode = undefined; } - return ts.concatenate(moduleReferences, getReferencedSymbolsForSymbol(symbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options)); + return ts.concatenate(moduleReferences, getReferencedSymbolsForSymbol(symbol, referencedNode, sourceFiles, sourceFilesSet, checker, cancellationToken, options)); } Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; function isModuleSymbol(symbol) { - return symbol.flags & 1536 /* Module */ && ts.find(symbol.declarations, ts.isSourceFile); + return symbol.flags & 1536 /* Module */ ? ts.find(symbol.declarations, ts.isSourceFile) : undefined; } function getReferencedSymbolsForModule(program, symbol, excludeImportTypeOfExportEquals, sourceFiles, sourceFilesSet) { ts.Debug.assert(!!symbol.valueDeclaration); @@ -90667,10 +91131,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 273 /* SourceFile */: + case 274 /* 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 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push({ type: "node", node: decl.name }); } @@ -90718,7 +91182,7 @@ var ts; searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); } else { - var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.implementations) : [symbol] }); + var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, !!options.implementations) : [symbol] }); // Try to get the smallest valid scope that we can limit our search to; // otherwise we'll need to search globally (i.e. include each file). var scope = getSymbolScope(symbol); @@ -90826,7 +91290,7 @@ var ts; State.prototype.getImportSearches = function (exportSymbol, exportInfo) { if (!this.importTracker) this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); - return this.importTracker(exportSymbol, exportInfo, this.options.isForRename); + return this.importTracker(exportSymbol, exportInfo, !!this.options.isForRename); }; /** @param allSearchSymbols set of additinal symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { @@ -90837,7 +91301,7 @@ var ts; // here appears to be intentional). var _a = searchOptions.text, text = _a === void 0 ? ts.stripQuotes(ts.unescapeLeadingUnderscores((ts.getLocalSymbolForExportDefault(symbol) || symbol).escapedName)) : _a, _b = searchOptions.allSearchSymbols, allSearchSymbols = _b === void 0 ? [symbol] : _b; var escapedText = ts.escapeLeadingUnderscores(text); - var parents = this.options.implementations && location && getParentSymbolsOfPropertyAccess(location, symbol, this.checker); + var parents = this.options.implementations && location ? getParentSymbolsOfPropertyAccess(location, symbol, this.checker) : undefined; return { symbol: symbol, comingFrom: comingFrom, text: text, escapedText: escapedText, parents: parents, allSearchSymbols: allSearchSymbols, includes: function (sym) { return ts.contains(allSearchSymbols, sym); } }; }; /** @@ -90938,13 +91402,14 @@ var ts; } } function getPropertySymbolOfDestructuringAssignment(location, checker) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - checker.getPropertySymbolOfDestructuringAssignment(location); + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) + ? checker.getPropertySymbolOfDestructuringAssignment(location) + : undefined; } function getObjectBindingElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 181 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 182 /* BindingElement */); if (bindingElement && - bindingElement.parent.kind === 179 /* ObjectBindingPattern */ && + bindingElement.parent.kind === 180 /* ObjectBindingPattern */ && ts.isIdentifier(bindingElement.name) && !bindingElement.propertyName) { return bindingElement; @@ -90966,7 +91431,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 === 191 /* FunctionExpression */ || valueDeclaration.kind === 204 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 192 /* FunctionExpression */ || valueDeclaration.kind === 205 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -90976,7 +91441,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 234 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 235 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -90998,14 +91463,14 @@ var ts; return undefined; } var scope; - for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { - var declaration = declarations_9[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; var container = ts.getContainerNode(declaration); if (scope && scope !== container) { // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 273 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 274 /* 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; @@ -91018,23 +91483,32 @@ var ts; // declare module "a" { export type T = number; } // declare module "b" { import { T } from "a"; export const x: T; } // So we must search the whole source file. (Because we will mark the source file as seen, we we won't return to it when searching for imports.) - return exposedByParent ? scope.getSourceFile() : scope; + return exposedByParent ? scope.getSourceFile() : scope; // TODO: GH#18217 } /** Used as a quick check for whether a symbol is used at all in a file (besides its definition). */ function isSymbolReferencedInFile(definition, checker, sourceFile) { - var symbol = checker.getSymbolAtLocation(definition); - if (!symbol) - return true; // Be lenient with invalid code. - return getPossibleSymbolReferenceNodes(sourceFile, symbol.name).some(function (token) { - if (!ts.isIdentifier(token) || token === definition || token.escapedText !== definition.escapedText) - return false; - var referenceSymbol = checker.getSymbolAtLocation(token); - return referenceSymbol === symbol - || checker.getShorthandAssignmentValueSymbol(token.parent) === symbol - || ts.isExportSpecifier(token.parent) && getLocalSymbolForExportSpecifier(token, referenceSymbol, token.parent, checker) === symbol; - }); + return eachSymbolReferenceInFile(definition, checker, sourceFile, function () { return true; }) || false; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; + function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { + var symbol = checker.getSymbolAtLocation(definition); + if (!symbol) + return undefined; + for (var _i = 0, _a = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _i < _a.length; _i++) { + var token = _a[_i]; + if (!ts.isIdentifier(token) || token === definition || token.escapedText !== definition.escapedText) + continue; + var referenceSymbol = checker.getSymbolAtLocation(token); // See GH#19955 for why the type annotation is necessary + if (referenceSymbol === symbol + || checker.getShorthandAssignmentValueSymbol(token.parent) === symbol + || ts.isExportSpecifier(token.parent) && getLocalSymbolForExportSpecifier(token, referenceSymbol, token.parent, checker) === symbol) { + var res = cb(token); + if (res) + return res; + } + } + } + Core.eachSymbolReferenceInFile = eachSymbolReferenceInFile; function getPossibleSymbolReferenceNodes(sourceFile, symbolName, container) { if (container === void 0) { container = sourceFile; } return getPossibleSymbolReferencePositions(sourceFile, symbolName, container).map(function (pos) { return ts.getTouchingPropertyName(sourceFile, pos, /*includeJsDocComment*/ true); }); @@ -91210,7 +91684,8 @@ var ts; if (!(referenceLocation === propertyName && state.options.isForRename)) { var exportKind = referenceLocation.originalKeywordKind === 79 /* DefaultKeyword */ ? 1 /* Default */ : 0 /* Named */; var exportInfo = FindAllReferences.getExportInfo(referenceSymbol, exportKind, state.checker); - ts.Debug.assert(!!exportInfo); + if (!exportInfo) + return ts.Debug.fail(); searchForImportsOfExport(referenceLocation, referenceSymbol, exportInfo, state); } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. @@ -91327,12 +91802,12 @@ var ts; for (var _i = 0, _a = classSymbol.members.get("__constructor" /* Constructor */).declarations; _i < _a.length; _i++) { var decl = _a[_i]; var ctrKeyword = ts.findChildOfKind(decl, 123 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 154 /* Constructor */ && !!ctrKeyword); + ts.Debug.assert(decl.kind === 155 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 153 /* MethodDeclaration */) { + if (decl && decl.kind === 154 /* MethodDeclaration */) { var body = decl.body; if (body) { forEachDescendantOfKind(body, 99 /* ThisKeyword */, function (thisKeyword) { @@ -91346,14 +91821,13 @@ var ts; } /** Find references to `super` in the constructor of an extending class. */ function findSuperConstructorAccesses(cls, addNode) { - var symbol = cls.symbol; - var ctr = symbol.members.get("__constructor" /* Constructor */); + var ctr = cls.symbol.members.get("__constructor" /* Constructor */); if (!ctr) { return; } for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 154 /* Constructor */); + ts.Debug.assert(decl.kind === 155 /* Constructor */); var body = decl.body; if (body) { forEachDescendantOfKind(body, 97 /* SuperKeyword */, function (node) { @@ -91367,13 +91841,13 @@ var ts; function addImplementationReferences(refNode, addReference, state) { // Check if we found a function/propertyAssignment/method with an implementation or initializer if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - addReference(refNode.parent); + addReference(refNode); return; } if (refNode.kind !== 71 /* Identifier */) { return; } - if (refNode.parent.kind === 270 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 271 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -91393,7 +91867,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 212 /* Block */) { + if (body.kind === 213 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -91421,13 +91895,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 190 /* ParenthesizedExpression */: + case 191 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 192 /* ArrowFunction */: - case 191 /* FunctionExpression */: - case 183 /* ObjectLiteralExpression */: - case 204 /* ClassExpression */: - case 182 /* ArrayLiteralExpression */: + case 193 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 184 /* ObjectLiteralExpression */: + case 205 /* ClassExpression */: + case 183 /* ArrayLiteralExpression */: return true; default: return false; @@ -91480,13 +91954,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -91511,34 +91985,34 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 273 /* SourceFile */: + case 274 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // falls through - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 192 /* 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 === 273 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 274 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -91546,19 +92020,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 204 /* ClassExpression */: - case 234 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 235 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 273 /* SourceFile */: - return container.kind === 273 /* SourceFile */ && !ts.isExternalModule(container); + case 274 /* SourceFile */: + return container.kind === 274 /* SourceFile */ && !ts.isExternalModule(container); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -91643,37 +92117,11 @@ var ts; return cbSymbol(sym, rootSymbol) // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */) && allowBaseTypes(rootSymbol) - ? getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base); }) + ? ts.getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base); }) : undefined); }); } } - /** - * Find symbol of the given property-name and add the symbol to the given result array - * @param symbol a symbol to start searching for the given propertyName - * @param propertyName a name of property to search for - * @param result an array of symbol of found property symbols - * @param previousIterationSymbolsCache a cache of symbol from previous iterations of calling this function to prevent infinite revisiting of the same symbol. - * The value of previousIterationSymbol is undefined when the function is first called. - */ - function getPropertySymbolsFromBaseTypes(symbol, propertyName, checker, cb) { - var seen = ts.createMap(); - return recur(symbol); - function recur(symbol) { - // Use `addToSeen` to ensure we don't infinitely recurse in this situation: - // interface C extends C { - // /*findRef*/propName: string; - // } - if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) - return; - return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { - var type = checker.getTypeAtLocation(typeReference); - var propertySymbol = type && type.symbol && checker.getPropertyOfType(type, propertyName); - // Visit the typeReference as well to see if it directly or indirectly uses that property - return propertySymbol && (ts.firstDefined(checker.getRootSymbols(propertySymbol), cb) || recur(type.symbol)); - }); }); - } - } function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { var checker = state.checker; return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, function (sym, rootSymbol, baseSymbol) { return search.includes(baseSymbol || rootSymbol || sym) @@ -91690,7 +92138,7 @@ var ts; var name = ts.getNameFromPropertyName(node.name); var symbol = contextualType && name && contextualType.getProperty(name); return symbol ? [symbol] : - contextualType && contextualType.isUnion() ? ts.mapDefined(contextualType.types, function (t) { return t.getProperty(name); }) : ts.emptyArray; + contextualType && contextualType.isUnion() ? ts.mapDefined(contextualType.types, function (t) { return t.getProperty(name); }) : ts.emptyArray; // TODO: GH#18217 } /** * Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations @@ -91712,8 +92160,8 @@ var ts; // To achieve that we will keep iterating until the result stabilizes. // Remember the last meaning lastIterationMeaning = meaning; - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var declaration = declarations_10[_i]; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; var declarationMeaning = ts.getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -91774,6 +92222,184 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, preferences) { + var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); + var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + var oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName); + var newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName); + return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { + updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); + updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences); + }); + } + ts.getEditsForFileRename = getEditsForFileRename; + function getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName) { + var canonicalOldPath = getCanonicalFileName(oldFileOrDirPath); + return function (path) { + var canonicalPath = getCanonicalFileName(path); + if (canonicalPath === canonicalOldPath) + return newFileOrDirPath; + var suffix = ts.tryRemoveDirectoryPrefix(canonicalPath, canonicalOldPath); + return suffix === undefined ? undefined : newFileOrDirPath + "/" + suffix; + }; + } + function updateTsconfigFiles(program, changeTracker, oldToNew, newFileOrDirPath, currentDirectory, useCaseSensitiveFileNames) { + var configFile = program.getCompilerOptions().configFile; + if (!configFile) + return; + var configDir = ts.getDirectoryPath(configFile.fileName); + var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(configFile); + if (!jsonObjectLiteral) + return; + forEachProperty(jsonObjectLiteral, function (property, propertyName) { + switch (propertyName) { + case "files": + case "include": + case "exclude": { + var foundExactMatch = updatePaths(property); + if (!foundExactMatch && propertyName === "include" && ts.isArrayLiteralExpression(property.initializer)) { + var includes = ts.mapDefined(property.initializer.elements, function (e) { return ts.isStringLiteral(e) ? e.text : undefined; }); + var matchers = ts.getFileMatcherPatterns(configDir, /*excludes*/ [], includes, useCaseSensitiveFileNames, currentDirectory); + // If there isn't some include for this, add a new one. + if (!ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { + changeTracker.insertNodeAfter(configFile, ts.last(property.initializer.elements), ts.createStringLiteral(relativePath(newFileOrDirPath))); + } + } + break; + } + case "compilerOptions": + forEachProperty(property.initializer, function (property, propertyName) { + var option = ts.getOptionFromName(propertyName); + if (option && (option.isFilePath || option.type === "list" && option.element.isFilePath)) { + updatePaths(property); + } + else if (propertyName === "paths") { + forEachProperty(property.initializer, function (pathsProperty) { + if (!ts.isArrayLiteralExpression(pathsProperty.initializer)) + return; + for (var _i = 0, _a = pathsProperty.initializer.elements; _i < _a.length; _i++) { + var e = _a[_i]; + tryUpdateString(e); + } + }); + } + }); + break; + } + }); + function updatePaths(property) { + // Type annotation needed due to #7294 + var elements = ts.isArrayLiteralExpression(property.initializer) ? property.initializer.elements : [property.initializer]; + var foundExactMatch = false; + for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) { + var element = elements_5[_i]; + foundExactMatch = tryUpdateString(element) || foundExactMatch; + } + return foundExactMatch; + } + function tryUpdateString(element) { + if (!ts.isStringLiteral(element)) + return false; + var elementFileName = combinePathsSafe(configDir, element.text); + var updated = oldToNew(elementFileName); + if (updated !== undefined) { + changeTracker.replaceRangeWithText(configFile, createStringRange(element, configFile), relativePath(updated)); + return true; + } + return false; + } + function relativePath(path) { + return ts.getRelativePathFromDirectory(configDir, path, /*ignoreCase*/ !useCaseSensitiveFileNames); + } + } + function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName, preferences) { + var _loop_14 = function (sourceFile) { + var newImportFromPath = oldToNew(sourceFile.fileName) || sourceFile.fileName; + var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); + var oldFromNew = newToOld(sourceFile.fileName); + var oldImportFromPath = oldFromNew || sourceFile.fileName; + var oldImportFromDirectory = ts.getDirectoryPath(oldImportFromPath); + updateImportsWorker(sourceFile, changeTracker, function (referenceText) { + if (!ts.pathIsRelative(referenceText)) + return undefined; + var oldAbsolute = combinePathsSafe(oldImportFromDirectory, referenceText); + var newAbsolute = oldToNew(oldAbsolute); + return newAbsolute === undefined ? undefined : ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(newImportFromDirectory, newAbsolute, getCanonicalFileName)); + }, function (importLiteral) { + 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. + // TODO:GH#18217 + ? getSourceFileToImportFromResolved(ts.resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host), oldToNew, program) + : getSourceFileToImport(importLiteral, sourceFile, program, host, oldToNew); + return toImport === undefined ? undefined : ts.moduleSpecifiers.getModuleSpecifier(program, sourceFile, newImportFromPath, toImport, host, preferences); + }); + }; + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + _loop_14(sourceFile); + } + } + function combineNormal(pathA, pathB) { + return ts.normalizePath(ts.combinePaths(pathA, pathB)); + } + function combinePathsSafe(pathA, pathB) { + return ts.ensurePathIsNonModuleName(combineNormal(pathA, pathB)); + } + function getSourceFileToImport(importLiteral, importingSourceFile, program, host, oldToNew) { + var symbol = program.getTypeChecker().getSymbolAtLocation(importLiteral); + if (symbol) { + if (symbol.declarations.some(function (d) { return ts.isAmbientModule(d); })) + return undefined; // No need to update if it's an ambient module + var oldFileName = ts.find(symbol.declarations, ts.isSourceFile).fileName; + return oldToNew(oldFileName) || oldFileName; + } + else { + var resolved = host.resolveModuleNames + ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName) + : program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName); + return getSourceFileToImportFromResolved(resolved, oldToNew, program); + } + } + function getSourceFileToImportFromResolved(resolved, oldToNew, program) { + return resolved && ((resolved.resolvedModule && getIfInProgram(resolved.resolvedModule.resolvedFileName)) || ts.firstDefined(resolved.failedLookupLocations, getIfInProgram)); + function getIfInProgram(oldLocation) { + var newLocation = oldToNew(oldLocation); + return program.getSourceFile(oldLocation) || newLocation !== undefined && program.getSourceFile(newLocation) + ? newLocation || oldLocation + : undefined; + } + } + function updateImportsWorker(sourceFile, changeTracker, updateRef, updateImport) { + for (var _i = 0, _a = sourceFile.referencedFiles; _i < _a.length; _i++) { + var ref = _a[_i]; + var updated = updateRef(ref.fileName); + if (updated !== undefined && updated !== sourceFile.text.slice(ref.pos, ref.end)) + changeTracker.replaceRangeWithText(sourceFile, ref, updated); + } + for (var _b = 0, _c = sourceFile.imports; _b < _c.length; _b++) { + var importStringLiteral = _c[_b]; + var updated = updateImport(importStringLiteral); + if (updated !== undefined && updated !== importStringLiteral.text) + changeTracker.replaceRangeWithText(sourceFile, createStringRange(importStringLiteral, sourceFile), updated); + } + } + function createStringRange(node, sourceFile) { + return ts.createTextRange(node.getStart(sourceFile) + 1, node.end - 1); + } + function forEachProperty(objectLiteral, cb) { + if (!ts.isObjectLiteralExpression(objectLiteral)) + return; + for (var _i = 0, _a = objectLiteral.properties; _i < _a.length; _i++) { + var property = _a[_i]; + if (ts.isPropertyAssignment(property) && ts.isStringLiteral(property.name)) { + cb(property, property.name.text); + } + } + } +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var GoToDefinition; (function (GoToDefinition) { @@ -91786,10 +92412,11 @@ var ts; if (node === sourceFile) { return undefined; } + var parent = node.parent; // Labels if (ts.isJumpStatementTarget(node)) { var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 } var typeChecker = program.getTypeChecker(); var symbol = getSymbol(node, typeChecker); @@ -91805,7 +92432,7 @@ var ts; // If this is the original constructor definition, parent is the class. return typeChecker.getRootSymbols(symbol).some(function (s) { return calledDeclaration.symbol === s || calledDeclaration.symbol.parent === s; }) || // TODO: GH#23742 Following check shouldn't be necessary if 'require' is an alias - symbol.declarations.some(function (d) { return ts.isVariableDeclaration(d) && d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ false); }) + symbol.declarations.some(function (d) { return ts.isVariableDeclaration(d) && !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ false); }) ? [sigInfo] : [sigInfo].concat(getDefinitionFromSymbol(typeChecker, symbol, node)); } @@ -91814,7 +92441,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 270 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 271 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -91829,9 +92456,9 @@ var ts; // pr/*destination*/op1: number // } // bar(({pr/*goto*/op1})=>{}); - if (ts.isPropertyName(node) && ts.isBindingElement(node.parent) && ts.isObjectBindingPattern(node.parent.parent) && - (node === (node.parent.propertyName || node.parent.name))) { - var type = typeChecker.getTypeAtLocation(node.parent.parent); + if (ts.isPropertyName(node) && ts.isBindingElement(parent) && ts.isObjectBindingPattern(parent.parent) && + (node === (parent.propertyName || parent.name))) { + var type = typeChecker.getTypeAtLocation(parent.parent); if (type) { var propSymbols = ts.getPropertySymbolsFromType(type, node); if (propSymbols) { @@ -91866,7 +92493,7 @@ var ts; var typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { var reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName); - var file_17 = reference && program.getSourceFile(reference.resolvedFileName); + var file_17 = reference && program.getSourceFile(reference.resolvedFileName); // TODO:GH#18217 return file_17 && { fileName: typeReferenceDirective.fileName, file: file_17 }; } return undefined; @@ -91883,7 +92510,7 @@ var ts; if (!type) { return undefined; } - if (type.isUnion() && !(type.flags & 16 /* Enum */)) { + if (type.isUnion() && !(type.flags & 32 /* Enum */)) { return ts.flatMap(type.types, function (t) { return t.symbol && getDefinitionFromSymbol(typeChecker, t.symbol, node); }); } return type.symbol && getDefinitionFromSymbol(typeChecker, type.symbol, node); @@ -91941,11 +92568,11 @@ var ts; return true; } switch (declaration.kind) { - case 244 /* ImportClause */: - case 242 /* ImportEqualsDeclaration */: + case 245 /* ImportClause */: + case 243 /* ImportEqualsDeclaration */: return true; - case 247 /* ImportSpecifier */: - return declaration.parent.kind === 246 /* NamedImports */; + case 248 /* ImportSpecifier */: + return declaration.parent.kind === 247 /* NamedImports */; default: return false; } @@ -92009,14 +92636,14 @@ var ts; kind: "script" /* scriptElement */, name: name, containerName: undefined, - containerKind: undefined + containerKind: undefined, }; } /** Returns a CallLikeExpression where `node` is the target being invoked. */ function getAncestorCallLikeExpression(node) { var target = climbPastManyPropertyAccesses(node); var callLike = target.parent; - return callLike && ts.isCallLikeExpression(callLike) && ts.getInvokedExpression(callLike) === target && callLike; + return callLike && ts.isCallLikeExpression(callLike) && ts.getInvokedExpression(callLike) === target ? callLike : undefined; } function climbPastManyPropertyAccesses(node) { return ts.isRightSideOfPropertyAccess(node) ? climbPastManyPropertyAccesses(node.parent) : node; @@ -92104,11 +92731,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 292 /* JSDocParameterTag */: - case 297 /* JSDocPropertyTag */: + case 293 /* JSDocParameterTag */: + case 298 /* JSDocPropertyTag */: return [declaration]; - case 291 /* JSDocCallbackTag */: - case 296 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 297 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -92129,16 +92756,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 289 /* JSDocAugmentsTag */: + case 290 /* JSDocAugmentsTag */: return withNode(tag.class); - case 295 /* JSDocTemplateTag */: + case 296 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 294 /* JSDocTypeTag */: + case 295 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: - case 297 /* JSDocPropertyTag */: - case 292 /* JSDocParameterTag */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: + case 298 /* JSDocPropertyTag */: + case 293 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -92220,7 +92847,7 @@ var ts; if (!ts.isIdentifier(param.name)) return undefined; var name = param.name.text; - if (jsdoc.tags.some(function (t) { return t !== tag && ts.isJSDocParameterTag(t) && ts.isIdentifier(t.name) && t.name.escapedText === name; }) + if (jsdoc.tags.some(function (t) { return t !== tag && ts.isJSDocParameterTag(t) && ts.isIdentifier(t.name) && t.name.escapedText === name; }) // TODO: GH#18217 || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } @@ -92269,7 +92896,7 @@ var ts; return undefined; } var tokenAtPos = ts.getTokenAtPosition(sourceFile, position, /*includeJsDocComment*/ false); - var tokenStart = tokenAtPos.getStart(); + var tokenStart = tokenAtPos.getStart(sourceFile); if (!tokenAtPos || tokenStart < position) { return undefined; } @@ -92278,7 +92905,7 @@ var ts; return undefined; } var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters; - if (commentOwner.getStart() < position) { + if (commentOwner.getStart(sourceFile) < position) { return undefined; } if (!parameters || parameters.length === 0) { @@ -92290,18 +92917,6 @@ var ts; var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; // replace non-whitespace characters in prefix with spaces. var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); - var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); - var docParams = ""; - for (var i = 0; i < parameters.length; i++) { - var currentName = parameters[i].name; - var paramName = currentName.kind === 71 /* Identifier */ ? currentName.escapedText : "param" + i; - if (isJavaScriptFile) { - docParams += indentationStr + " * @param {any} " + paramName + newLine; - } - else { - docParams += indentationStr + " * @param " + paramName + newLine; - } - } // A doc comment consists of the following // * The opening comment line // * the first line (without a param) for the object's untagged info (this is also where the caret ends up) @@ -92312,29 +92927,37 @@ var ts; var preamble = "/**" + newLine + indentationStr + " * "; var result = preamble + newLine + - docParams + + parameterDocComments(parameters, ts.hasJavaScriptFileExtension(sourceFile.fileName), indentationStr, newLine) + indentationStr + " */" + (tokenStart === position ? newLine + indentationStr : ""); return { newText: result, caretOffset: preamble.length }; } JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; + function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { + return parameters.map(function (_a, i) { + var name = _a.name, dotDotDotToken = _a.dotDotDotToken; + var paramName = name.kind === 71 /* Identifier */ ? name.text : "param" + i; + var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; + return indentationStr + " * @param " + type + paramName + newLine; + }).join(""); + } function getCommentOwnerInfo(tokenAtPos) { for (var commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: - case 152 /* MethodSignature */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: + case 153 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 150 /* PropertySignature */: - case 237 /* EnumDeclaration */: - case 272 /* EnumMember */: - case 236 /* TypeAliasDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 151 /* PropertySignature */: + case 238 /* EnumDeclaration */: + case 273 /* EnumMember */: + case 237 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 213 /* VariableStatement */: { + case 214 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -92342,14 +92965,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 273 /* SourceFile */: + case 274 /* SourceFile */: return undefined; - case 238 /* ModuleDeclaration */: + case 239 /* 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 === 238 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 199 /* BinaryExpression */: { + return commentOwner.parent.kind === 239 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 200 /* BinaryExpression */: { var be = commentOwner; if (ts.getSpecialPropertyAssignmentKind(be) === 0 /* None */) { return undefined; @@ -92369,16 +92992,16 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 190 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 191 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return rightHandSide.parameters; - case 204 /* ClassExpression */: { + case 205 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); - return ctr && ctr.parameters; + return ctr ? ctr.parameters : ts.emptyArray; } } return ts.emptyArray; @@ -92562,7 +93185,8 @@ var ts; } // Add the cached typing locations for inferred typings that are already installed packageNameToTypingLocation.forEach(function (typing, name) { - if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && isTypingUpToDate(typing, typesRegistry.get(name))) { + var registryEntry = typesRegistry.get(name); + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && registryEntry !== undefined && isTypingUpToDate(typing, registryEntry)) { inferredTypings.set(name, typing.typingLocation); } }); @@ -92589,7 +93213,7 @@ var ts; return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { - inferredTypings.set(typingName, undefined); + inferredTypings.set(typingName, undefined); // TODO: GH#18217 } } function addInferredTypings(typingNames, message) { @@ -92740,7 +93364,7 @@ var ts; case 0 /* Ok */: return ts.Debug.fail(); // Shouldn't have called this. default: - ts.Debug.assertNever(result); + throw ts.Debug.assertNever(result); } } JsTyping.renderPackageNameValidationFailure = renderPackageNameValidationFailure; @@ -92756,7 +93380,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_14 = function (sourceFile) { + var _loop_15 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */)) { return "continue"; @@ -92768,7 +93392,7 @@ var ts; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { var sourceFile = sourceFiles_7[_i]; - _loop_14(sourceFile); + _loop_15(sourceFile); } rawItems.sort(compareNavigateToItems); if (maxResultCount !== undefined) { @@ -92784,12 +93408,12 @@ var ts; if (!match) { return; // continue to next named declarations } - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; + for (var _i = 0, declarations_12 = declarations; _i < declarations_12.length; _i++) { + var declaration = declarations_12[_i]; if (!shouldKeepItem(declaration, checker)) continue; if (patternMatcher.patternContainsDots) { - var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); + var fullMatch = patternMatcher.getFullMatch(getContainers(declaration), name); // TODO: GH#18217 if (fullMatch) { rawItems.push({ name: name, fileName: fileName, matchKind: fullMatch.kind, isCaseSensitive: fullMatch.isCaseSensitive, declaration: declaration }); } @@ -92802,9 +93426,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 244 /* ImportClause */: - case 247 /* ImportSpecifier */: - case 242 /* ImportEqualsDeclaration */: + case 245 /* ImportClause */: + case 248 /* ImportSpecifier */: + case 243 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -92818,7 +93442,7 @@ var ts; containers.unshift(ts.getTextOfIdentifierOrLiteral(name)); return true; } - else if (name && name.kind === 146 /* ComputedPropertyName */) { + else if (name && name.kind === 147 /* ComputedPropertyName */) { return tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ true); } else { @@ -92850,16 +93474,16 @@ 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.kind === 146 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { + if (name.kind === 147 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } // Now, walk up our containers, adding all their names to the container array. - declaration = ts.getContainerNode(declaration); - while (declaration) { - if (!tryAddSingleDeclarationName(declaration, containers)) { + var container = ts.getContainerNode(declaration); + while (container) { + if (!tryAddSingleDeclarationName(container, containers)) { return undefined; } - declaration = ts.getContainerNode(declaration); + container = ts.getContainerNode(container); } return containers; } @@ -92882,7 +93506,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ + containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ // TODO: GH#18217 Just use `container ? ...` }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -93016,7 +93640,7 @@ var ts; return; } switch (node.kind) { - case 154 /* Constructor */: + case 155 /* 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); @@ -93028,21 +93652,21 @@ var ts; } } break; - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 152 /* MethodSignature */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 153 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 244 /* ImportClause */: + case 245 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -93054,7 +93678,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 245 /* NamespaceImport */) { + if (namedBindings.kind === 246 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -93065,8 +93689,8 @@ var ts; } } break; - case 181 /* BindingElement */: - case 231 /* VariableDeclaration */: + case 182 /* BindingElement */: + case 232 /* VariableDeclaration */: var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); @@ -93087,12 +93711,12 @@ var ts; addNodeWithRecursiveChild(node, initializer); } break; - case 192 /* ArrowFunction */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -93102,9 +93726,9 @@ var ts; } endNode(); break; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -93112,18 +93736,18 @@ var ts; } endNode(); break; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 251 /* ExportSpecifier */: - case 242 /* ImportEqualsDeclaration */: - case 159 /* IndexSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 236 /* TypeAliasDeclaration */: + case 252 /* ExportSpecifier */: + case 243 /* ImportEqualsDeclaration */: + case 160 /* IndexSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 237 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 199 /* BinaryExpression */: { + case 200 /* BinaryExpression */: { var special = ts.getSpecialPropertyAssignmentKind(node); switch (special) { case 1 /* ExportsProperty */: @@ -93202,12 +93826,12 @@ var ts; return false; } switch (a.kind) { - case 151 /* PropertyDeclaration */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 152 /* PropertyDeclaration */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -93216,7 +93840,8 @@ 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) { - return a.body.kind === b.body.kind && (a.body.kind !== 238 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + // TODO: GH#18217 + return a.body.kind === b.body.kind && (a.body.kind !== 239 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -93237,7 +93862,7 @@ var ts; children.sort(compareChildren); } function compareChildren(child1, child2) { - return ts.compareStringsCaseSensitiveUI(tryGetName(child1.node), tryGetName(child2.node)) + return ts.compareStringsCaseSensitiveUI(tryGetName(child1.node), tryGetName(child2.node)) // TODO: GH#18217 || ts.compareValues(navigationBarNodeKind(child1), navigationBarNodeKind(child2)); } /** @@ -93246,24 +93871,24 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 238 /* ModuleDeclaration */) { + if (node.kind === 239 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); if (declName) { - return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); + return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 } switch (node.kind) { - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 204 /* ClassExpression */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 205 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 238 /* ModuleDeclaration */) { + if (node.kind === 239 /* ModuleDeclaration */) { return getModuleName(node); } var name = ts.getNameOfDeclaration(node); @@ -93274,16 +93899,16 @@ var ts; } } switch (node.kind) { - case 273 /* SourceFile */: + case 274 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 192 /* ArrowFunction */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: + case 193 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -93291,13 +93916,13 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 154 /* Constructor */: + case 155 /* Constructor */: return "constructor"; - case 158 /* ConstructSignature */: + case 159 /* ConstructSignature */: return "new()"; - case 157 /* CallSignature */: + case 158 /* CallSignature */: return "()"; - case 159 /* IndexSignature */: + case 160 /* IndexSignature */: return "[]"; default: return ""; @@ -93321,25 +93946,25 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 237 /* EnumDeclaration */: - case 235 /* InterfaceDeclaration */: - case 238 /* ModuleDeclaration */: - case 273 /* SourceFile */: - case 236 /* TypeAliasDeclaration */: - case 296 /* JSDocTypedefTag */: - case 291 /* JSDocCallbackTag */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 238 /* EnumDeclaration */: + case 236 /* InterfaceDeclaration */: + case 239 /* ModuleDeclaration */: + case 274 /* SourceFile */: + case 237 /* TypeAliasDeclaration */: + case 297 /* JSDocTypedefTag */: + case 292 /* JSDocCallbackTag */: return true; - case 154 /* Constructor */: - case 153 /* MethodDeclaration */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 231 /* VariableDeclaration */: + case 155 /* Constructor */: + case 154 /* MethodDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 232 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 192 /* ArrowFunction */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -93349,19 +93974,19 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 239 /* ModuleBlock */: - case 273 /* SourceFile */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: + case 240 /* ModuleBlock */: + case 274 /* SourceFile */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: return true; default: return hasSomeImportantChild(item); } } function hasSomeImportantChild(item) { - return ts.forEach(item.children, function (child) { + return ts.some(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 231 /* VariableDeclaration */ && childKind !== 181 /* BindingElement */; + return childKind !== 232 /* VariableDeclaration */ && childKind !== 182 /* BindingElement */; }); } } @@ -93417,7 +94042,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 238 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 239 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -93428,16 +94053,16 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 238 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 239 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; // TODO: GH#18217 } function isComputedProperty(member) { - return !member.name || member.name.kind === 146 /* ComputedPropertyName */; + return !member.name || member.name.kind === 147 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 273 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 274 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 231 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 232 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -93447,16 +94072,16 @@ var ts; return ts.declarationNameToString(node.name); } // See if it is a var initializer. If so, use the var name. - else if (node.parent.kind === 231 /* VariableDeclaration */) { + else if (node.parent.kind === 232 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (node.parent.kind === 199 /* BinaryExpression */ && + else if (node.parent.kind === 200 /* BinaryExpression */ && node.parent.operatorToken.kind === 58 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name - else if (node.parent.kind === 269 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 270 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } // Default exports are named "default" @@ -93469,9 +94094,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 192 /* ArrowFunction */: - case 191 /* FunctionExpression */: - case 204 /* ClassExpression */: + case 193 /* ArrowFunction */: + case 192 /* FunctionExpression */: + case 205 /* ClassExpression */: return true; default: return false; @@ -93501,7 +94126,7 @@ var ts; organizeImportsWorker(topLevelExportDecls, coalesceExports); for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) { var ambientModule = _a[_i]; - var ambientModuleBody = getModuleBlock(ambientModule); + var ambientModuleBody = getModuleBlock(ambientModule); // TODO: GH#18217 var ambientModuleImportDecls = ambientModuleBody.statements.filter(ts.isImportDeclaration); organizeImportsWorker(ambientModuleImportDecls, coalesceAndOrganizeImports); var ambientModuleExportDecls = ambientModuleBody.statements.filter(ts.isExportDeclaration); @@ -93549,12 +94174,12 @@ var ts; OrganizeImports.organizeImports = organizeImports; function getModuleBlock(moduleDecl) { var body = moduleDecl.body; - return body && !ts.isIdentifier(body) && (ts.isModuleBlock(body) ? body : getModuleBlock(body)); + return body && !ts.isIdentifier(body) ? (ts.isModuleBlock(body) ? body : getModuleBlock(body)) : undefined; } function removeUnusedImports(oldImports, sourceFile, program) { var typeChecker = program.getTypeChecker(); var jsxNamespace = typeChecker.getJsxNamespace(); - var jsxContext = sourceFile.languageVariant === 1 /* JSX */ && program.getCompilerOptions().jsx; + var jsxElementsPresent = !!(sourceFile.transformFlags & 4 /* ContainsJsx */); var usedImports = []; for (var _i = 0, oldImports_1 = oldImports; _i < oldImports_1.length; _i++) { var importDecl = oldImports_1[_i]; @@ -93592,8 +94217,8 @@ var ts; } return usedImports; function isDeclarationUsed(identifier) { - // The JSX factory symbol is always used. - return jsxContext && (identifier.text === jsxNamespace) || ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile); + // The JSX factory symbol is always used if JSX elements are present - even if they are not allowed. + return jsxElementsPresent && (identifier.text === jsxNamespace) || ts.FindAllReferences.Core.isSymbolReferencedInFile(identifier, typeChecker, sourceFile); } } function getExternalModuleName(specifier) { @@ -93619,16 +94244,16 @@ var ts; if (defaultImports.length === 1 && namespaceImports.length === 1 && namedImports.length === 0) { // Add the namespace import to the existing default ImportDeclaration. var defaultImport = defaultImports[0]; - coalescedImports.push(updateImportDeclarationAndClause(defaultImport, defaultImport.importClause.name, namespaceImports[0].importClause.namedBindings)); + coalescedImports.push(updateImportDeclarationAndClause(defaultImport, defaultImport.importClause.name, namespaceImports[0].importClause.namedBindings)); // TODO: GH#18217 return coalescedImports; } var sortedNamespaceImports = ts.stableSort(namespaceImports, function (i1, i2) { return compareIdentifiers(i1.importClause.namedBindings.name, i2.importClause.namedBindings.name); - }); + }); // TODO: GH#18217 for (var _i = 0, sortedNamespaceImports_1 = sortedNamespaceImports; _i < sortedNamespaceImports_1.length; _i++) { var namespaceImport = sortedNamespaceImports_1[_i]; // Drop the name, if any - coalescedImports.push(updateImportDeclarationAndClause(namespaceImport, /*name*/ undefined, namespaceImport.importClause.namedBindings)); + coalescedImports.push(updateImportDeclarationAndClause(namespaceImport, /*name*/ undefined, namespaceImport.importClause.namedBindings)); // TODO: GH#18217 } if (defaultImports.length === 0 && namedImports.length === 0) { return coalescedImports; @@ -93641,10 +94266,10 @@ var ts; else { for (var _b = 0, defaultImports_1 = defaultImports; _b < defaultImports_1.length; _b++) { var defaultImport = defaultImports_1[_b]; - newImportSpecifiers.push(ts.createImportSpecifier(ts.createIdentifier("default"), defaultImport.importClause.name)); + newImportSpecifiers.push(ts.createImportSpecifier(ts.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217 } } - newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); + newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217 var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers); var importDecl = defaultImports.length > 0 ? defaultImports[0] @@ -93655,7 +94280,7 @@ var ts; : ts.createNamedImports(ts.emptyArray) : namedImports.length === 0 ? ts.createNamedImports(sortedImportSpecifiers) - : ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); + : ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); // TODO: GH#18217 coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, newNamedImports)); return coalescedImports; /* @@ -93749,7 +94374,8 @@ var ts; } OrganizeImports.coalesceExports = coalesceExports; function updateImportDeclarationAndClause(importDeclaration, name, namedBindings) { - return ts.updateImportDeclaration(importDeclaration, importDeclaration.decorators, importDeclaration.modifiers, ts.updateImportClause(importDeclaration.importClause, name, namedBindings), importDeclaration.moduleSpecifier); + return ts.updateImportDeclaration(importDeclaration, importDeclaration.decorators, importDeclaration.modifiers, ts.updateImportClause(importDeclaration.importClause, name, namedBindings), // TODO: GH#18217 + importDeclaration.moduleSpecifier); } function sortSpecifiers(specifiers) { return ts.stableSort(specifiers, function (s1, s2) { @@ -93773,73 +94399,6 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; -(function (ts) { - function getEditsForFileRename(program, oldFilePath, newFilePath, host, formatContext) { - var pathUpdater = getPathUpdater(oldFilePath, newFilePath, host); - return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { - updateTsconfigFiles(program, changeTracker, oldFilePath, newFilePath); - for (var _i = 0, _a = getImportsToUpdate(program, oldFilePath, host); _i < _a.length; _i++) { - var _b = _a[_i], sourceFile = _b.sourceFile, toUpdate = _b.toUpdate; - var newPath = pathUpdater(isRef(toUpdate) ? toUpdate.fileName : toUpdate.text); - if (newPath !== undefined) { - var range = isRef(toUpdate) ? toUpdate : createStringRange(toUpdate, sourceFile); - changeTracker.replaceRangeWithText(sourceFile, range, isRef(toUpdate) ? newPath : ts.removeFileExtension(newPath)); - } - } - }); - } - ts.getEditsForFileRename = getEditsForFileRename; - function updateTsconfigFiles(program, changeTracker, oldFilePath, newFilePath) { - var configFile = program.getCompilerOptions().configFile; - var oldFile = ts.getTsConfigPropArrayElementValue(configFile, "files", oldFilePath); - if (oldFile) { - changeTracker.replaceRangeWithText(configFile, createStringRange(oldFile, configFile), newFilePath); - } - } - function isRef(toUpdate) { - return "fileName" in toUpdate; - } - function getImportsToUpdate(program, oldFilePath, host) { - var checker = program.getTypeChecker(); - var result = []; - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) { - var ref = _c[_b]; - if (!program.getSourceFileFromReference(sourceFile, ref) && ts.resolveTripleslashReference(ref.fileName, sourceFile.fileName) === oldFilePath) { - result.push({ sourceFile: sourceFile, toUpdate: ref }); - } - } - for (var _d = 0, _e = sourceFile.imports; _d < _e.length; _d++) { - var importStringLiteral = _e[_d]; - // If it resolved to something already, ignore. - if (checker.getSymbolAtLocation(importStringLiteral)) - continue; - var resolved = host.resolveModuleNames - ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importStringLiteral.text, sourceFile.fileName) - : program.getResolvedModuleWithFailedLookupLocationsFromCache(importStringLiteral.text, sourceFile.fileName); - if (resolved && ts.contains(resolved.failedLookupLocations, oldFilePath)) { - result.push({ sourceFile: sourceFile, toUpdate: importStringLiteral }); - } - } - } - return result; - } - function getPathUpdater(oldFilePath, newFilePath, host) { - // Get the relative path from old to new location, and append it on to the end of imports and normalize. - var rel = ts.getRelativePathFromFile(oldFilePath, newFilePath, ts.createGetCanonicalFileName(ts.hostUsesCaseSensitiveFileNames(host))); - return function (oldPath) { - if (!ts.pathIsRelative(oldPath)) - return; - return ts.ensurePathIsNonModuleName(ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(oldPath), rel))); - }; - } - function createStringRange(node, sourceFile) { - return ts.createTextRange(node.getStart(sourceFile) + 1, node.end - 1); - } -})(ts || (ts = {})); -/* @internal */ -var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { @@ -93964,24 +94523,24 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 212 /* Block */: + case 213 /* Block */: if (ts.isFunctionBlock(n)) { - return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 192 /* ArrowFunction */); + return spanForNode(n.parent, /*autoCollapse*/ n.parent.kind !== 193 /* ArrowFunction */); } // Check if the block is standalone, or 'attached' to some parent statement. // 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 217 /* DoStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 219 /* ForStatement */: - case 216 /* IfStatement */: - case 218 /* WhileStatement */: - case 225 /* WithStatement */: - case 268 /* CatchClause */: + case 218 /* DoStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 220 /* ForStatement */: + case 217 /* IfStatement */: + case 219 /* WhileStatement */: + case 226 /* WithStatement */: + case 269 /* CatchClause */: return spanForNode(n.parent); - case 229 /* TryStatement */: + case 230 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { @@ -93996,16 +94555,16 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return spanForNode(n.parent); - case 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 240 /* CaseBlock */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 241 /* CaseBlock */: return spanForNode(n); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 21 /* OpenBracketToken */); } function spanForObjectOrArrayLiteral(node, open) { @@ -94075,7 +94634,7 @@ var ts; // First, check that the last part of the dot separated pattern matches the name of the // candidate. If not, then there's no point in proceeding and doing the more // expensive work. - var candidateMatch = matchSegment(candidate, ts.lastOrUndefined(dotSeparatedSegments), stringToWordSpans); + var candidateMatch = matchSegment(candidate, ts.last(dotSeparatedSegments), stringToWordSpans); if (!candidateMatch) { return undefined; } @@ -94316,13 +94875,13 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_15 = function (start) { + var _loop_16 = 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_4 = _loop_15(start); + var state_4 = _loop_16(start); if (typeof state_4 === "object") return state_4.value; } @@ -94595,7 +95154,7 @@ var ts; else { if (token === 71 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -94626,7 +95185,7 @@ var ts; } if (token === 18 /* CloseBraceToken */) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -94642,7 +95201,7 @@ var ts; token = nextToken(); if (token === 71 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -94672,7 +95231,7 @@ var ts; } if (token === 18 /* CloseBraceToken */) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -94684,7 +95243,7 @@ var ts; } else if (token === 39 /* AsteriskToken */) { token = nextToken(); - if (token === 142 /* FromKeyword */) { + if (token === 143 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -94808,7 +95367,7 @@ var ts; importedFiles.push(decl.ref); } } - return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: pragmaContext.hasNoDefaultLib, ambientExternalModules: undefined }; + return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: !!pragmaContext.hasNoDefaultLib, ambientExternalModules: undefined }; } else { // for global scripts ambient modules still can have augmentations - look for ambient modules with depth > 0 @@ -94827,7 +95386,7 @@ var ts; } } } - return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: pragmaContext.hasNoDefaultLib, ambientExternalModules: ambientModuleNames }; + return { referencedFiles: pragmaContext.referencedFiles, typeReferenceDirectives: pragmaContext.typeReferenceDirectives, importedFiles: importedFiles, isLibFile: !!pragmaContext.hasNoDefaultLib, ambientExternalModules: ambientModuleNames }; } } ts.preProcessFile = preProcessFile; @@ -94856,36 +95415,30 @@ var ts; Rename.getRenameInfo = getRenameInfo; function getRenameInfoForNode(node, typeChecker, sourceFile, isDefinedInLibraryFile) { var symbol = typeChecker.getSymbolAtLocation(node); + if (!symbol) + return; // Only allow a symbol to be renamed if it actually has at least one declaration. - if (symbol) { - var declarations = symbol.declarations; - if (declarations && declarations.length > 0) { - // Disallow rename for elements that are defined in the standard TypeScript library. - if (declarations.some(isDefinedInLibraryFile)) { - 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 === 79 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { - return undefined; - } - // Can't rename a module name. - if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) - return undefined; - var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteral(node) && node.parent.kind === 146 /* 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(symbol), node, sourceFile); - } + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) + return; + // Disallow rename for elements that are defined in the standard TypeScript library. + if (declarations.some(isDefinedInLibraryFile)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } - else if (ts.isStringLiteral(node)) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); - } - return getRenameInfoSuccess(node.text, node.text, "var" /* variableElement */, "" /* none */, node, sourceFile); + // Cannot rename `default` as in `import { default as foo } from "./someModule"; + if (ts.isIdentifier(node) && node.originalKeywordKind === 79 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + return undefined; } + // Can't rename a module name. + if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) + return undefined; + var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteral(node) && node.parent.kind === 147 /* 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(symbol), node, sourceFile); } function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { return { @@ -94899,6 +95452,7 @@ var ts; }; } function getRenameInfoError(diagnostic) { + // TODO: GH#18217 return { canRename: false, localizedErrorMessage: ts.getLocaleSpecificMessage(diagnostic), @@ -94944,7 +95498,12 @@ var ts; ArgumentListKind[ArgumentListKind["CallArguments"] = 1] = "CallArguments"; ArgumentListKind[ArgumentListKind["TaggedTemplateArguments"] = 2] = "TaggedTemplateArguments"; ArgumentListKind[ArgumentListKind["JSXAttributesArguments"] = 3] = "JSXAttributesArguments"; - })(ArgumentListKind = SignatureHelp.ArgumentListKind || (SignatureHelp.ArgumentListKind = {})); + })(ArgumentListKind || (ArgumentListKind = {})); + var InvocationKind; + (function (InvocationKind) { + InvocationKind[InvocationKind["Call"] = 0] = "Call"; + InvocationKind[InvocationKind["TypeArgs"] = 1] = "TypeArgs"; + })(InvocationKind || (InvocationKind = {})); function getSignatureHelpItems(program, sourceFile, position, cancellationToken) { var typeChecker = program.getTypeChecker(); // Decide whether to show signature help @@ -94958,11 +95517,9 @@ var ts; return undefined; cancellationToken.throwIfCancellationRequested(); // Semantic filtering of signature help - var call = argumentInfo.invocation; - var candidates = []; - var resolvedSignature = typeChecker.getResolvedSignature(call, candidates, argumentInfo.argumentCount); + var candidateInfo = getCandidateInfo(argumentInfo, typeChecker); cancellationToken.throwIfCancellationRequested(); - if (!candidates.length) { + if (!candidateInfo) { // We didn't have any sig help items produced by the TS compiler. If this is a JS // file, then see if we can figure out anything better. if (ts.isSourceFileJavaScript(sourceFile)) { @@ -94970,54 +95527,76 @@ var ts; } return undefined; } - return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo, typeChecker); }); + return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker); }); } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; - function createJavaScriptSignatureHelpItems(argumentInfo, program, cancellationToken) { - if (argumentInfo.invocation.kind !== 186 /* CallExpression */) { - return undefined; + function getCandidateInfo(argumentInfo, checker) { + var invocation = argumentInfo.invocation; + if (invocation.kind === 0 /* Call */) { + var candidates = []; + var resolvedSignature = checker.getResolvedSignature(invocation.node, candidates, argumentInfo.argumentCount); // TODO: GH#18217 + return candidates.length === 0 ? undefined : { candidates: candidates, resolvedSignature: resolvedSignature }; } + else { + var type = checker.getTypeAtLocation(invocation.called); // TODO: GH#18217 + var signatures = ts.isNewExpression(invocation.called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); + var candidates = signatures.filter(function (candidate) { return !!candidate.typeParameters && candidate.typeParameters.length >= argumentInfo.argumentCount; }); + return candidates.length === 0 ? undefined : { candidates: candidates, resolvedSignature: ts.first(candidates) }; + } + } + function createJavaScriptSignatureHelpItems(argumentInfo, program, cancellationToken) { // See if we can find some symbol with the call expression name that has call signatures. - var callExpression = argumentInfo.invocation; - var expression = callExpression.expression; + var expression = getExpressionFromInvocation(argumentInfo.invocation); var name = ts.isIdentifier(expression) ? expression : ts.isPropertyAccessExpression(expression) ? expression.name : undefined; if (!name || !name.escapedText) { return undefined; } var typeChecker = program.getTypeChecker(); - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; + var _loop_17 = function (sourceFile) { var nameToDeclarations = sourceFile.getNamedDeclarations(); var declarations = nameToDeclarations.get(name.text); if (declarations) { - var _loop_16 = function (declaration) { + var _loop_18 = function (declaration) { var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); if (type) { var callSignatures_1 = type.getCallSignatures(); if (callSignatures_1 && callSignatures_1.length) { - return { value: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(callSignatures_1, callSignatures_1[0], argumentInfo, typeChecker); }) }; + return { value: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return createSignatureHelpItems(callSignatures_1, callSignatures_1[0], argumentInfo, sourceFile, typeChecker); }) }; } } } }; - for (var _b = 0, declarations_12 = declarations; _b < declarations_12.length; _b++) { - var declaration = declarations_12[_b]; - var state_5 = _loop_16(declaration); - if (typeof state_5 === "object") - return state_5.value; + for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { + var declaration = declarations_13[_i]; + var state_6 = _loop_18(declaration); + if (typeof state_6 === "object") + return state_6; } } + }; + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + var state_5 = _loop_17(sourceFile); + if (typeof state_5 === "object") + return state_5.value; } } + function getArgumentInfoForCompletions(node, position, sourceFile) { + var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile); + return !info || info.kind === 0 /* TypeArguments */ || info.invocation.kind === 1 /* TypeArgs */ ? undefined + : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex }; + } + SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions; /** * Returns relevant information for the argument list and the current argument if we are * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (ts.isCallOrNewExpression(node.parent)) { - var invocation = node.parent; + var parent = node.parent; + if (ts.isCallOrNewExpression(parent)) { + var invocation = parent; var list = void 0; var argumentIndex = void 0; // There are 3 cases to handle: @@ -95037,7 +95616,7 @@ var ts; if (node.kind === 27 /* LessThanToken */ || node.kind === 19 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. - list = getChildListThatStartsWithOpenerToken(invocation, node, sourceFile); + list = getChildListThatStartsWithOpenerToken(parent, node, sourceFile); ts.Debug.assert(list !== undefined); argumentIndex = 0; } @@ -95053,60 +95632,66 @@ var ts; return undefined; argumentIndex = getArgumentIndex(list, node); } - var kind = invocation.typeArguments && invocation.typeArguments.pos === list.pos ? 0 /* TypeArguments */ : 1 /* CallArguments */; + var kind = parent.typeArguments && parent.typeArguments.pos === list.pos ? 0 /* TypeArguments */ : 1 /* CallArguments */; var argumentCount = getArgumentCount(list); if (argumentIndex !== 0) { ts.Debug.assertLessThan(argumentIndex, argumentCount); } var argumentsSpan = getApplicableSpanForArguments(list, sourceFile); - return { kind: kind, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; + return { kind: kind, invocation: { kind: 0 /* Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } - else if (node.kind === 13 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 188 /* TaggedTemplateExpression */) { + else if (ts.isNoSubstitutionTemplateLiteral(node) && ts.isTaggedTemplateExpression(parent)) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. - if (ts.isInsideTemplateLiteral(node, position)) { - return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0, sourceFile); + if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { + return getArgumentListInfoForTemplate(parent, /*argumentIndex*/ 0, sourceFile); } } - else if (node.kind === 14 /* TemplateHead */ && node.parent.parent.kind === 188 /* TaggedTemplateExpression */) { - var templateExpression = node.parent; + else if (ts.isTemplateHead(node) && parent.parent.kind === 189 /* TaggedTemplateExpression */) { + var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 201 /* TemplateExpression */); - var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; + ts.Debug.assert(templateExpression.kind === 202 /* TemplateExpression */); + var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 210 /* TemplateSpan */ && node.parent.parent.parent.kind === 188 /* TaggedTemplateExpression */) { - var templateSpan = node.parent; - var templateExpression = templateSpan.parent; - var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 201 /* TemplateExpression */); + else if (ts.isTemplateSpan(parent) && ts.isTaggedTemplateExpression(parent.parent.parent)) { + var templateSpan = parent; + var tagExpression = parent.parent.parent; // If we're just after a template tail, don't show signature help. - if (node.kind === 16 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (ts.isTemplateTail(node) && !ts.isInsideTemplateLiteral(node, position, sourceFile)) { return undefined; } - var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); - var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); + var spanIndex = templateSpan.parent.templateSpans.indexOf(templateSpan); + var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position, sourceFile); return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent && ts.isJsxOpeningLikeElement(node.parent)) { + else if (ts.isJsxOpeningLikeElement(parent)) { // Provide a signature help for JSX opening element or JSX self-closing element. // This is not guarantee that JSX tag-name is resolved into stateless function component. (that is done in "getSignatureHelpItems") // i.e // export function MainButton(props: ButtonProps, context: any): JSX.Element { ... } // 0 && ts.lastOrUndefined(listChildren).kind === 26 /* CommaToken */) { + if (listChildren.length > 0 && ts.last(listChildren).kind === 26 /* CommaToken */) { argumentCount++; } return argumentCount; } // spanIndex is either the index for a given template span. // This does not give appropriate results for a NoSubstitutionTemplateLiteral - function getArgumentIndexForTemplatePiece(spanIndex, node, position) { + function getArgumentIndexForTemplatePiece(spanIndex, node, position, sourceFile) { // Because the TemplateStringsArray is the first argument, we have to offset each substitution expression by 1. // There are three cases we can encounter: // 1. We are precisely in the template literal (argIndex = 0). @@ -95167,8 +95752,8 @@ var ts; // Case: 1 1 3 2 1 3 2 2 1 // tslint:enable no-double-space ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); - if (ts.isTemplateLiteralKind(node.kind)) { - if (ts.isInsideTemplateLiteral(node, position)) { + if (ts.isTemplateLiteralToken(node)) { + if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { return 0; } return spanIndex + 2; @@ -95183,7 +95768,7 @@ var ts; } return { kind: 2 /* TaggedTemplateArguments */, - invocation: tagExpression, + invocation: { kind: 0 /* Call */, node: tagExpression }, argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile), argumentIndex: argumentIndex, argumentCount: argumentCount @@ -95214,8 +95799,8 @@ 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 === 201 /* TemplateExpression */) { - var lastSpan = ts.lastOrUndefined(template.templateSpans); + if (template.kind === 202 /* TemplateExpression */) { + var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); } @@ -95223,39 +95808,40 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 273 /* SourceFile */; n = n.parent) { - if (ts.isFunctionBlock(n)) { - return undefined; - } + var _loop_19 = 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. - if (n.pos < n.parent.pos || n.end > n.parent.end) { - ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); - } + ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.showSyntaxKind(n) + ", parent: " + ts.Debug.showSyntaxKind(n.parent); }); var argumentInfo = getImmediatelyContainingArgumentInfo(n, position, sourceFile); if (argumentInfo) { - return argumentInfo; + return { value: argumentInfo }; } - // TODO: Handle generic call with incomplete syntax + }; + for (var n = node; !ts.isBlock(n) && !ts.isSourceFile(n); n = n.parent) { + var state_7 = _loop_19(n); + if (typeof state_7 === "object") + return state_7.value; } return undefined; } - SignatureHelp.getContainingArgumentInfo = getContainingArgumentInfo; function getChildListThatStartsWithOpenerToken(parent, openerToken, sourceFile) { var children = parent.getChildren(sourceFile); var indexOfOpenerToken = children.indexOf(openerToken); ts.Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1); return children[indexOfOpenerToken + 1]; } + function getExpressionFromInvocation(invocation) { + return invocation.kind === 0 /* Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; + } var signatureHelpNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 3112960 /* IgnoreErrors */; - function createSignatureHelpItems(candidates, resolvedSignature, argumentListInfo, typeChecker) { + function createSignatureHelpItems(candidates, resolvedSignature, argumentListInfo, sourceFile, typeChecker) { var argumentCount = argumentListInfo.argumentCount, applicableSpan = argumentListInfo.argumentsSpan, invocation = argumentListInfo.invocation, argumentIndex = argumentListInfo.argumentIndex; var isTypeParameterList = argumentListInfo.kind === 0 /* TypeArguments */; - var callTarget = ts.getInvokedExpression(invocation); - var callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget); + var enclosingDeclaration = invocation.kind === 0 /* Call */ ? invocation.node : invocation.called; + var callTargetSymbol = typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)); var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); var printer = ts.createPrinter({ removeComments: true }); - var items = ts.map(candidates, function (candidateSignature) { + var items = candidates.map(function (candidateSignature) { var signatureHelpParameters; var prefixDisplayParts = []; var suffixDisplayParts = []; @@ -95270,9 +95856,9 @@ var ts; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : ts.emptyArray; suffixDisplayParts.push(ts.punctuationPart(29 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { - var thisParameter = candidateSignature.thisParameter ? [typeChecker.symbolToParameterDeclaration(candidateSignature.thisParameter, invocation, signatureHelpNodeBuilderFlags)] : []; - var params = ts.createNodeArray(thisParameter.concat(ts.map(candidateSignature.parameters, function (param) { return typeChecker.symbolToParameterDeclaration(param, invocation, signatureHelpNodeBuilderFlags); }))); - printer.writeList(1296 /* CallExpressionArguments */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var thisParameter = candidateSignature.thisParameter ? [typeChecker.symbolToParameterDeclaration(candidateSignature.thisParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags)] : []; + var params = ts.createNodeArray(thisParameter.concat(candidateSignature.parameters.map(function (param) { return typeChecker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); + printer.writeList(1296 /* CallExpressionArguments */, params, sourceFile, writer); }); ts.addRange(suffixDisplayParts, parameterParts); } @@ -95280,8 +95866,8 @@ var ts; isVariadic = candidateSignature.hasRestParameter; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { - var args = ts.createNodeArray(ts.map(candidateSignature.typeParameters, function (p) { return typeChecker.typeParameterToDeclaration(p, invocation); })); - printer.writeList(26896 /* TypeParameters */, args, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var args = ts.createNodeArray(candidateSignature.typeParameters.map(function (p) { return typeChecker.typeParameterToDeclaration(p, enclosingDeclaration); })); + printer.writeList(26896 /* TypeParameters */, args, sourceFile, writer); } }); ts.addRange(prefixDisplayParts, typeParameterParts); @@ -95294,10 +95880,10 @@ var ts; writer.writeSpace(" "); var predicate = typeChecker.getTypePredicateOfSignature(candidateSignature); if (predicate) { - typeChecker.writeTypePredicate(predicate, invocation, /*flags*/ undefined, writer); + typeChecker.writeTypePredicate(predicate, enclosingDeclaration, /*flags*/ undefined, writer); } else { - typeChecker.writeType(typeChecker.getReturnTypeOfSignature(candidateSignature), invocation, /*flags*/ undefined, writer); + typeChecker.writeType(typeChecker.getReturnTypeOfSignature(candidateSignature), enclosingDeclaration, /*flags*/ undefined, writer); } }); ts.addRange(suffixDisplayParts, returnTypeParts); @@ -95319,8 +95905,8 @@ var ts; return { items: items, applicableSpan: applicableSpan, selectedItemIndex: selectedItemIndex, argumentIndex: argumentIndex, argumentCount: argumentCount }; function createSignatureHelpParameterForParameter(parameter) { var displayParts = ts.mapToDisplayParts(function (writer) { - var param = typeChecker.symbolToParameterDeclaration(parameter, invocation, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var param = typeChecker.symbolToParameterDeclaration(parameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); + printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); }); return { name: parameter.name, @@ -95331,8 +95917,8 @@ var ts; } function createSignatureHelpParameterForTypeParameter(typeParameter) { var displayParts = ts.mapToDisplayParts(function (writer) { - var param = typeChecker.typeParameterToDeclaration(typeParameter, invocation); - printer.writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(invocation)), writer); + var param = typeChecker.typeParameterToDeclaration(typeParameter, enclosingDeclaration); + printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); }); return { name: typeParameter.symbol.name, @@ -95347,9 +95933,8 @@ var ts; /* @internal */ var ts; (function (ts) { - function computeSuggestionDiagnostics(sourceFile, program) { - program.getSemanticDiagnostics(sourceFile); - var checker = program.getDiagnosticsProducingTypeChecker(); + function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) { + program.getSemanticDiagnostics(sourceFile, cancellationToken); var diags = []; if (sourceFile.commonJsModuleIndicator && (ts.programContainsEs6Modules(program) || ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) && @@ -95357,40 +95942,10 @@ var ts; diags.push(ts.createDiagnosticForNode(getErrorNodeFromCommonJsIndicator(sourceFile.commonJsModuleIndicator), ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module)); } var isJsFile = ts.isSourceFileJavaScript(sourceFile); - function check(node) { - switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - if (isJsFile) { - var symbol = node.symbol; - if (symbol.members && (symbol.members.size > 0)) { - diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); - } - } - break; - } - if (!isJsFile && ts.codefix.parameterShouldGetTypeFromJSDoc(node)) { - diags.push(ts.createDiagnosticForNode(node.name || node, ts.Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types)); - } - node.forEachChild(check); - } check(sourceFile); - if (!isJsFile) { - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var statement = _a[_i]; - if (ts.isVariableStatement(statement) && - statement.declarationList.flags & 2 /* Const */ && - statement.declarationList.declarations.length === 1) { - var init = statement.declarationList.declarations[0].initializer; - if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) { - diags.push(ts.createDiagnosticForNode(init, ts.Diagnostics.require_call_may_be_converted_to_an_import)); - } - } - } - } if (ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())) { - for (var _b = 0, _c = sourceFile.imports; _b < _c.length; _b++) { - var moduleSpecifier = _c[_b]; + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var moduleSpecifier = _a[_i]; var importNode = ts.importFromModuleSpecifier(moduleSpecifier); var name = importNameForConvertToDefaultImport(importNode); if (!name) @@ -95402,18 +95957,57 @@ var ts; } } } - return diags.concat(checker.getSuggestionDiagnostics(sourceFile)).sort(function (d1, d2) { return d1.start - d2.start; }); + ts.addRange(diags, sourceFile.bindSuggestionDiagnostics); + ts.addRange(diags, program.getSuggestionDiagnostics(sourceFile, cancellationToken)); + return diags.sort(function (d1, d2) { return d1.start - d2.start; }); + function check(node) { + if (isJsFile) { + switch (node.kind) { + case 192 /* FunctionExpression */: + var decl = ts.getDeclarationOfJSInitializer(node); + if (decl) { + var symbol_3 = decl.symbol; + if (symbol_3 && (symbol_3.exports && symbol_3.exports.size || symbol_3.members && symbol_3.members.size)) { + diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); + break; + } + } + // falls through if no diagnostic was created + case 234 /* FunctionDeclaration */: + var symbol = node.symbol; + if (symbol.members && (symbol.members.size > 0)) { + diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); + } + break; + } + } + else { + if (ts.isVariableStatement(node) && + node.parent === sourceFile && + node.declarationList.flags & 2 /* Const */ && + node.declarationList.declarations.length === 1) { + var init = node.declarationList.declarations[0].initializer; + if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) { + diags.push(ts.createDiagnosticForNode(init, ts.Diagnostics.require_call_may_be_converted_to_an_import)); + } + } + if (ts.codefix.parameterShouldGetTypeFromJSDoc(node)) { + diags.push(ts.createDiagnosticForNode(node.name || node, ts.Diagnostics.JSDoc_types_may_be_moved_to_TypeScript_types)); + } + } + node.forEachChild(check); + } } ts.computeSuggestionDiagnostics = computeSuggestionDiagnostics; // convertToEs6Module only works on top-level, so don't trigger it if commonjs code only appears in nested scopes. function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); - }); - case 215 /* ExpressionStatement */: { + }); // TODO: GH#18217 + case 216 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -95430,12 +96024,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings.kind === 245 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 246 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -95458,7 +96052,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 204 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 205 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -95546,11 +96140,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 256 /* JsxOpeningElement */: - case 254 /* JsxElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 255 /* JsxElement */: + case 256 /* JsxSelfClosingElement */: return location.kind === 71 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 261 /* JsxAttribute */: + case 262 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -95576,7 +96170,7 @@ var ts; var tags; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - var hasAddedSymbolInfo; + var hasAddedSymbolInfo = false; var isThisExpression = location.kind === 99 /* ThisKeyword */ && ts.isExpression(location); var type; var printer; @@ -95590,7 +96184,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 184 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 185 /* 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)) { @@ -95610,8 +96204,8 @@ var ts; } if (callExpressionLike) { var candidateSignatures = []; - signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); - var useConstructSignatures = callExpressionLike.kind === 187 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); + signature = typeChecker.getResolvedSignature(callExpressionLike, candidateSignatures); // TODO: GH#18217 + var useConstructSignatures = callExpressionLike.kind === 188 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -95666,7 +96260,7 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 154 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 155 /* 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 @@ -95674,21 +96268,21 @@ var ts; return declaration === (location.kind === 123 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 154 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 155 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { - signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); + signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 154 /* Constructor */) { + if (functionDeclaration_1.kind === 155 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 157 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 158 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -95698,7 +96292,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 204 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 205 /* 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 @@ -95742,7 +96336,7 @@ var ts; } if (symbolFlags & 1536 /* Module */) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 238 /* ModuleDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 239 /* ModuleDeclaration */); var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; displayParts.push(ts.keywordPart(isNamespace ? 130 /* NamespaceKeyword */ : 129 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); @@ -95763,23 +96357,24 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 147 /* TypeParameter */); - ts.Debug.assert(decl !== undefined); + var decl = ts.getDeclarationOfKind(symbol, 148 /* TypeParameter */); + if (decl === undefined) + return ts.Debug.fail(); var declaration = decl.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); - var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 158 /* ConstructSignature */) { + var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 + if (declaration.kind === 159 /* ConstructSignature */) { displayParts.push(ts.keywordPart(94 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 157 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 158 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 236 /* TypeAliasDeclaration */) { + else if (declaration.kind === 237 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path @@ -95796,7 +96391,7 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 272 /* EnumMember */) { + if (declaration.kind === 273 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); @@ -95826,17 +96421,17 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 241 /* NamespaceExportDeclaration */: + case 242 /* NamespaceExportDeclaration */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(130 /* NamespaceKeyword */)); break; - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 58 /* EqualsToken */ : 79 /* DefaultKeyword */)); break; - case 251 /* ExportSpecifier */: + case 252 /* ExportSpecifier */: displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); break; default: @@ -95845,7 +96440,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 242 /* ImportEqualsDeclaration */) { + if (declaration.kind === 243 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); @@ -95923,10 +96518,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 === 273 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 274 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 199 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 200 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -96009,6 +96604,7 @@ var ts; } } function addSignatureDisplayParts(signature, allSignatures, flags) { + if (flags === void 0) { flags = 0 /* None */; } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); @@ -96037,16 +96633,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 191 /* FunctionExpression */) { + if (declaration.kind === 192 /* FunctionExpression */) { return true; } - if (declaration.kind !== 231 /* VariableDeclaration */ && declaration.kind !== 233 /* FunctionDeclaration */) { + if (declaration.kind !== 232 /* VariableDeclaration */ && declaration.kind !== 234 /* 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 === 273 /* SourceFile */ || parent.kind === 239 /* ModuleBlock */) { + if (parent.kind === 274 /* SourceFile */ || parent.kind === 240 /* ModuleBlock */) { return false; } } @@ -96094,7 +96690,7 @@ var ts; options.noResolve = true; // if jsx is specified then treat file as .tsx var inputFileName = transpileOptions.fileName || (options.jsx ? "module.tsx" : "module.ts"); - var sourceFile = ts.createSourceFile(inputFileName, input, options.target); + var sourceFile = ts.createSourceFile(inputFileName, input, options.target); // TODO: GH#18217 if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; } @@ -96135,7 +96731,8 @@ var ts; } // Emit program.emit(/*targetSourceFile*/ undefined, /*writeFile*/ undefined, /*cancellationToken*/ undefined, /*emitOnlyDtsFiles*/ undefined, transpileOptions.transformers); - ts.Debug.assert(outputText !== undefined, "Output generation failed"); + if (outputText === undefined) + return ts.Debug.fail("Output generation failed"); return { outputText: outputText, diagnostics: diagnostics, sourceMapText: sourceMapText }; } ts.transpileModule = transpileModule; @@ -96158,7 +96755,7 @@ var ts; return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.cloneCompilerOptions(options); - var _loop_17 = function (opt) { + var _loop_20 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -96177,7 +96774,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_17(opt); + _loop_20(opt); } return options; } @@ -96314,7 +96911,7 @@ var ts; lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - wasNewLine = trailingTrivia && ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */; + wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* NewLineTrivia */; } else { scanner.scan(); @@ -96354,10 +96951,10 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 261 /* JsxAttribute */: - case 256 /* JsxOpeningElement */: - case 257 /* JsxClosingElement */: - case 255 /* JsxSelfClosingElement */: + case 262 /* JsxAttribute */: + case 257 /* JsxOpeningElement */: + case 258 /* JsxClosingElement */: + case 256 /* 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 === 71 /* Identifier */; } @@ -96534,7 +97131,7 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 144 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 145 /* LastToken */; token++) { allTokens.push(token); } function anyTokenExcept() { @@ -96546,9 +97143,9 @@ var ts; } var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(allTokens.concat([3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(72 /* FirstKeyword */, 144 /* LastKeyword */); + var keywords = tokenRangeFromRange(72 /* FirstKeyword */, 145 /* LastKeyword */); var binaryOperators = tokenRangeFromRange(27 /* FirstBinaryOperator */, 70 /* LastBinaryOperator */); - var binaryKeywordOperators = [92 /* InKeyword */, 93 /* InstanceOfKeyword */, 144 /* OfKeyword */, 118 /* AsKeyword */, 127 /* IsKeyword */]; + var binaryKeywordOperators = [92 /* InKeyword */, 93 /* InstanceOfKeyword */, 145 /* OfKeyword */, 118 /* AsKeyword */, 127 /* IsKeyword */]; var unaryPrefixOperators = [43 /* PlusPlusToken */, 44 /* MinusMinusToken */, 52 /* TildeToken */, 51 /* ExclamationToken */]; var unaryPrefixExpressions = [ 8 /* NumericLiteral */, 71 /* Identifier */, 19 /* OpenParenToken */, 21 /* OpenBracketToken */, @@ -96669,11 +97266,11 @@ var ts; 136 /* SetKeyword */, 115 /* StaticKeyword */, 139 /* TypeKeyword */, - 142 /* FromKeyword */, + 143 /* FromKeyword */, 128 /* KeyOfKeyword */, 126 /* InferKeyword */, ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [85 /* ExtendsKeyword */, 108 /* ImplementsKeyword */, 142 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [85 /* ExtendsKeyword */, 108 /* ImplementsKeyword */, 143 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), // 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", 9 /* StringLiteral */, 17 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), // Lambda expressions @@ -96838,45 +97435,45 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 219 /* ForStatement */; + return context.contextNode.kind === 220 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 199 /* BinaryExpression */: - case 200 /* ConditionalExpression */: - case 170 /* ConditionalType */: - case 207 /* AsExpression */: - case 251 /* ExportSpecifier */: - case 247 /* ImportSpecifier */: - case 160 /* TypePredicate */: - case 168 /* UnionType */: - case 169 /* IntersectionType */: + case 200 /* BinaryExpression */: + case 201 /* ConditionalExpression */: + case 171 /* ConditionalType */: + case 208 /* AsExpression */: + case 252 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 161 /* TypePredicate */: + case 169 /* UnionType */: + case 170 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 181 /* BindingElement */: + case 182 /* BindingElement */: // equals in type X = ... - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: // equal in p = 0; - case 148 /* Parameter */: - case 272 /* EnumMember */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 149 /* Parameter */: + case 273 /* EnumMember */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return context.currentTokenSpan.kind === 58 /* EqualsToken */ || context.nextTokenSpan.kind === 58 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: return context.currentTokenSpan.kind === 92 /* InKeyword */ || context.nextTokenSpan.kind === 92 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 221 /* ForOfStatement */: - return context.currentTokenSpan.kind === 144 /* OfKeyword */ || context.nextTokenSpan.kind === 144 /* OfKeyword */; + case 222 /* ForOfStatement */: + return context.currentTokenSpan.kind === 145 /* OfKeyword */ || context.nextTokenSpan.kind === 145 /* OfKeyword */; } return false; } @@ -96888,22 +97485,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 151 /* PropertyDeclaration */ || - contextKind === 150 /* PropertySignature */ || - contextKind === 148 /* Parameter */ || - contextKind === 231 /* VariableDeclaration */ || + return contextKind === 152 /* PropertyDeclaration */ || + contextKind === 151 /* PropertySignature */ || + contextKind === 149 /* Parameter */ || + contextKind === 232 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 200 /* ConditionalExpression */ || - context.contextNode.kind === 170 /* ConditionalType */; + return context.contextNode.kind === 201 /* ConditionalExpression */ || + context.contextNode.kind === 171 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 179 /* ObjectBindingPattern */ || - context.contextNode.kind === 176 /* MappedType */ || + return context.contextNode.kind === 180 /* ObjectBindingPattern */ || + context.contextNode.kind === 177 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -96929,31 +97526,31 @@ var ts; return true; } switch (node.kind) { - case 212 /* Block */: - case 240 /* CaseBlock */: - case 183 /* ObjectLiteralExpression */: - case 239 /* ModuleBlock */: + case 213 /* Block */: + case 241 /* CaseBlock */: + case 184 /* ObjectLiteralExpression */: + case 240 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 157 /* CallSignature */: - case 191 /* FunctionExpression */: - case 154 /* Constructor */: - case 192 /* ArrowFunction */: + case 158 /* CallSignature */: + case 192 /* FunctionExpression */: + case 155 /* Constructor */: + case 193 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 235 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 236 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -96962,40 +97559,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 233 /* FunctionDeclaration */ || context.contextNode.kind === 191 /* FunctionExpression */; + return context.contextNode.kind === 234 /* FunctionDeclaration */ || context.contextNode.kind === 192 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 165 /* TypeLiteral */: - case 238 /* ModuleDeclaration */: - case 249 /* ExportDeclaration */: - case 250 /* NamedExports */: - case 243 /* ImportDeclaration */: - case 246 /* NamedImports */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 166 /* TypeLiteral */: + case 239 /* ModuleDeclaration */: + case 250 /* ExportDeclaration */: + case 251 /* NamedExports */: + case 244 /* ImportDeclaration */: + case 247 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 234 /* ClassDeclaration */: - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 268 /* CatchClause */: - case 239 /* ModuleBlock */: - case 226 /* SwitchStatement */: + case 235 /* ClassDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 269 /* CatchClause */: + case 240 /* ModuleBlock */: + case 227 /* SwitchStatement */: return true; - case 212 /* Block */: { + case 213 /* 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 !== 192 /* ArrowFunction */ && blockParent.kind !== 191 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 193 /* ArrowFunction */ && blockParent.kind !== 192 /* FunctionExpression */) { return true; } } @@ -97004,31 +97601,31 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 216 /* IfStatement */: - case 226 /* SwitchStatement */: - case 219 /* ForStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 218 /* WhileStatement */: - case 229 /* TryStatement */: - case 217 /* DoStatement */: - case 225 /* WithStatement */: + case 217 /* IfStatement */: + case 227 /* SwitchStatement */: + case 220 /* ForStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 219 /* WhileStatement */: + case 230 /* TryStatement */: + case 218 /* DoStatement */: + case 226 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 268 /* CatchClause */: + case 269 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 183 /* ObjectLiteralExpression */; + return context.contextNode.kind === 184 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 186 /* CallExpression */; + return context.contextNode.kind === 187 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 187 /* NewExpression */; + return context.contextNode.kind === 188 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -97040,35 +97637,35 @@ var ts; return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 192 /* ArrowFunction */; + return context.contextNode.kind === 193 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 178 /* ImportType */; + return context.contextNode.kind === 179 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 254 /* JsxElement */ && context.contextNode.kind !== 258 /* JsxFragment */; + return context.contextNode.kind !== 255 /* JsxElement */ && context.contextNode.kind !== 259 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 264 /* JsxExpression */ || context.contextNode.kind === 263 /* JsxSpreadAttribute */; + return context.contextNode.kind === 265 /* JsxExpression */ || context.contextNode.kind === 264 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 261 /* JsxAttribute */; + return context.nextTokenParent.kind === 262 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 261 /* JsxAttribute */; + return context.contextNode.kind === 262 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 255 /* JsxSelfClosingElement */; + return context.contextNode.kind === 256 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); } function isEndOfDecoratorContextOnSameLine(context) { return context.TokensAreOnSameLine() && - context.contextNode.decorators && + !!context.contextNode.decorators && nodeIsInDecoratorContext(context.currentTokenParent) && !nodeIsInDecoratorContext(context.nextTokenParent); } @@ -97076,45 +97673,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 149 /* Decorator */; + return node.kind === 150 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 232 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 233 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 238 /* ModuleDeclaration */; + return context.contextNode.kind === 239 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 165 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 166 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 158 /* ConstructSignature */; + return context.contextNode.kind === 159 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { if (token.kind !== 27 /* LessThanToken */ && token.kind !== 29 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 161 /* TypeReference */: - case 189 /* TypeAssertionExpression */: - case 236 /* TypeAliasDeclaration */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 206 /* ExpressionWithTypeArguments */: + case 162 /* TypeReference */: + case 190 /* TypeAssertionExpression */: + case 237 /* TypeAliasDeclaration */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 207 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -97125,16 +97722,16 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 189 /* TypeAssertionExpression */; + return context.contextNode.kind === 190 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 195 /* VoidExpression */; + return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 196 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 202 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 203 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 208 /* NonNullExpression */; + return context.contextNode.kind === 209 /* NonNullExpression */; } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -97185,12 +97782,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 144 /* LastKeyword */ && column <= 144 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 145 /* LastKeyword */ && column <= 145 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 144 /* LastToken */ + 1; + var mapRowLength = 145 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; @@ -97368,17 +97965,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 234 /* ClassDeclaration */: - case 235 /* InterfaceDeclaration */: + case 235 /* ClassDeclaration */: + case 236 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 239 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 273 /* SourceFile */: - case 212 /* Block */: - case 239 /* ModuleBlock */: + return !!body && body.kind === 240 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 274 /* SourceFile */: + case 213 /* Block */: + case 240 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -97407,7 +98004,7 @@ var ts; } // pick only errors that fall in range var sorted = errors - .filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }) + .filter(function (d) { return ts.rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length); }) // TODO: GH#18217 .sort(function (e1, e2) { return e1.start - e2.start; }); if (!sorted.length) { return rangeHasNoErrors; @@ -97535,7 +98132,7 @@ var ts; if (!formattingScanner.isOnToken()) { var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { - processTrivia(leadingTrivia, enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); + processTrivia(leadingTrivia, enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); // TODO: GH#18217 trimTrailingWhitespacesForRemainingRange(); } } @@ -97601,19 +98198,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 234 /* ClassDeclaration */: return 75 /* ClassKeyword */; - case 235 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; - case 233 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; - case 237 /* EnumDeclaration */: return 237 /* EnumDeclaration */; - case 155 /* GetAccessor */: return 125 /* GetKeyword */; - case 156 /* SetAccessor */: return 136 /* SetKeyword */; - case 153 /* MethodDeclaration */: + case 235 /* ClassDeclaration */: return 75 /* ClassKeyword */; + case 236 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; + case 234 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; + case 238 /* EnumDeclaration */: return 238 /* EnumDeclaration */; + case 156 /* GetAccessor */: return 125 /* GetKeyword */; + case 157 /* SetAccessor */: return 136 /* SetKeyword */; + case 154 /* MethodDeclaration */: if (node.asteriskToken) { return 39 /* AsteriskToken */; } // falls through - case 151 /* PropertyDeclaration */: - case 148 /* Parameter */: + case 152 /* PropertyDeclaration */: + case 149 /* Parameter */: return ts.getNameOfDeclaration(node).kind; } } @@ -97658,15 +98255,15 @@ var ts; case 41 /* SlashToken */: case 29 /* GreaterThanToken */: switch (container.kind) { - case 256 /* JsxOpeningElement */: - case 257 /* JsxClosingElement */: - case 255 /* JsxSelfClosingElement */: + case 257 /* JsxOpeningElement */: + case 258 /* JsxClosingElement */: + case 256 /* JsxSelfClosingElement */: return false; } break; case 21 /* OpenBracketToken */: case 22 /* CloseBracketToken */: - if (container.kind !== 176 /* MappedType */) { + if (container.kind !== 177 /* MappedType */) { return false; } break; @@ -97758,7 +98355,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 149 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 150 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); if (child.kind === 10 /* JsxText */) { @@ -97766,7 +98363,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 182 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 183 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -97896,6 +98493,7 @@ var ts; } } } + // TODO: GH#18217 use an enum instead of `boolean | undefined` function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); var lineAction = 0 /* None */; @@ -98177,12 +98775,12 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 154 /* Constructor */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 192 /* ArrowFunction */: + case 155 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 193 /* ArrowFunction */: if (node.typeParameters === list) { return 27 /* LessThanToken */; } @@ -98190,8 +98788,8 @@ var ts; return 19 /* OpenParenToken */; } break; - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: if (node.typeArguments === list) { return 27 /* LessThanToken */; } @@ -98199,7 +98797,7 @@ var ts; return 19 /* OpenParenToken */; } break; - case 161 /* TypeReference */: + case 162 /* TypeReference */: if (node.typeArguments === list) { return 27 /* LessThanToken */; } @@ -98316,7 +98914,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 199 /* BinaryExpression */) { + if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 200 /* 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 */) { @@ -98368,7 +98966,7 @@ var ts; // handle cases when codefix is about to be inserted before the close brace ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* CloseBrace */ ? options.indentSize : 0 : lineAtPosition !== currentStart.line ? options.indentSize : 0; - return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); + return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } // check if current node is a list item - if yes, take indentation from it var actualIndentation = getActualIndentationForListItem(current, sourceFile, options); @@ -98377,7 +98975,7 @@ var ts; } actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { - return actualIndentation + options.indentSize; + return actualIndentation + options.indentSize; // TODO: GH#18217 } previous = current; current = current.parent; @@ -98472,7 +99070,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 === 273 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 274 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -98520,7 +99118,7 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 216 /* IfStatement */ && parent.elseStatement === child) { + if (parent.kind === 217 /* IfStatement */ && parent.elseStatement === child) { var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; @@ -98536,40 +99134,40 @@ var ts; if (node.parent) { var end = node.end; switch (node.parent.kind) { - case 161 /* TypeReference */: + case 162 /* TypeReference */: return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), end); - case 183 /* ObjectLiteralExpression */: + case 184 /* ObjectLiteralExpression */: return node.parent.properties; - case 182 /* ArrayLiteralExpression */: + case 183 /* ArrayLiteralExpression */: return node.parent.elements; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 154 /* Constructor */: - case 163 /* ConstructorType */: - case 158 /* ConstructSignature */: { + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 155 /* Constructor */: + case 164 /* ConstructorType */: + case 159 /* ConstructSignature */: { var start = node.getStart(sourceFile); return getListIfStartEndIsInListRange(node.parent.typeParameters, start, end) || getListIfStartEndIsInListRange(node.parent.parameters, start, end); } - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return getListIfStartEndIsInListRange(node.parent.typeParameters, node.getStart(sourceFile), end); - case 187 /* NewExpression */: - case 186 /* CallExpression */: { + case 188 /* NewExpression */: + case 187 /* CallExpression */: { var start = node.getStart(sourceFile); return getListIfStartEndIsInListRange(node.parent.typeArguments, start, end) || getListIfStartEndIsInListRange(node.parent.arguments, start, end); } - case 232 /* VariableDeclarationList */: + case 233 /* VariableDeclarationList */: return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), end); - case 246 /* NamedImports */: - case 250 /* NamedExports */: + case 247 /* NamedImports */: + case 251 /* NamedExports */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), end); } } @@ -98609,10 +99207,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 184 /* PropertyAccessExpression */: - case 185 /* ElementAccessExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 185 /* PropertyAccessExpression */: + case 186 /* ElementAccessExpression */: node = node.expression; break; default: @@ -98674,91 +99272,89 @@ var ts; return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; } SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; - function nodeContentIsAlwaysIndented(kind) { - switch (kind) { - case 215 /* ExpressionStatement */: - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 182 /* ArrayLiteralExpression */: - case 212 /* Block */: - case 239 /* ModuleBlock */: - case 183 /* ObjectLiteralExpression */: - case 165 /* TypeLiteral */: - case 176 /* MappedType */: - case 167 /* TupleType */: - case 240 /* CaseBlock */: - case 266 /* DefaultClause */: - case 265 /* CaseClause */: - case 190 /* ParenthesizedExpression */: - case 184 /* PropertyAccessExpression */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 213 /* VariableStatement */: - case 231 /* VariableDeclaration */: - case 248 /* ExportAssignment */: - case 224 /* ReturnStatement */: - case 200 /* ConditionalExpression */: - case 180 /* ArrayBindingPattern */: - case 179 /* ObjectBindingPattern */: - case 256 /* JsxOpeningElement */: - case 259 /* JsxOpeningFragment */: - case 255 /* JsxSelfClosingElement */: - case 264 /* JsxExpression */: - case 152 /* MethodSignature */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 148 /* Parameter */: - case 162 /* FunctionType */: - case 163 /* ConstructorType */: - case 172 /* ParenthesizedType */: - case 188 /* TaggedTemplateExpression */: - case 196 /* AwaitExpression */: - case 250 /* NamedExports */: - case 246 /* NamedImports */: - case 251 /* ExportSpecifier */: - case 247 /* ImportSpecifier */: - case 269 /* PropertyAssignment */: - case 151 /* PropertyDeclaration */: - return true; - } - return false; - } function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 231 /* VariableDeclaration */: - case 269 /* PropertyAssignment */: - case 183 /* ObjectLiteralExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 183 /* ObjectLiteralExpression */) { + case 216 /* ExpressionStatement */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 183 /* ArrayLiteralExpression */: + case 213 /* Block */: + case 240 /* ModuleBlock */: + case 184 /* ObjectLiteralExpression */: + case 166 /* TypeLiteral */: + case 177 /* MappedType */: + case 168 /* TupleType */: + case 241 /* CaseBlock */: + case 267 /* DefaultClause */: + case 266 /* CaseClause */: + case 191 /* ParenthesizedExpression */: + case 185 /* PropertyAccessExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 214 /* VariableStatement */: + case 249 /* ExportAssignment */: + case 225 /* ReturnStatement */: + case 201 /* ConditionalExpression */: + case 181 /* ArrayBindingPattern */: + case 180 /* ObjectBindingPattern */: + case 257 /* JsxOpeningElement */: + case 260 /* JsxOpeningFragment */: + case 256 /* JsxSelfClosingElement */: + case 265 /* JsxExpression */: + case 153 /* MethodSignature */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 149 /* Parameter */: + case 163 /* FunctionType */: + case 164 /* ConstructorType */: + case 173 /* ParenthesizedType */: + case 189 /* TaggedTemplateExpression */: + case 197 /* AwaitExpression */: + case 251 /* NamedExports */: + case 247 /* NamedImports */: + case 252 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 152 /* PropertyDeclaration */: + return true; + case 232 /* VariableDeclaration */: + case 270 /* PropertyAssignment */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 184 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - break; - case 217 /* DoStatement */: - case 218 /* WhileStatement */: - case 220 /* ForInStatement */: - case 221 /* ForOfStatement */: - case 219 /* ForStatement */: - case 216 /* IfStatement */: - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 192 /* ArrowFunction */: - case 154 /* Constructor */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - return childKind !== 212 /* Block */; - case 249 /* ExportDeclaration */: - return childKind !== 250 /* NamedExports */; - case 243 /* ImportDeclaration */: - return childKind !== 244 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 246 /* NamedImports */); - case 254 /* JsxElement */: - return childKind !== 257 /* JsxClosingElement */; - case 258 /* JsxFragment */: - return childKind !== 260 /* JsxClosingFragment */; + return true; + case 218 /* DoStatement */: + case 219 /* WhileStatement */: + case 221 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 220 /* ForStatement */: + case 217 /* IfStatement */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 193 /* ArrowFunction */: + case 155 /* Constructor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + return childKind !== 213 /* Block */; + case 250 /* ExportDeclaration */: + return childKind !== 251 /* NamedExports */; + case 244 /* ImportDeclaration */: + return childKind !== 245 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 247 /* NamedImports */); + case 255 /* JsxElement */: + return childKind !== 258 /* JsxClosingElement */; + case 259 /* JsxFragment */: + return childKind !== 261 /* JsxClosingFragment */; + case 170 /* IntersectionType */: + case 169 /* UnionType */: + if (childKind === 166 /* TypeLiteral */) { + return false; + } + // falls through } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -98766,17 +99362,17 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 224 /* ReturnStatement */: - case 228 /* ThrowStatement */: { - if (parent.kind !== 212 /* Block */) { + case 225 /* ReturnStatement */: + case 229 /* ThrowStatement */: { + if (parent.kind !== 213 /* Block */) { return true; } var grandParent = parent.parent; // In a function, we may want to write inner functions after this. - return !(grandParent && grandParent.kind === 191 /* FunctionExpression */ || grandParent.kind === 233 /* FunctionDeclaration */); + return !(grandParent && grandParent.kind === 192 /* FunctionExpression */ || grandParent.kind === 234 /* FunctionDeclaration */); } - case 222 /* ContinueStatement */: - case 223 /* BreakStatement */: + case 223 /* ContinueStatement */: + case 224 /* BreakStatement */: return true; default: return false; @@ -98788,7 +99384,7 @@ var ts; */ function shouldIndentChildNode(settings, parent, child, sourceFile, isNextChild) { if (isNextChild === void 0) { isNextChild = false; } - return (nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(settings, parent, child, sourceFile, /*indentByDefault*/ false)) + return nodeWillIndentChild(settings, parent, child, sourceFile, /*indentByDefault*/ false) && !(isNextChild && child && isControlFlowEndingStatement(child.kind, parent)); } SmartIndenter.shouldIndentChildNode = shouldIndentChildNode; @@ -98905,7 +99501,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 === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 183 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 184 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -98951,6 +99547,12 @@ var ts; this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); return this; }; + ChangeTracker.prototype.deleteNodeRangeExcludingEnd = function (sourceFile, startNode, afterEndNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); + var endPosition = afterEndNode === undefined ? sourceFile.text.length : getAdjustedStartPosition(sourceFile, afterEndNode, options, Position.FullStart); + this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + }; ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { var containingList = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); if (!containingList) { @@ -99064,7 +99666,7 @@ var ts; } } else { - endNode = node.kind !== 231 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 232 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); }; @@ -99168,7 +99770,7 @@ var ts; else if (ts.isStatement(node) || ts.isClassOrTypeElement(node)) { return { suffix: this.newLineCharacter }; } - else if (ts.isVariableDeclaration(node)) { + else if (ts.isVariableDeclaration(node) || ts.isStringLiteral(node)) { return { prefix: ", " }; } else if (ts.isPropertyAssignment(node)) { @@ -99181,7 +99783,7 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 192 /* ArrowFunction */) { + if (node.kind === 193 /* ArrowFunction */) { var arrow = ts.findChildOfKind(node, 36 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 19 /* OpenParenToken */, sourceFile); if (lparen) { @@ -99195,14 +99797,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(20 /* CloseParenToken */)); } - if (node.body.kind !== 212 /* Block */) { + if (node.body.kind !== 213 /* Block */) { // `() => 0` => `function f() { return 0; }` this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(17 /* OpenBraceToken */), ts.createToken(96 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(25 /* SemicolonToken */), ts.createToken(18 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 191 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 192 /* FunctionExpression */ ? 89 /* FunctionKeyword */ : 75 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -99358,7 +99960,7 @@ var ts; var changes = changesToText.getTextChangesFromChanges(this.changes, this.newLineCharacter, this.formatContext, validate); for (var _i = 0, _a = this.newFiles; _i < _a.length; _i++) { var _b = _a[_i], oldFile = _b.oldFile, fileName = _b.fileName, statements = _b.statements; - changes.push(changesToText.newFileChanges(oldFile, fileName, statements, this.newLineCharacter)); + changes.push(changesToText.newFileChanges(oldFile, fileName, statements, this.newLineCharacter, this.formatContext)); } return changes; }; @@ -99383,14 +99985,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_18 = function (i) { + var _loop_21 = 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_18(i); + _loop_21(i); } var textChanges = normalized.map(function (c) { return ts.createTextChange(ts.createTextSpanFromRange(c.range), computeNewText(c, sourceFile, newLineCharacter, formatContext, validate)); @@ -99399,8 +100001,12 @@ var ts; }); } changesToText.getTextChangesFromChanges = getTextChangesFromChanges; - function newFileChanges(oldFile, fileName, statements, newLineCharacter) { - var text = statements.map(function (s) { return getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + function newFileChanges(oldFile, fileName, statements, newLineCharacter, formatContext) { + // TODO: this emits the file, parses it back, then formats it that -- may be a less roundabout way to do this + var nonFormattedText = statements.map(function (s) { return getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + var sourceFile = ts.createSourceFile(fileName, nonFormattedText, 6 /* ESNext */); + var changes = ts.formatting.formatDocument(sourceFile, formatContext); + var text = applyChanges(nonFormattedText, changes); return { fileName: fileName, textChanges: [ts.createTextChange(ts.createTextSpan(0, 0), text)], isNewFile: true }; } changesToText.newFileChanges = newFileChanges; @@ -99414,7 +100020,7 @@ var ts; var _a = change.options, options = _a === void 0 ? {} : _a, pos = change.range.pos; var format = function (n) { return getFormattedTextOfNode(n, sourceFile, pos, options, newLineCharacter, formatContext, validate); }; var text = change.kind === ChangeKind.ReplaceWithMultipleNodes - ? change.nodes.map(function (n) { return ts.removeSuffix(format(n), newLineCharacter); }).join(change.options.joiner || newLineCharacter) + ? change.nodes.map(function (n) { return ts.removeSuffix(format(n), newLineCharacter); }).join(change.options.joiner || newLineCharacter) // TODO: GH#18217 : format(change.node); // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, ""); @@ -99457,7 +100063,7 @@ var ts; return ts.skipTrivia(s, 0) === s.length; } function assignPositionsToNode(node) { - var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); + var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // TODO: GH#18217 // create proxy node for non synthesized nodes var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited); newNode.pos = getPos(node); @@ -99647,7 +100253,7 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 146 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 147 /* ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } })(textChanges = ts.textChanges || (ts.textChanges = {})); @@ -99718,8 +100324,8 @@ var ts; } codefix.codeFixAll = codeFixAll; function eachDiagnostic(_a, errorCodes, cb) { - var program = _a.program, sourceFile = _a.sourceFile; - for (var _i = 0, _b = program.getSemanticDiagnostics(sourceFile).concat(ts.computeSuggestionDiagnostics(sourceFile, program)); _i < _b.length; _i++) { + var program = _a.program, sourceFile = _a.sourceFile, cancellationToken = _a.cancellationToken; + for (var _i = 0, _b = program.getSemanticDiagnostics(sourceFile, cancellationToken).concat(ts.computeSuggestionDiagnostics(sourceFile, program, cancellationToken)); _i < _b.length; _i++) { var diag = _b[_i]; if (ts.contains(errorCodes, diag.code)) { cb(diag); @@ -99855,29 +100461,29 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 231 /* VariableDeclaration */ || - node.kind === 150 /* PropertySignature */ || - node.kind === 151 /* PropertyDeclaration */; + node.kind === 232 /* VariableDeclaration */ || + node.kind === 151 /* PropertySignature */ || + node.kind === 152 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 278 /* JSDocAllType */: - case 279 /* JSDocUnknownType */: + case 279 /* JSDocAllType */: + case 280 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 282 /* JSDocOptionalType */: + case 283 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 281 /* JSDocNonNullableType */: + case 282 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 280 /* JSDocNullableType */: + case 281 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 284 /* JSDocVariadicType */: + case 285 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 283 /* JSDocFunctionType */: + case 284 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 161 /* TypeReference */: + case 162 /* TypeReference */: return transformJSDocTypeReference(node); default: - var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); + var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 ts.setEmitFlags(visited, 1 /* SingleLine */); return visited; } @@ -99896,7 +100502,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 284 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; + var isRest = node.type.kind === 285 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(24 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -99972,16 +100578,16 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: precedingNode = ctorDeclaration; deleteNode(ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { - copyComments(precedingNode, newClassDeclaration, sourceFile); + copyComments(precedingNode, newClassDeclaration, sourceFile); // TODO: GH#18217 deleteNode(precedingNode); } else { @@ -100048,7 +100654,7 @@ var ts; return; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 215 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 216 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; deleteNode(nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -100056,7 +100662,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 191 /* FunctionExpression */: { + case 192 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 120 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, @@ -100064,12 +100670,12 @@ var ts; copyComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 192 /* ArrowFunction */: { + case 193 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 212 /* Block */) { + if (arrowFunctionBody.kind === 213 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] @@ -100097,13 +100703,13 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 191 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 192 /* FunctionExpression */) { return undefined; } if (node.name.kind !== 71 /* Identifier */) { return undefined; } - var memberElements = createClassElementsFromSymbol(initializer.symbol); + var memberElements = createClassElementsFromSymbol(node.symbol); if (initializer.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } @@ -100153,13 +100759,13 @@ var ts; codefix.registerCodeFix({ errorCodes: [ts.Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module.code], getCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program; + var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences; var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { - var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, program.getCompilerOptions().target); + var moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, program.getCompilerOptions().target, preferences); if (moduleExportsChangedToDefault) { for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var importingFile = _a[_i]; - fixImportOfModuleExports(importingFile, sourceFile, changes); + fixImportOfModuleExports(importingFile, sourceFile, changes, preferences); } } }); @@ -100167,7 +100773,7 @@ var ts; return [codefix.createCodeFixActionNoFixId("convertToEs6Module", changes, ts.Diagnostics.Convert_to_ES6_module)]; }, }); - function fixImportOfModuleExports(importingFile, exportingFile, changes) { + function fixImportOfModuleExports(importingFile, exportingFile, changes, preferences) { for (var _i = 0, _a = importingFile.imports; _i < _a.length; _i++) { var moduleSpecifier = _a[_i]; var imported = ts.getResolvedModule(importingFile, moduleSpecifier.text); @@ -100176,10 +100782,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 242 /* ImportEqualsDeclaration */: - changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier)); + case 243 /* ImportEqualsDeclaration */: + changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, preferences)); break; - case 186 /* CallExpression */: + case 187 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -100188,14 +100794,14 @@ var ts; } } /** @returns Whether we converted a `module.exports =` to a default export. */ - function convertFileToEs6Module(sourceFile, checker, changes, target) { + function convertFileToEs6Module(sourceFile, checker, changes, target, preferences) { var identifiers = { original: collectFreeIdentifiers(sourceFile), additional: ts.createMap() }; var exports = collectExportRenames(sourceFile, checker, identifiers); convertExportsAccesses(sourceFile, exports, changes); var moduleExportsChangedToDefault = false; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - var moduleExportsChanged = convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports); + var moduleExportsChanged = convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, preferences); moduleExportsChangedToDefault = moduleExportsChangedToDefault || moduleExportsChanged; } return moduleExportsChangedToDefault; @@ -100230,22 +100836,22 @@ var ts; node.forEachChild(recur); }); } - function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports) { + function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, preferences) { switch (statement.kind) { - case 213 /* VariableStatement */: - convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target); + case 214 /* VariableStatement */: + convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, preferences); return false; - case 215 /* ExpressionStatement */: { + case 216 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 186 /* CallExpression */: { + case 187 /* 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])); + changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], preferences)); } return false; } - case 199 /* BinaryExpression */: { + case 200 /* BinaryExpression */: { var operatorToken = expression.operatorToken; return operatorToken.kind === 58 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } @@ -100256,7 +100862,7 @@ var ts; return false; } } - function convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target) { + function convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, preferences) { var declarationList = statement.declarationList; var foundImport = false; var newNodes = ts.flatMap(declarationList.declarations, function (decl) { @@ -100269,11 +100875,11 @@ var ts; } else if (ts.isRequireCall(initializer, /*checkArgumentIsStringLiteralLike*/ true)) { foundImport = true; - return convertSingleImport(sourceFile, name, initializer.arguments[0], changes, checker, identifiers, target); + return convertSingleImport(sourceFile, name, initializer.arguments[0], changes, checker, identifiers, target, preferences); } else if (ts.isPropertyAccessExpression(initializer) && ts.isRequireCall(initializer.expression, /*checkArgumentIsStringLiteralLike*/ true)) { foundImport = true; - return convertPropertyAccessImport(name, initializer.name.text, initializer.expression.arguments[0], identifiers); + return convertPropertyAccessImport(name, initializer.name.text, initializer.expression.arguments[0], identifiers, preferences); } } // Move it out to its own variable statement. (This will not be used if `!foundImport`) @@ -100285,22 +100891,22 @@ var ts; } } /** Converts `const name = require("moduleSpecifier").propertyName` */ - function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers) { + function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, preferences) { switch (name.kind) { - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: { + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ - makeSingleImport(tmp, propertyName, moduleSpecifier), + makeSingleImport(tmp, propertyName, moduleSpecifier, preferences), makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } case 71 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; - return [makeSingleImport(name.text, propertyName, moduleSpecifier)]; + return [makeSingleImport(name.text, propertyName, moduleSpecifier, preferences)]; default: - ts.Debug.assertNever(name); + return ts.Debug.assertNever(name); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -100339,15 +100945,15 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 270 /* ShorthandPropertyAssignment */: - case 271 /* SpreadAssignment */: + case 271 /* ShorthandPropertyAssignment */: + case 272 /* SpreadAssignment */: return undefined; - case 269 /* PropertyAssignment */: + case 270 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(84 /* ExportKeyword */)], prop); default: ts.Debug.assertNever(prop); @@ -100413,7 +101019,7 @@ var ts; function convertExportsDotXEquals_replaceNode(name, exported) { var modifiers = [ts.createToken(84 /* ExportKeyword */)]; switch (exported.kind) { - case 191 /* FunctionExpression */: { + case 192 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -100421,10 +101027,10 @@ var ts; } } // falls through - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 204 /* ClassExpression */: + case 205 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -100432,7 +101038,7 @@ var ts; } function exportConst() { // `exports.x = 0;` --> `export const x = 0;` - return makeConst(modifiers, ts.createIdentifier(name), exported); + return makeConst(modifiers, ts.createIdentifier(name), exported); // TODO: GH#18217 } } /** @@ -100440,41 +101046,41 @@ var ts; * Returns nodes that will replace the variable declaration for the commonjs import. * May also make use `changes` to remove qualifiers at the use sites of imports, to change `mod.x` to `x`. */ - function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target) { + function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, preferences) { switch (name.kind) { - case 179 /* ObjectBindingPattern */: { + case 180 /* 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 : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); + }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) if (importSpecifiers) { - return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier)]; + return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, preferences)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 180 /* ArrayBindingPattern */: { + case 181 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; */ var tmp = makeUniqueName(codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, target), identifiers); return [ - ts.makeImport(ts.createIdentifier(tmp), /*namedImports*/ undefined, moduleSpecifier), + ts.makeImport(ts.createIdentifier(tmp), /*namedImports*/ undefined, moduleSpecifier, preferences), makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } case 71 /* Identifier */: - return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers); + return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, preferences); default: - ts.Debug.assertNever(name); + return ts.Debug.assertNever(name); } } /** * Convert `import x = require("x").` * Also converts uses like `x.y()` to `y()` and uses a named import. */ - function convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers) { + function convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, preferences) { var nameSymbol = checker.getSymbolAtLocation(name); // Maps from module property name to name actually used. (The same if there isn't shadowing.) var namedBindingsNames = ts.createMap(); @@ -100509,7 +101115,7 @@ var ts; // If it was unused, ensure that we at least import *something*. needDefaultImport = true; } - return [ts.makeImport(needDefaultImport ? ts.getSynthesizedDeepClone(name) : undefined, namedBindings, moduleSpecifier)]; + return [ts.makeImport(needDefaultImport ? ts.getSynthesizedDeepClone(name) : undefined, namedBindings, moduleSpecifier, preferences)]; } // Identifiers helpers function makeUniqueName(name, identifiers) { @@ -100521,20 +101127,26 @@ var ts; } function collectFreeIdentifiers(file) { var map = ts.createMultiMap(); - file.forEachChild(function recur(node) { - if (ts.isIdentifier(node) && isFreeIdentifier(node)) { - map.add(node.text, node); - } - node.forEachChild(recur); - }); + forEachFreeIdentifier(file, function (id) { return map.add(id.text, id); }); return map; } + /** + * A free identifier is an identifier that can be accessed through name lookup as a local variable. + * In the expression `x.y`, `x` is a free identifier, but `y` is not. + */ + function forEachFreeIdentifier(node, cb) { + if (ts.isIdentifier(node) && isFreeIdentifier(node)) + cb(node); + node.forEachChild(function (child) { return forEachFreeIdentifier(child, cb); }); + } function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: return parent.name !== node; - case 181 /* BindingElement */: + case 182 /* BindingElement */: + return parent.propertyName !== node; + case 248 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -100549,10 +101161,10 @@ var ts; return ts.createClassDeclaration(ts.getSynthesizedDeepClones(cls.decorators), // TODO: GH#19915 Don't think this is even legal. ts.concatenate(additionalModifiers, ts.getSynthesizedDeepClones(cls.modifiers)), name, ts.getSynthesizedDeepClones(cls.typeParameters), ts.getSynthesizedDeepClones(cls.heritageClauses), ts.getSynthesizedDeepClones(cls.members)); } - function makeSingleImport(localName, propertyName, moduleSpecifier) { + function makeSingleImport(localName, propertyName, moduleSpecifier, preferences) { return propertyName === "default" - ? ts.makeImport(ts.createIdentifier(localName), /*namedImports*/ undefined, moduleSpecifier) - : ts.makeImport(/*name*/ undefined, [makeImportSpecifier(propertyName, localName)], moduleSpecifier); + ? ts.makeImport(ts.createIdentifier(localName), /*namedImports*/ undefined, moduleSpecifier, preferences) + : ts.makeImport(/*name*/ undefined, [makeImportSpecifier(propertyName, localName)], moduleSpecifier, preferences); } function makeImportSpecifier(propertyName, name) { return ts.createImportSpecifier(propertyName !== undefined && propertyName !== name ? ts.createIdentifier(propertyName) : undefined, ts.createIdentifier(name)); @@ -100640,12 +101252,16 @@ var ts; function getClass(sourceFile, pos) { return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false))); } + function symbolPointsToNonPrivateMember(symbol) { + return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); + } function addMissingDeclarations(checker, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) { + var maybeHeritageClauseSymbol = getHeritageClauseSymbolTable(classDeclaration, checker); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. var implementedType = checker.getTypeAtLocation(implementedTypeNode); var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); - var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); }); + var nonPrivateAndNotExistedInHeritageClauseMembers = implementedTypeSymbols.filter(ts.and(symbolPointsToNonPrivateMember, function (symbol) { return !maybeHeritageClauseSymbol.has(symbol.escapedName); })); var classType = checker.getTypeAtLocation(classDeclaration); if (!classType.getNumberIndexType()) { createMissingIndexSignatureDeclaration(implementedType, 1 /* Number */); @@ -100653,7 +101269,7 @@ var ts; if (!classType.getStringIndexType()) { createMissingIndexSignatureDeclaration(implementedType, 0 /* String */); } - codefix.createMissingMemberNodes(classDeclaration, nonPrivateMembers, checker, preferences, function (member) { return changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member); }); + codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, checker, preferences, function (member) { return changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member); }); function createMissingIndexSignatureDeclaration(type, kind) { var indexInfoOfKind = checker.getIndexInfoOfType(type, kind); if (indexInfoOfKind) { @@ -100661,6 +101277,14 @@ var ts; } } } + function getHeritageClauseSymbolTable(classDeclaration, checker) { + var heritageClauseNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + if (!heritageClauseNode) + return ts.createSymbolTable(); + var heritageClauseType = checker.getTypeAtLocation(heritageClauseNode); + var heritageClauseTypeSymbols = checker.getPropertiesOfType(heritageClauseType); + return ts.createSymbolTable(heritageClauseTypeSymbols.filter(symbolPointsToNonPrivateMember)); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -100677,7 +101301,9 @@ var ts; ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code, ], - getCodeActions: getImportCodeActions, + getCodeActions: function (context) { return context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ? getActionsForUMDImport(context) + : getActionsForNonUMDImport(context); }, // TODO: GH#20315 fixIds: [], getAllCodeActions: ts.notImplemented, @@ -100696,7 +101322,6 @@ var ts; program: program, checker: checker, compilerOptions: program.getCompilerOptions(), - cachedImportDeclarations: [], getCanonicalFileName: ts.createGetCanonicalFileName(ts.hostUsesCaseSensitiveFileNames(context.host)), symbolName: symbolName, symbolToken: symbolToken, @@ -100742,9 +101367,17 @@ var ts; return result; } function getCodeActionsForImport_separateExistingAndNew(exportInfos, context, useExisting, addNew) { - var existingImports = ts.flatMap(exportInfos, function (info) { - return getImportDeclarations(info, context.checker, context.sourceFile, context.cachedImportDeclarations); - }); + var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, context.checker, context.sourceFile); }); + ts.append(useExisting, tryUseExistingNamespaceImport(existingImports, context, context.symbolToken, context.checker)); + var addToExisting = tryAddToExistingImport(existingImports, context); + if (addToExisting) { + useExisting.push(addToExisting); + } + else { // Don't bother providing an action to add a new import if we can add to an existing one. + getCodeActionsForAddImport(exportInfos, context, existingImports, addNew); + } + } + function tryUseExistingNamespaceImport(existingImports, context, symbolToken, checker) { // It is possible that multiple import statements with the same specifier exist in the file. // e.g. // @@ -100757,44 +101390,46 @@ var ts; // 1. change "member3" to "ns.member3" // 2. add "member3" to the second import statement's import list // and it is up to the user to decide which one fits best. - if (context.symbolToken && ts.isIdentifier(context.symbolToken)) { - for (var _i = 0, existingImports_1 = existingImports; _i < existingImports_1.length; _i++) { - var declaration = existingImports_1[_i].declaration; - var namespace_2 = getNamespaceImportName(declaration); - if (namespace_2) { - var moduleSymbol = context.checker.getAliasedSymbol(context.checker.getSymbolAtLocation(namespace_2)); - if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(context.symbolName))) { - useExisting.push(getCodeActionForUseExistingNamespaceImport(namespace_2.text, context, context.symbolToken)); - } + return !symbolToken || !ts.isIdentifier(symbolToken) ? undefined : ts.firstDefined(existingImports, function (_a) { + var declaration = _a.declaration; + var namespace = getNamespaceImportName(declaration); + if (namespace) { + var moduleSymbol = namespace && checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)); + if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(context.symbolName))) { + return getCodeActionForUseExistingNamespaceImport(namespace.text, context, symbolToken); } } - } - getCodeActionsForAddImport(exportInfos, context, existingImports, useExisting, addNew); + }); + } + function tryAddToExistingImport(existingImports, context) { + return ts.firstDefined(existingImports, function (_a) { + var declaration = _a.declaration, importKind = _a.importKind; + if (declaration.kind === 244 /* ImportDeclaration */ && declaration.importClause) { + var changes = tryUpdateExistingImport(context, declaration.importClause, importKind); + if (changes) { + var moduleSpecifierWithoutQuotes = ts.stripQuotes(declaration.moduleSpecifier.getText()); + return createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [context.symbolName, moduleSpecifierWithoutQuotes], changes); + } + } + }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 243 /* ImportDeclaration */) { + if (declaration.kind === 244 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 245 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 246 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; } } - // TODO(anhans): This doesn't seem important to cache... just use an iterator instead of creating a new array? - function getImportDeclarations(_a, checker, _b, cachedImportDeclarations) { + function getExistingImportDeclarations(_a, checker, _b) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind; var imports = _b.imports; - if (cachedImportDeclarations === void 0) { cachedImportDeclarations = []; } - var moduleSymbolId = ts.getUniqueSymbolId(moduleSymbol, checker); - var cached = cachedImportDeclarations[moduleSymbolId]; - if (!cached) { - cached = cachedImportDeclarations[moduleSymbolId] = ts.mapDefined(imports, function (moduleSpecifier) { - var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 243 /* ImportDeclaration */ || i.kind === 242 /* ImportEqualsDeclaration */) - && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; - }); - } - return cached; + return ts.mapDefined(imports, function (moduleSpecifier) { + var i = ts.importFromModuleSpecifier(moduleSpecifier); + return (i.kind === 244 /* ImportDeclaration */ || i.kind === 243 /* ImportEqualsDeclaration */) + && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; + }); } function getCodeActionForNewImport(context, _a) { var moduleSpecifier = _a.moduleSpecifier, importKind = _a.importKind; @@ -100819,7 +101454,7 @@ var ts; }); // if this file doesn't have any import statements, insert an import statement and then insert a new line // between the only import statement and user code. Otherwise just insert the statement because chances - // are there are already a new line seperating code and import statements. + // are there are already a new line separating code and import statements. return createCodeAction(ts.Diagnostics.Import_0_from_module_1, [symbolName, moduleSpecifierWithoutQuotes], changes); } function shouldUseSingleQuote(sourceFile, preferences) { @@ -100853,21 +101488,7 @@ var ts; // Sort to keep the shortest paths first, but keep [relativePath, importRelativeToBaseUrl] groups together return ts.flatten(choicesForEachExportingModule.sort(function (a, b) { return ts.first(a).moduleSpecifier.length - ts.first(b).moduleSpecifier.length; })); } - function getCodeActionsForAddImport(exportInfos, ctx, existingImports, useExisting, addNew) { - var fromExistingImport = ts.firstDefined(existingImports, function (_a) { - var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind === 243 /* ImportDeclaration */ && declaration.importClause) { - var changes = tryUpdateExistingImport(ctx, ts.isImportClause(declaration.importClause) && declaration.importClause || undefined, importKind); - if (changes) { - var moduleSpecifierWithoutQuotes = ts.stripQuotes(declaration.moduleSpecifier.getText()); - return createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [ctx.symbolName, moduleSpecifierWithoutQuotes], changes); - } - } - }); - if (fromExistingImport) { - useExisting.push(fromExistingImport); - return; - } + function getCodeActionsForAddImport(exportInfos, ctx, existingImports, addNew) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); var newImportInfos = existingDeclaration ? [existingDeclaration] @@ -100879,9 +101500,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 243 /* ImportDeclaration */ + var expression = declaration.kind === 244 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 253 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 254 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -100889,7 +101510,7 @@ var ts; function tryUpdateExistingImport(context, importClause, importKind) { var symbolName = context.symbolName, sourceFile = context.sourceFile; var name = importClause.name; - var namedBindings = (importClause.kind !== 242 /* ImportEqualsDeclaration */ && importClause).namedBindings; + var namedBindings = (importClause.kind !== 243 /* ImportEqualsDeclaration */ && importClause).namedBindings; // TODO: GH#18217 switch (importKind) { case 1 /* Default */: return name ? undefined : ChangeTracker.with(context, function (t) { @@ -100897,11 +101518,11 @@ var ts; }); case 0 /* Named */: { var newImportSpecifier_1 = ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(symbolName)); - if (namedBindings && namedBindings.kind === 246 /* NamedImports */ && namedBindings.elements.length !== 0) { + if (namedBindings && namedBindings.kind === 247 /* NamedImports */ && namedBindings.elements.length !== 0) { // There are already named imports; add another. return ChangeTracker.with(context, function (t) { return t.insertNodeInListAfter(sourceFile, namedBindings.elements[namedBindings.elements.length - 1], newImportSpecifier_1); }); } - if (!namedBindings || namedBindings.kind === 246 /* NamedImports */ && namedBindings.elements.length === 0) { + if (!namedBindings || namedBindings.kind === 247 /* NamedImports */ && namedBindings.elements.length === 0) { return ChangeTracker.with(context, function (t) { return t.replaceNode(sourceFile, importClause, ts.createImportClause(name, ts.createNamedImports([newImportSpecifier_1]))); }); @@ -100935,11 +101556,6 @@ var ts; }); return createCodeAction(ts.Diagnostics.Change_0_to_1, [symbolName, namespacePrefix + "." + symbolName], changes); } - function getImportCodeActions(context) { - return context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code - ? getActionsForUMDImport(context) - : getActionsForNonUMDImport(context); - } function getActionsForUMDImport(context) { var token = ts.getTokenAtPosition(context.sourceFile, context.span.start, /*includeJsDocComment*/ false); var checker = context.program.getTypeChecker(); @@ -100952,7 +101568,7 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(parent); - if ((ts.isJsxOpeningLikeElement && parent.tagName === token) || parent.kind === 259 /* JsxOpeningFragment */) { + if ((ts.isJsxOpeningLikeElement && parent.tagName === token) || parent.kind === 260 /* JsxOpeningFragment */) { umdSymbol = checker.resolveName(checker.getJsxNamespace(parent), isNodeOpeningLikeElement ? parent.tagName : parent, 67216319 /* Value */, /*excludeGlobals*/ false); } } @@ -101001,7 +101617,14 @@ var ts; return undefined; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here ts.Debug.assert(symbolName !== "default"); - var currentTokenMeaning = ts.getMeaningFromLocation(symbolToken); + var addToExistingDeclaration = []; + var addNewDeclaration = []; + getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).forEach(function (exportInfos) { + getCodeActionsForImport_separateExistingAndNew(exportInfos, convertToImportCodeFixContext(context, symbolToken, symbolName), addToExistingDeclaration, addNewDeclaration); + }); + return addToExistingDeclaration.concat(addNewDeclaration); + } + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { // 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(); @@ -101026,7 +101649,7 @@ var ts; addSymbol(moduleSymbol, exportSymbolWithIdenticalName, 0 /* Named */); } function getEscapedNameForExportDefault(symbol) { - return ts.firstDefined(symbol.declarations, function (declaration) { + return symbol.declarations && ts.firstDefined(symbol.declarations, function (declaration) { if (ts.isExportAssignment(declaration)) { if (ts.isIdentifier(declaration.expression)) { return declaration.expression.escapedText; @@ -101034,19 +101657,12 @@ var ts; } else if (ts.isExportSpecifier(declaration)) { ts.Debug.assert(declaration.name.escapedText === "default" /* Default */); - if (declaration.propertyName) { - return declaration.propertyName.escapedText; - } + return declaration.propertyName && declaration.propertyName.escapedText; } }); } }); - var addToExistingDeclaration = []; - var addNewDeclaration = []; - originalSymbolToExportInfos.forEach(function (exportInfos) { - getCodeActionsForImport_separateExistingAndNew(exportInfos, convertToImportCodeFixContext(context, symbolToken, symbolName), addToExistingDeclaration, addNewDeclaration); - }); - return addToExistingDeclaration.concat(addNewDeclaration); + return originalSymbolToExportInfos; } function checkSymbolHasMeaning(_a, meaning) { var declarations = _a.declarations; @@ -101068,7 +101684,7 @@ var ts; for (var _b = 0, allSourceFiles_1 = allSourceFiles; _b < allSourceFiles_1.length; _b++) { var sourceFile = allSourceFiles_1[_b]; if (ts.isExternalOrCommonJsModule(sourceFile)) { - cb(sourceFile.symbol, sourceFile); + cb(checker.getMergedSymbol(sourceFile.symbol), sourceFile); } } } @@ -101285,7 +101901,7 @@ var ts; } function addMissingMemberInJs(changeTracker, classDeclarationSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 204 /* ClassExpression */) { + if (classDeclaration.kind === 205 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -101311,10 +101927,10 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 199 /* BinaryExpression */) { + if (token.parent.parent.kind === 200 /* 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))); + var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); // TODO: GH#18217 typeNode = checker.typeToTypeNode(widenedType, classDeclaration); } return typeNode || ts.createKeywordTypeNode(119 /* AnyKeyword */); @@ -101370,7 +101986,13 @@ var ts; } function addMethodDeclaration(changeTracker, classDeclarationSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(callExpression, token.text, inJs, makeStatic, preferences); - changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); + var containingMethodDeclaration = ts.getAncestor(callExpression, 154 /* MethodDeclaration */); + if (containingMethodDeclaration && containingMethodDeclaration.parent === classDeclaration) { + changeTracker.insertNodeAfter(classDeclarationSourceFile, containingMethodDeclaration, methodDeclaration); + } + else { + changeTracker.insertNodeAtClassStart(classDeclarationSourceFile, classDeclaration, methodDeclaration); + } } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -101409,7 +102031,7 @@ var ts; var packageName = ts.getPackageName(moduleName).packageName; return diagCode === errorCodeCannotFindModule ? (ts.JsTyping.nodeCoreModules.has(packageName) ? "@types/node" : undefined) - : (host.isKnownTypesPackageName(packageName) ? ts.getTypesPackageName(packageName) : undefined); + : (host.isKnownTypesPackageName(packageName) ? ts.getTypesPackageName(packageName) : undefined); // TODO: GH#18217 } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -101628,7 +102250,9 @@ var ts; }, fixIds: [fixId], getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - doChange(changes, context.sourceFile, getInfo(diag.file, diag.start, diag.code)); + var info = getInfo(diag.file, diag.start, diag.code); + if (info) + doChange(changes, context.sourceFile, info); }); }, }); function getInfo(sourceFile, pos, diagCode) { @@ -101659,23 +102283,30 @@ var ts; ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code, ts.Diagnostics.All_imports_in_import_declaration_are_unused.code, ts.Diagnostics.All_destructured_elements_are_unused.code, + ts.Diagnostics.All_variables_are_unused.code, ]; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var errorCode = context.errorCode, sourceFile = context.sourceFile; - var importDecl = tryGetFullImport(sourceFile, context.span.start); + var errorCode = context.errorCode, sourceFile = context.sourceFile, program = context.program; + var checker = program.getTypeChecker(); + var startToken = ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); + var importDecl = tryGetFullImport(startToken); if (importDecl) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return t.deleteNode(sourceFile, importDecl); }); return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Remove_import_from_0, ts.showModuleSpecifier(importDecl)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } - var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, context.span.start, /*deleted*/ undefined); }); + var delDestructure = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullDestructure(t, sourceFile, startToken, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); if (delDestructure.length) { return [codefix.createCodeFixAction(fixName, delDestructure, ts.Diagnostics.Remove_destructuring, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; } + var delVar = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteFullVariableStatement(t, sourceFile, startToken, /*deleted*/ undefined); }); + if (delVar.length) { + return [codefix.createCodeFixAction(fixName, delVar, ts.Diagnostics.Remove_variable_statement, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)]; + } var token = getToken(sourceFile, ts.textSpanEnd(context.span)); var result = []; - var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, /*deleted*/ undefined); }); + var deletion = ts.textChanges.ChangeTracker.with(context, function (t) { return tryDeleteDeclaration(t, sourceFile, token, /*deleted*/ undefined, checker, /*isFixAll*/ false); }); if (deletion.length) { result.push(codefix.createCodeFixAction(fixName, deletion, [ts.Diagnostics.Remove_declaration_for_Colon_0, token.getText(sourceFile)], fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations)); } @@ -101688,9 +102319,11 @@ var ts; fixIds: [fixIdPrefix, fixIdDelete], getAllCodeActions: function (context) { // Track a set of deleted nodes that may be ancestors of other marked for deletion -- only delete the ancestors. - var deleted = new NodeSet(); + var deleted = new ts.NodeSet(); + var sourceFile = context.sourceFile, program = context.program; + var checker = program.getTypeChecker(); return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var sourceFile = context.sourceFile; + var startToken = ts.getTokenAtPosition(sourceFile, diag.start, /*includeJsDocComment*/ false); var token = ts.findPrecedingToken(ts.textSpanEnd(diag), diag.file); switch (context.fixId) { case fixIdPrefix: @@ -101702,14 +102335,13 @@ var ts; // Ignore if this range was already deleted. if (deleted.some(function (d) { return ts.rangeContainsPosition(d, diag.start); })) break; - var importDecl = tryGetFullImport(diag.file, diag.start); + var importDecl = tryGetFullImport(startToken); if (importDecl) { changes.deleteNode(sourceFile, importDecl); } - else { - if (!tryDeleteFullDestructure(changes, sourceFile, diag.start, deleted)) { - tryDeleteDeclaration(changes, sourceFile, token, deleted); - } + else if (!tryDeleteFullDestructure(changes, sourceFile, startToken, deleted, checker, /*isFixAll*/ true) && + !tryDeleteFullVariableStatement(changes, sourceFile, startToken, deleted)) { + tryDeleteDeclaration(changes, sourceFile, token, deleted, checker, /*isFixAll*/ true); } break; default: @@ -101719,25 +102351,25 @@ var ts; }, }); // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. - function tryGetFullImport(sourceFile, pos) { - var startToken = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + function tryGetFullImport(startToken) { return startToken.kind === 91 /* ImportKeyword */ ? ts.tryCast(startToken.parent, ts.isImportDeclaration) : undefined; } - function tryDeleteFullDestructure(changes, sourceFile, pos, deletedAncestors) { - var startToken = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + function tryDeleteFullDestructure(changes, sourceFile, startToken, deletedAncestors, checker, isFixAll) { if (startToken.kind !== 17 /* OpenBraceToken */ || !ts.isObjectBindingPattern(startToken.parent)) return false; - var decl = startToken.parent.parent; + var decl = ts.cast(startToken.parent, ts.isObjectBindingPattern).parent; switch (decl.kind) { - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: tryDeleteVariableDeclaration(changes, sourceFile, decl, deletedAncestors); break; - case 148 /* Parameter */: + case 149 /* Parameter */: + if (!mayDeleteParameter(decl, checker, isFixAll)) + break; if (deletedAncestors) deletedAncestors.add(decl); changes.deleteNodeInList(sourceFile, decl); break; - case 181 /* BindingElement */: + case 182 /* BindingElement */: if (deletedAncestors) deletedAncestors.add(decl); changes.deleteNode(sourceFile, decl); @@ -101747,6 +102379,16 @@ var ts; } return true; } + function tryDeleteFullVariableStatement(changes, sourceFile, startToken, deletedAncestors) { + var declarationList = ts.tryCast(startToken.parent, ts.isVariableDeclarationList); + if (declarationList && declarationList.getChildren(sourceFile)[0] === startToken) { + if (deletedAncestors) + deletedAncestors.add(declarationList); + changes.deleteNode(sourceFile, declarationList.parent.kind === 214 /* VariableStatement */ ? declarationList.parent : declarationList); + return true; + } + return false; + } function getToken(sourceFile, pos) { var token = ts.findPrecedingToken(pos, sourceFile, /*startNode*/ undefined, /*includeJsDoc*/ true); // this handles var ["computed"] = 12; @@ -101760,26 +102402,26 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 148 /* Parameter */: + case 149 /* Parameter */: return true; - case 231 /* VariableDeclaration */: { + case 232 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 221 /* ForOfStatement */: - case 220 /* ForInStatement */: + case 222 /* ForOfStatement */: + case 221 /* ForInStatement */: return true; } } } return false; } - function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors) { + function tryDeleteDeclaration(changes, sourceFile, token, deletedAncestors, checker, isFixAll) { switch (token.kind) { case 71 /* Identifier */: - tryDeleteIdentifier(changes, sourceFile, token, deletedAncestors); + tryDeleteIdentifier(changes, sourceFile, token, deletedAncestors, checker, isFixAll); break; - case 151 /* PropertyDeclaration */: - case 245 /* NamespaceImport */: + case 152 /* PropertyDeclaration */: + case 246 /* NamespaceImport */: if (deletedAncestors) deletedAncestors.add(token.parent); changes.deleteNode(sourceFile, token.parent); @@ -101800,13 +102442,13 @@ var ts; changes.deleteNode(sourceFile, token.parent.parent); } } - function tryDeleteIdentifier(changes, sourceFile, identifier, deletedAncestors) { + function tryDeleteIdentifier(changes, sourceFile, identifier, deletedAncestors, checker, isFixAll) { var parent = identifier.parent; switch (parent.kind) { - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: tryDeleteVariableDeclaration(changes, sourceFile, parent, deletedAncestors); break; - case 147 /* TypeParameter */: + case 148 /* TypeParameter */: var typeParameters = ts.getEffectiveTypeParameterDeclarations(parent.parent); if (typeParameters.length === 1) { var _a = ts.cast(typeParameters, ts.isNodeArray), pos = _a.pos, end = _a.end; @@ -101820,18 +102462,17 @@ var ts; changes.deleteNodeInList(sourceFile, parent); } break; - case 148 /* Parameter */: - var oldFunction = parent.parent; - if (ts.isSetAccessor(oldFunction)) { - // Setter must have a parameter + case 149 /* Parameter */: + if (!mayDeleteParameter(parent, checker, isFixAll)) break; - } + var oldFunction = parent.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1) { // Lambdas with exactly one parameter are special because, after removal, there // must be an empty parameter list (i.e. `()`) and this won't necessarily be the // case if the parameter is simply removed (e.g. in `x => 1`). var newFunction = ts.updateArrowFunction(oldFunction, oldFunction.modifiers, oldFunction.typeParameters, - /*parameters*/ undefined, oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); + /*parameters*/ undefined, // TODO: GH#18217 + oldFunction.type, oldFunction.equalsGreaterThanToken, oldFunction.body); // Drop leading and trailing trivia of the new function because we're only going // to replace the span (vs the full span) of the old function - the old leading // and trailing trivia will remain. @@ -101842,13 +102483,13 @@ var ts; changes.deleteNodeInList(sourceFile, parent); } break; - case 181 /* BindingElement */: { + case 182 /* BindingElement */: { var pattern = parent.parent; switch (pattern.kind) { - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: changes.deleteNode(sourceFile, parent); // Don't delete ',' break; - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: changes.deleteNodeInList(sourceFile, parent); break; default: @@ -101857,11 +102498,11 @@ var ts; break; } // handle case where 'import a = A;' - case 242 /* ImportEqualsDeclaration */: - var importEquals = ts.getAncestor(identifier, 242 /* ImportEqualsDeclaration */); + case 243 /* ImportEqualsDeclaration */: + var importEquals = ts.getAncestor(identifier, 243 /* ImportEqualsDeclaration */); changes.deleteNode(sourceFile, importEquals); break; - case 247 /* ImportSpecifier */: + case 248 /* ImportSpecifier */: var namedImports = parent.parent; if (namedImports.elements.length === 1) { tryDeleteNamedImportBinding(changes, sourceFile, namedImports); @@ -101871,10 +102512,10 @@ var ts; changes.deleteNodeInList(sourceFile, parent); } break; - case 244 /* ImportClause */: // this covers both 'import |d|' and 'import |d,| *' + case 245 /* ImportClause */: // this covers both 'import |d|' and 'import |d,| *' var importClause = parent; if (!importClause.namedBindings) { // |import d from './file'| - changes.deleteNode(sourceFile, ts.getAncestor(importClause, 243 /* ImportDeclaration */)); + changes.deleteNode(sourceFile, ts.getAncestor(importClause, 244 /* ImportDeclaration */)); } else { // import |d,| * as ns from './file' @@ -101890,7 +102531,7 @@ var ts; } } break; - case 245 /* NamespaceImport */: + case 246 /* NamespaceImport */: tryDeleteNamedImportBinding(changes, sourceFile, parent); break; default: @@ -101912,14 +102553,14 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(namedBindings, 243 /* ImportDeclaration */); + var importDecl = ts.getAncestor(namedBindings, 244 /* ImportDeclaration */); changes.deleteNode(sourceFile, importDecl); } } // token.parent is a variableDeclaration function tryDeleteVariableDeclaration(changes, sourceFile, varDecl, deletedAncestors) { switch (varDecl.parent.parent.kind) { - case 219 /* ForStatement */: { + case 220 /* ForStatement */: { var forStatement = varDecl.parent.parent; var forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { @@ -101934,16 +102575,16 @@ var ts; } break; } - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: var forOfStatement = varDecl.parent.parent; - ts.Debug.assert(forOfStatement.initializer.kind === 232 /* VariableDeclarationList */); + ts.Debug.assert(forOfStatement.initializer.kind === 233 /* VariableDeclarationList */); var forOfInitializer = forOfStatement.initializer; if (deletedAncestors) deletedAncestors.add(forOfInitializer.declarations[0]); changes.replaceNode(sourceFile, forOfInitializer.declarations[0], ts.createObjectLiteral()); break; - case 220 /* ForInStatement */: - case 229 /* TryStatement */: + case 221 /* ForInStatement */: + case 230 /* TryStatement */: break; default: var variableStatement = varDecl.parent.parent; @@ -101959,18 +102600,34 @@ var ts; } } } - var NodeSet = /** @class */ (function () { - function NodeSet() { - this.map = ts.createMap(); + function mayDeleteParameter(p, checker, isFixAll) { + var parent = p.parent; + switch (parent.kind) { + case 154 /* MethodDeclaration */: + // Don't remove a parameter if this overrides something + var symbol = checker.getSymbolAtLocation(parent.name); + if (ts.isMemberSymbolInBaseType(symbol, checker)) + return false; + // falls through + case 155 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: { + // Can't remove a non-last parameter. Can remove a parameter in code-fix-all if future parameters are also unused. + var parameters = parent.parameters; + var index = parameters.indexOf(p); + ts.Debug.assert(index !== -1); + return isFixAll + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 71 /* Identifier */ && !p.symbol.isReferenced; }) + : index === parameters.length - 1; + } + case 157 /* SetAccessor */: + // Setter must have a parameter + return false; + default: + return ts.Debug.failBadSyntaxKind(parent); } - NodeSet.prototype.add = function (node) { - this.map.set(String(ts.getNodeId(node)), node); - }; - NodeSet.prototype.some = function (pred) { - return ts.forEachEntry(this.map, pred) || false; - }; - return NodeSet; - }()); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -101995,7 +102652,7 @@ var ts; ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; switch (container.kind) { - case 216 /* IfStatement */: + case 217 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { changes.deleteNodeRange(sourceFile, ts.first(statement.parent.statements), ts.last(statement.parent.statements)); @@ -102006,8 +102663,8 @@ var ts; break; } // falls through - case 218 /* WhileStatement */: - case 219 /* ForStatement */: + case 219 /* WhileStatement */: + case 220 /* ForStatement */: changes.deleteNode(sourceFile, container); break; default: @@ -102027,13 +102684,15 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: return true; - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return ts.getModuleInstanceState(s) !== 1 /* Instantiated */; - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); + default: + return false; } } function sliceAfter(arr, value) { @@ -102094,10 +102753,10 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 280 /* JSDocNullableType */) { + if (typeNode.kind === 281 /* 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, 4096 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 8192 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -102114,13 +102773,13 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 280 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 4096 /* Undefined */) : type; + var fixedType = typeNode.kind === 281 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 8192 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } }); function doChange(changes, sourceFile, oldTypeNode, newType, checker) { - changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(newType, /*enclosingDeclaration*/ oldTypeNode)); + changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(newType, /*enclosingDeclaration*/ oldTypeNode)); // TODO: GH#18217 } function getInfo(sourceFile, pos, checker) { var decl = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false), isTypeContainer); @@ -102131,22 +102790,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 207 /* AsExpression */: - case 157 /* CallSignature */: - case 158 /* ConstructSignature */: - case 233 /* FunctionDeclaration */: - case 155 /* GetAccessor */: - case 159 /* IndexSignature */: - case 176 /* MappedType */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 148 /* Parameter */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: - case 156 /* SetAccessor */: - case 236 /* TypeAliasDeclaration */: - case 189 /* TypeAssertionExpression */: - case 231 /* VariableDeclaration */: + case 208 /* AsExpression */: + case 158 /* CallSignature */: + case 159 /* ConstructSignature */: + case 234 /* FunctionDeclaration */: + case 156 /* GetAccessor */: + case 160 /* IndexSignature */: + case 177 /* MappedType */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 149 /* Parameter */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: + case 157 /* SetAccessor */: + case 237 /* TypeAliasDeclaration */: + case 190 /* TypeAssertionExpression */: + case 232 /* VariableDeclaration */: return true; default: return false; @@ -102200,20 +102859,20 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: insertBefore = ts.findChildOfKind(containingFunction, 89 /* FunctionKeyword */, sourceFile); break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 19 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: return; } - return { + return insertBefore && { insertBefore: insertBefore, returnType: getReturnType(containingFunction) }; @@ -102316,17 +102975,17 @@ var ts; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); switch (declaration.kind) { - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 150 /* PropertySignature */: - case 151 /* PropertyDeclaration */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 151 /* PropertySignature */: + case 152 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration); out(ts.createProperty( /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 152 /* MethodSignature */: - case 153 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 154 /* 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 @@ -102366,7 +103025,7 @@ var ts; } } function signatureToMethodDeclaration(checker, signature, enclosingDeclaration, modifiers, name, optional, body) { - var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 153 /* MethodDeclaration */, enclosingDeclaration, 256 /* SuppressAnyReturnType */); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 154 /* MethodDeclaration */, enclosingDeclaration, 256 /* SuppressAnyReturnType */); if (!signatureDeclaration) { return undefined; } @@ -102508,7 +103167,7 @@ var ts; function getDiagnostic(errorCode, token) { switch (errorCode) { case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: - return ts.isSetAccessor(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; + return ts.isSetAccessor(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217 case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: return ts.Diagnostics.Infer_parameter_types_from_usage; default: @@ -102583,11 +103242,11 @@ var ts; } function isApplicableFunctionForInference(declaration) { switch (declaration.kind) { - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 154 /* Constructor */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 155 /* Constructor */: return true; - case 191 /* FunctionExpression */: + case 192 /* FunctionExpression */: return !!declaration.name; } return false; @@ -102626,6 +103285,7 @@ var ts; var notAccessible = function () { typeIsAccessible = false; }; var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { trackSymbol: function (symbol, declaration, meaning) { + // TODO: GH#18217 typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; }, reportInaccessibleThisError: notAccessible, @@ -102645,11 +103305,11 @@ var ts; } function inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken) { switch (containingFunction.kind) { - case 154 /* Constructor */: - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - var isConstructor = containingFunction.kind === 154 /* Constructor */; + case 155 /* Constructor */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + var isConstructor = containingFunction.kind === 155 /* Constructor */; var searchToken = isConstructor ? ts.findChildOfKind(containingFunction, 123 /* ConstructorKeyword */, sourceFile) : containingFunction.name; @@ -102683,7 +103343,7 @@ var ts; cancellationToken.throwIfCancellationRequested(); inferTypeFromContext(reference, checker, usageContext); } - var isConstructor = declaration.kind === 154 /* Constructor */; + var isConstructor = declaration.kind === 155 /* Constructor */; var callContexts = isConstructor ? usageContext.constructContexts : usageContext.callContexts; return callContexts && declaration.parameters.map(function (parameter, parameterIndex) { var types = []; @@ -102715,21 +103375,21 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 198 /* PostfixUnaryExpression */: + case 199 /* PostfixUnaryExpression */: usageContext.isNumber = true; break; - case 197 /* PrefixUnaryExpression */: + case 198 /* PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); break; - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); break; - case 186 /* CallExpression */: - case 187 /* NewExpression */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpressionContext(node.parent, checker, usageContext); } @@ -102737,13 +103397,13 @@ var ts; inferTypeFromContextualType(node, checker, usageContext); } break; - case 184 /* PropertyAccessExpression */: + case 185 /* PropertyAccessExpression */: inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); break; - case 185 /* ElementAccessExpression */: + case 186 /* ElementAccessExpression */: inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); break; - case 231 /* VariableDeclaration */: { + case 232 /* 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. @@ -102813,7 +103473,7 @@ var ts; case 29 /* GreaterThanToken */: case 31 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 272 /* EnumLike */) { + if (operandType.flags & 544 /* EnumLike */) { addCandidateType(usageContext, operandType); } else { @@ -102823,13 +103483,13 @@ var ts; case 59 /* PlusEqualsToken */: case 37 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 272 /* EnumLike */) { + if (otherOperandType.flags & 544 /* EnumLike */) { addCandidateType(usageContext, otherOperandType); } - else if (otherOperandType.flags & 84 /* NumberLike */) { + else if (otherOperandType.flags & 168 /* NumberLike */) { usageContext.isNumber = true; } - else if (otherOperandType.flags & 34 /* StringLike */) { + else if (otherOperandType.flags & 68 /* StringLike */) { usageContext.isString = true; } else { @@ -102852,7 +103512,7 @@ var ts; // LogicalOperator case 54 /* BarBarToken */: if (node === parent.left && - (node.parent.parent.kind === 231 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 232 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); @@ -102880,7 +103540,7 @@ var ts; } } inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 186 /* CallExpression */) { + if (parent.kind === 187 /* CallExpression */) { (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); } else { @@ -102905,7 +103565,7 @@ var ts; var indexType = checker.getTypeAtLocation(parent); var indexUsageContext = {}; inferTypeFromContext(parent, checker, indexUsageContext); - if (indexType.flags & 84 /* NumberLike */) { + if (indexType.flags & 168 /* NumberLike */) { usageContext.numberIndexContext = indexUsageContext; } else { @@ -102927,7 +103587,7 @@ var ts; return checker.getWidenedType(checker.getUnionType(usageContext.candidateTypes.map(function (t) { return checker.getBaseTypeOfLiteralType(t); }), 2 /* Subtype */)); } else if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); + var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 var types = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); return checker.createPromiseType(types.length ? checker.getUnionType(types, 2 /* Subtype */) : checker.getAnyType()); } @@ -102960,12 +103620,12 @@ var ts; } } if (usageContext.numberIndexContext) { - numberIndexInfo = checker.createIndexInfo(getTypeFromUsageContext(usageContext.numberIndexContext, checker), /*isReadonly*/ false); + numberIndexInfo = checker.createIndexInfo(getTypeFromUsageContext(usageContext.numberIndexContext, checker), /*isReadonly*/ false); // TODO: GH#18217 } if (usageContext.stringIndexContext) { stringIndexInfo = checker.createIndexInfo(getTypeFromUsageContext(usageContext.stringIndexContext, checker), /*isReadonly*/ false); } - return checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); + return checker.createAnonymousType(/*symbol*/ undefined, members_6, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo); // TODO: GH#18217 } else { return undefined; @@ -103000,15 +103660,16 @@ var ts; parameters.push(symbol); } var returnType = getTypeFromUsageContext(callContext.returnType, checker) || checker.getVoidType(); + // TODO: GH#18217 return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); } function addCandidateType(context, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 16384 /* Never */)) { + if (type && !(type.flags & 1 /* Any */) && !(type.flags & 32768 /* Never */)) { (context.candidateTypes || (context.candidateTypes = [])).push(type); } } function hasCallContext(usageContext) { - return usageContext && usageContext.callContexts; + return !!usageContext && !!usageContext.callContexts; } })(InferFromReference || (InferFromReference = {})); })(codefix = ts.codefix || (ts.codefix = {})); @@ -103041,7 +103702,7 @@ var ts; var opts = context.program.getCompilerOptions(); var variations = []; // import Bluebird from "bluebird"; - variations.push(createAction(context, sourceFile, node, ts.makeImport(namespace.name, /*namedImports*/ undefined, node.moduleSpecifier))); + variations.push(createAction(context, sourceFile, node, ts.makeImport(namespace.name, /*namedImports*/ undefined, node.moduleSpecifier, context.preferences))); if (ts.getEmitModuleKind(opts) === ts.ModuleKind.CommonJS) { // import Bluebird = require("bluebird"); variations.push(createAction(context, sourceFile, node, ts.createImportEqualsDeclaration( @@ -103063,18 +103724,18 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 186 /* CallExpression */ : 187 /* NewExpression */; + var targetKind = ts.Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? 187 /* CallExpression */ : 188 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), function (a) { return a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length); }); if (!node) { return []; } var expr = node.expression; - var type = context.program.getTypeChecker().getTypeAtLocation(expr); + var type = context.program.getTypeChecker().getTypeAtLocation(expr); // TODO: GH#18217 if (!(type.symbol && type.symbol.originatingImport)) { return []; } var fixes = []; - var relatedImport = type.symbol.originatingImport; + var relatedImport = type.symbol.originatingImport; // TODO: GH#18217 if (!ts.isImportCall(relatedImport)) { ts.addRange(fixes, getCodeFixesForImportDeclaration(context, relatedImport)); } @@ -103151,8 +103812,9 @@ var ts; } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { var undefinedTypeNode = ts.createKeywordTypeNode(140 /* UndefinedKeyword */); - var types = ts.isUnionTypeNode(propertyDeclaration.type) ? propertyDeclaration.type.types.concat(undefinedTypeNode) : [propertyDeclaration.type, undefinedTypeNode]; - changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration.type, ts.createUnionTypeNode(types)); + var type = propertyDeclaration.type; // TODO: GH#18217 + var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; + changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.createUnionTypeNode(types)); } function getActionForAddMissingInitializer(context, propertyDeclaration) { var checker = context.program.getTypeChecker(); @@ -103167,16 +103829,16 @@ var ts; changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getInitializer(checker, propertyDeclaration) { - return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); + return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 2 /* String */) { + if (type.flags & 4 /* String */) { return ts.createLiteral(""); } - else if (type.flags & 4 /* Number */) { + else if (type.flags & 8 /* Number */) { return ts.createNumericLiteral("0"); } - else if (type.flags & 8 /* Boolean */) { + else if (type.flags & 16 /* Boolean */) { return ts.createFalse(); } else if (type.isLiteral()) { @@ -103204,78 +103866,99 @@ var ts; (function (ts) { var moduleSpecifiers; (function (moduleSpecifiers) { + // Note: fromSourceFile is just for usesJsExtensionOnImports + function getModuleSpecifier(program, fromSourceFile, fromSourceFileName, toFileName, host, preferences) { + var info = getInfo(program.getCompilerOptions(), fromSourceFile, fromSourceFileName, host); + var compilerOptions = program.getCompilerOptions(); + return getGlobalModuleSpecifier(toFileName, info, host, compilerOptions) || + ts.first(getLocalModuleSpecifiers(toFileName, info, compilerOptions, preferences)); + } + moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; // For each symlink/original for a module, returns a list of ways to import that file. function getModuleSpecifiers(moduleSymbol, program, importingSourceFile, host, preferences) { + var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); + if (ambient) + return [[ambient]]; var compilerOptions = program.getCompilerOptions(); - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; - var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); - var addJsExtension = usesJsExtensionOnImports(importingSourceFile); - var getCanonicalFileName = ts.hostGetCanonicalFileName(host); - var sourceDirectory = ts.getDirectoryPath(importingSourceFile.fileName); - return getAllModulePaths(program, moduleSymbol.valueDeclaration.getSourceFile()).map(function (moduleFileName) { - var global = tryGetModuleNameFromAmbientModule(moduleSymbol) - || tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) - || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) - || rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); - if (global) { - return [global]; - } - var relativePath = removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); - if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { - return [relativePath]; - } - var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName); - if (!relativeToBaseUrl) { - return [relativePath]; - } - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, moduleResolutionKind, addJsExtension); - if (paths) { - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - if (fromPaths) { - return [fromPaths]; - } - } - if (preferences.importModuleSpecifierPreference === "non-relative") { - return [importRelativeToBaseUrl]; - } - if (preferences.importModuleSpecifierPreference !== undefined) - ts.Debug.assertNever(preferences.importModuleSpecifierPreference); - if (isPathRelativeToParent(relativeToBaseUrl)) { - return [relativePath]; - } - /* - Prefer a relative import over a baseUrl import if it doesn't traverse up to baseUrl. - - Suppose we have: - baseUrl = /base - sourceDirectory = /base/a/b - moduleFileName = /base/foo/bar - Then: - relativePath = ../../foo/bar - getRelativePathNParents(relativePath) = 2 - pathFromSourceToBaseUrl = ../../ - getRelativePathNParents(pathFromSourceToBaseUrl) = 2 - 2 < 2 = false - In this case we should prefer using the baseUrl path "/a/b" instead of the relative path "../../foo/bar". - - Suppose we have: - baseUrl = /base - sourceDirectory = /base/foo/a - moduleFileName = /base/foo/bar - Then: - relativePath = ../a - getRelativePathNParents(relativePath) = 1 - pathFromSourceToBaseUrl = ../../ - getRelativePathNParents(pathFromSourceToBaseUrl) = 2 - 1 < 2 = true - In this case we should prefer using the relative path "../a" instead of the baseUrl path "foo/a". - */ - var pathFromSourceToBaseUrl = ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, baseUrl, getCanonicalFileName)); - var relativeFirst = getRelativePathNParents(relativePath) < getRelativePathNParents(pathFromSourceToBaseUrl); - return relativeFirst ? [relativePath, importRelativeToBaseUrl] : [importRelativeToBaseUrl, relativePath]; + var info = getInfo(compilerOptions, importingSourceFile, importingSourceFile.fileName, host); + var modulePaths = getAllModulePaths(program, moduleSymbol.valueDeclaration.getSourceFile()); + var global = ts.mapDefined(modulePaths, function (moduleFileName) { return getGlobalModuleSpecifier(moduleFileName, info, host, compilerOptions); }); + return global.length ? global.map(function (g) { return [g]; }) : modulePaths.map(function (moduleFileName) { + return getLocalModuleSpecifiers(moduleFileName, info, compilerOptions, preferences); }); } moduleSpecifiers.getModuleSpecifiers = getModuleSpecifiers; + // importingSourceFileName is separate because getEditsForFileRename may need to specify an updated path + function getInfo(compilerOptions, importingSourceFile, importingSourceFileName, host) { + var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions); + var addJsExtension = usesJsExtensionOnImports(importingSourceFile); + var getCanonicalFileName = ts.hostGetCanonicalFileName(host); + var sourceDirectory = ts.getDirectoryPath(importingSourceFileName); + return { moduleResolutionKind: moduleResolutionKind, addJsExtension: addJsExtension, getCanonicalFileName: getCanonicalFileName, sourceDirectory: sourceDirectory }; + } + function getGlobalModuleSpecifier(moduleFileName, _a, host, compilerOptions) { + var addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; + return tryGetModuleNameFromTypeRoots(compilerOptions, host, getCanonicalFileName, moduleFileName, addJsExtension) + || tryGetModuleNameAsNodeModule(compilerOptions, moduleFileName, host, getCanonicalFileName, sourceDirectory) + || compilerOptions.rootDirs && tryGetModuleNameFromRootDirs(compilerOptions.rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName); + } + function getLocalModuleSpecifiers(moduleFileName, _a, compilerOptions, preferences) { + var moduleResolutionKind = _a.moduleResolutionKind, addJsExtension = _a.addJsExtension, getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var relativePath = removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), moduleResolutionKind, addJsExtension); + if (!baseUrl || preferences.importModuleSpecifierPreference === "relative") { + return [relativePath]; + } + var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseUrl, getCanonicalFileName); + if (!relativeToBaseUrl) { + return [relativePath]; + } + var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, moduleResolutionKind, addJsExtension); + if (paths) { + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); + if (fromPaths) { + return [fromPaths]; + } + } + if (preferences.importModuleSpecifierPreference === "non-relative") { + return [importRelativeToBaseUrl]; + } + if (preferences.importModuleSpecifierPreference !== undefined) + ts.Debug.assertNever(preferences.importModuleSpecifierPreference); + if (isPathRelativeToParent(relativeToBaseUrl)) { + return [relativePath]; + } + /* + Prefer a relative import over a baseUrl import if it doesn't traverse up to baseUrl. + + Suppose we have: + baseUrl = /base + sourceDirectory = /base/a/b + moduleFileName = /base/foo/bar + Then: + relativePath = ../../foo/bar + getRelativePathNParents(relativePath) = 2 + pathFromSourceToBaseUrl = ../../ + getRelativePathNParents(pathFromSourceToBaseUrl) = 2 + 2 < 2 = false + In this case we should prefer using the baseUrl path "/a/b" instead of the relative path "../../foo/bar". + + Suppose we have: + baseUrl = /base + sourceDirectory = /base/foo/a + moduleFileName = /base/foo/bar + Then: + relativePath = ../a + getRelativePathNParents(relativePath) = 1 + pathFromSourceToBaseUrl = ../../ + getRelativePathNParents(pathFromSourceToBaseUrl) = 2 + 1 < 2 = true + In this case we should prefer using the relative path "../a" instead of the baseUrl path "foo/a". + */ + var pathFromSourceToBaseUrl = ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, baseUrl, getCanonicalFileName)); + var relativeFirst = getRelativePathNParents(relativePath) < getRelativePathNParents(pathFromSourceToBaseUrl); + return relativeFirst ? [relativePath, importRelativeToBaseUrl] : [importRelativeToBaseUrl, relativePath]; + } function usesJsExtensionOnImports(_a) { var imports = _a.imports; return ts.firstDefined(imports, function (_a) { @@ -103369,14 +104052,16 @@ var ts; // If the module could be imported by a directory name, use that directory's name var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); // Get a path that's relative to node_modules or the importing file's path - moduleSpecifier = getNodeResolvablePath(moduleSpecifier); + // if node_modules folder is in this folder or any of its parent folders, no need to keep it. + if (!ts.startsWith(sourceDirectory, moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex))) + return undefined; // If the module was found in @types, get the actual Node package name - return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier); + return ts.getPackageNameFromAtTypesDirectory(moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1)); function getDirectoryOrExtensionlessFileName(path) { // If the file is the main module, it can be imported by the package name var packageRootPath = path.substring(0, parts.packageRootIndex); var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - if (host.fileExists(packageJsonPath)) { + if (host.fileExists(packageJsonPath)) { // TODO: GH#18217 var packageJsonContent = JSON.parse(host.readFile(packageJsonPath)); if (packageJsonContent) { var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main; @@ -103396,16 +104081,6 @@ var ts; } return fullModulePathWithoutExtension; } - function getNodeResolvablePath(path) { - var basePath = path.substring(0, parts.topLevelNodeModulesIndex); - if (sourceDirectory.indexOf(basePath) === 0) { - // if node_modules folder is in this folder or any of its parent folders, no need to keep it. - return path.substring(parts.topLevelPackageNameIndex + 1); - } - else { - return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, path, getCanonicalFileName)); - } - } } function getNodeModulePathParts(fullPath) { // If fullPath can't be valid module file within node_modules, returns undefined. @@ -103461,7 +104136,7 @@ var ts; } function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) { return ts.firstDefined(rootDirs, function (rootDir) { - var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName); + var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName); // TODO: GH#18217 return isPathRelativeToParent(relativePath) ? undefined : relativePath; }); } @@ -103527,14 +104202,14 @@ var ts; var info = getInfo(sourceFile, start); if (!info) return undefined; - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info, context.preferences); }); return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_default_import, fixId, ts.Diagnostics.Convert_all_to_default_imports)]; }, fixIds: [fixId], getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { var info = getInfo(diag.file, diag.start); if (info) - doChange(changes, diag.file, info); + doChange(changes, diag.file, info, context.preferences); }); }, }); function getInfo(sourceFile, pos) { @@ -103550,8 +104225,8 @@ var ts; return { importNode: importNode, name: name, moduleSpecifier: importNode.moduleSpecifier }; } } - function doChange(changes, sourceFile, info) { - changes.replaceNode(sourceFile, info.importNode, ts.makeImport(info.name, /*namedImports*/ undefined, info.moduleSpecifier)); + function doChange(changes, sourceFile, info, preferences) { + changes.replaceNode(sourceFile, info.importNode, ts.makeImport(info.name, /*namedImports*/ undefined, info.moduleSpecifier, preferences)); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -103579,7 +104254,7 @@ var ts; function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); ts.Debug.assert(token.kind === 91 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 178 /* ImportType */); + ts.Debug.assert(token.parent.kind === 179 /* ImportType */); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -103590,6 +104265,187 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixIdAddMissingTypeof = "fixConvertToMappedObjectType"; + var fixId = fixIdAddMissingTypeof; + var errorCodes = [ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span; + var info = getInfo(sourceFile, span.start); + if (!info) + return undefined; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info); }); + var name = ts.idText(info.container.name); + return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Convert_0_to_mapped_object_type, name], fixId, [ts.Diagnostics.Convert_0_to_mapped_object_type, name])]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var info = getInfo(diag.file, diag.start); + if (info) + doChange(changes, diag.file, info); + }); } + }); + function getInfo(sourceFile, pos) { + var token = ts.getTokenAtPosition(sourceFile, pos, /*includeJsDocComment*/ false); + var indexSignature = ts.cast(token.parent.parent, ts.isIndexSignatureDeclaration); + if (ts.isClassDeclaration(indexSignature.parent)) + return undefined; + var container = ts.isInterfaceDeclaration(indexSignature.parent) ? indexSignature.parent : ts.cast(indexSignature.parent.parent, ts.isTypeAliasDeclaration); + return { indexSignature: indexSignature, container: container }; + } + function createTypeAliasFromInterface(declaration, type) { + return ts.createTypeAliasDeclaration(declaration.decorators, declaration.modifiers, declaration.name, declaration.typeParameters, type); + } + function doChange(changes, sourceFile, _a) { + var indexSignature = _a.indexSignature, container = _a.container; + var members = ts.isInterfaceDeclaration(container) ? container.members : container.type.members; + var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); + var parameter = ts.first(indexSignature.parameters); + var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(132 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var intersectionType = ts.createIntersectionTypeNode(ts.getAllSuperTypeNodes(container).concat([ + mappedIntersectionType + ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); + changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var refactor; + (function (refactor) { + var generateGetAccessorAndSetAccessor; + (function (generateGetAccessorAndSetAccessor) { + var refactorName = "Convert import"; + var actionNameNamespaceToNamed = "Convert namespace import to named imports"; + var actionNameNamedToNamespace = "Convert named imports to namespace import"; + refactor.registerRefactor(refactorName, { + getAvailableActions: function (context) { + var i = getImportToConvert(context); + if (!i) + return undefined; + var description = i.kind === 246 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 246 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; + }, + getEditsForAction: function (context, actionName) { + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + return { edits: edits, renameFilename: undefined, renameLocation: undefined }; + } + }); + // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`. + function getImportToConvert(context) { + var file = context.file; + var span = ts.getRefactorContextSpan(context); + var token = ts.getTokenAtPosition(file, span.start, /*includeJsDocComment*/ false); + var importDecl = ts.getParentNodeInSpan(token, file, span); + if (!importDecl || !ts.isImportDeclaration(importDecl)) + return undefined; + var importClause = importDecl.importClause; + return importClause && importClause.namedBindings; + } + function doChange(sourceFile, program, changes, toConvert) { + var checker = program.getTypeChecker(); + if (toConvert.kind === 246 /* NamespaceImport */) { + doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); + } + else { + doChangeNamedToNamespace(sourceFile, checker, changes, toConvert); + } + } + function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { + var usedAsNamespaceOrDefault = false; + var nodesToReplace = []; + var conflictingNames = ts.createMap(); + ts.FindAllReferences.Core.eachSymbolReferenceInFile(toConvert.name, checker, sourceFile, function (id) { + if (!ts.isPropertyAccessExpression(id.parent)) { + usedAsNamespaceOrDefault = true; + } + else { + var parent = ts.cast(id.parent, ts.isPropertyAccessExpression); + var exportName = parent.name.text; + if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { + conflictingNames.set(exportName, true); + } + ts.Debug.assert(parent.expression === id); + nodesToReplace.push(parent); + } + }); + // We may need to change `mod.x` to `_x` to avoid a name conflict. + var exportNameToImportName = ts.createMap(); + for (var _i = 0, nodesToReplace_1 = nodesToReplace; _i < nodesToReplace_1.length; _i++) { + var propertyAccess = nodesToReplace_1[_i]; + var exportName = propertyAccess.name.text; + var importName = exportNameToImportName.get(exportName); + if (importName === undefined) { + exportNameToImportName.set(exportName, importName = conflictingNames.has(exportName) ? ts.getUniqueName(exportName, sourceFile) : exportName); + } + changes.replaceNode(sourceFile, propertyAccess, ts.createIdentifier(importName)); + } + var importSpecifiers = []; + exportNameToImportName.forEach(function (name, propertyName) { + importSpecifiers.push(ts.createImportSpecifier(name === propertyName ? undefined : ts.createIdentifier(propertyName), ts.createIdentifier(name))); + }); + var importDecl = toConvert.parent.parent; + if (usedAsNamespaceOrDefault && !allowSyntheticDefaultImports) { + // Need to leave the namespace import alone + changes.insertNodeAfter(sourceFile, importDecl, updateImport(importDecl, /*defaultImportName*/ undefined, importSpecifiers)); + } + else { + changes.replaceNode(sourceFile, importDecl, updateImport(importDecl, usedAsNamespaceOrDefault ? ts.createIdentifier(toConvert.name.text) : undefined, importSpecifiers)); + } + } + function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) { + var importDecl = toConvert.parent.parent; + var moduleSpecifier = importDecl.moduleSpecifier; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 6 /* ESNext */) : "module"; + var namespaceNameConflicts = toConvert.elements.some(function (element) { + return ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { + return !!checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + }) || false; + }); + var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; + var neededNamedImports = []; + var _loop_22 = function (element) { + var propertyName = (element.propertyName || element.name).text; + ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { + var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); + if (ts.isShorthandPropertyAssignment(id.parent)) { + changes.replaceNode(sourceFile, id.parent, ts.createPropertyAssignment(id.text, access)); + } + else if (ts.isExportSpecifier(id.parent) && !id.parent.propertyName) { + if (!neededNamedImports.some(function (n) { return n.name === element.name; })) { + neededNamedImports.push(ts.createImportSpecifier(element.propertyName && ts.createIdentifier(element.propertyName.text), ts.createIdentifier(element.name.text))); + } + } + else { + changes.replaceNode(sourceFile, id, access); + } + }); + }; + for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { + var element = _a[_i]; + _loop_22(element); + } + changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); + if (neededNamedImports.length) { + changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, neededNamedImports)); + } + } + function updateImport(old, defaultImportName, elements) { + return ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImportName, elements && elements.length ? ts.createNamedImports(elements) : undefined), old.moduleSpecifier); + } + })(generateGetAccessorAndSetAccessor = refactor.generateGetAccessorAndSetAccessor || (refactor.generateGetAccessorAndSetAccessor = {})); + })(refactor = ts.refactor || (ts.refactor = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -103672,7 +104528,7 @@ var ts; /* Exported for tests */ function getEditsForAction(context, actionName) { var rangeToExtract = getRangeToExtract(context.file, ts.getRefactorContextSpan(context)); - var targetRange = rangeToExtract.targetRange; + var targetRange = rangeToExtract.targetRange; // TODO:GH#18217 var parsedFunctionIndexMatch = /^function_scope_(\d+)$/.exec(actionName); if (parsedFunctionIndexMatch) { var index = +parsedFunctionIndexMatch[1]; @@ -103743,9 +104599,9 @@ var ts; } // 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 start = getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); + var start = ts.getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); // Do the same for the ending position - var end = getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); + var end = ts.getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); 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. @@ -103764,7 +104620,8 @@ var ts; return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } var statements = []; - for (var _i = 0, _a = start.parent.statements; _i < _a.length; _i++) { + var start2 = start; // TODO: GH#18217 Need to alias `start` to get this to compile. See https://github.com/Microsoft/TypeScript/issues/19955#issuecomment-344118248 + for (var _i = 0, _a = start2.parent.statements; _i < _a.length; _i++) { var statement = _a[_i]; if (statement === start || statements.length) { var errors_1 = checkNode(statement); @@ -103797,7 +104654,7 @@ var ts; if (errors) { return { errors: errors }; } - return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; + return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, declarations: declarations } }; // TODO: GH#18217 /** * Attempt to refine the extraction node (generally, by shrinking it) to produce better results. * @param node The unrefined extraction node. @@ -103839,20 +104696,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 151 /* PropertyDeclaration */) { + if (current.kind === 152 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 148 /* Parameter */) { + else if (current.kind === 149 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 154 /* Constructor */) { + if (ctorOrMethod.kind === 155 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 153 /* MethodDeclaration */) { + else if (current.kind === 154 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -103895,8 +104752,11 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 231 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 232 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(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`! + // Also TODO: GH#19956 (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; } @@ -103904,15 +104764,15 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; case 97 /* 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 === 186 /* CallExpression */) { + if (node.parent.kind === 187 /* CallExpression */) { // Super constructor call - var containingClass_1 = ts.getContainingClass(node); + var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractSuper)); return true; @@ -103923,10 +104783,10 @@ var ts; } break; } - if (!node || ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { + if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -103938,20 +104798,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 216 /* IfStatement */: + case 217 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 229 /* TryStatement */: + case 230 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 212 /* Block */: - if (node.parent && node.parent.kind === 229 /* TryStatement */ && node.parent.finallyBlock === node) { + case 213 /* Block */: + if (node.parent && node.parent.kind === 230 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 265 /* CaseClause */: + case 266 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -103963,11 +104823,11 @@ var ts; break; } switch (node.kind) { - case 173 /* ThisType */: + case 174 /* ThisType */: case 99 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); @@ -103975,8 +104835,8 @@ var ts; seenLabels.pop(); break; } - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: { var label = node.label; if (label) { @@ -103986,20 +104846,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 223 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 224 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 196 /* AwaitExpression */: + case 197 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 202 /* YieldExpression */: + case 203 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -104053,7 +104913,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 === 148 /* Parameter */) { + if (current.kind === 149 /* 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; } @@ -104064,7 +104924,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 273 /* SourceFile */) { + if (current.kind === 274 /* SourceFile */) { return scopes; } } @@ -104073,7 +104933,7 @@ var ts; function getFunctionExtractionAtIndex(targetRange, context, requestedChangesIndex) { var _a = getPossibleExtractionsWorker(targetRange, context), scopes = _a.scopes, _b = _a.readsAndWrites, target = _b.target, usagesPerScope = _b.usagesPerScope, functionErrorsPerScope = _b.functionErrorsPerScope, exposedVariableDeclarations = _b.exposedVariableDeclarations; ts.Debug.assert(!functionErrorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?"); - context.cancellationToken.throwIfCancellationRequested(); + context.cancellationToken.throwIfCancellationRequested(); // TODO: GH#18217 return extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], exposedVariableDeclarations, targetRange, context); } function getConstantExtractionAtIndex(targetRange, context, requestedChangesIndex) { @@ -104154,32 +105014,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 154 /* Constructor */: + case 155 /* Constructor */: return "constructor"; - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: return "arrow function"; - case 153 /* MethodDeclaration */: + case 154 /* MethodDeclaration */: return "method '" + scope.name.getText(); - case 155 /* GetAccessor */: + case 156 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 156 /* SetAccessor */: + case 157 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 234 /* ClassDeclaration */ + return scope.kind === 235 /* 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 === 239 /* ModuleBlock */ + return scope.kind === 240 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -104197,7 +105057,7 @@ var ts; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted function var file = scope.getSourceFile(); - var functionNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newMethod" : "newFunction", file.text); + var functionNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newMethod" : "newFunction", file); var isJS = ts.isInJavaScriptFile(scope); var functionName = ts.createIdentifier(functionNameText); var returnType; @@ -104238,7 +105098,7 @@ var ts; // to avoid problems when there are literal types present if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); - returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); + returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); // TODO: GH#18217 } var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; ts.suppressLeadingAndTrailingTrivia(body); @@ -104306,7 +105166,8 @@ var ts; /*propertyName*/ undefined, /*name*/ ts.getSynthesizedDeepClone(variableDeclaration.name))); // Being returned through an object literal will have widened the type. - var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NoTruncation */); + var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), // TODO: GH#18217 + scope, 1 /* NoTruncation */); typeElements.push(ts.createPropertySignature( /*modifiers*/ undefined, /*name*/ variableDeclaration.symbol.name, @@ -104413,11 +105274,11 @@ var ts; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable var file = scope.getSourceFile(); - var localNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file.text); + var localNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file); var isJS = ts.isInJavaScriptFile(scope); var variableType = isJS || !checker.isContextSensitive(node) ? undefined - : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); + : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); @@ -104433,7 +105294,7 @@ var ts; /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); var localReference = ts.createPropertyAccess(rangeFacts & RangeFacts.InStaticRegion - ? ts.createIdentifier(scope.name.getText()) + ? ts.createIdentifier(scope.name.getText()) // TODO: GH#18217 : ts.createThis(), ts.createIdentifier(localNameText)); // Declare var maxInsertionPos = node.pos; @@ -104457,7 +105318,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 215 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 216 /* 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.createVariableStatement( @@ -104476,7 +105337,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 215 /* ExpressionStatement */) { + if (node.parent.kind === 216 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.deleteNode(context.file, node.parent, ts.textChanges.useNonAdjustedPositions); } @@ -104527,7 +105388,7 @@ var ts; function getCalledExpression(scope, range, functionNameText) { var functionReference = ts.createIdentifier(functionNameText); if (ts.isClassLike(scope)) { - var lhs = range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.text) : ts.createThis(); + var lhs = range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.text) : ts.createThis(); // TODO: GH#18217 return ts.createPropertyAccess(lhs, functionReference); } else { @@ -104563,7 +105424,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 224 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 225 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -104599,7 +105460,7 @@ var ts; } function getStatementsOrClassElements(scope) { if (ts.isFunctionLikeDeclaration(scope)) { - var body = scope.body; + var body = scope.body; // TODO: GH#18217 if (ts.isBlock(body)) { return body.statements; } @@ -104644,7 +105505,8 @@ var ts; } prevMember = member; } - ts.Debug.assert(prevMember !== undefined); // If the loop didn't return, then it did set prevMember. + if (prevMember === undefined) + return ts.Debug.fail(); // If the loop didn't return, then it did set prevMember. return prevMember; } function getNodeToInsertConstantBefore(node, scope) { @@ -104671,18 +105533,15 @@ var ts; return curr.parent.parent; } // There must be at least one statement since we started in one. - ts.Debug.assert(prevStatement !== undefined); - return prevStatement; - } - if (curr === scope) { - ts.Debug.fail("Didn't encounter a block-like before encountering scope"); - break; + return ts.Debug.assertDefined(prevStatement); } + ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } } function getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes) { var variableAssignments = ts.map(exposedVariableDeclarations, function (v) { return ts.createShorthandPropertyAssignment(v.symbol.name); }); var writeAssignments = ts.map(writes, function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + // TODO: GH#18217 `variableAssignments` not possibly undefined! return variableAssignments === undefined ? writeAssignments : writeAssignments === undefined @@ -104735,7 +105594,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (2048 /* Void */ | 16384 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (4096 /* Void */ | 32768 /* Never */)) { // TODO: GH#18217 expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -104743,7 +105602,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 233 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 234 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -104768,7 +105627,7 @@ var ts; // will use the contextual type of an expression as the return type of the extracted // method (and will therefore "use" all the types involved). if (inGenericContext && !isReadonlyArray(targetRange.range)) { - var contextualType = checker.getContextualType(targetRange.range); + var contextualType = checker.getContextualType(targetRange.range); // TODO: GH#18217 recordTypeParameterUsages(contextualType); } if (allTypeParameterUsages.size > 0) { @@ -104806,7 +105665,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_19 = function (i) { + var _loop_23 = 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 @@ -104846,7 +105705,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_19(i); + _loop_23(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -104868,7 +105727,7 @@ var ts; function collectUsages(node, valueUsage) { if (valueUsage === void 0) { valueUsage = 1 /* Read */; } if (inGenericContext) { - var type = checker.getTypeAtLocation(node); + var type = checker.getTypeAtLocation(node); // TODO: GH#18217 recordTypeParameterUsages(type); } if (ts.isDeclaration(node) && node.symbol) { @@ -105049,20 +105908,6 @@ var ts; : ts.createPropertyAccess(prefix, symbol.name); } } - function getParentNodeInSpan(node, file, span) { - if (!node) - return undefined; - while (node.parent) { - if (ts.isSourceFile(node.parent) || !spanContainsNode(span, node.parent, file)) { - return node; - } - node = node.parent; - } - } - function spanContainsNode(span, node, file) { - return ts.textSpanContainsPosition(span, node.getStart(file)) && - node.getEnd() <= ts.textSpanEnd(span); - } /** * Computes whether or not a node represents an expression in a position where it could * be extracted. @@ -105071,31 +105916,32 @@ var ts; * in the sense of something that you could extract on */ function isExtractableExpression(node) { - switch (node.parent.kind) { - case 272 /* EnumMember */: + var parent = node.parent; + switch (parent.kind) { + case 273 /* EnumMember */: return false; } switch (node.kind) { case 9 /* StringLiteral */: - return node.parent.kind !== 243 /* ImportDeclaration */ && - node.parent.kind !== 247 /* ImportSpecifier */; - case 203 /* SpreadElement */: - case 179 /* ObjectBindingPattern */: - case 181 /* BindingElement */: + return parent.kind !== 244 /* ImportDeclaration */ && + parent.kind !== 248 /* ImportSpecifier */; + case 204 /* SpreadElement */: + case 180 /* ObjectBindingPattern */: + case 182 /* BindingElement */: return false; case 71 /* Identifier */: - return node.parent.kind !== 181 /* BindingElement */ && - node.parent.kind !== 247 /* ImportSpecifier */ && - node.parent.kind !== 251 /* ExportSpecifier */; + return parent.kind !== 182 /* BindingElement */ && + parent.kind !== 248 /* ImportSpecifier */ && + parent.kind !== 252 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 212 /* Block */: - case 273 /* SourceFile */: - case 239 /* ModuleBlock */: - case 265 /* CaseClause */: + case 213 /* Block */: + case 274 /* SourceFile */: + case 240 /* ModuleBlock */: + case 266 /* CaseClause */: return true; default: return false; @@ -105172,7 +106018,7 @@ var ts; var renameLocation = renameLocationOffset + ts.getRenameLocation(edits, renameFilename, nameNeedRename.text, /*preferLastLocation*/ ts.isParameter(declaration)); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; } - function isConvertableName(name) { + function isConvertibleName(name) { return ts.isIdentifier(name) || ts.isStringLiteral(name); } function isAcceptedDeclaration(node) { @@ -105182,7 +106028,7 @@ var ts; return ts.isIdentifier(originalName) ? ts.createIdentifier(name) : ts.createLiteral(name); } function createAccessorAccessExpression(fieldName, isStatic, container) { - var leftHead = isStatic ? container.name : ts.createThis(); + var leftHead = isStatic ? container.name : ts.createThis(); // TODO: GH#18217 return ts.isIdentifier(fieldName) ? ts.createPropertyAccess(leftHead, fieldName) : ts.createElementAccess(leftHead, ts.createLiteral(fieldName)); } function getModifiers(isJS, isStatic, accessModifier) { @@ -105198,18 +106044,18 @@ var ts; var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; - if (!declaration || !ts.rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition) - || !isConvertableName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) + if (!declaration || !ts.rangeOverlapsWithStartEnd(declaration.name, startPosition, endPosition) // TODO: GH#18217 + || !isConvertibleName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) return undefined; var name = declaration.name.text; var startWithUnderscore = startsWithUnderscore(name); - var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file.text), declaration.name); - var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file.text) : name, declaration.name); + var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file), declaration.name); + var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file) : name, declaration.name); return { isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 148 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 149 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name, declaration: declaration, fieldName: fieldName, @@ -105220,7 +106066,8 @@ var ts; function generateGetAccessor(fieldName, accessorName, type, modifiers, isStatic, container) { return ts.createGetAccessor( /*decorators*/ undefined, modifiers, accessorName, - /*parameters*/ undefined, type, ts.createBlock([ + /*parameters*/ undefined, // TODO: GH#18217 + type, ts.createBlock([ ts.createReturn(createAccessorAccessExpression(fieldName, isStatic, container)) ], /*multiLine*/ true)); } @@ -105264,7 +106111,9 @@ var ts; if (!constructor.body) return; var file = context.file, program = context.program, cancellationToken = context.cancellationToken; - var referenceEntries = ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(originalName.parent.pos, originalName, program, [file], cancellationToken), function (entry) { return ((entry.type === "node" && ts.rangeContainsRange(constructor, entry.node) && ts.isIdentifier(entry.node) && ts.isWriteAccess(entry.node)) ? entry.node : undefined); }); + var referenceEntries = ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(originalName.parent.pos, originalName, program, [file], cancellationToken), function (entry) { + return (entry.type === "node" && ts.rangeContainsRange(constructor, entry.node) && ts.isIdentifier(entry.node) && ts.isWriteAccess(entry.node)) ? entry.node : undefined; + }); ts.forEach(referenceEntries, function (entry) { var parent = entry.parent; var accessorName = ts.createIdentifier(fieldName.text); @@ -105287,7 +106136,7 @@ var ts; var refactorName = "Move to a new file"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { - if (!context.preferences.allowTextChangesInNewFiles || getFirstAndLastStatementToMove(context) === undefined) + if (!context.preferences.allowTextChangesInNewFiles || getStatementsToMove(context) === undefined) return undefined; var description = ts.getLocaleSpecificMessage(ts.Diagnostics.Move_to_a_new_file); return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; @@ -105295,27 +106144,34 @@ var ts; getEditsForAction: function (context, actionName) { ts.Debug.assert(actionName === refactorName); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); - function getFirstAndLastStatementToMove(context) { + function getRangeToMove(context) { var file = context.file; var range = ts.createTextRangeFromSpan(ts.getRefactorContextSpan(context)); var statements = file.statements; var startNodeIndex = ts.findIndex(statements, function (s) { return s.end > range.pos; }); if (startNodeIndex === -1) return undefined; + var startStatement = statements[startNodeIndex]; + if (ts.isNamedDeclaration(startStatement) && startStatement.name && ts.rangeContainsRange(startStatement.name, range)) { + return { toMove: [statements[startNodeIndex]], afterLast: statements[startNodeIndex + 1] }; + } // Can't only partially include the start node or be partially into the next node - if (range.pos > statements[startNodeIndex].getStart(file)) + if (range.pos > startStatement.getStart(file)) return undefined; var afterEndNodeIndex = ts.findIndex(statements, function (s) { return s.end > range.end; }, startNodeIndex); // Can't be partially into the next node if (afterEndNodeIndex !== -1 && (afterEndNodeIndex === 0 || statements[afterEndNodeIndex].getStart(file) < range.end)) return undefined; - return { first: startNodeIndex, afterLast: afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex }; + return { + toMove: statements.slice(startNodeIndex, afterEndNodeIndex === -1 ? statements.length : afterEndNodeIndex), + afterLast: afterEndNodeIndex === -1 ? undefined : statements[afterEndNodeIndex], + }; } - function doChange(oldFile, program, toMove, changes, host) { + function doChange(oldFile, program, toMove, changes, host, preferences) { var checker = program.getTypeChecker(); var usage = getUsageInfo(oldFile, toMove.all, checker); var currentDirectory = ts.getDirectoryPath(oldFile.fileName); @@ -105323,31 +106179,32 @@ var ts; var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host); var newFileNameWithExtension = newModuleName + extension; // If previous file was global, this is easy. - changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatements(oldFile, usage, changes, toMove, program, newModuleName)); + changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences)); addNewFileToTsconfig(program, changes, oldFile.fileName, newFileNameWithExtension, ts.hostGetCanonicalFileName(host)); } // Filters imports out of the range of statements to move. Imports will be copied to the new file anyway, and may still be needed in the old file. function getStatementsToMove(context) { - var statements = context.file.statements; - var _a = getFirstAndLastStatementToMove(context), first = _a.first, afterLast = _a.afterLast; + var rangeToMove = getRangeToMove(context); + if (rangeToMove === undefined) + return undefined; var all = []; var ranges = []; - var rangeToMove = statements.slice(first, afterLast); - ts.getRangesWhere(rangeToMove, function (s) { return !isPureImport(s); }, function (start, afterEnd) { - for (var i = start; i < afterEnd; i++) - all.push(rangeToMove[i]); - ranges.push({ first: rangeToMove[start], last: rangeToMove[afterEnd - 1] }); + var toMove = rangeToMove.toMove, afterLast = rangeToMove.afterLast; + ts.getRangesWhere(toMove, function (s) { return !isPureImport(s); }, function (start, afterEndIndex) { + for (var i = start; i < afterEndIndex; i++) + all.push(toMove[i]); + ranges.push({ first: toMove[start], afterLast: afterLast }); }); - return { all: all, ranges: ranges }; + return all.length === 0 ? undefined : { all: all, ranges: ranges }; } function isPureImport(node) { switch (node.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: return true; - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 213 /* VariableStatement */: - return node.declarationList.declarations.every(function (d) { return d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); + case 214 /* VariableStatement */: + return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; } @@ -105366,26 +106223,26 @@ var ts; changes.insertNodeInListAfter(cfg, ts.last(filesProp.initializer.elements), ts.createLiteral(newFilePath), filesProp.initializer.elements); } } - function getNewStatements(oldFile, usage, changes, toMove, program, newModuleName) { + function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences) { var checker = program.getTypeChecker(); if (!oldFile.externalModuleIndicator && !oldFile.commonJsModuleIndicator) { deleteMovedStatements(oldFile, toMove.ranges, changes); return toMove.all; } var useEs6ModuleSyntax = !!oldFile.externalModuleIndicator; - var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax); + var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax, preferences); if (importsFromNewFile) { changes.insertNodeBefore(oldFile, oldFile.statements[0], importsFromNewFile, /*blankLineBetween*/ true); } deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); deleteMovedStatements(oldFile, toMove.ranges, changes); updateImportsInOtherFiles(changes, program, oldFile, usage.movedSymbols, newModuleName); - return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); + return getNewFileImportsAndAddExportInOldFile(oldFile, usage.oldImportsNeededByNewFile, usage.newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, preferences).concat(addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEs6ModuleSyntax)); } function deleteMovedStatements(sourceFile, moved, changes) { for (var _i = 0, moved_1 = moved; _i < moved_1.length; _i++) { - var _a = moved_1[_i], first_1 = _a.first, last_3 = _a.last; - changes.deleteNodeRange(sourceFile, first_1, last_3); + var _a = moved_1[_i], first_1 = _a.first, afterLast = _a.afterLast; + changes.deleteNodeRangeExcludingEnd(sourceFile, first_1, afterLast); } } function deleteUnusedOldImports(oldFile, toMove, changes, toDelete, checker) { @@ -105398,15 +106255,17 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_20 = function (sourceFile) { + var _loop_24 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_21 = function (statement) { + var _loop_25 = function (statement) { forEachImportInStatement(statement, function (importNode) { + if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) + return; var shouldMove = function (name) { var symbol = ts.isBindingElement(name.parent) ? ts.getPropertySymbolFromBindingElement(checker, name.parent) - : ts.skipAlias(checker.getSymbolAtLocation(name), checker); + : ts.skipAlias(checker.getSymbolAtLocation(name), checker); // TODO: GH#18217 return !!symbol && movedSymbols.has(symbol); }; deleteUnusedImports(sourceFile, importNode, changes, shouldMove); // These will be changed to imports from the new file @@ -105414,21 +106273,73 @@ var ts; var newImportDeclaration = filterImport(importNode, ts.createLiteral(newModuleSpecifier), shouldMove); if (newImportDeclaration) changes.insertNodeAfter(sourceFile, statement, newImportDeclaration); + var ns = getNamespaceLikeImport(importNode); + if (ns) + updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, ns, importNode); }); }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_21(statement); + _loop_25(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_20(sourceFile); + _loop_24(sourceFile); + } + } + function getNamespaceLikeImport(node) { + switch (node.kind) { + case 244 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 246 /* NamespaceImport */ ? + node.importClause.namedBindings.name : undefined; + case 243 /* ImportEqualsDeclaration */: + return node.name; + case 232 /* VariableDeclaration */: + return ts.tryCast(node.name, ts.isIdentifier); + default: + return ts.Debug.assertNever(node); + } + } + function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { + var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 6 /* ESNext */); + var needUniqueName = false; + var toChange = []; + ts.FindAllReferences.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, function (ref) { + if (!ts.isPropertyAccessExpression(ref.parent)) + return; + needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* All */, /*excludeGlobals*/ true); + if (movedSymbols.has(checker.getSymbolAtLocation(ref.parent.name))) { + toChange.push(ref); + } + }); + if (toChange.length) { + var newNamespaceName = needUniqueName ? ts.getUniqueName(preferredNewNamespaceName, sourceFile) : preferredNewNamespaceName; + for (var _i = 0, toChange_1 = toChange; _i < toChange_1.length; _i++) { + var ref = toChange_1[_i]; + changes.replaceNode(sourceFile, ref, ts.createIdentifier(newNamespaceName)); + } + changes.insertNodeAfter(sourceFile, oldImportNode, updateNamespaceLikeImportNode(oldImportNode, newModuleName, newModuleSpecifier)); + } + } + function updateNamespaceLikeImportNode(node, newNamespaceName, newModuleSpecifier) { + var newNamespaceId = ts.createIdentifier(newNamespaceName); + var newModuleString = ts.createLiteral(newModuleSpecifier); + switch (node.kind) { + case 244 /* ImportDeclaration */: + return ts.createImportDeclaration( + /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); + case 243 /* ImportEqualsDeclaration */: + return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); + case 232 /* VariableDeclaration */: + return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); + default: + return ts.Debug.assertNever(node); } } function moduleSpecifierFromImport(i) { - return (i.kind === 243 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 242 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 244 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 243 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -105450,24 +106361,24 @@ var ts; } } } - function createOldFileImportsFromNewFile(newFileNeedExport, newFileNameWithExtension, useEs6Imports) { + function createOldFileImportsFromNewFile(newFileNeedExport, newFileNameWithExtension, useEs6Imports, preferences) { var defaultImport; var imports = []; newFileNeedExport.forEach(function (symbol) { if (symbol.escapedName === "default" /* Default */) { - defaultImport = ts.createIdentifier(ts.symbolNameNoDefault(symbol)); + defaultImport = ts.createIdentifier(ts.symbolNameNoDefault(symbol)); // TODO: GH#18217 } else { imports.push(symbol.name); } }); - return makeImportOrRequire(defaultImport, imports, newFileNameWithExtension, useEs6Imports); + return makeImportOrRequire(defaultImport, imports, newFileNameWithExtension, useEs6Imports, preferences); } - function makeImportOrRequire(defaultImport, imports, path, useEs6Imports) { + function makeImportOrRequire(defaultImport, imports, path, useEs6Imports, preferences) { path = ts.ensurePathIsNonModuleName(path); if (useEs6Imports) { var specifiers = imports.map(function (i) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(i)); }); - return ts.makeImportIfNecessary(defaultImport, specifiers, path); + return ts.makeImportIfNecessary(defaultImport, specifiers, path, preferences); } else { ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. @@ -105498,15 +106409,15 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.deleteNode(sourceFile, importDecl); } break; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: @@ -105519,7 +106430,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 245 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 246 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.deleteNode(sourceFile, importDecl); } @@ -105531,7 +106442,7 @@ var ts; if (namedBindingsUnused) { changes.deleteNode(sourceFile, namedBindings); } - else if (namedBindings.kind === 246 /* NamedImports */) { + else if (namedBindings.kind === 247 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -105549,9 +106460,9 @@ var ts; changes.deleteNode(sourceFile, name); } break; - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: break; - case 179 /* ObjectBindingPattern */: + case 180 /* ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.deleteNode(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -105566,7 +106477,7 @@ var ts; break; } } - function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax) { + function getNewFileImportsAndAddExportInOldFile(oldFile, importsToCopy, newFileImportsFromOldFile, changes, checker, useEs6ModuleSyntax, preferences) { var copiedOldImports = []; for (var _i = 0, _a = oldFile.statements; _i < _a.length; _i++) { var oldStatement = _a[_i]; @@ -105598,7 +106509,7 @@ var ts; } } }); - ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEs6ModuleSyntax)); + ts.append(copiedOldImports, makeImportOrRequire(oldFileDefault, oldFileNamedImports, ts.removeFileExtension(ts.getBaseFileName(oldFile.fileName)), useEs6ModuleSyntax, preferences)); return copiedOldImports; } function makeUniqueModuleName(moduleName, extension, inDirectory, host) { @@ -105606,7 +106517,7 @@ var ts; for (var i = 1;; i++) { var name = ts.combinePaths(inDirectory, newModuleName + extension); if (!host.fileExists(name)) - return newModuleName; + return newModuleName; // TODO: GH#18217 newModuleName = moduleName + "." + i; } } @@ -105633,7 +106544,7 @@ var ts; if (isInImport(decl)) { oldImportsNeededByNewFile.add(symbol); } - else if (isTopLevelDeclaration(decl) && !movedSymbols.has(symbol)) { + else if (isTopLevelDeclaration(decl) && sourceFileOfTopLevelDeclaration(decl) === oldFile && !movedSymbols.has(symbol)) { newFileImportsFromOldFile.add(symbol); } } @@ -105656,13 +106567,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 242 /* ImportEqualsDeclaration */: - case 247 /* ImportSpecifier */: - case 244 /* ImportClause */: + case 243 /* ImportEqualsDeclaration */: + case 248 /* ImportSpecifier */: + case 245 /* ImportClause */: return true; - case 231 /* VariableDeclaration */: + case 232 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 181 /* BindingElement */: + case 182 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -105674,7 +106585,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 243 /* ImportDeclaration */: { + case 244 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -105684,9 +106595,9 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 231 /* VariableDeclaration */: { + case 232 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } @@ -105695,7 +106606,7 @@ var ts; } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 245 /* NamespaceImport */) { + if (namedBindings.kind === 246 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -105707,9 +106618,9 @@ var ts; switch (name.kind) { case 71 /* Identifier */: return keep(name) ? name : undefined; - case 180 /* ArrayBindingPattern */: + case 181 /* ArrayBindingPattern */: return name; - case 179 /* ObjectBindingPattern */: { + case 180 /* 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.createObjectBindingPattern(newElements) : undefined; @@ -105755,7 +106666,10 @@ var ts; return SymbolSet; }()); function isTopLevelDeclaration(node) { - return isNonVariableTopLevelDeclaration(node) || ts.isVariableDeclaration(node) && ts.isSourceFile(node.parent.parent.parent); + return isNonVariableTopLevelDeclaration(node) && ts.isSourceFile(node.parent) || ts.isVariableDeclaration(node) && ts.isSourceFile(node.parent.parent.parent); + } + function sourceFileOfTopLevelDeclaration(node) { + return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { ts.Debug.assert(ts.isSourceFile(node.parent)); @@ -105763,13 +106677,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 235 /* InterfaceDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 243 /* ImportEqualsDeclaration */: return true; default: return false; @@ -105777,17 +106691,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 235 /* InterfaceDeclaration */: - case 242 /* ImportEqualsDeclaration */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 243 /* ImportEqualsDeclaration */: return cb(statement); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return ts.forEach(statement.declarationList.declarations, cb); - case 215 /* ExpressionStatement */: { + case 216 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getSpecialPropertyAssignmentKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -105796,7 +106710,7 @@ var ts; } } function nameOfTopLevelDeclaration(d) { - return d.kind === 215 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); + return d.kind === 216 /* ExpressionStatement */ ? d.expression.left.name : ts.tryCast(d.name, ts.isIdentifier); } function getTopLevelDeclarationStatement(d) { return ts.isVariableDeclaration(d) ? d.parent.parent : d; @@ -105828,23 +106742,23 @@ var ts; function addEs6Export(d) { var modifiers = ts.concatenate([ts.createModifier(84 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 233 /* FunctionDeclaration */: + case 234 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 236 /* TypeAliasDeclaration */: + case 237 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 235 /* InterfaceDeclaration */: + case 236 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: return ts.Debug.assertNever(d); @@ -105855,21 +106769,21 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 233 /* FunctionDeclaration */: - case 234 /* ClassDeclaration */: - return [decl.name.text]; - case 213 /* VariableStatement */: + case 234 /* FunctionDeclaration */: + case 235 /* ClassDeclaration */: + return [decl.name.text]; // TODO: GH#18217 + case 214 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 238 /* ModuleDeclaration */: - case 237 /* EnumDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 235 /* InterfaceDeclaration */: - case 242 /* ImportEqualsDeclaration */: - return undefined; - case 215 /* ExpressionStatement */: + case 239 /* ModuleDeclaration */: + case 238 /* EnumDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 243 /* ImportEqualsDeclaration */: + return ts.emptyArray; + case 216 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - ts.Debug.assertNever(decl); + return ts.Debug.assertNever(decl); } } /** Creates `exports.x = x;` */ @@ -106089,7 +107003,7 @@ var ts; var value = 0; for (; moreDigits; state.decodingIndex++) { if (createErrorIfCondition(state.decodingIndex >= state.encodedText.length, "Error in decoding base64VLQFormatDecode, past the mapping string")) { - return; + return undefined; // TODO: GH#18217 } // 6 digit number var currentByte = base64FormatDecode(state.encodedText.charAt(state.decodingIndex)); @@ -106139,7 +107053,7 @@ var ts; this.pos = pos; this.end = end; this.flags = 0 /* None */; - this.transformFlags = undefined; + this.transformFlags = undefined; // TODO: GH#18217 this.parent = undefined; this.kind = kind; } @@ -106201,8 +107115,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 277 /* FirstJSDocNode */ || kid.kind > 297 /* LastJSDocNode */; }); - return child.kind < 145 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 278 /* FirstJSDocNode */ || kid.kind > 298 /* LastJSDocNode */; }); + return child.kind < 146 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -106213,7 +107127,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 145 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 146 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -106271,7 +107185,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(298 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(299 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { @@ -106325,7 +107239,7 @@ var ts; return 0; }; TokenOrIdentifierObject.prototype.getChildAt = function () { - return undefined; + return undefined; // TODO: GH#18217 }; TokenOrIdentifierObject.prototype.getChildren = function () { return ts.emptyArray; @@ -106449,25 +107363,25 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 131072 /* Union */); + return !!(this.flags & 262144 /* Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 262144 /* Intersection */); + return !!(this.flags & 524288 /* Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 393216 /* UnionOrIntersection */); + return !!(this.flags & 786432 /* UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 224 /* Literal */); + return !!(this.flags & 448 /* Literal */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 32 /* StringLiteral */); + return !!(this.flags & 64 /* StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 64 /* NumberLiteral */); + return !!(this.flags & 128 /* NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 32768 /* TypeParameter */); + return !!(this.flags & 65536 /* TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); @@ -106517,9 +107431,9 @@ var ts; return ts.emptyArray; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); if (doc.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - for (var _i = 0, declarations_13 = declarations; _i < declarations_13.length; _i++) { - var declaration = declarations_13[_i]; - var inheritedDocs = findInheritedJSDocComments(declaration, declaration.symbol.name, checker); + for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { + var declaration = declarations_14[_i]; + var inheritedDocs = findInheritedJSDocComments(declaration, declaration.symbol.name, checker); // TODO: GH#18217 // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc); @@ -106604,10 +107518,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 233 /* FunctionDeclaration */: - case 191 /* FunctionExpression */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: + case 234 /* FunctionDeclaration */: + case 192 /* FunctionExpression */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -106627,31 +107541,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 234 /* ClassDeclaration */: - case 204 /* ClassExpression */: - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: - case 237 /* EnumDeclaration */: - case 238 /* ModuleDeclaration */: - case 242 /* ImportEqualsDeclaration */: - case 251 /* ExportSpecifier */: - case 247 /* ImportSpecifier */: - case 244 /* ImportClause */: - case 245 /* NamespaceImport */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 165 /* TypeLiteral */: + case 235 /* ClassDeclaration */: + case 205 /* ClassExpression */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: + case 238 /* EnumDeclaration */: + case 239 /* ModuleDeclaration */: + case 243 /* ImportEqualsDeclaration */: + case 252 /* ExportSpecifier */: + case 248 /* ImportSpecifier */: + case 245 /* ImportClause */: + case 246 /* NamespaceImport */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 166 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 148 /* Parameter */: + case 149 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 231 /* VariableDeclaration */: - case 181 /* BindingElement */: { + case 232 /* VariableDeclaration */: + case 182 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -106662,19 +107576,19 @@ var ts; } } // falls through - case 272 /* EnumMember */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 273 /* EnumMember */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: addDeclaration(node); break; - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -106686,7 +107600,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 245 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 246 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -106695,7 +107609,7 @@ var ts; } } break; - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (ts.getSpecialPropertyAssignmentKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -106823,7 +107737,7 @@ var ts; }; HostCache.prototype.getOrCreateEntryByPath = function (fileName, path) { var info = this.getEntryByPath(path) || this.createEntry(fileName, path); - return ts.isString(info) ? undefined : info; + return ts.isString(info) ? undefined : info; // TODO: GH#18217 }; HostCache.prototype.getRootFileNames = function () { var names = []; @@ -106841,11 +107755,11 @@ var ts; }; HostCache.prototype.getVersion = function (path) { var file = this.getHostFileInformation(path); - return file && file.version; + return (file && file.version); // TODO: GH#18217 }; HostCache.prototype.getScriptSnapshot = function (path) { var file = this.getHostFileInformation(path); - return file && file.scriptSnapshot; + return (file && file.scriptSnapshot); // TODO: GH#18217 }; return HostCache; }()); @@ -106948,7 +107862,7 @@ var ts; this.cancellationToken = cancellationToken; } CancellationTokenObject.prototype.isCancellationRequested = function () { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + return !!this.cancellationToken && this.cancellationToken.isCancellationRequested(); }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { @@ -106998,7 +107912,7 @@ var ts; if (!host.fileExists || !host.readFile || !host.fileExists(path)) return; // And failing that, check the disk - var text = host.readFile(path); + var text = host.readFile(path); // TODO: GH#18217 var file = { text: text, lineMap: undefined, @@ -107056,7 +107970,7 @@ var ts; var typeRootsVersion = host.getTypeRootsVersion ? host.getTypeRootsVersion() : 0; if (lastTypesRootVersion !== typeRootsVersion) { log("TypeRoots version has changed; provide new program"); - program = undefined; + program = undefined; // TODO: GH#18217 lastTypesRootVersion = typeRootsVersion; } // Get a fresh cache of the host information @@ -107064,7 +107978,7 @@ var ts; var rootFileNames = hostCache.getRootFileNames(); var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; // If the program is already up-to-date, we can reuse it - if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (path) { return hostCache.getVersion(path); }, fileExists, hasInvalidatedResolution, host.hasChangedAutomaticTypeDirectiveNames)) { + if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (path) { return hostCache.getVersion(path); }, fileExists, hasInvalidatedResolution, !!host.hasChangedAutomaticTypeDirectiveNames)) { return; } // IMPORTANT - It is critical from this moment onward that we do not check @@ -107141,7 +108055,7 @@ var ts; var entry = hostCache.getEntryByPath(path); return entry ? !ts.isString(entry) : - (host.fileExists && host.fileExists(fileName)); + (!!host.fileExists && host.fileExists(fileName)); } // Release any files we have acquired in the old program but are // not part of the new program. @@ -107201,6 +108115,7 @@ var ts; return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } } + // TODO: GH#18217 frequently asserted as defined function getProgram() { if (syntaxOnly) { ts.Debug.assert(program === undefined); @@ -107210,14 +108125,14 @@ var ts; return program; } function cleanupSemanticCache() { - program = undefined; + program = undefined; // TODO: GH#18217 } function dispose() { if (program) { ts.forEach(program.getSourceFiles(), function (f) { return documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions()); }); - program = undefined; + program = undefined; // TODO: GH#18217 } host = undefined; } @@ -107245,7 +108160,7 @@ var ts; } function getSuggestionDiagnostics(fileName) { synchronizeHostData(); - return ts.computeSuggestionDiagnostics(getValidSourceFile(fileName), program); + return ts.computeSuggestionDiagnostics(getValidSourceFile(fileName), program, cancellationToken); } function getCompilerOptionsDiagnostics() { synchronizeHostData(); @@ -107261,7 +108176,8 @@ var ts; function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { if (preferences === void 0) { preferences = ts.defaultPreferences; } synchronizeHostData(); - return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, formattingOptions && ts.formatting.getFormatContext(formattingOptions), getCanonicalFileName, preferences, cancellationToken); + return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions)), // TODO: GH#18217 + getCanonicalFileName, preferences, cancellationToken); } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); @@ -107286,10 +108202,10 @@ var ts; return undefined; } // falls through - case 184 /* PropertyAccessExpression */: - case 145 /* QualifiedName */: + case 185 /* PropertyAccessExpression */: + case 146 /* QualifiedName */: case 99 /* ThisKeyword */: - case 173 /* ThisType */: + case 174 /* ThisType */: case 97 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type_4 = typeChecker.getTypeAtLocation(node); @@ -107330,7 +108246,7 @@ var ts; } function toLineColumnOffset(fileName, position) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); - var file = program.getSourceFile(path) || sourcemappedFileCache.get(path); + var file = program.getSourceFile(path) || sourcemappedFileCache.get(path); // TODO: GH#18217 return file.getLineAndCharacterOfPosition(position); } // Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M]) @@ -107397,7 +108313,7 @@ var ts; var location = possibleMapLocations_1[_i]; var mapPath = ts.toPath(location, ts.getDirectoryPath(fileName), getCanonicalFileName); if (host.fileExists(mapPath)) { - return convertDocumentToSourceMapper(file, host.readFile(mapPath), mapPath); + return convertDocumentToSourceMapper(file, host.readFile(mapPath), mapPath); // TODO: GH#18217 } } return file.sourceMapper = ts.sourcemaps.identitySourceMapper; @@ -107509,18 +108425,9 @@ var ts; function getReferences(fileName, position, options) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. - var sourceFiles = []; - if (options && options.isForRename) { - for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { - var sourceFile = _a[_i]; - if (!program.isSourceFileDefaultLibrary(sourceFile)) { - sourceFiles.push(sourceFile); - } - } - } - else { - sourceFiles = program.getSourceFiles().slice(); - } + var sourceFiles = options && options.isForRename + ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) + : program.getSourceFiles(); return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); } function findReferences(fileName, position) { @@ -107529,11 +108436,13 @@ var ts; } /// NavigateTo function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { + if (excludeDtsFiles === void 0) { excludeDtsFiles = false; } synchronizeHostData(); var sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); } function getEmitOutput(fileName, emitOnlyDtsFiles) { + if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); @@ -107552,31 +108461,28 @@ var ts; function getNonBoundSourceFile(fileName) { return syntaxTreeCache.getCurrentSourceFile(fileName); } - function getSourceFile(fileName) { - return getNonBoundSourceFile(fileName); - } function getNameOrDottedNameSpan(fileName, startPos, _endPos) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); // Get node at the location var node = ts.getTouchingPropertyName(sourceFile, startPos, /*includeJsDocComment*/ false); if (node === sourceFile) { - return; + return undefined; } switch (node.kind) { - case 184 /* PropertyAccessExpression */: - case 145 /* QualifiedName */: + case 185 /* PropertyAccessExpression */: + case 146 /* QualifiedName */: case 9 /* StringLiteral */: case 86 /* FalseKeyword */: case 101 /* TrueKeyword */: case 95 /* NullKeyword */: case 97 /* SuperKeyword */: case 99 /* ThisKeyword */: - case 173 /* ThisType */: + case 174 /* ThisType */: case 71 /* Identifier */: break; // Cant create the text span default: - return; + return undefined; } var nodeForStartPos = node; while (true) { @@ -107588,7 +108494,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 === 238 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 239 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -107725,8 +108631,9 @@ var ts; var formatContext = ts.formatting.getFormatContext(formatOptions); return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); } - function getEditsForFileRename(oldFilePath, newFilePath, formatOptions) { - return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions)); + function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { + if (preferences === void 0) { preferences = ts.defaultPreferences; } + return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions), preferences); } function applyCodeActionCommand(fileName, actionOrUndefined) { var action = typeof fileName === "string" ? actionOrUndefined : fileName; @@ -107739,7 +108646,7 @@ var ts; ? host.installPackage({ fileName: ts.toPath(action.file, currentDirectory, getCanonicalFileName), packageName: action.packageName }) : Promise.reject("Host does not implement `installPackage`"); default: - ts.Debug.fail(); + return ts.Debug.fail(); // TODO: Debug.assertNever(action); will only work if there is more than one type. } } @@ -107775,6 +108682,17 @@ var ts; } return true; } + function getJsxClosingTagAtPosition(fileName, position) { + var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + var token = ts.findPrecedingToken(position, sourceFile); + if (!token) + return undefined; + var element = token.kind === 29 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + : ts.isJsxText(token) ? token.parent : undefined; + if (element && !ts.tagNamesAreEquivalent(element.openingElement.tagName, element.closingElement.tagName)) { + return { newText: "" }; + } + } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position, onlyMultiLine); @@ -107830,7 +108748,8 @@ var ts; descriptor = descriptors[i]; } } - ts.Debug.assert(descriptor !== undefined); + if (descriptor === undefined) + return ts.Debug.fail(); // We don't want to match something like 'TODOBY', so we make sure a non // letter/digit follows the match. if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { @@ -107973,6 +108892,7 @@ var ts; getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition: getDocCommentTemplateAtPosition, isValidBraceCompletionAtPosition: isValidBraceCompletionAtPosition, + getJsxClosingTagAtPosition: getJsxClosingTagAtPosition, getSpanOfEnclosingComment: getSpanOfEnclosingComment, getCodeFixesAtPosition: getCodeFixesAtPosition, getCombinedCodeFix: getCombinedCodeFix, @@ -107981,7 +108901,6 @@ var ts; getEditsForFileRename: getEditsForFileRename, getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, - getSourceFile: getSourceFile, getProgram: getProgram, getApplicableRefactors: getApplicableRefactors, getEditsForRefactor: getEditsForRefactor, @@ -107995,7 +108914,7 @@ var ts; if (!sourceFile.nameTable) { initializeNameTable(sourceFile); } - return sourceFile.nameTable; + return sourceFile.nameTable; // TODO: GH#18217 } ts.getNameTable = getNameTable; function initializeNameTable(sourceFile) { @@ -108022,7 +108941,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 253 /* ExternalModuleReference */ || + node.parent.kind === 254 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -108034,13 +108953,13 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 146 /* ComputedPropertyName */) { + if (node.parent.kind === 147 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through case 71 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 183 /* ObjectLiteralExpression */ || node.parent.parent.kind === 262 /* JsxAttributes */) && + (node.parent.parent.kind === 184 /* ObjectLiteralExpression */ || node.parent.parent.kind === 263 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -108049,8 +108968,8 @@ var ts; /* @internal */ function getPropertySymbolsFromContextualType(typeChecker, node) { var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - return getPropertySymbolsFromType(contextualType, node.name); + var contextualType = typeChecker.getContextualType(objectLiteral); // TODO: GH#18217 + return getPropertySymbolsFromType(contextualType, node.name); // TODO: GH#18217 } ts.getPropertySymbolsFromContextualType = getPropertySymbolsFromContextualType; /* @internal */ @@ -108059,7 +108978,7 @@ var ts; if (name && type) { var result_7 = []; var symbol = type.getProperty(name); - if (type.flags & 131072 /* Union */) { + if (type.flags & 262144 /* Union */) { ts.forEach(type.types, function (t) { var symbol = t.getProperty(name); if (symbol) { @@ -108079,7 +108998,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 185 /* ElementAccessExpression */ && + node.parent.kind === 186 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -108118,11 +109037,12 @@ var ts; // let y = 10; // token at position will return let keyword on second line as the token but we would like to use // token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line - tokenAtLocation = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); + var preceding = ts.findPrecedingToken(tokenAtLocation.pos, sourceFile); // It's a blank line - if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) { + if (!preceding || sourceFile.getLineAndCharacterOfPosition(preceding.getEnd()).line !== lineOfPosition) { return undefined; } + tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations if (tokenAtLocation.flags & 4194304 /* Ambient */) { @@ -108156,115 +109076,116 @@ var ts; } function spanInNode(node) { if (node) { + var parent = node.parent; switch (node.kind) { - case 213 /* VariableStatement */: + case 214 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 231 /* VariableDeclaration */: - case 151 /* PropertyDeclaration */: - case 150 /* PropertySignature */: + case 232 /* VariableDeclaration */: + case 152 /* PropertyDeclaration */: + case 151 /* PropertySignature */: return spanInVariableDeclaration(node); - case 148 /* Parameter */: + case 149 /* Parameter */: return spanInParameterDeclaration(node); - case 233 /* FunctionDeclaration */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 154 /* Constructor */: - case 191 /* FunctionExpression */: - case 192 /* ArrowFunction */: + case 234 /* FunctionDeclaration */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 155 /* Constructor */: + case 192 /* FunctionExpression */: + case 193 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 212 /* Block */: + case 213 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 239 /* ModuleBlock */: + case 240 /* ModuleBlock */: return spanInBlock(node); - case 268 /* CatchClause */: + case 269 /* CatchClause */: return spanInBlock(node.block); - case 215 /* ExpressionStatement */: + case 216 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 224 /* ReturnStatement */: + case 225 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 218 /* WhileStatement */: + case 219 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 217 /* DoStatement */: + case 218 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 230 /* DebuggerStatement */: + case 231 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 216 /* IfStatement */: + case 217 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 227 /* LabeledStatement */: + case 228 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 223 /* BreakStatement */: - case 222 /* ContinueStatement */: + case 224 /* BreakStatement */: + case 223 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 219 /* ForStatement */: + case 220 /* ForStatement */: return spanInForStatement(node); - case 220 /* ForInStatement */: + case 221 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 221 /* ForOfStatement */: + case 222 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 226 /* SwitchStatement */: + case 227 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 265 /* CaseClause */: - case 266 /* DefaultClause */: + case 266 /* CaseClause */: + case 267 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 229 /* TryStatement */: + case 230 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 228 /* ThrowStatement */: + case 229 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 248 /* ExportAssignment */: + case 249 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 242 /* ImportEqualsDeclaration */: + case 243 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 243 /* ImportDeclaration */: + case 244 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 249 /* ExportDeclaration */: + case 250 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 234 /* ClassDeclaration */: - case 237 /* EnumDeclaration */: - case 272 /* EnumMember */: - case 181 /* BindingElement */: + case 235 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 273 /* EnumMember */: + case 182 /* BindingElement */: // span on complete node return textSpan(node); - case 225 /* WithStatement */: + case 226 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 149 /* Decorator */: - return spanInNodeArray(node.parent.decorators); - case 179 /* ObjectBindingPattern */: - case 180 /* ArrayBindingPattern */: + case 150 /* Decorator */: + return spanInNodeArray(parent.decorators); + case 180 /* ObjectBindingPattern */: + case 181 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 235 /* InterfaceDeclaration */: - case 236 /* TypeAliasDeclaration */: + case 236 /* InterfaceDeclaration */: + case 237 /* TypeAliasDeclaration */: return undefined; // Tokens: case 25 /* SemicolonToken */: @@ -108294,7 +109215,7 @@ var ts; case 74 /* CatchKeyword */: case 87 /* FinallyKeyword */: return spanInNextNode(node); - case 144 /* OfKeyword */: + case 145 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -108307,13 +109228,13 @@ var ts; // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern if ((node.kind === 71 /* Identifier */ || - node.kind === 203 /* SpreadElement */ || - node.kind === 269 /* PropertyAssignment */ || - node.kind === 270 /* ShorthandPropertyAssignment */) && - ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + node.kind === 204 /* SpreadElement */ || + node.kind === 270 /* PropertyAssignment */ || + node.kind === 271 /* ShorthandPropertyAssignment */) && + ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 199 /* BinaryExpression */) { + if (node.kind === 200 /* 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 @@ -108334,23 +109255,23 @@ var ts; } } if (ts.isExpressionNode(node)) { - switch (node.parent.kind) { - case 217 /* DoStatement */: + switch (parent.kind) { + case 218 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 149 /* Decorator */: + case 150 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 219 /* ForStatement */: - case 221 /* ForOfStatement */: + case 220 /* ForStatement */: + case 222 /* ForOfStatement */: return textSpan(node); - case 199 /* BinaryExpression */: + case 200 /* BinaryExpression */: if (node.parent.operatorToken.kind === 26 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 192 /* ArrowFunction */: + case 193 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -108359,21 +109280,21 @@ var ts; } } switch (node.parent.kind) { - case 269 /* PropertyAssignment */: + case 270 /* 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 189 /* TypeAssertionExpression */: + case 190 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 231 /* VariableDeclaration */: - case 148 /* Parameter */: { + case 232 /* VariableDeclaration */: + case 149 /* 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)) { @@ -108381,7 +109302,7 @@ var ts; } break; } - case 199 /* BinaryExpression */: { + case 200 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -108411,9 +109332,10 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 220 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 221 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } + var parent = variableDeclaration.parent; // If this is a destructuring pattern, set breakpoint in binding pattern if (ts.isBindingPattern(variableDeclaration.name)) { return spanInBindingPattern(variableDeclaration.name); @@ -108422,7 +109344,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 221 /* ForOfStatement */) { + parent.parent.kind === 222 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -108463,7 +109385,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 234 /* ClassDeclaration */ && functionDeclaration.kind !== 154 /* Constructor */); + (functionDeclaration.parent.kind === 235 /* ClassDeclaration */ && functionDeclaration.kind !== 155 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -108486,26 +109408,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 238 /* ModuleDeclaration */: + case 239 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // falls through // Set on parent if on same line otherwise on first statement - case 218 /* WhileStatement */: - case 216 /* IfStatement */: - case 220 /* ForInStatement */: + case 219 /* WhileStatement */: + case 217 /* IfStatement */: + case 221 /* 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 219 /* ForStatement */: - case 221 /* ForOfStatement */: + case 220 /* ForStatement */: + case 222 /* 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 === 232 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 233 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -108530,21 +109452,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 205 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 181 /* BindingElement */) { + if (bindingPattern.parent.kind === 182 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 180 /* ArrayBindingPattern */ && node.kind !== 179 /* ObjectBindingPattern */); - var elements = node.kind === 182 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 205 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 181 /* ArrayBindingPattern */ && node.kind !== 180 /* ObjectBindingPattern */); + var elements = node.kind === 183 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 206 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -108552,18 +109474,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 === 199 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 200 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 237 /* EnumDeclaration */: + case 238 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 234 /* ClassDeclaration */: + case 235 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -108571,25 +109493,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 239 /* ModuleBlock */: + case 240 /* 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 237 /* EnumDeclaration */: - case 234 /* ClassDeclaration */: + case 238 /* EnumDeclaration */: + case 235 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 212 /* Block */: + case 213 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 268 /* CatchClause */: + case 269 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 240 /* CaseBlock */: + case 241 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -108597,7 +109519,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 179 /* ObjectBindingPattern */: + case 180 /* 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); @@ -108613,7 +109535,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 180 /* ArrayBindingPattern */: + case 181 /* 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); @@ -108628,12 +109550,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 217 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 186 /* CallExpression */ || - node.parent.kind === 187 /* NewExpression */) { + if (node.parent.kind === 218 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 187 /* CallExpression */ || + node.parent.kind === 188 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 190 /* ParenthesizedExpression */) { + if (node.parent.kind === 191 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -108642,21 +109564,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 191 /* FunctionExpression */: - case 233 /* FunctionDeclaration */: - case 192 /* ArrowFunction */: - case 153 /* MethodDeclaration */: - case 152 /* MethodSignature */: - case 155 /* GetAccessor */: - case 156 /* SetAccessor */: - case 154 /* Constructor */: - case 218 /* WhileStatement */: - case 217 /* DoStatement */: - case 219 /* ForStatement */: - case 221 /* ForOfStatement */: - case 186 /* CallExpression */: - case 187 /* NewExpression */: - case 190 /* ParenthesizedExpression */: + case 192 /* FunctionExpression */: + case 234 /* FunctionDeclaration */: + case 193 /* ArrowFunction */: + case 154 /* MethodDeclaration */: + case 153 /* MethodSignature */: + case 156 /* GetAccessor */: + case 157 /* SetAccessor */: + case 155 /* Constructor */: + case 219 /* WhileStatement */: + case 218 /* DoStatement */: + case 220 /* ForStatement */: + case 222 /* ForOfStatement */: + case 187 /* CallExpression */: + case 188 /* NewExpression */: + case 191 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -108666,20 +109588,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 269 /* PropertyAssignment */ || - node.parent.kind === 148 /* Parameter */) { + node.parent.kind === 270 /* PropertyAssignment */ || + node.parent.kind === 149 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 189 /* TypeAssertionExpression */) { + if (node.parent.kind === 190 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 217 /* DoStatement */) { + if (node.parent.kind === 218 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -108687,7 +109609,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 221 /* ForOfStatement */) { + if (node.parent.kind === 222 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -108709,7 +109631,7 @@ var ts; */ function transform(source, transformers, compilerOptions) { var diagnostics = []; - compilerOptions = ts.fixupCompilerOptions(compilerOptions, diagnostics); + compilerOptions = ts.fixupCompilerOptions(compilerOptions, diagnostics); // TODO: GH#18217 var nodes = ts.isArray(source) ? source : [source]; var result = ts.transformNodes(/*resolver*/ undefined, /*emitHost*/ undefined, compilerOptions, nodes, transformers, /*allowDtsFiles*/ true); result.diagnostics = ts.concatenate(result.diagnostics, diagnostics); @@ -108758,16 +109680,16 @@ var ts; var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); if (encoded === null) { - return null; + return null; // TODO: GH#18217 } - var decoded = JSON.parse(encoded); + var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; ScriptSnapshotShimAdapter.prototype.dispose = function () { // if scriptSnapshotShim is a COM object then property check becomes method call with no arguments // 'in' does not have this effect if ("dispose" in this.scriptSnapshotShim) { - this.scriptSnapshotShim.dispose(); + this.scriptSnapshotShim.dispose(); // TODO: GH#18217 Can we just use `if (this.scriptSnapshotShim.dispose)`? } }; return ScriptSnapshotShimAdapter; @@ -108782,10 +109704,10 @@ var ts; // 'in' does not have this effect. if ("getModuleResolutionsForFile" in this.shimHost) { this.resolveModuleNames = function (moduleNames, containingFile) { - var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); + var resolutionsInFile = JSON.parse(_this.shimHost.getModuleResolutionsForFile(containingFile)); // TODO: GH#18217 return ts.map(moduleNames, function (name) { var result = ts.getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; + return result ? { resolvedFileName: result, extension: ts.extensionFromPath(result), isExternalLibraryImport: false } : undefined; // TODO: GH#18217 }); }; } @@ -108794,8 +109716,8 @@ var ts; } if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { this.resolveTypeReferenceDirectives = function (typeDirectiveNames, containingFile) { - var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); - return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); + var typeDirectivesForFile = JSON.parse(_this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); // TODO: GH#18217 + return ts.map(typeDirectiveNames, function (name) { return ts.getProperty(typeDirectivesForFile, name); }); // TODO: GH#18217 }; } } @@ -108815,7 +109737,7 @@ var ts; LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { if (!this.shimHost.getProjectVersion) { // shimmed host does not support getProjectVersion - return undefined; + return undefined; // TODO: GH#18217 } return this.shimHost.getProjectVersion(); }; @@ -108848,7 +109770,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getScriptKind = function (fileName) { if ("getScriptKind" in this.shimHost) { - return this.shimHost.getScriptKind(fileName); + return this.shimHost.getScriptKind(fileName); // TODO: GH#18217 } else { return 0 /* Unknown */; @@ -108884,7 +109806,7 @@ var ts; return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); }; LanguageServiceShimHostAdapter.prototype.readDirectory = function (path, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + var pattern = ts.getFileMatcherPatterns(path, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); // TODO: GH#18217 return JSON.parse(this.shimHost.readDirectory(path, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); }; LanguageServiceShimHostAdapter.prototype.readFile = function (path, encoding) { @@ -108905,11 +109827,11 @@ var ts; this.directoryExists = function (directoryName) { return _this.shimHost.directoryExists(directoryName); }; } if ("realpath" in this.shimHost) { - this.realpath = function (path) { return _this.shimHost.realpath(path); }; + this.realpath = function (path) { return _this.shimHost.realpath(path); }; // TODO: GH#18217 } } CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extensions, exclude, include, depth) { - var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); + var pattern = ts.getFileMatcherPatterns(rootDir, exclude, include, this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); // TODO: GH#18217 return JSON.parse(this.shimHost.readDirectory(rootDir, JSON.stringify(extensions), JSON.stringify(pattern.basePaths), pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern, depth)); }; CoreServicesShimHostAdapter.prototype.fileExists = function (fileName) { @@ -108981,7 +109903,8 @@ var ts; start: diagnostic.start, length: diagnostic.length, category: ts.diagnosticCategoryName(diagnostic), - code: diagnostic.code + code: diagnostic.code, + reportsUnnecessary: diagnostic.reportsUnnecessary, }; } var LanguageServiceShimObject = /** @class */ (function (_super) { @@ -109287,10 +110210,12 @@ var ts; } ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { var _this = this; + if (syntacticClassifierAbsent === void 0) { syntacticClassifierAbsent = false; } return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); }; /// COLORIZATION ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { + if (classifyKeywordsInGenerics === void 0) { classifyKeywordsInGenerics = false; } var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); var result = ""; for (var _i = 0, _a = classification.entries; _i < _a.length; _i++) { diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index ab3cb0310f4..ba3e6d73daf 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -179,7 +179,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.versionMajorMinor = "2.9"; + ts.versionMajorMinor = "3.0"; ts.version = ts.versionMajorMinor + ".0-dev"; })(ts || (ts = {})); (function (ts) { @@ -310,6 +310,10 @@ var ts; return array ? array.length : 0; } ts.length = length; + function hasEntries(map) { + return !!map && !!map.size; + } + ts.hasEntries = hasEntries; function forEach(array, callback) { if (array) { for (var i = 0; i < array.length; i++) { @@ -450,7 +454,7 @@ var ts; return result; } } - Debug.fail(); + return Debug.fail(); } ts.findMap = findMap; function contains(array, value, equalityComparer) { @@ -980,15 +984,6 @@ var ts; return to; } ts.addRange = addRange; - function prependRange(to, from) { - if (from === undefined || from.length === 0) - return to; - if (to === undefined) - return from.slice(); - to.unshift.apply(to, from); - return to; - } - ts.prependRange = prependRange; function pushIfUnique(array, toAdd, equalityComparer) { if (contains(array, toAdd, equalityComparer)) { return false; @@ -1381,10 +1376,10 @@ var ts; if (value !== undefined && test(value)) return value; if (value && typeof value.kind === "number") { - Debug.fail("Invalid cast. The supplied " + Debug.showSyntaxKind(value) + " did not pass the test '" + Debug.getFunctionName(test) + "'."); + return Debug.fail("Invalid cast. The supplied " + Debug.showSyntaxKind(value) + " did not pass the test '" + Debug.getFunctionName(test) + "'."); } else { - Debug.fail("Invalid cast. The supplied value did not pass the test '" + Debug.getFunctionName(test) + "'."); + return Debug.fail("Invalid cast. The supplied value did not pass the test '" + Debug.getFunctionName(test) + "'."); } } ts.cast = cast; @@ -1464,7 +1459,7 @@ var ts; } ts.compose = compose; function formatStringFromArgs(text, args, baseIndex) { - baseIndex = baseIndex || 0; + if (baseIndex === void 0) { baseIndex = 0; } return text.replace(/{(\d+)}/g, function (_match, index) { return Debug.assertDefined(args[+index + baseIndex]); }); } ts.formatStringFromArgs = formatStringFromArgs; @@ -1701,7 +1696,9 @@ var ts; return compareValues(a ? 1 : 0, b ? 1 : 0); } ts.compareBooleans = compareBooleans; - function compareMessageText(text1, text2) { + function compareMessageText(t1, t2) { + var text1 = t1; + var text2 = t2; while (text1 && text2) { var string1 = isString(text1) ? text1 : text1.messageText; var string2 = isString(text2) ? text2 : text2.messageText; @@ -1735,6 +1732,14 @@ var ts; return moduleResolution; } ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; + function unreachableCodeIsError(options) { + return options.allowUnreachableCode === false; + } + ts.unreachableCodeIsError = unreachableCodeIsError; + function unusedLabelIsError(options) { + return options.allowUnusedLabels === false; + } + ts.unusedLabelIsError = unusedLabelIsError; function getAreDeclarationMapsEnabled(options) { return !!(options.declaration && options.declarationMap); } @@ -1753,7 +1758,7 @@ var ts; } ts.getEmitDeclarations = getEmitDeclarations; function getStrictOptionValue(compilerOptions, flag) { - return compilerOptions[flag] === undefined ? compilerOptions.strict : compilerOptions[flag]; + return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; } ts.getStrictOptionValue = getStrictOptionValue; function hasZeroOrOneAsteriskCharacter(str) { @@ -2131,6 +2136,23 @@ var ts; return startsWith(str, prefix) ? str.substr(prefix.length) : str; } ts.removePrefix = removePrefix; + function tryRemovePrefix(str, prefix) { + return startsWith(str, prefix) ? str.substring(prefix.length) : undefined; + } + ts.tryRemovePrefix = tryRemovePrefix; + function tryRemoveDirectoryPrefix(path, dirPath) { + var a = tryRemovePrefix(path, dirPath); + if (a === undefined) + return undefined; + switch (a.charCodeAt(0)) { + case 47: + case 92: + return a.slice(1); + default: + return undefined; + } + } + ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix; function endsWith(str, suffix) { var expectedPos = str.length - suffix.length; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; @@ -2140,6 +2162,10 @@ var ts; return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str; } ts.removeSuffix = removeSuffix; + function tryRemoveSuffix(str, suffix) { + return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : undefined; + } + ts.tryRemoveSuffix = tryRemoveSuffix; function stringContains(str, substring) { return str.indexOf(substring) !== -1; } @@ -2213,7 +2239,7 @@ var ts; var subpattern = ""; var hasWrittenComponent = false; var components = getNormalizedPathComponents(spec, basePath); - var lastComponent = lastOrUndefined(components); + var lastComponent = last(components); if (usage !== "exclude" && lastComponent === "**") { return undefined; } @@ -2279,14 +2305,17 @@ var ts; }; } ts.getFileMatcherPatterns = getFileMatcherPatterns; + function getRegexFromPattern(pattern, useCaseSensitiveFileNames) { + return new RegExp(pattern, useCaseSensitiveFileNames ? "" : "i"); + } + ts.getRegexFromPattern = getRegexFromPattern; function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries) { path = normalizePath(path); currentDirectory = normalizePath(currentDirectory); var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory); - var regexFlag = useCaseSensitiveFileNames ? "" : "i"; - var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return new RegExp(pattern, regexFlag); }); - var includeDirectoryRegex = patterns.includeDirectoryPattern && new RegExp(patterns.includeDirectoryPattern, regexFlag); - var excludeRegex = patterns.excludePattern && new RegExp(patterns.excludePattern, regexFlag); + var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return getRegexFromPattern(pattern, useCaseSensitiveFileNames); }); + var includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames); + var excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames); var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]]; for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; @@ -2404,11 +2433,11 @@ var ts; return scriptKind === 1 || scriptKind === 2; } function hasJavaScriptFileExtension(fileName) { - return forEach(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + return some(ts.supportedJavascriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); } ts.hasJavaScriptFileExtension = hasJavaScriptFileExtension; function hasTypeScriptFileExtension(fileName) { - return forEach(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); + return some(ts.supportedTypeScriptExtensions, function (extension) { return fileExtensionIs(fileName, extension); }); } ts.hasTypeScriptFileExtension = hasTypeScriptFileExtension; function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) { @@ -2582,7 +2611,8 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { - assert(value !== undefined && value !== null, message); + if (value === undefined || value === null) + return fail(message); return value; } Debug.assertDefined = assertDefined; @@ -2740,10 +2770,7 @@ var ts; ts.resolutionExtensionIsTypeScriptOrJson = resolutionExtensionIsTypeScriptOrJson; function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - if (ext !== undefined) { - return ext; - } - Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : Debug.fail("File " + path + " has unknown extension."); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -3292,6 +3319,7 @@ var ts; return watchDirectoryRecursively(directoryName, callback); } watchDirectory(directoryName, callback); + return undefined; }; } function createNonPollingWatchFile() { @@ -3522,6 +3550,7 @@ var ts; switch (entryKind) { case 0: return stat.isFile(); case 1: return stat.isDirectory(); + default: return false; } } catch (e) { @@ -3700,6 +3729,7 @@ var ts; The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), + Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), @@ -4151,6 +4181,7 @@ var ts; Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2568, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators_2568", "Type '{0}' is not an array type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators: diag(2569, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterati_2569", "Type '{0}' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators."), Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await: diag(2570, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_forget_to_use_await_2570", "Property '{0}' does not exist on type '{1}'. Did you forget to use 'await'?"), + Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."), JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -4204,7 +4235,7 @@ var ts; _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: diag(2692, ts.DiagnosticCategory.Error, "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible."), _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: diag(2693, ts.DiagnosticCategory.Error, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", "'{0}' only refers to a type, but is being used as a value here."), 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."), + 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."), 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."), @@ -4234,6 +4265,7 @@ var ts; Cannot_invoke_an_object_which_is_possibly_undefined: diag(2722, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_undefined_2722", "Cannot invoke an object which is possibly 'undefined'."), Cannot_invoke_an_object_which_is_possibly_null_or_undefined: diag(2723, ts.DiagnosticCategory.Error, "Cannot_invoke_an_object_which_is_possibly_null_or_undefined_2723", "Cannot invoke an object which is possibly 'null' or 'undefined'."), Module_0_has_no_exported_member_1_Did_you_mean_2: diag(2724, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_2_2724", "Module '{0}' has no exported member '{1}'. Did you mean '{2}'?"), + Class_name_cannot_be_Object_when_targeting_ES5_with_module_0: diag(2725, ts.DiagnosticCategory.Error, "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725", "Class name cannot be 'Object' when targeting ES5 with module {0}."), 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}'."), @@ -4532,6 +4564,7 @@ var ts; _0_is_declared_but_never_used: diag(6196, ts.DiagnosticCategory.Error, "_0_is_declared_but_never_used_6196", "'{0}' is declared but never used.", true), Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"), All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", true), + All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", true), 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"), Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), @@ -4559,7 +4592,7 @@ var ts; Function_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: diag(7024, ts.DiagnosticCategory.Error, "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", "Function 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."), Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: diag(7025, ts.DiagnosticCategory.Error, "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type."), JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: diag(7026, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists."), - Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected."), + Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected.", true), Unused_label: diag(7028, ts.DiagnosticCategory.Error, "Unused_label_7028", "Unused label.", true), Fallthrough_case_in_switch: diag(7029, ts.DiagnosticCategory.Error, "Fallthrough_case_in_switch_7029", "Fallthrough case in switch."), Not_all_code_paths_return_a_value: diag(7030, ts.DiagnosticCategory.Error, "Not_all_code_paths_return_a_value_7030", "Not all code paths return a value."), @@ -4640,6 +4673,7 @@ var ts; Implement_inherited_abstract_class: diag(90007, ts.DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"), Add_0_to_unresolved_variable: diag(90008, ts.DiagnosticCategory.Message, "Add_0_to_unresolved_variable_90008", "Add '{0}.' to unresolved variable"), Remove_destructuring: diag(90009, ts.DiagnosticCategory.Message, "Remove_destructuring_90009", "Remove destructuring"), + Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"), Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""), Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"), Add_0_to_existing_import_declaration_from_1: diag(90015, ts.DiagnosticCategory.Message, "Add_0_to_existing_import_declaration_from_1_90015", "Add '{0}' to existing import declaration from \"{1}\""), @@ -4709,6 +4743,9 @@ var ts; Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing 'typeof'"), Remove_unused_label: diag(95053, ts.DiagnosticCategory.Message, "Remove_unused_label_95053", "Remove unused label"), Remove_all_unused_labels: diag(95054, ts.DiagnosticCategory.Message, "Remove_all_unused_labels_95054", "Remove all unused labels"), + Convert_0_to_mapped_object_type: diag(95055, ts.DiagnosticCategory.Message, "Convert_0_to_mapped_object_type_95055", "Convert '{0}' to mapped object type"), + Convert_namespace_import_to_named_imports: diag(95056, ts.DiagnosticCategory.Message, "Convert_namespace_import_to_named_imports_95056", "Convert namespace import to named imports"), + Convert_named_imports_to_namespace_import: diag(95057, ts.DiagnosticCategory.Message, "Convert_named_imports_to_namespace_import_95057", "Convert named imports to namespace import"), }; })(ts || (ts = {})); var ts; @@ -4806,7 +4843,7 @@ var ts; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function packageIdIsEqual(a, b) { - return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; + return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; } function packageIdToString(_a) { var name = _a.name, subModuleName = _a.subModuleName, version = _a.version; @@ -4849,7 +4886,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 273) { + while (node && node.kind !== 274) { node = node.parent; } return node; @@ -4857,11 +4894,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 212: - case 240: - case 219: + case 213: + case 241: case 220: case 221: + case 222: return true; } return false; @@ -4897,9 +4934,8 @@ var ts; } } ts.getEndLinePosition = getEndLinePosition; - function isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) { - return !(hasGlobalName && hasGlobalName(name)) - && !currentSourceFile.identifiers.has(name); + function isFileLevelUniqueName(sourceFile, name, hasGlobalName) { + return !(hasGlobalName && hasGlobalName(name)) && !sourceFile.identifiers.has(name); } ts.isFileLevelUniqueName = isFileLevelUniqueName; function nodeIsMissing(node) { @@ -4913,6 +4949,19 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + function prependStatements(to, from) { + if (from === undefined || from.length === 0) + return to; + if (to === undefined) + return from.slice(); + var prologue = to.length && isPrologueDirective(to[0]) && to.shift(); + to.unshift.apply(to, from); + if (prologue) { + to.unshift(prologue); + } + return to; + } + ts.prependStatements = prependStatements; function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { if (text.charCodeAt(commentPos + 1) === 47 && commentPos + 2 < commentEnd && @@ -4942,7 +4991,7 @@ var ts; if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 298 && node._children.length > 0) { + if (node.kind === 299 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -4982,7 +5031,7 @@ var ts; ts.indexOfNode = indexOfNode; function getEmitFlags(node) { var emitNode = node.emitNode; - return emitNode && emitNode.flags; + return emitNode && emitNode.flags || 0; } ts.getEmitFlags = getEmitFlags; function getLiteralText(node, sourceFile) { @@ -5010,7 +5059,7 @@ var ts; case 12: return node.text; } - ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); } ts.getLiteralText = getLiteralText; function getTextOfConstantValue(value) { @@ -5036,7 +5085,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 231 && node.parent.kind === 268; + return node.kind === 232 && node.parent.kind === 269; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -5056,11 +5105,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node && node.kind === 238 && (!node.body); + return node && node.kind === 239 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 273 || - node.kind === 238 || + return node.kind === 274 || + node.kind === 239 || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -5074,9 +5123,9 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isModuleAugmentationExternal(node) { switch (node.parent.kind) { - case 273: + case 274: return ts.isExternalModule(node.parent); - case 239: + case 240: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -5088,51 +5137,51 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 273: - case 240: - case 268: - case 238: - case 219: + case 274: + case 241: + case 269: + case 239: case 220: case 221: - case 154: - case 153: + case 222: case 155: + case 154: case 156: - case 233: - case 191: + case 157: + case 234: case 192: + case 193: return true; - case 212: - return parentNode && !ts.isFunctionLike(parentNode); + case 213: + return !ts.isFunctionLike(parentNode); } return false; } ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 157: case 158: - case 152: case 159: - case 162: - case 163: - case 283: - case 234: - case 204: - case 235: - case 236: - case 295: - case 233: case 153: + case 160: + case 163: + case 164: + case 284: + case 235: + case 205: + case 236: + case 237: + case 296: + case 234: case 154: case 155: case 156: - case 191: + case 157: case 192: - case 291: - case 296: - case 287: + case 193: + case 292: + case 297: + case 288: return true; default: ts.assertTypeIsNever(node); @@ -5142,8 +5191,8 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isAnyImportSyntax(node) { switch (node.kind) { + case 244: case 243: - case 242: return true; default: return false; @@ -5152,15 +5201,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { + case 244: case 243: - case 242: - case 213: - case 234: - case 233: - case 238: - case 236: + case 214: case 235: + case 234: + case 239: case 237: + case 236: + case 238: return true; default: return false; @@ -5190,7 +5239,7 @@ var ts; case 9: case 8: return escapeLeadingUnderscores(name.text); - case 146: + case 147: return isStringOrNumericLiteral(name.expression) ? escapeLeadingUnderscores(name.expression.text) : undefined; default: ts.Debug.assertNever(name); @@ -5201,10 +5250,12 @@ var ts; switch (name.kind) { case 71: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 145: + case 146: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 184: + case 185: return entityNameToString(name.expression) + "." + entityNameToString(name.name); + default: + throw ts.Debug.assertNever(name); } } ts.entityNameToString = entityNameToString; @@ -5223,11 +5274,6 @@ var ts; return ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3); } ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile; - function createDiagnosticForNodeSpan(sourceFile, startNode, endNode, message, arg0, arg1, arg2, arg3) { - var start = ts.skipTrivia(sourceFile.text, startNode.pos); - return ts.createFileDiagnostic(sourceFile, start, endNode.end - start, message, arg0, arg1, arg2, arg3); - } - ts.createDiagnosticForNodeSpan = createDiagnosticForNodeSpan; function createDiagnosticForNodeFromMessageChain(node, messageChain) { var sourceFile = getSourceFileOfNode(node); var span = getErrorSpanForNode(sourceFile, node); @@ -5250,7 +5296,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 212) { + if (node.body && node.body.kind === 213) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -5262,31 +5308,31 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 273: + case 274: 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 231: - case 181: - case 234: - case 204: + case 232: + case 182: case 235: - case 238: - case 237: - case 272: - case 233: - case 191: - case 153: - case 155: - case 156: + case 205: case 236: + case 239: + case 238: + case 273: + case 234: + case 192: + case 154: + case 156: + case 157: + case 237: + case 152: case 151: - case 150: errorNode = node.name; break; - case 192: + case 193: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -5316,7 +5362,7 @@ var ts; } ts.isJsonSourceFile = isJsonSourceFile; function isConstEnumDeclaration(node) { - return node.kind === 237 && isConst(node); + return node.kind === 238 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -5329,21 +5375,21 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 186 && n.expression.kind === 97; + return n.kind === 187 && n.expression.kind === 97; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 186 && n.expression.kind === 91; + return n.kind === 187 && n.expression.kind === 91; } ts.isImportCall = isImportCall; function isLiteralImportTypeNode(n) { - return n.kind === 178 && - n.argument.kind === 177 && + return n.kind === 179 && + n.argument.kind === 178 && ts.isStringLiteral(n.argument.literal); } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 215 + return node.kind === 216 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -5352,11 +5398,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 148 || - node.kind === 147 || - node.kind === 191 || + var commentRanges = (node.kind === 149 || + node.kind === 148 || node.kind === 192 || - node.kind === 190) ? + node.kind === 193 || + node.kind === 191) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); return ts.filter(commentRanges, function (comment) { @@ -5371,11 +5417,12 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (160 <= node.kind && node.kind <= 178) { + if (161 <= node.kind && node.kind <= 179) { return true; } switch (node.kind) { case 119: + case 142: case 134: case 137: case 122: @@ -5384,63 +5431,64 @@ var ts; case 131: return true; case 105: - return node.parent.kind !== 195; - case 206: + return node.parent.kind !== 196; + case 207: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 147: - return node.parent.kind === 176 || node.parent.kind === 171; + case 148: + return node.parent.kind === 177 || node.parent.kind === 172; case 71: - if (node.parent.kind === 145 && node.parent.right === node) { + if (node.parent.kind === 146 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 184 && node.parent.name === node) { + else if (node.parent.kind === 185 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 71 || node.kind === 145 || node.kind === 184, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 145: - case 184: - case 99: + ts.Debug.assert(node.kind === 71 || node.kind === 146 || node.kind === 185, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 146: + case 185: + case 99: { var parent = node.parent; - if (parent.kind === 164) { + if (parent.kind === 165) { return false; } - if (parent.kind === 178) { + if (parent.kind === 179) { return !parent.isTypeOf; } - if (160 <= parent.kind && parent.kind <= 178) { + if (161 <= parent.kind && parent.kind <= 179) { return true; } switch (parent.kind) { - case 206: + case 207: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 147: - return node === parent.constraint; - case 151: - case 150: case 148: - case 231: + return node === parent.constraint; + case 152: + case 151: + case 149: + case 232: return node === parent.type; - case 233: - case 191: + case 234: case 192: + case 193: + case 155: case 154: case 153: - case 152: - case 155: case 156: - return node === parent.type; case 157: + return node === parent.type; case 158: case 159: + case 160: return node === parent.type; - case 189: + case 190: return node === parent.type; - case 186: case 187: - return ts.contains(parent.typeArguments, node); case 188: + return ts.contains(parent.typeArguments, node); + case 189: return false; } + } } return false; } @@ -5459,23 +5507,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224: + case 225: return visitor(node); - case 240: - case 212: - case 216: + case 241: + case 213: case 217: case 218: case 219: case 220: case 221: - case 225: + case 222: case 226: - case 265: - case 266: case 227: - case 229: - case 268: + case 266: + case 267: + case 228: + case 230: + case 269: return ts.forEachChild(node, traverse); } } @@ -5485,23 +5533,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 202: + case 203: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 237: - case 235: case 238: case 236: - case 234: - case 204: + case 239: + case 237: + case 235: + case 205: return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 146) { + if (node.name && node.name.kind === 147) { traverse(node.name.expression); return; } @@ -5514,10 +5562,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 166) { + if (node && node.kind === 167) { return node.elementType; } - else if (node && node.kind === 161) { + else if (node && node.kind === 162) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -5527,12 +5575,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { + case 236: case 235: - case 234: - case 204: - case 165: + case 205: + case 166: return node.members; - case 183: + case 184: return node.properties; } } @@ -5540,14 +5588,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 181: - case 272: - case 148: - case 269: - case 151: - case 150: + case 182: + case 273: + case 149: case 270: - case 231: + case 152: + case 151: + case 271: + case 232: return true; } } @@ -5559,8 +5607,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 232 - && node.parent.parent.kind === 213; + return node.parent.kind === 233 + && node.parent.parent.kind === 214; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -5571,13 +5619,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 153: - case 152: case 154: + case 153: case 155: case 156: - case 233: - case 191: + case 157: + case 234: + case 192: return true; } return false; @@ -5588,7 +5636,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 227) { + if (node.statement.kind !== 228) { return node.statement; } node = node.statement; @@ -5596,17 +5644,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 212 && ts.isFunctionLike(node.parent); + return node && node.kind === 213 && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 153 && node.parent.kind === 183; + return node && node.kind === 154 && node.parent.kind === 184; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 153 && - (node.parent.kind === 183 || - node.parent.kind === 204); + return node.kind === 154 && + (node.parent.kind === 184 || + node.parent.kind === 205); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -5618,31 +5666,35 @@ var ts; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { - return ts.filter(objectLiteral.properties, function (property) { - if (property.kind === 269) { + return objectLiteral.properties.filter(function (property) { + if (property.kind === 270) { var propName = getTextOfPropertyName(property.name); - return key === propName || (key2 && key2 === propName); + return key === propName || (!!key2 && key2 === propName); } + return false; }); } ts.getPropertyAssignment = getPropertyAssignment; function getTsConfigObjectLiteralExpression(tsConfigSourceFile) { if (tsConfigSourceFile && tsConfigSourceFile.statements.length) { var expression = tsConfigSourceFile.statements[0].expression; - return ts.isObjectLiteralExpression(expression) && expression; + return ts.tryCast(expression, ts.isObjectLiteralExpression); } } ts.getTsConfigObjectLiteralExpression = getTsConfigObjectLiteralExpression; function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) { - var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile); - return jsonObjectLiteral && - ts.firstDefined(getPropertyAssignment(jsonObjectLiteral, propKey), function (property) { - return ts.isArrayLiteralExpression(property.initializer) ? - ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) : - undefined; - }); + return ts.firstDefined(getTsConfigPropArray(tsConfigSourceFile, propKey), function (property) { + return ts.isArrayLiteralExpression(property.initializer) ? + ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) : + undefined; + }); } ts.getTsConfigPropArrayElementValue = getTsConfigPropArrayElementValue; + function getTsConfigPropArray(tsConfigSourceFile, propKey) { + var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile); + return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : ts.emptyArray; + } + ts.getTsConfigPropArray = getTsConfigPropArray; function getContainingFunction(node) { return ts.findAncestor(node.parent, ts.isFunctionLike); } @@ -5652,45 +5704,46 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { + ts.Debug.assert(node.kind !== 274); while (true) { node = node.parent; if (!node) { - return undefined; + return ts.Debug.fail(); } switch (node.kind) { - case 146: + case 147: if (ts.isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 149: - if (node.parent.kind === 148 && ts.isClassElement(node.parent.parent)) { + case 150: + if (node.parent.kind === 149 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { node = node.parent; } break; - case 192: + case 193: if (!includeArrowFunctions) { continue; } - case 233: - case 191: - case 238: - case 151: - case 150: - case 153: + case 234: + case 192: + case 239: case 152: + case 151: case 154: + case 153: case 155: case 156: case 157: case 158: case 159: - case 237: - case 273: + case 160: + case 238: + case 274: return node; } } @@ -5700,9 +5753,9 @@ var ts; var container = getThisContainer(node, false); if (container) { switch (container.kind) { - case 154: - case 233: - case 191: + case 155: + case 234: + case 192: return container; } } @@ -5716,25 +5769,25 @@ var ts; return node; } switch (node.kind) { - case 146: + case 147: node = node.parent; break; - case 233: - case 191: + case 234: case 192: + case 193: if (!stopOnFunctions) { continue; } - case 151: - case 150: - case 153: case 152: + case 151: case 154: + case 153: case 155: case 156: + case 157: return node; - case 149: - if (node.parent.kind === 148 && ts.isClassElement(node.parent.parent)) { + case 150: + if (node.parent.kind === 149 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { @@ -5746,14 +5799,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 191 || func.kind === 192) { + if (func.kind === 192 || func.kind === 193) { var prev = func; var parent = func.parent; - while (parent.kind === 190) { + while (parent.kind === 191) { prev = parent; parent = parent.parent; } - if (parent.kind === 186 && parent.expression === prev) { + if (parent.kind === 187 && parent.expression === prev) { return parent; } } @@ -5761,26 +5814,26 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 184 || kind === 185) + return (kind === 185 || kind === 186) && node.expression.kind === 97; } ts.isSuperProperty = isSuperProperty; function isThisProperty(node) { var kind = node.kind; - return (kind === 184 || kind === 185) + return (kind === 185 || kind === 186) && node.expression.kind === 99; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 161: + case 162: return node.typeName; - case 206: + case 207: return isEntityNameExpression(node.expression) ? node.expression : undefined; case 71: - case 145: + case 146: return node; } return undefined; @@ -5788,10 +5841,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 188: + case 189: return node.tag; + case 257: case 256: - case 255: return node.tagName; default: return node.expression; @@ -5800,21 +5853,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 234: + case 235: return true; - case 151: - return parent.kind === 234; - case 155: + case 152: + return parent.kind === 235; case 156: - case 153: + case 157: + case 154: return node.body !== undefined - && parent.kind === 234; - case 148: + && parent.kind === 235; + case 149: return parent.body !== undefined - && (parent.kind === 154 - || parent.kind === 153 - || parent.kind === 156) - && grandparent.kind === 234; + && (parent.kind === 155 + || parent.kind === 154 + || parent.kind === 157) + && grandparent.kind === 235; } return false; } @@ -5830,19 +5883,21 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 234: - return ts.forEach(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); - case 153: - case 156: - return ts.forEach(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); + case 235: + return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); + case 154: + case 157: + return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); + default: + return false; } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 256 || - parent.kind === 255 || - parent.kind === 257) { + if (parent.kind === 257 || + parent.kind === 256 || + parent.kind === 258) { return parent.tagName === node; } return false; @@ -5855,45 +5910,45 @@ var ts; case 101: case 86: case 12: - case 182: case 183: case 184: case 185: case 186: case 187: case 188: - case 207: case 189: case 208: case 190: + case 209: case 191: - case 204: case 192: - case 195: + case 205: case 193: + case 196: case 194: - case 197: + case 195: case 198: case 199: case 200: - case 203: case 201: - case 13: - case 205: - case 254: - case 255: - case 258: + case 204: case 202: - case 196: - case 209: + case 13: + case 206: + case 255: + case 256: + case 259: + case 203: + case 197: + case 210: return true; - case 145: - while (node.parent.kind === 145) { + case 146: + while (node.parent.kind === 146) { node = node.parent; } - return node.parent.kind === 164 || isJSXTagName(node); + return node.parent.kind === 165 || isJSXTagName(node); case 71: - if (node.parent.kind === 164 || isJSXTagName(node)) { + if (node.parent.kind === 165 || isJSXTagName(node)) { return true; } case 8: @@ -5908,47 +5963,47 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 231: - case 148: + case 232: + case 149: + case 152: case 151: - case 150: - case 272: - case 269: - case 181: + case 273: + case 270: + case 182: return parent.initializer === node; - case 215: case 216: case 217: case 218: - case 224: + case 219: case 225: case 226: - case 265: - case 228: + case 227: + case 266: + case 229: return parent.expression === node; - case 219: + case 220: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 232) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 233) || forStatement.condition === node || forStatement.incrementor === node; - case 220: case 221: + case 222: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 232) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 233) || forInStatement.expression === node; - case 189: - case 207: + case 190: + case 208: return node === parent.expression; - case 210: + case 211: return node === parent.expression; - case 146: + case 147: return node === parent.expression; - case 149: + case 150: + case 265: case 264: - case 263: - case 271: + case 272: return true; - case 206: + case 207: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: return isExpressionNode(parent); @@ -5956,7 +6011,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 242 && node.moduleReference.kind === 253; + return node.kind === 243 && node.moduleReference.kind === 254; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5965,7 +6020,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 242 && node.moduleReference.kind !== 253; + return node.kind === 243 && node.moduleReference.kind !== 254; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -5977,15 +6032,15 @@ var ts; } ts.isSourceFileNotJavaScript = isSourceFileNotJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 65536); + return !!node && !!(node.flags & 65536); } ts.isInJavaScriptFile = isInJavaScriptFile; function isInJsonFile(node) { - return node && !!(node.flags & 16777216); + return !!node && !!(node.flags & 16777216); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return node && !!(node.flags & 2097152); + return !!node && !!(node.flags & 2097152); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -5997,7 +6052,7 @@ var ts; } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 186) { + if (callExpression.kind !== 187) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; @@ -6019,22 +6074,48 @@ var ts; return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34; } ts.isStringDoubleQuoted = isStringDoubleQuoted; - function getJSInitializerSymbol(symbol) { - if (!symbol || !symbol.valueDeclaration) { - return symbol; + function getDeclarationOfJSInitializer(node) { + if (!isInJavaScriptFile(node) || !node.parent) { + return undefined; } - var declaration = symbol.valueDeclaration; - var e = getDeclaredJavascriptInitializer(declaration) || getAssignedJavascriptInitializer(declaration); - return e && e.symbol ? e.symbol : symbol; - } - ts.getJSInitializerSymbol = getJSInitializerSymbol; - function getDeclaredJavascriptInitializer(node) { - if (node && ts.isVariableDeclaration(node) && node.initializer) { - return getJavascriptInitializer(node.initializer, false) || - ts.isIdentifier(node.name) && getDefaultedJavascriptInitializer(node.name, node.initializer, false); + var name; + var decl; + if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) { + name = node.parent.name; + decl = node.parent; } + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 && node.parent.right === node) { + name = node.parent.left; + decl = name; + } + else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 54) { + if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { + name = node.parent.parent.name; + decl = node.parent.parent; + } + else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 58 && node.parent.parent.right === node.parent) { + name = node.parent.parent.left; + decl = name; + } + if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { + return undefined; + } + } + if (!name || !getJavascriptInitializer(node, isPrototypeAccess(name))) { + return undefined; + } + return decl; } - ts.getDeclaredJavascriptInitializer = getDeclaredJavascriptInitializer; + ts.getDeclarationOfJSInitializer = getDeclarationOfJSInitializer; + function getEffectiveInitializer(node) { + if (isInJavaScriptFile(node) && node.initializer && + ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 54 && + node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { + return node.initializer.right; + } + return node.initializer; + } + ts.getEffectiveInitializer = getEffectiveInitializer; function getAssignedJavascriptInitializer(node) { if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); @@ -6046,11 +6127,11 @@ var ts; function getJavascriptInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 191 || e.kind === 192 ? initializer : undefined; + return e.kind === 192 || e.kind === 193 ? initializer : undefined; } - if (initializer.kind === 191 || - initializer.kind === 204 || - initializer.kind === 192) { + if (initializer.kind === 192 || + initializer.kind === 205 || + initializer.kind === 193) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -6064,6 +6145,13 @@ var ts; return e; } } + function isDefaultedJavascriptInitializer(node) { + var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 58 ? node.parent.left : + undefined; + return name && getJavascriptInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); + } + ts.isDefaultedJavascriptInitializer = isDefaultedJavascriptInitializer; function getOuterNameOfJsInitializer(node) { if (ts.isBinaryExpression(node.parent)) { var parent = (node.parent.operatorToken.kind === 54 && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; @@ -6156,7 +6244,7 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJavaScriptFile(expr) && - expr.parent && expr.parent.kind === 215 && + expr.parent && expr.parent.kind === 216 && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -6166,14 +6254,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 243: - case 249: + case 244: + case 250: return node.parent; - case 253: + case 254: return node.parent.parent; - case 186: + case 187: return node.parent; - case 177: + case 178: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -6183,12 +6271,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 243: - case 249: + case 244: + case 250: return node.moduleSpecifier; - case 242: - return node.moduleReference.kind === 253 ? node.moduleReference.expression : undefined; - case 178: + case 243: + return node.moduleReference.kind === 254 ? node.moduleReference.expression : undefined; + case 179: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -6197,11 +6285,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 243: + case 244: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 242: + case 243: return node; - case 249: + case 250: return undefined; default: return ts.Debug.assertNever(node); @@ -6209,19 +6297,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 243 && node.importClause && !!node.importClause.name; + return node.kind === 244 && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 148: + case 149: + case 154: case 153: - case 152: + case 271: case 270: - case 269: + case 152: case 151: - case 150: return node.questionToken !== undefined; } } @@ -6229,14 +6317,14 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 283 && + return node.kind === 284 && node.parameters.length > 0 && node.parameters[0].name && node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 296 || node.kind === 291; + return node.kind === 297 || node.kind === 292; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -6246,38 +6334,39 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 58 && - node.expression.right; + node.expression.operatorToken.kind === 58 + ? node.expression.right + : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && getSpecialPropertyAssignmentKind(node.expression) !== 0 && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 54 && - node.expression.right.right; + node.expression.right.operatorToken.kind === 54 + ? node.expression.right.right + : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 213: + case 214: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 151: + case 152: return node.initializer; - case 269: + case 270: return node.initializer; } } function getSingleVariableOfVariableStatement(node) { - return ts.isVariableStatement(node) && - node.declarationList.declarations.length > 0 && - node.declarationList.declarations[0]; + return ts.isVariableStatement(node) ? ts.firstOrUndefined(node.declarationList.declarations) : undefined; } function getNestedModuleDeclaration(node) { - return node.kind === 238 && + return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 238 && - node.body; + node.body.kind === 239 + ? node.body + : undefined; } function getJSDocCommentsAndTags(hostNode) { var result; @@ -6287,7 +6376,7 @@ var ts; var parent = node.parent; if (!parent) return; - if (parent.kind === 269 || parent.kind === 151 || getNestedModuleDeclaration(parent)) { + if (parent.kind === 270 || parent.kind === 152 || getNestedModuleDeclaration(parent)) { getJSDocCommentsAndTagsWorker(parent); } if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node)) { @@ -6301,10 +6390,10 @@ var ts; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 58 || ts.isBinaryExpression(parent) && parent.operatorToken.kind === 58 || - node.kind === 184 && node.parent && node.parent.kind === 215) { + node.kind === 185 && node.parent && node.parent.kind === 216) { getJSDocCommentsAndTagsWorker(parent); } - if (node.kind === 148) { + if (node.kind === 149) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); } if (isVariableLike(node) && ts.hasInitializer(node) && node.initializer !== hostNode && ts.hasJSDocNodes(node.initializer)) { @@ -6358,43 +6447,43 @@ var ts; ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { var last = ts.lastOrUndefined(s.parameters); - return last && isRestParameter(last); + return !!last && isRestParameter(last); } 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 === 284; + return node.dotDotDotToken !== undefined || !!type && type.kind === 285; } ts.isRestParameter = isRestParameter; function getAssignmentTargetKind(node) { var parent = node.parent; while (true) { switch (parent.kind) { - case 199: + case 200: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? binaryOperator === 58 ? 1 : 2 : 0; - case 197: case 198: + case 199: var unaryOperator = parent.operator; return unaryOperator === 43 || unaryOperator === 44 ? 2 : 0; - case 220: case 221: + case 222: return parent.initializer === node ? 1 : 0; - case 190: - case 182: - case 203: - case 208: + case 191: + case 183: + case 204: + case 209: node = parent; break; - case 270: + case 271: if (parent.name !== node) { return 0; } node = parent.parent; break; - case 269: + case 270: if (parent.name === node) { return 0; } @@ -6413,22 +6502,22 @@ var ts; ts.isAssignmentTarget = isAssignmentTarget; function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 212: case 213: - case 225: - case 216: + case 214: case 226: - case 240: - case 265: - case 266: + case 217: case 227: - case 219: + case 241: + case 266: + case 267: + case 228: case 220: case 221: - case 217: + case 222: case 218: - case 229: - case 268: + case 219: + case 230: + case 269: return true; } return false; @@ -6445,26 +6534,26 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 172); + return walkUp(node, 173); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 190); + return walkUp(node, 191); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 190) { + while (node.kind === 191) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function isDeleteTarget(node) { - if (node.kind !== 184 && node.kind !== 185) { + if (node.kind !== 185 && node.kind !== 186) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 193; + return node && node.kind === 194; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -6484,9 +6573,10 @@ var ts; switch (name.kind) { case 71: case 9: - case 8: - if (ts.isDeclaration(name.parent)) { - return name.parent.name === name; + case 8: { + var parent = name.parent; + if (ts.isDeclaration(parent)) { + return parent.name === name; } else if (ts.isQualifiedName(name.parent)) { var tag = name.parent.parent; @@ -6496,6 +6586,7 @@ var ts; var binExp = name.parent.parent; return ts.isBinaryExpression(binExp) && getSpecialPropertyAssignmentKind(binExp) !== 0 && ts.getNameOfDeclaration(binExp) === name; } + } default: return false; } @@ -6503,49 +6594,49 @@ var ts; ts.isAnyDeclarationName = isAnyDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 146 && + node.parent.kind === 147 && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 151: - case 150: - case 153: case 152: - case 155: + case 151: + case 154: + case 153: case 156: - case 272: - case 269: - case 184: + case 157: + case 273: + case 270: + case 185: return parent.name === node; - case 145: + case 146: if (parent.right === node) { - while (parent.kind === 145) { + while (parent.kind === 146) { parent = parent.parent; } - return parent.kind === 164 || parent.kind === 161; + return parent.kind === 165 || parent.kind === 162; } return false; - case 181: - case 247: + case 182: + case 248: return parent.propertyName === node; - case 251: - case 261: + case 252: + case 262: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 242 || - node.kind === 241 || - node.kind === 244 && !!node.name || - node.kind === 245 || - node.kind === 247 || - node.kind === 251 || - node.kind === 248 && exportAssignmentIsAlias(node) || + return node.kind === 243 || + node.kind === 242 || + node.kind === 245 && !!node.name || + node.kind === 246 || + node.kind === 248 || + node.kind === 252 || + node.kind === 249 && exportAssignmentIsAlias(node) || ts.isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) === 2; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; @@ -6605,11 +6696,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 72 <= token && token <= 144; + return 72 <= token && token <= 145; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 117 <= token && token <= 144; + return 117 <= token && token <= 145; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -6631,13 +6722,13 @@ var ts; } var flags = 0; switch (node.kind) { - case 233: - case 191: - case 153: + case 234: + case 192: + case 154: if (node.asteriskToken) { flags |= 1; } - case 192: + case 193: if (hasModifier(node, 256)) { flags |= 2; } @@ -6651,10 +6742,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 233: - case 191: + case 234: case 192: - case 153: + case 193: + case 154: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256); @@ -6670,11 +6761,11 @@ var ts; ts.isStringOrNumericLiteral = isStringOrNumericLiteral; function hasDynamicName(declaration) { var name = ts.getNameOfDeclaration(declaration); - return name && isDynamicName(name); + return !!name && isDynamicName(name); } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 146 && + return name.kind === 147 && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -6690,7 +6781,7 @@ var ts; if (name.kind === 9 || name.kind === 8) { return escapeLeadingUnderscores(name.text); } - if (name.kind === 146) { + if (name.kind === 147) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -6740,11 +6831,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 148; + return root.kind === 149; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 181) { + while (node.kind === 182) { node = node.parent.parent; } return node; @@ -6752,15 +6843,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 154 - || kind === 191 - || kind === 233 + return kind === 155 || kind === 192 - || kind === 153 - || kind === 155 + || kind === 234 + || kind === 193 + || kind === 154 || kind === 156 - || kind === 238 - || kind === 273; + || kind === 157 + || kind === 239 + || kind === 274; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -6774,23 +6865,23 @@ var ts; ts.getOriginalSourceFile = getOriginalSourceFile; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 187 && expression.arguments !== undefined; + var hasArguments = expression.kind === 188 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 187: + case 188: return hasArguments ? 0 : 1; - case 197: - case 194: + case 198: case 195: - case 193: case 196: - case 200: - case 202: + case 194: + case 197: + case 201: + case 203: return 1; - case 199: + case 200: switch (operator) { case 40: case 58: @@ -6814,15 +6905,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 187 && expression.arguments !== undefined; + var hasArguments = expression.kind === 188 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 199) { + if (expression.kind === 200) { return expression.operatorToken.kind; } - else if (expression.kind === 197 || expression.kind === 198) { + else if (expression.kind === 198 || expression.kind === 199) { return expression.operator; } else { @@ -6832,15 +6923,15 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 301: + case 302: return 0; - case 203: + case 204: return 1; - case 202: + case 203: return 2; - case 200: + case 201: return 4; - case 199: + case 200: switch (operatorKind) { case 26: return 0; @@ -6861,21 +6952,21 @@ var ts; default: return getBinaryOperatorPrecedence(operatorKind); } - case 197: - case 194: - case 195: - case 193: - case 196: - return 16; case 198: + case 195: + case 196: + case 194: + case 197: + return 16; + case 199: return 17; - case 186: - return 18; case 187: - return hasArguments ? 19 : 18; + return 18; case 188: - case 184: + return hasArguments ? 19 : 18; + case 189: case 185: + case 186: return 19; case 99: case 97: @@ -6885,19 +6976,19 @@ var ts; case 86: case 8: case 9: - case 182: case 183: - case 191: + case 184: case 192: - case 204: - case 254: + case 193: + case 205: case 255: - case 258: + case 256: + case 259: case 12: case 13: - case 201: - case 190: - case 205: + case 202: + case 191: + case 206: return 20; default: return -1; @@ -7097,7 +7188,7 @@ var ts; var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { lineCount = lineCount + lineStartsOfS.length - 1; - linePos = output.length - s.length + ts.lastOrUndefined(lineStartsOfS); + linePos = output.length - s.length + ts.last(lineStartsOfS); } } } @@ -7256,7 +7347,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 71 && identifierIsThisKeyword(node); + return !!node && node.kind === 71 && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { @@ -7270,10 +7361,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 155) { + if (accessor.kind === 156) { getAccessor = accessor; } - else if (accessor.kind === 156) { + else if (accessor.kind === 157) { setAccessor = accessor; } else { @@ -7282,7 +7373,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 155 || member.kind === 156) + if ((member.kind === 156 || member.kind === 157) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -7293,10 +7384,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 155 && !getAccessor) { + if (member.kind === 156 && !getAccessor) { getAccessor = member; } - if (member.kind === 156 && !setAccessor) { + if (member.kind === 157 && !setAccessor) { setAccessor = member; } } @@ -7331,24 +7422,19 @@ var ts; return ts.emptyArray; } if (isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 285); - var templateTags = ts.flatMap(ts.filter(node.parent.tags, ts.isJSDocTemplateTag), function (tag) { return tag.typeParameters; }); - var templateTagNodes = templateTags; - templateTagNodes.pos = templateTagNodes.length > 0 ? ts.first(templateTagNodes).pos : node.pos; - templateTagNodes.end = templateTagNodes.length > 0 ? ts.last(templateTagNodes).end : node.end; - templateTagNodes.hasTrailingComma = false; - return templateTagNodes; + ts.Debug.assert(node.parent.kind === 286); + return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } return node.typeParameters || (isInJavaScriptFile(node) ? getJSDocTypeParameterDeclarations(node) : ts.emptyArray); } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getJSDocTypeParameterDeclarations(node) { - var tag = ts.find(ts.getJSDocTags(node), function (tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 285 && tag.parent.tags.some(isJSDocTypeAlias)); - }); - return (tag && tag.typeParameters) || ts.emptyArray; + return ts.flatMap(ts.getJSDocTags(node), function (tag) { return isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined; }); } ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; + function isNonTypeAliasTemplate(tag) { + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 286 && tag.parent.tags.some(isJSDocTypeAlias)); + } function getEffectiveSetAccessorTypeAnnotationNode(node) { var parameter = getSetAccessorValueParameter(node); return parameter && getEffectiveTypeAnnotationNode(parameter); @@ -7425,12 +7511,12 @@ var ts; lastComment = comment; } if (detachedComments.length) { - var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end); + var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.last(detachedComments).end); var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos)); if (nodeLine >= lastCommentLine + 2) { emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments); emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment); - currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.last(detachedComments).end }; } } } @@ -7573,7 +7659,7 @@ var ts; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 206 && + if (ts.isExpressionWithTypeArguments(node) && node.parent.token === 85 && ts.isClassLike(node.parent.parent)) { return node.parent.parent; @@ -7591,8 +7677,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 183 - || kind === 182; + return kind === 184 + || kind === 183; } return false; } @@ -7602,7 +7688,7 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isExpressionWithTypeArgumentsInClassImplementsClause(node) { - return node.kind === 206 + return node.kind === 207 && isEntityNameExpression(node.expression) && node.parent && node.parent.token === 108 @@ -7623,17 +7709,17 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 145 && node.parent.right === node) || - (node.parent.kind === 184 && node.parent.name === node); + return (node.parent.kind === 146 && node.parent.right === node) || + (node.parent.kind === 185 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 183 && + return expression.kind === 184 && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 182 && + return expression.kind === 183 && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -7730,14 +7816,14 @@ var ts; return output; } function base64encode(host, input) { - if (host.base64encode) { + if (host && host.base64encode) { return host.base64encode(input); } return convertToBase64(input); } ts.base64encode = base64encode; function base64decode(host, input) { - if (host.base64decode) { + if (host && host.base64decode) { return host.base64decode(input); } var length = input.length; @@ -7913,8 +7999,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 237: case 238: + case 239: return parseNode === parseNode.parent.name; } } @@ -7976,20 +8062,20 @@ var ts; if (!parent) return 0; switch (parent.kind) { + case 199: case 198: - case 197: var operator = parent.operator; return operator === 43 || operator === 44 ? writeOrReadWrite() : 0; - case 199: + case 200: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0; - case 184: + case 185: return parent.name !== node ? 0 : accessKind(parent); default: return 0; } function writeOrReadWrite() { - return parent.parent && parent.parent.kind === 215 ? 1 : 2; + return parent.parent && parent.parent.kind === 216 ? 1 : 2; } } function compareDataObjects(dst, src) { @@ -8066,7 +8152,7 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 65536 ? type.objectFlags : 0; + return type.flags & 131072 ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { @@ -8245,9 +8331,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 147) { + if (d && d.kind === 148) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 235) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 236) { return current; } } @@ -8255,7 +8341,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 154; + return ts.hasModifier(node, 92) && node.parent.kind === 155; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -8273,7 +8359,7 @@ var ts; } ts.isEmptyBindingElement = isEmptyBindingElement; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 181 || ts.isBindingPattern(node))) { + while (node && (node.kind === 182 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -8281,14 +8367,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 231) { + if (node.kind === 232) { node = node.parent; } - if (node && node.kind === 232) { + if (node && node.kind === 233) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 213) { + if (node && node.kind === 214) { flags |= ts.getModifierFlags(node); } return flags; @@ -8297,14 +8383,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 231) { + if (node.kind === 232) { node = node.parent; } - if (node && node.kind === 232) { + if (node && node.kind === 233) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 213) { + if (node && node.kind === 214) { flags |= node.flags; } return flags; @@ -8348,7 +8434,7 @@ var ts; try { ts.localizedDiagnosticMessages = JSON.parse(fileContents); } - catch (e) { + catch (_a) { if (errors) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath)); } @@ -8408,17 +8494,17 @@ var ts; return getDeclarationIdentifier(hostNode); } switch (hostNode.kind) { - case 213: + case 214: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } return undefined; - case 215: + case 216: var expr = hostNode.expression; switch (expr.kind) { - case 184: - return expr.name; case 185: + return expr.name; + case 186: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; @@ -8427,10 +8513,10 @@ var ts; return undefined; case 1: return undefined; - case 190: { + case 191: { return getDeclarationIdentifier(hostNode.expression); } - case 227: { + case 228: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -8457,23 +8543,23 @@ var ts; return undefined; } switch (declaration.kind) { - case 204: - case 191: + case 205: + case 192: if (!declaration.name) { return getAssignedName(declaration); } break; case 71: return declaration; - case 297: - case 292: { + case 298: + case 293: { var name = declaration.name; - if (name.kind === 145) { + if (name.kind === 146) { return name.right; } break; } - case 199: { + case 200: { var expr = declaration; switch (ts.getSpecialPropertyAssignmentKind(expr)) { case 1: @@ -8485,11 +8571,11 @@ var ts; return undefined; } } - case 291: + case 292: return declaration.name; - case 296: + case 297: return getNameOfJSDocTypedef(declaration); - case 248: { + case 249: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } @@ -8628,628 +8714,628 @@ var ts; } ts.isIdentifier = isIdentifier; function isQualifiedName(node) { - return node.kind === 145; + return node.kind === 146; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 146; + return node.kind === 147; } ts.isComputedPropertyName = isComputedPropertyName; function isTypeParameterDeclaration(node) { - return node.kind === 147; + return node.kind === 148; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 148; + return node.kind === 149; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 149; + return node.kind === 150; } ts.isDecorator = isDecorator; function isPropertySignature(node) { - return node.kind === 150; + return node.kind === 151; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 151; + return node.kind === 152; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 152; + return node.kind === 153; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 153; + return node.kind === 154; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 154; + return node.kind === 155; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 155; + return node.kind === 156; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 156; + return node.kind === 157; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 157; + return node.kind === 158; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 158; + return node.kind === 159; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 159; + return node.kind === 160; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; function isGetOrSetAccessorDeclaration(node) { - return node.kind === 156 || node.kind === 155; + return node.kind === 157 || node.kind === 156; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isTypePredicateNode(node) { - return node.kind === 160; + return node.kind === 161; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 161; + return node.kind === 162; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 162; + return node.kind === 163; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 163; + return node.kind === 164; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 164; + return node.kind === 165; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 165; + return node.kind === 166; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 166; + return node.kind === 167; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 167; + return node.kind === 168; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 168; + return node.kind === 169; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 169; + return node.kind === 170; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 170; + return node.kind === 171; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 171; + return node.kind === 172; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 172; + return node.kind === 173; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 173; + return node.kind === 174; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 174; + return node.kind === 175; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 175; + return node.kind === 176; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 176; + return node.kind === 177; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 177; + return node.kind === 178; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 178; + return node.kind === 179; } ts.isImportTypeNode = isImportTypeNode; function isObjectBindingPattern(node) { - return node.kind === 179; + return node.kind === 180; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 180; + return node.kind === 181; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 181; + return node.kind === 182; } ts.isBindingElement = isBindingElement; function isArrayLiteralExpression(node) { - return node.kind === 182; + return node.kind === 183; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 183; + return node.kind === 184; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 184; + return node.kind === 185; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 185; + return node.kind === 186; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 186; + return node.kind === 187; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 187; + return node.kind === 188; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 188; + return node.kind === 189; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 189; + return node.kind === 190; } ts.isTypeAssertion = isTypeAssertion; function isParenthesizedExpression(node) { - return node.kind === 190; + return node.kind === 191; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 300) { + while (node.kind === 301) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 191; + return node.kind === 192; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 192; + return node.kind === 193; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 194; + return node.kind === 195; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 195; + return node.kind === 196; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 196; + return node.kind === 197; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 197; + return node.kind === 198; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 198; + return node.kind === 199; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 199; + return node.kind === 200; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 200; + return node.kind === 201; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 201; + return node.kind === 202; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 202; + return node.kind === 203; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 203; + return node.kind === 204; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 204; + return node.kind === 205; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 205; + return node.kind === 206; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 206; + return node.kind === 207; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 207; + return node.kind === 208; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 208; + return node.kind === 209; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 209; + return node.kind === 210; } ts.isMetaProperty = isMetaProperty; function isTemplateSpan(node) { - return node.kind === 210; + return node.kind === 211; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 211; + return node.kind === 212; } ts.isSemicolonClassElement = isSemicolonClassElement; function isBlock(node) { - return node.kind === 212; + return node.kind === 213; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 213; + return node.kind === 214; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 214; + return node.kind === 215; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 215; + return node.kind === 216; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 216; + return node.kind === 217; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 217; + return node.kind === 218; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 218; + return node.kind === 219; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 219; + return node.kind === 220; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 220; + return node.kind === 221; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 221; + return node.kind === 222; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 222; + return node.kind === 223; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 223; + return node.kind === 224; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 223 || node.kind === 222; + return node.kind === 224 || node.kind === 223; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 224; + return node.kind === 225; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 225; + return node.kind === 226; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 226; + return node.kind === 227; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 227; + return node.kind === 228; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 228; + return node.kind === 229; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 229; + return node.kind === 230; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 230; + return node.kind === 231; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 231; + return node.kind === 232; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 232; + return node.kind === 233; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 233; + return node.kind === 234; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 234; + return node.kind === 235; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 235; + return node.kind === 236; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 236; + return node.kind === 237; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 237; + return node.kind === 238; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 238; + return node.kind === 239; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 239; + return node.kind === 240; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 240; + return node.kind === 241; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 241; + return node.kind === 242; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 242; + return node.kind === 243; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 243; + return node.kind === 244; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 244; + return node.kind === 245; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 245; + return node.kind === 246; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 246; + return node.kind === 247; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 247; + return node.kind === 248; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 248; + return node.kind === 249; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 249; + return node.kind === 250; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 250; + return node.kind === 251; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 251; + return node.kind === 252; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 252; + return node.kind === 253; } ts.isMissingDeclaration = isMissingDeclaration; function isExternalModuleReference(node) { - return node.kind === 253; + return node.kind === 254; } ts.isExternalModuleReference = isExternalModuleReference; function isJsxElement(node) { - return node.kind === 254; + return node.kind === 255; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 255; + return node.kind === 256; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 256; + return node.kind === 257; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 257; + return node.kind === 258; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 258; + return node.kind === 259; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 259; + return node.kind === 260; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 260; + return node.kind === 261; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 261; + return node.kind === 262; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 262; + return node.kind === 263; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 263; + return node.kind === 264; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 264; + return node.kind === 265; } ts.isJsxExpression = isJsxExpression; function isCaseClause(node) { - return node.kind === 265; + return node.kind === 266; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 266; + return node.kind === 267; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 267; + return node.kind === 268; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 268; + return node.kind === 269; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 269; + return node.kind === 270; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 270; + return node.kind === 271; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 271; + return node.kind === 272; } ts.isSpreadAssignment = isSpreadAssignment; function isEnumMember(node) { - return node.kind === 272; + return node.kind === 273; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 273; + return node.kind === 274; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 274; + return node.kind === 275; } ts.isBundle = isBundle; function isJSDocTypeExpression(node) { - return node.kind === 277; + return node.kind === 278; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 278; + return node.kind === 279; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 279; + return node.kind === 280; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 280; + return node.kind === 281; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 281; + return node.kind === 282; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 282; + return node.kind === 283; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 283; + return node.kind === 284; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 284; + return node.kind === 285; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 285; + return node.kind === 286; } ts.isJSDoc = isJSDoc; function isJSDocAugmentsTag(node) { - return node.kind === 289; + return node.kind === 290; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 290; + return node.kind === 291; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocParameterTag(node) { - return node.kind === 292; + return node.kind === 293; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 293; + return node.kind === 294; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 294; + return node.kind === 295; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 295; + return node.kind === 296; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 296; + return node.kind === 297; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 297; + return node.kind === 298; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 297 || node.kind === 292; + return node.kind === 298 || node.kind === 293; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 286; + return node.kind === 287; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 291; + return node.kind === 292; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 287; + return node.kind === 288; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); (function (ts) { function isSyntaxList(n) { - return n.kind === 298; + return n.kind === 299; } ts.isSyntaxList = isSyntaxList; function isNode(node) { @@ -9257,11 +9343,11 @@ var ts; } ts.isNode = isNode; function isNodeKind(kind) { - return kind >= 145; + return kind >= 146; } ts.isNodeKind = isNodeKind; function isToken(n) { - return n.kind >= 0 && n.kind <= 144; + return n.kind >= 0 && n.kind <= 145; } ts.isToken = isToken; function isNodeArray(array) { @@ -9280,6 +9366,10 @@ var ts; return 13 <= kind && kind <= 16; } ts.isTemplateLiteralKind = isTemplateLiteralKind; + function isTemplateLiteralToken(node) { + return isTemplateLiteralKind(node.kind); + } + ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; return kind === 15 @@ -9326,7 +9416,7 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 145 + return kind === 146 || kind === 71; } ts.isEntityName = isEntityName; @@ -9335,14 +9425,14 @@ var ts; return kind === 71 || kind === 9 || kind === 8 - || kind === 146; + || kind === 147; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; return kind === 71 - || kind === 179 - || kind === 180; + || kind === 180 + || kind === 181; } ts.isBindingName = isBindingName; function isFunctionLike(node) { @@ -9355,13 +9445,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 233: - case 153: + case 234: case 154: case 155: case 156: - case 191: + case 157: case 192: + case 193: return true; default: return false; @@ -9369,14 +9459,14 @@ var ts; } function isFunctionLikeKind(kind) { switch (kind) { - case 152: - case 157: - case 287: + case 153: case 158: + case 288: case 159: - case 162: - case 283: + case 160: case 163: + case 284: + case 164: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -9389,28 +9479,28 @@ var ts; ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock; function isClassElement(node) { var kind = node.kind; - return kind === 154 - || kind === 151 - || kind === 153 - || kind === 155 + return kind === 155 + || kind === 152 + || kind === 154 || kind === 156 - || kind === 159 - || kind === 211; + || kind === 157 + || kind === 160 + || kind === 212; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 234 || node.kind === 204); + return node && (node.kind === 235 || node.kind === 205); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 155 || node.kind === 156); + return node && (node.kind === 156 || node.kind === 157); } ts.isAccessor = isAccessor; function isMethodOrAccessor(node) { switch (node.kind) { - case 153: - case 155: + case 154: case 156: + case 157: return true; default: return false; @@ -9419,11 +9509,11 @@ var ts; ts.isMethodOrAccessor = isMethodOrAccessor; function isTypeElement(node) { var kind = node.kind; - return kind === 158 - || kind === 157 - || kind === 150 - || kind === 152 - || kind === 159; + return kind === 159 + || kind === 158 + || kind === 151 + || kind === 153 + || kind === 160; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -9432,17 +9522,18 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 269 - || kind === 270 + return kind === 270 || kind === 271 - || kind === 153 - || kind === 155 - || kind === 156; + || kind === 272 + || kind === 154 + || kind === 156 + || kind === 157; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 160 && kind <= 178) + return (kind >= 161 && kind <= 179) || kind === 119 + || kind === 142 || kind === 134 || kind === 135 || kind === 122 @@ -9453,14 +9544,14 @@ var ts; || kind === 140 || kind === 95 || kind === 131 - || kind === 206 - || kind === 278 + || kind === 207 || kind === 279 || kind === 280 || kind === 281 || kind === 282 || kind === 283 - || kind === 284; + || kind === 284 + || kind === 285; } function isTypeNode(node) { return isTypeNodeKind(node.kind); @@ -9468,8 +9559,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 162: case 163: + case 164: return true; } return false; @@ -9478,29 +9569,29 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 180 - || kind === 179; + return kind === 181 + || kind === 180; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 182 - || kind === 183; + return kind === 183 + || kind === 184; } ts.isAssignmentPattern = isAssignmentPattern; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 181 - || kind === 205; + return kind === 182 + || kind === 206; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 231: - case 148: - case 181: + case 232: + case 149: + case 182: return true; } return false; @@ -9513,8 +9604,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 179: - case 183: + case 180: + case 184: return true; } return false; @@ -9522,8 +9613,8 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 180: - case 182: + case 181: + case 183: return true; } return false; @@ -9531,25 +9622,25 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 184 - || kind === 145 - || kind === 178; + return kind === 185 + || kind === 146 + || kind === 179; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 184 - || kind === 145; + return kind === 185 + || kind === 146; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { + case 257: case 256: - case 255: - case 186: case 187: case 188: - case 149: + case 189: + case 150: return true; default: return false; @@ -9557,12 +9648,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 186 || node.kind === 187; + return node.kind === 187 || node.kind === 188; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 201 + return kind === 202 || kind === 13; } ts.isTemplateLiteral = isTemplateLiteral; @@ -9572,32 +9663,32 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 184: case 185: - case 187: case 186: - case 254: - case 255: - case 258: case 188: - case 182: - case 190: + case 187: + case 255: + case 256: + case 259: + case 189: case 183: - case 204: case 191: + case 184: + case 205: + case 192: case 71: case 12: case 8: case 9: case 13: - case 201: + case 202: case 86: case 95: case 99: case 101: case 97: - case 208: case 209: + case 210: case 91: return true; default: @@ -9610,13 +9701,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 197: case 198: - case 193: + case 199: case 194: case 195: case 196: - case 189: + case 197: + case 190: return true; default: return isLeftHandSideExpressionKind(kind); @@ -9624,9 +9715,9 @@ var ts; } function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 198: + case 199: return true; - case 197: + case 198: return expr.operator === 43 || expr.operator === 44; default: @@ -9640,15 +9731,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 200: - case 202: - case 192: - case 199: + case 201: case 203: - case 207: - case 205: + case 193: + case 200: + case 204: + case 208: + case 206: + case 302: case 301: - case 300: return true; default: return isUnaryExpressionKind(kind); @@ -9656,16 +9747,16 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 189 - || kind === 207; + return kind === 190 + || kind === 208; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 300; + return node.kind === 301; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 299; + return node.kind === 300; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -9675,20 +9766,20 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 219: case 220: case 221: - case 217: + case 222: case 218: + case 219: return true; - case 227: + case 228: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; function isForInOrOfStatement(node) { - return node.kind === 220 || node.kind === 221; + return node.kind === 221 || node.kind === 222; } ts.isForInOrOfStatement = isForInOrOfStatement; function isConciseBody(node) { @@ -9707,108 +9798,108 @@ var ts; ts.isForInitializer = isForInitializer; function isModuleBody(node) { var kind = node.kind; - return kind === 239 - || kind === 238 + return kind === 240 + || kind === 239 || kind === 71; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 239 - || kind === 238; + return kind === 240 + || kind === 239; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; return kind === 71 - || kind === 238; + || kind === 239; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 246 - || kind === 245; + return kind === 247 + || kind === 246; } ts.isNamedImportBindings = isNamedImportBindings; function isModuleOrEnumDeclaration(node) { - return node.kind === 238 || node.kind === 237; + return node.kind === 239 || node.kind === 238; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 192 - || kind === 181 - || kind === 234 - || kind === 204 - || kind === 154 - || kind === 237 - || kind === 272 - || kind === 251 - || kind === 233 - || kind === 191 - || kind === 155 - || kind === 244 - || kind === 242 - || kind === 247 + return kind === 193 + || kind === 182 || kind === 235 - || kind === 261 - || kind === 153 - || kind === 152 + || kind === 205 + || kind === 155 || kind === 238 - || kind === 241 - || kind === 245 - || kind === 148 - || kind === 269 - || kind === 151 - || kind === 150 - || kind === 156 - || kind === 270 - || kind === 236 - || kind === 147 - || kind === 231 - || kind === 296 - || kind === 291 - || kind === 297; - } - function isDeclarationStatementKind(kind) { - return kind === 233 + || kind === 273 || kind === 252 || kind === 234 + || kind === 192 + || kind === 156 + || kind === 245 + || kind === 243 + || kind === 248 + || kind === 236 + || kind === 262 + || kind === 154 + || kind === 153 + || kind === 239 + || kind === 242 + || kind === 246 + || kind === 149 + || kind === 270 + || kind === 152 + || kind === 151 + || kind === 157 + || kind === 271 + || kind === 237 + || kind === 148 + || kind === 232 + || kind === 297 + || kind === 292 + || kind === 298; + } + function isDeclarationStatementKind(kind) { + return kind === 234 + || kind === 253 || kind === 235 || kind === 236 || kind === 237 || kind === 238 + || kind === 239 + || kind === 244 || kind === 243 - || kind === 242 + || kind === 250 || kind === 249 - || kind === 248 - || kind === 241; + || kind === 242; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 223 - || kind === 222 - || kind === 230 - || kind === 217 - || kind === 215 - || kind === 214 - || kind === 220 - || kind === 221 - || kind === 219 - || kind === 216 - || kind === 227 - || kind === 224 - || kind === 226 - || kind === 228 - || kind === 229 - || kind === 213 + return kind === 224 + || kind === 223 + || kind === 231 || kind === 218 + || kind === 216 + || kind === 215 + || kind === 221 + || kind === 222 + || kind === 220 + || kind === 217 + || kind === 228 || kind === 225 - || kind === 299 - || kind === 303 - || kind === 302; + || kind === 227 + || kind === 229 + || kind === 230 + || kind === 214 + || kind === 219 + || kind === 226 + || kind === 300 + || kind === 304 + || kind === 303; } function isDeclaration(node) { - if (node.kind === 147) { - return node.parent.kind !== 295 || ts.isInJavaScriptFile(node); + if (node.kind === 148) { + return node.parent.kind !== 296 || ts.isInJavaScriptFile(node); } return isDeclarationKind(node.kind); } @@ -9829,10 +9920,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 212) + if (node.kind !== 213) return false; if (node.parent !== undefined) { - if (node.parent.kind === 229 || node.parent.kind === 268) { + if (node.parent.kind === 230 || node.parent.kind === 269) { return false; } } @@ -9840,8 +9931,8 @@ var ts; } function isModuleReference(node) { var kind = node.kind; - return kind === 253 - || kind === 145 + return kind === 254 + || kind === 146 || kind === 71; } ts.isModuleReference = isModuleReference; @@ -9849,64 +9940,65 @@ var ts; var kind = node.kind; return kind === 99 || kind === 71 - || kind === 184; + || kind === 185; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 254 - || kind === 264 - || kind === 255 + return kind === 255 + || kind === 265 + || kind === 256 || kind === 10 - || kind === 258; + || kind === 259; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 261 - || kind === 263; + return kind === 262 + || kind === 264; } ts.isJsxAttributeLike = isJsxAttributeLike; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 264; + || kind === 265; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 256 - || kind === 255; + return kind === 257 + || kind === 256; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 265 - || kind === 266; + return kind === 266 + || kind === 267; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isJSDocNode(node) { - return node.kind >= 277 && node.kind <= 297; + return node.kind >= 278 && node.kind <= 298; } ts.isJSDocNode = isJSDocNode; function isJSDocCommentContainingNode(node) { - return node.kind === 285 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 286 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; function isJSDocTag(node) { - return node.kind >= 288 && node.kind <= 297; + return node.kind >= 289 && node.kind <= 298; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 156; + return node.kind === 157; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 155; + return node.kind === 156; } ts.isGetAccessor = isGetAccessor; function hasJSDocNodes(node) { - return !!node.jsDoc && node.jsDoc.length > 0; + var jsDoc = node.jsDoc; + return !!jsDoc && jsDoc.length > 0; } ts.hasJSDocNodes = hasJSDocNodes; function hasType(node) { @@ -9915,8 +10007,7 @@ var ts; ts.hasType = hasType; function couldHaveType(node) { switch (node.kind) { - case 148: - case 150: + case 149: case 151: case 152: case 153: @@ -9927,24 +10018,25 @@ var ts; case 158: case 159: case 160: - case 162: + case 161: case 163: - case 172: - case 174: - case 176: - case 189: - case 191: + case 164: + case 173: + case 175: + case 177: + case 190: case 192: - case 207: - case 231: - case 233: - case 236: - case 277: - case 280: + case 193: + case 208: + case 232: + case 234: + case 237: + case 278: case 281: case 282: case 283: case 284: + case 285: return true; } return false; @@ -9960,13 +10052,13 @@ var ts; ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { switch (node.kind) { - case 261: - case 263: - case 269: + case 262: + case 264: case 270: - case 153: - case 155: + case 271: + case 154: case 156: + case 157: return true; default: return false; @@ -9974,7 +10066,7 @@ var ts; } ts.isObjectLiteralElement = isObjectLiteralElement; function isTypeReferenceType(node) { - return node.kind === 161 || node.kind === 206; + return node.kind === 162 || node.kind === 207; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -10006,7 +10098,7 @@ var ts; } ts.isStringLiteralLike = isStringLiteralLike; function isNamedImportsOrExports(node) { - return node.kind === 246 || node.kind === 250; + return node.kind === 247 || node.kind === 251; } ts.isNamedImportsOrExports = isNamedImportsOrExports; })(ts || (ts = {})); @@ -10044,7 +10136,7 @@ var ts; "false": 86, "finally": 87, "for": 88, - "from": 142, + "from": 143, "function": 89, "get": 125, "if": 90, @@ -10070,7 +10162,7 @@ var ts; "public": 114, "readonly": 132, "require": 133, - "global": 143, + "global": 144, "return": 96, "set": 136, "static": 115, @@ -10086,6 +10178,7 @@ var ts; "typeof": 103, "undefined": 140, "unique": 141, + "unknown": 142, "var": 104, "void": 105, "while": 106, @@ -10093,7 +10186,7 @@ var ts; "yield": 116, "async": 120, "await": 121, - "of": 144, + "of": 145, "{": 17, "}": 18, "(": 19, @@ -10599,8 +10692,9 @@ var ts; return true; } ts.isIdentifierText = isIdentifierText; - function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { if (languageVariant === void 0) { languageVariant = 0; } + var text = textInitial; var pos; var end; var startPos; @@ -11710,7 +11804,7 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 273) { + if (kind === 274) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } else if (kind === 71) { @@ -11748,28 +11842,28 @@ var ts; } ts.isJSDocLikeText = isJSDocLikeText; function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 144) { + if (!node || node.kind <= 145) { return; } switch (node.kind) { - case 145: + case 146: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 147: + case 148: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 270: + case 271: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 271: + case 272: return visitNode(cbNode, node.expression); - case 148: + case 149: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -11777,59 +11871,59 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); + case 152: + return visitNodes(cbNode, cbNodes, node.decorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNode(cbNode, node.questionToken) || + visitNode(cbNode, node.exclamationToken) || + visitNode(cbNode, node.type) || + visitNode(cbNode, node.initializer); case 151: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || - visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 150: - 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 269: + case 270: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 231: + case 232: 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 181: + case 182: 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 162: case 163: - case 157: + case 164: case 158: case 159: + case 160: 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 153: - case 152: case 154: + case 153: case 155: case 156: - case 191: - case 233: + case 157: case 192: + case 234: + case 193: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -11840,187 +11934,180 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 161: + case 162: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 160: + case 161: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 164: - return visitNode(cbNode, node.exprName); case 165: - return visitNodes(cbNode, cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 166: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNode, cbNodes, node.members); case 167: - return visitNodes(cbNode, cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 168: + return visitNodes(cbNode, cbNodes, node.elementTypes); case 169: - return visitNodes(cbNode, cbNodes, node.types); case 170: + return visitNodes(cbNode, cbNodes, node.types); + case 171: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 171: + case 172: return visitNode(cbNode, node.typeParameter); - case 178: + case 179: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 172: - case 174: - return visitNode(cbNode, node.type); + case 173: case 175: + return visitNode(cbNode, node.type); + case 176: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 176: + case 177: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 177: + case 178: return visitNode(cbNode, node.literal); - case 179: case 180: - return visitNodes(cbNode, cbNodes, node.elements); - case 182: + case 181: return visitNodes(cbNode, cbNodes, node.elements); case 183: - return visitNodes(cbNode, cbNodes, node.properties); + return visitNodes(cbNode, cbNodes, node.elements); case 184: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNode, cbNodes, node.properties); case 185: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 186: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 187: + case 188: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 188: + case 189: return visitNode(cbNode, node.tag) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 189: + case 190: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 190: - return visitNode(cbNode, node.expression); - case 193: + case 191: return visitNode(cbNode, node.expression); case 194: return visitNode(cbNode, node.expression); case 195: return visitNode(cbNode, node.expression); - case 197: - return visitNode(cbNode, node.operand); - case 202: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 196: return visitNode(cbNode, node.expression); case 198: return visitNode(cbNode, node.operand); + case 203: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 197: + return visitNode(cbNode, node.expression); case 199: + return visitNode(cbNode, node.operand); + case 200: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 207: + case 208: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 208: - return visitNode(cbNode, node.expression); case 209: + return visitNode(cbNode, node.expression); + case 210: return visitNode(cbNode, node.name); - case 200: + case 201: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 203: + case 204: return visitNode(cbNode, node.expression); - case 212: - case 239: + case 213: + case 240: return visitNodes(cbNode, cbNodes, node.statements); - case 273: + case 274: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 213: + case 214: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 232: + case 233: return visitNodes(cbNode, cbNodes, node.declarations); - case 215: - return visitNode(cbNode, node.expression); case 216: + return visitNode(cbNode, node.expression); + case 217: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 217: + case 218: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 218: + case 219: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 219: + case 220: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 220: + case 221: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 221: + case 222: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 222: case 223: - return visitNode(cbNode, node.label); case 224: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.label); case 225: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); + return visitNode(cbNode, node.expression); case 226: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 227: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 240: + case 241: return visitNodes(cbNode, cbNodes, node.clauses); - case 265: + case 266: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 266: + case 267: return visitNodes(cbNode, cbNodes, node.statements); - case 227: + case 228: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 228: - return visitNode(cbNode, node.expression); case 229: + return visitNode(cbNode, node.expression); + case 230: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 268: + case 269: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 149: + case 150: return visitNode(cbNode, node.expression); - case 234: - case 204: - 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 235: + case 205: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -12032,112 +12119,119 @@ var ts; visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || - visitNode(cbNode, node.type); + visitNodes(cbNode, cbNodes, node.heritageClauses) || + visitNodes(cbNode, cbNodes, node.members); case 237: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNode, cbNodes, node.members); - case 272: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNode, cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 238: + return visitNodes(cbNode, cbNodes, node.decorators) || + visitNodes(cbNode, cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNode, cbNodes, node.members); + case 273: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 239: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 242: + case 243: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 243: + case 244: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 244: + case 245: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 241: - return visitNode(cbNode, node.name); - case 245: + case 242: return visitNode(cbNode, node.name); case 246: - case 250: + return visitNode(cbNode, node.name); + case 247: + case 251: return visitNodes(cbNode, cbNodes, node.elements); - case 249: + case 250: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 247: - case 251: + case 248: + case 252: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 248: + case 249: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 201: + case 202: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 210: + case 211: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 146: + case 147: return visitNode(cbNode, node.expression); - case 267: + case 268: return visitNodes(cbNode, cbNodes, node.types); - case 206: + case 207: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 253: - return visitNode(cbNode, node.expression); - case 252: - return visitNodes(cbNode, cbNodes, node.decorators); - case 301: - return visitNodes(cbNode, cbNodes, node.elements); case 254: + return visitNode(cbNode, node.expression); + case 253: + return visitNodes(cbNode, cbNodes, node.decorators); + case 302: + return visitNodes(cbNode, cbNodes, node.elements); + case 255: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 258: + case 259: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 255: case 256: + case 257: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 262: + case 263: return visitNodes(cbNode, cbNodes, node.properties); - case 261: + case 262: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 263: - return visitNode(cbNode, node.expression); case 264: + return visitNode(cbNode, node.expression); + case 265: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 257: + case 258: return visitNode(cbNode, node.tagName); - case 277: - return visitNode(cbNode, node.type); - case 281: - return visitNode(cbNode, node.type); - case 280: + case 278: return visitNode(cbNode, node.type); case 282: return visitNode(cbNode, node.type); + case 281: + return visitNode(cbNode, node.type); case 283: + return visitNode(cbNode, node.type); + case 284: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 284: - return visitNode(cbNode, node.type); case 285: + return visitNode(cbNode, node.type); + case 286: return visitNodes(cbNode, cbNodes, node.tags); - case 292: - case 297: + case 293: + case 298: if (node.isNameFirst) { return visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression); @@ -12146,17 +12240,17 @@ var ts; return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); } - case 293: - return visitNode(cbNode, node.typeExpression); case 294: return visitNode(cbNode, node.typeExpression); - case 289: - return visitNode(cbNode, node.class); case 295: - return visitNodes(cbNode, cbNodes, node.typeParameters); + return visitNode(cbNode, node.typeExpression); + case 290: + return visitNode(cbNode, node.class); case 296: + return visitNodes(cbNode, cbNodes, node.typeParameters); + case 297: if (node.typeExpression && - node.typeExpression.kind === 277) { + node.typeExpression.kind === 278) { return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName); } @@ -12164,16 +12258,16 @@ var ts; return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); } - case 291: + case 292: return visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 287: + case 288: 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 286: + case 287: if (node.jsDocPropertyTags) { for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { var tag = _a[_i]; @@ -12181,7 +12275,7 @@ var ts; } } return; - case 300: + case 301: return visitNode(cbNode, node.expression); } } @@ -12214,6 +12308,7 @@ var ts; } ts.isExternalModule = isExternalModule; function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { + if (aggressiveChecks === void 0) { aggressiveChecks = false; } var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); newSourceFile.flags |= (sourceFile.flags & 1572864); return newSourceFile; @@ -12251,6 +12346,7 @@ var ts; var contextFlags; var parseErrorBeforeNextFinishedNode = false; function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) { + if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); if (scriptKind === 6) { var result_1 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); @@ -12278,6 +12374,7 @@ var ts; if (languageVersion === void 0) { languageVersion = 2; } initializeState(sourceText, languageVersion, syntaxCursor, 6); sourceFile = createSourceFile(fileName, 2, 6, false); + sourceFile.flags = contextFlags; nextToken(); var pos = getNodePos(); if (token() === 1) { @@ -12285,7 +12382,7 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(215); + var statement = createNode(216); switch (token()) { case 21: statement.expression = parseArrayLiteralExpression(); @@ -12428,10 +12525,11 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { - var sourceFile = new SourceFileConstructor(273, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(274, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; + sourceFile.bindSuggestionDiagnostics = undefined; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); sourceFile.languageVariant = getLanguageVariant(scriptKind); @@ -12745,7 +12843,7 @@ var ts; return parsePropertyNameWorker(true); } function parseComputedPropertyName() { - var node = createNode(146); + var node = createNode(147); parseExpected(21); node.expression = allowInAnd(parseExpression); parseExpected(22); @@ -12859,7 +12957,7 @@ var ts; case 14: return true; } - ts.Debug.fail("Non-exhaustive case in 'isListElement'."); + return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { ts.Debug.assert(token() === 17); @@ -12935,6 +13033,8 @@ var ts; return token() === 29 || token() === 41; case 14: return token() === 27 && lookAhead(nextTokenIsSlash); + default: + return false; } } function isVariableDeclaratorListTerminator() { @@ -13053,14 +13153,14 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 154: - case 159: case 155: + case 160: case 156: - case 151: - case 211: + case 157: + case 152: + case 212: return true; - case 153: + case 154: var methodDeclaration = node; var nameIsConstructor = methodDeclaration.name.kind === 71 && methodDeclaration.name.originalKeywordKind === 123; @@ -13072,8 +13172,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 265: case 266: + case 267: return true; } } @@ -13082,65 +13182,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 233: + case 234: + case 214: case 213: - case 212: + case 217: case 216: - case 215: - case 228: + case 229: + case 225: + case 227: case 224: - case 226: case 223: + case 221: case 222: case 220: - case 221: case 219: - case 218: - case 225: - case 214: - case 229: - case 227: - case 217: + case 226: + case 215: case 230: + case 228: + case 218: + case 231: + case 244: case 243: - case 242: + case 250: case 249: - case 248: - case 238: - case 234: + case 239: case 235: - case 237: case 236: + case 238: + case 237: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 272; + return node.kind === 273; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 158: - case 152: case 159: - case 150: - case 157: + case 153: + case 160: + case 151: + case 158: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 231) { + if (node.kind !== 232) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 148) { + if (node.kind !== 149) { return false; } var parameter = node; @@ -13179,6 +13279,7 @@ var ts; case 22: return ts.Diagnostics.Identifier_expected; case 13: return ts.Diagnostics.Identifier_expected; case 14: return ts.Diagnostics.Identifier_expected; + default: return undefined; } } function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { @@ -13247,7 +13348,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(145, entity.pos); + var node = createNode(146, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -13262,19 +13363,19 @@ var ts; return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(201); + var template = createNode(202); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14, "Template head has wrong token kind"); var list = []; var listPos = getNodePos(); do { list.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(list).literal.kind === 15); + } while (ts.last(list).literal.kind === 15); template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { - var span = createNode(210); + var span = createNode(211); span.expression = allowInAnd(parseExpression); var literal; if (token() === 18) { @@ -13318,7 +13419,7 @@ var ts; return node; } function parseTypeReference() { - var node = createNode(161); + var node = createNode(162); node.typeName = parseEntityName(true, ts.Diagnostics.Type_expected); if (!scanner.hasPrecedingLineBreak() && token() === 27) { node.typeArguments = parseBracketedList(19, parseType, 27, 29); @@ -13327,20 +13428,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(160, lhs.pos); + var node = createNode(161, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(173); + var node = createNode(174); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(278); + var result = createNode(279); if (postFixEquals) { - return createJSDocPostfixType(282, result); + return createJSDocPostfixType(283, result); } else { nextToken(); @@ -13348,7 +13449,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(281); + var result = createNode(282); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -13362,28 +13463,28 @@ var ts; token() === 29 || token() === 58 || token() === 49) { - var result = createNode(279, pos); + var result = createNode(280, pos); return finishNode(result); } else { - var result = createNode(280, pos); + var result = createNode(281, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(283); + var result = createNodeWithJSDoc(284); nextToken(); fillSignature(56, 4 | 32, result); return finishNode(result); } - var node = createNode(161); + var node = createNode(162); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(148); + var parameter = createNode(149); if (token() === 99 || token() === 94) { parameter.name = parseIdentifierName(); parseExpected(56); @@ -13395,23 +13496,23 @@ var ts; var dotdotdot = parseOptionalToken(24); var type = parseType(); if (dotdotdot) { - var variadic = createNode(284, dotdotdot.pos); + var variadic = createNode(285, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } if (token() === 58) { - return createJSDocPostfixType(282, type); + return createJSDocPostfixType(283, type); } return type; } function parseTypeQuery() { - var node = createNode(164); + var node = createNode(165); parseExpected(103); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(147); + var node = createNode(148); node.name = parseIdentifier(); if (parseOptional(85)) { if (isStartOfType() || !isStartOfExpression()) { @@ -13445,7 +13546,7 @@ var ts; isStartOfType(true); } function parseParameter() { - var node = createNodeWithJSDoc(148); + var node = createNodeWithJSDoc(149); if (token() === 99) { node.name = createIdentifier(true); node.type = parseParameterType(); @@ -13513,7 +13614,7 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 158) { + if (kind === 159) { parseExpected(94); } fillSignature(56, 4, node); @@ -13550,7 +13651,7 @@ var ts; return token() === 56 || token() === 26 || token() === 22; } function parseIndexSignatureDeclaration(node) { - node.kind = 159; + node.kind = 160; node.parameters = parseBracketedList(16, parseParameter, 21, 22); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -13560,11 +13661,11 @@ var ts; node.name = parsePropertyName(); node.questionToken = parseOptionalToken(55); if (token() === 19 || token() === 27) { - node.kind = 152; + node.kind = 153; fillSignature(56, 4, node); } else { - node.kind = 150; + node.kind = 151; node.type = parseTypeAnnotation(); if (token() === 58) { node.initializer = parseInitializer(); @@ -13577,7 +13678,7 @@ var ts; if (token() === 19 || token() === 27) { return true; } - var idToken; + var idToken = false; while (ts.isModifierKind(token())) { idToken = true; nextToken(); @@ -13601,10 +13702,10 @@ var ts; } function parseTypeMember() { if (token() === 19 || token() === 27) { - return parseSignatureMember(157); + return parseSignatureMember(158); } if (token() === 94 && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(158); + return parseSignatureMember(159); } var node = createNodeWithJSDoc(0); node.modifiers = parseModifiers(); @@ -13630,7 +13731,7 @@ var ts; return false; } function parseTypeLiteral() { - var node = createNode(165); + var node = createNode(166); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -13656,14 +13757,14 @@ var ts; return token() === 21 && nextTokenIsIdentifier() && nextToken() === 92; } function parseMappedTypeParameter() { - var node = createNode(147); + var node = createNode(148); node.name = parseIdentifier(); parseExpected(92); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(176); + var node = createNode(177); parseExpected(17); if (token() === 132 || token() === 37 || token() === 38) { node.readonlyToken = parseTokenNode(); @@ -13686,12 +13787,12 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(167); + var node = createNode(168); node.elementTypes = parseBracketedList(20, parseType, 21, 22); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(172); + var node = createNode(173); parseExpected(19); node.type = parseType(); if (!node.type) { @@ -13702,7 +13803,7 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 163) { + if (kind === 164) { parseExpected(94); } if (!fillSignature(36, 4 | (sourceFile.languageVariant === 1 ? 8 : 0), node)) { @@ -13718,10 +13819,10 @@ var ts; return token() === 23 ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(177); + var node = createNode(178); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(197); + unaryMinusExpression = createNode(198); unaryMinusExpression.operator = 38; nextToken(); } @@ -13742,7 +13843,7 @@ var ts; } function parseImportType() { sourceFile.flags |= 524288; - var node = createNode(178); + var node = createNode(179); if (parseOptional(103)) { node.isTypeOf = true; } @@ -13762,6 +13863,7 @@ var ts; function parseNonArrayType() { switch (token()) { case 119: + case 142: case 137: case 134: case 138: @@ -13817,6 +13919,7 @@ var ts; function isStartOfType(inStartOfParameter) { switch (token()) { case 119: + case 142: case 137: case 134: case 122: @@ -13863,25 +13966,25 @@ var ts; while (!scanner.hasPrecedingLineBreak()) { switch (token()) { case 51: - type = createJSDocPostfixType(281, type); + type = createJSDocPostfixType(282, type); break; case 55: if (!(contextFlags & 2097152) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createJSDocPostfixType(280, type); + type = createJSDocPostfixType(281, type); break; case 21: parseExpected(21); if (isStartOfType()) { - var node = createNode(175, type.pos); + var node = createNode(176, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(22); type = finishNode(node); } else { - var node = createNode(166, type.pos); + var node = createNode(167, type.pos); node.elementType = type; parseExpected(22); type = finishNode(node); @@ -13900,16 +14003,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(174); + var node = createNode(175); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(171); + var node = createNode(172); parseExpected(126); - var typeParameter = createNode(147); + var typeParameter = createNode(148); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -13940,10 +14043,10 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(169, parseTypeOperatorOrHigher, 48); + return parseUnionOrIntersectionType(170, parseTypeOperatorOrHigher, 48); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(168, parseIntersectionTypeOrHigher, 49); + return parseUnionOrIntersectionType(169, parseIntersectionTypeOrHigher, 49); } function isStartOfFunctionType() { if (token() === 27) { @@ -13989,7 +14092,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(160, typePredicateVariable.pos); + var node = createNode(161, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -14010,14 +14113,14 @@ var ts; } function parseTypeWorker(noConditionalTypes) { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(162); + return parseFunctionOrConstructorType(163); } if (token() === 94) { - return parseFunctionOrConstructorType(163); + return parseFunctionOrConstructorType(164); } var type = parseUnionTypeOrHigher(); if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(85)) { - var node = createNode(170, type.pos); + var node = createNode(171, type.pos); node.checkType = type; node.extendsType = parseTypeWorker(true); parseExpected(55); @@ -14139,7 +14242,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(202); + var node = createNode(203); nextToken(); if (!scanner.hasPrecedingLineBreak() && (token() === 39 || isStartOfExpression())) { @@ -14155,13 +14258,13 @@ var ts; ts.Debug.assert(token() === 36, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(192, asyncModifier.pos); + node = createNode(193, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(192, identifier.pos); + node = createNode(193, identifier.pos); } - var parameter = createNode(148, identifier.pos); + var parameter = createNode(149, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); @@ -14307,7 +14410,7 @@ var ts; return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(192); + var node = createNodeWithJSDoc(193); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256) ? 2 : 0; if (!fillSignature(56, isAsync | (allowAmbiguity ? 0 : 8), node)) { @@ -14341,7 +14444,7 @@ var ts; if (!questionToken) { return leftOperand; } - var node = createNode(200, leftOperand.pos); + var node = createNode(201, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); @@ -14356,7 +14459,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 92 || t === 144; + return t === 92 || t === 145; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -14393,43 +14496,43 @@ var ts; return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(199, left.pos); + var node = createNode(200, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(207, left.pos); + var node = createNode(208, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(197); + var node = createNode(198); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(193); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(194); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(195); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(196); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { if (token() === 121) { if (inAwaitContext()) { @@ -14440,7 +14543,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(196); + var node = createNode(197); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -14457,7 +14560,7 @@ var ts; if (token() === 40) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 189) { + if (simpleUnaryExpression.kind === 190) { 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 { @@ -14510,7 +14613,7 @@ var ts; } function parseUpdateExpression() { if (token() === 43 || token() === 44) { - var node = createNode(197); + var node = createNode(198); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); @@ -14522,7 +14625,7 @@ var ts; var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); if ((token() === 43 || token() === 44) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(198, expression.pos); + var node = createNode(199, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -14541,7 +14644,7 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); nextToken(); - var node = createNode(209, fullStart); + var node = createNode(210, fullStart); node.keywordToken = 91; node.name = parseIdentifierName(); expression = finishNode(node); @@ -14565,30 +14668,17 @@ var ts; if (token() === 19 || token() === 23 || token() === 21) { return expression; } - var node = createNode(184, expression.pos); + var node = createNode(185, expression.pos); node.expression = expression; parseExpectedToken(23, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } - function tagNamesAreEquivalent(lhs, rhs) { - if (lhs.kind !== rhs.kind) { - return false; - } - if (lhs.kind === 71) { - return lhs.escapedText === rhs.escapedText; - } - if (lhs.kind === 99) { - return true; - } - return lhs.name.escapedText === rhs.name.escapedText && - tagNamesAreEquivalent(lhs.expression, rhs.expression); - } function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 256) { - var node = createNode(254, opening.pos); + if (opening.kind === 257) { + var node = createNode(255, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -14597,22 +14687,22 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 259) { - var node = createNode(258, opening.pos); + else if (opening.kind === 260) { + var node = createNode(259, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 255); + ts.Debug.assert(opening.kind === 256); result = opening; } if (inExpressionContext && token() === 27) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(199, result.pos); + var badNode = createNode(200, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -14668,7 +14758,7 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(262); + var jsxAttributes = createNode(263); jsxAttributes.properties = parseList(13, parseJsxAttribute); return finishNode(jsxAttributes); } @@ -14676,7 +14766,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(27); if (token() === 29) { - var node_1 = createNode(259, fullStart); + var node_1 = createNode(260, fullStart); scanJsxText(); return finishNode(node_1); } @@ -14685,7 +14775,7 @@ var ts; var attributes = parseJsxAttributes(); var node; if (token() === 29) { - node = createNode(256, fullStart); + node = createNode(257, fullStart); scanJsxText(); } else { @@ -14697,7 +14787,7 @@ var ts; parseExpected(29, undefined, false); scanJsxText(); } - node = createNode(255, fullStart); + node = createNode(256, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -14709,7 +14799,7 @@ var ts; var expression = token() === 99 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(23)) { - var propertyAccess = createNode(184, expression.pos); + var propertyAccess = createNode(185, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14717,7 +14807,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(264); + var node = createNode(265); if (!parseExpected(17)) { return undefined; } @@ -14739,7 +14829,7 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(261); + var node = createNode(262); node.name = parseIdentifierName(); if (token() === 58) { switch (scanJsxAttributeValue()) { @@ -14754,7 +14844,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(263); + var node = createNode(264); parseExpected(17); parseExpected(24); node.expression = parseExpression(); @@ -14762,7 +14852,7 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(257); + var node = createNode(258); parseExpected(28); node.tagName = parseJsxElementName(); if (inExpressionContext) { @@ -14775,7 +14865,7 @@ var ts; return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(260); + var node = createNode(261); parseExpected(28); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); @@ -14790,7 +14880,7 @@ var ts; return finishNode(node); } function parseTypeAssertion() { - var node = createNode(189); + var node = createNode(190); parseExpected(27); node.type = parseType(); parseExpected(29); @@ -14801,7 +14891,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(23); if (dotToken) { - var propertyAccess = createNode(184, expression.pos); + var propertyAccess = createNode(185, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14809,13 +14899,13 @@ var ts; } if (token() === 51 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(208, expression.pos); + var nonNullExpression = createNode(209, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } if (!inDecoratorContext() && parseOptional(21)) { - var indexedAccess = createNode(185, expression.pos); + var indexedAccess = createNode(186, expression.pos); indexedAccess.expression = expression; if (token() === 22) { indexedAccess.argumentExpression = createMissingNode(71, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); @@ -14842,7 +14932,7 @@ var ts; return token() === 13 || token() === 14; } function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(188, tag.pos); + var tagExpression = createNode(189, tag.pos); tagExpression.tag = tag; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 13 @@ -14862,7 +14952,7 @@ var ts; expression = parseTaggedTemplateRest(expression, typeArguments); continue; } - var callExpr = createNode(186, expression.pos); + var callExpr = createNode(187, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -14870,7 +14960,7 @@ var ts; continue; } else if (token() === 19) { - var callExpr = createNode(186, expression.pos); + var callExpr = createNode(187, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -14967,28 +15057,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(190); + var node = createNodeWithJSDoc(191); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); return finishNode(node); } function parseSpreadElement() { - var node = createNode(203); + var node = createNode(204); parseExpected(24); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 24 ? parseSpreadElement() : - token() === 26 ? createNode(205) : + token() === 26 ? createNode(206) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(182); + var node = createNode(183); parseExpected(21); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15000,17 +15090,17 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0); if (parseOptionalToken(24)) { - node.kind = 271; + node.kind = 272; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); if (parseContextualModifier(125)) { - return parseAccessorDeclaration(node, 155); + return parseAccessorDeclaration(node, 156); } if (parseContextualModifier(136)) { - return parseAccessorDeclaration(node, 156); + return parseAccessorDeclaration(node, 157); } var asteriskToken = parseOptionalToken(39); var tokenIsIdentifier = isIdentifier(); @@ -15021,7 +15111,7 @@ var ts; } var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 || token() === 18 || token() === 58); if (isShorthandPropertyAssignment) { - node.kind = 270; + node.kind = 271; var equalsToken = parseOptionalToken(58); if (equalsToken) { node.equalsToken = equalsToken; @@ -15029,14 +15119,14 @@ var ts; } } else { - node.kind = 269; + node.kind = 270; parseExpected(56); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(183); + var node = createNode(184); parseExpected(17); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15050,7 +15140,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNodeWithJSDoc(191); + var node = createNodeWithJSDoc(192); node.modifiers = parseModifiers(); parseExpected(89); node.asteriskToken = parseOptionalToken(39); @@ -15075,7 +15165,7 @@ var ts; var fullStart = scanner.getStartPos(); parseExpected(94); if (parseOptional(23)) { - var node_2 = createNode(209, fullStart); + var node_2 = createNode(210, fullStart); node_2.keywordToken = 94; node_2.name = parseIdentifierName(); return finishNode(node_2); @@ -15092,7 +15182,7 @@ var ts; } break; } - var node = createNode(187, fullStart); + var node = createNode(188, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 19) { @@ -15101,7 +15191,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(212); + var node = createNode(213); if (parseExpected(17, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -15132,12 +15222,12 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(214); + var node = createNode(215); parseExpected(25); return finishNode(node); } function parseIfStatement() { - var node = createNode(216); + var node = createNode(217); parseExpected(90); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -15147,7 +15237,7 @@ var ts; return finishNode(node); } function parseDoStatement() { - var node = createNode(217); + var node = createNode(218); parseExpected(81); node.statement = parseStatement(); parseExpected(106); @@ -15158,7 +15248,7 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(218); + var node = createNode(219); parseExpected(106); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -15181,8 +15271,8 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(144) : parseOptional(144)) { - var forOfStatement = createNode(221, pos); + if (awaitToken ? parseExpected(145) : parseOptional(145)) { + var forOfStatement = createNode(222, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); @@ -15190,14 +15280,14 @@ var ts; forOrForInOrForOfStatement = forOfStatement; } else if (parseOptional(92)) { - var forInStatement = createNode(220, pos); + var forInStatement = createNode(221, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(20); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(219, pos); + var forStatement = createNode(220, pos); forStatement.initializer = initializer; parseExpected(25); if (token() !== 25 && token() !== 20) { @@ -15215,7 +15305,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 223 ? 72 : 77); + parseExpected(kind === 224 ? 72 : 77); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -15223,7 +15313,7 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(224); + var node = createNode(225); parseExpected(96); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); @@ -15232,7 +15322,7 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(225); + var node = createNode(226); parseExpected(107); parseExpected(19); node.expression = allowInAnd(parseExpression); @@ -15241,7 +15331,7 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(265); + var node = createNode(266); parseExpected(73); node.expression = allowInAnd(parseExpression); parseExpected(56); @@ -15249,7 +15339,7 @@ var ts; return finishNode(node); } function parseDefaultClause() { - var node = createNode(266); + var node = createNode(267); parseExpected(79); parseExpected(56); node.statements = parseList(3, parseStatement); @@ -15259,12 +15349,12 @@ var ts; return token() === 73 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(226); + var node = createNode(227); parseExpected(98); parseExpected(19); node.expression = allowInAnd(parseExpression); parseExpected(20); - var caseBlock = createNode(240); + var caseBlock = createNode(241); parseExpected(17); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(18); @@ -15272,14 +15362,14 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(228); + var node = createNode(229); parseExpected(100); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(229); + var node = createNode(230); parseExpected(102); node.tryBlock = parseBlock(false); node.catchClause = token() === 74 ? parseCatchClause() : undefined; @@ -15290,7 +15380,7 @@ var ts; return finishNode(node); } function parseCatchClause() { - var result = createNode(268); + var result = createNode(269); parseExpected(74); if (parseOptional(19)) { result.variableDeclaration = parseVariableDeclaration(); @@ -15303,7 +15393,7 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(230); + var node = createNode(231); parseExpected(78); parseSemicolon(); return finishNode(node); @@ -15312,12 +15402,12 @@ var ts; var node = createNodeWithJSDoc(0); var expression = allowInAnd(parseExpression); if (expression.kind === 71 && parseOptional(56)) { - node.kind = 227; + node.kind = 228; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 215; + node.kind = 216; node.expression = expression; parseSemicolon(); } @@ -15367,7 +15457,7 @@ var ts; return false; } continue; - case 143: + case 144: nextToken(); return token() === 17 || token() === 71 || token() === 84; case 91: @@ -15429,7 +15519,7 @@ var ts; case 129: case 130: case 139: - case 143: + case 144: return true; case 114: case 112: @@ -15455,16 +15545,16 @@ var ts; case 17: return parseBlock(false); case 104: - return parseVariableStatement(createNodeWithJSDoc(231)); + return parseVariableStatement(createNodeWithJSDoc(232)); case 110: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(231)); + return parseVariableStatement(createNodeWithJSDoc(232)); } break; case 89: - return parseFunctionDeclaration(createNodeWithJSDoc(233)); + return parseFunctionDeclaration(createNodeWithJSDoc(234)); case 75: - return parseClassDeclaration(createNodeWithJSDoc(234)); + return parseClassDeclaration(createNodeWithJSDoc(235)); case 90: return parseIfStatement(); case 81: @@ -15474,9 +15564,9 @@ var ts; case 88: return parseForOrForInOrForOfStatement(); case 77: - return parseBreakOrContinueStatement(222); - case 72: return parseBreakOrContinueStatement(223); + case 72: + return parseBreakOrContinueStatement(224); case 96: return parseReturnStatement(); case 107: @@ -15509,7 +15599,7 @@ var ts; case 117: case 115: case 132: - case 143: + case 144: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -15551,7 +15641,7 @@ var ts; return parseTypeAliasDeclaration(node); case 83: return parseEnumDeclaration(node); - case 143: + case 144: case 129: case 130: return parseModuleDeclaration(node); @@ -15570,12 +15660,13 @@ var ts; } default: if (node.decorators || node.modifiers) { - var missing = createMissingNode(252, true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(253, true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; return finishNode(missing); } + return undefined; } } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { @@ -15591,16 +15682,16 @@ var ts; } function parseArrayBindingElement() { if (token() === 26) { - return createNode(205); + return createNode(206); } - var node = createNode(181); + var node = createNode(182); node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(181); + var node = createNode(182); node.dotDotDotToken = parseOptionalToken(24); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); @@ -15616,14 +15707,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(179); + var node = createNode(180); parseExpected(17); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(18); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(180); + var node = createNode(181); parseExpected(21); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(22); @@ -15645,7 +15736,7 @@ var ts; return parseVariableDeclaration(true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(231); + var node = createNode(232); node.name = parseIdentifierOrPattern(); if (allowExclamation && node.name.kind === 71 && token() === 51 && !scanner.hasPrecedingLineBreak()) { @@ -15658,7 +15749,7 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(232); + var node = createNode(233); switch (token()) { case 104: break; @@ -15672,7 +15763,7 @@ var ts; ts.Debug.fail(); } nextToken(); - if (token() === 144 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 145 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -15687,13 +15778,13 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 20; } function parseVariableStatement(node) { - node.kind = 213; + node.kind = 214; node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 233; + node.kind = 234; parseExpected(89); node.asteriskToken = parseOptionalToken(39); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); @@ -15704,14 +15795,14 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(node) { - node.kind = 154; + node.kind = 155; parseExpected(123); fillSignature(56, 0, node); node.body = parseFunctionBlockOrSemicolon(0, ts.Diagnostics.or_expected); return finishNode(node); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 153; + node.kind = 154; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 : 0; var isAsync = ts.hasModifier(node, 256) ? 2 : 0; @@ -15720,7 +15811,7 @@ var ts; return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 151; + node.kind = 152; if (!node.questionToken && token() === 51 && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } @@ -15795,7 +15886,7 @@ var ts; if (!parseOptional(57)) { break; } - var decorator = createNode(149, decoratorStart); + var decorator = createNode(150, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -15836,7 +15927,7 @@ var ts; } function parseClassElement() { if (token() === 25) { - var result = createNode(211); + var result = createNode(212); nextToken(); return finishNode(result); } @@ -15844,10 +15935,10 @@ var ts; node.decorators = parseDecorators(); node.modifiers = parseModifiers(true); if (parseContextualModifier(125)) { - return parseAccessorDeclaration(node, 155); + return parseAccessorDeclaration(node, 156); } if (parseContextualModifier(136)) { - return parseAccessorDeclaration(node, 156); + return parseAccessorDeclaration(node, 157); } if (token() === 123) { return parseConstructorDeclaration(node); @@ -15866,13 +15957,13 @@ var ts; node.name = createMissingNode(71, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } - ts.Debug.fail("Should not have attempted to parse class member declaration."); + return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 204); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 205); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 234); + return parseClassDeclarationOrExpression(node, 235); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; @@ -15905,17 +15996,15 @@ var ts; } function parseHeritageClause() { var tok = token(); - if (tok === 85 || tok === 108) { - var node = createNode(267); - node.token = tok; - nextToken(); - node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); - return finishNode(node); - } - return undefined; + ts.Debug.assert(tok === 85 || tok === 108); + var node = createNode(268); + node.token = tok; + nextToken(); + node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); + return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(206); + var node = createNode(207); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); @@ -15932,7 +16021,7 @@ var ts; return parseList(5, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 235; + node.kind = 236; parseExpected(109); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -15941,7 +16030,7 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 236; + node.kind = 237; parseExpected(139); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); @@ -15951,13 +16040,13 @@ var ts; return finishNode(node); } function parseEnumMember() { - var node = createNodeWithJSDoc(272); + var node = createNodeWithJSDoc(273); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 237; + node.kind = 238; parseExpected(83); node.name = parseIdentifier(); if (parseExpected(17)) { @@ -15970,7 +16059,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(239); + var node = createNode(240); if (parseExpected(17)) { node.statements = parseList(1, parseStatement); parseExpected(18); @@ -15981,7 +16070,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 238; + node.kind = 239; var namespaceFlag = flags & 16; node.flags |= flags; node.name = parseIdentifier(); @@ -15991,8 +16080,8 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 238; - if (token() === 143) { + node.kind = 239; + if (token() === 144) { node.name = parseIdentifier(); node.flags |= 512; } @@ -16010,7 +16099,7 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 143) { + if (token() === 144) { return parseAmbientExternalModuleDeclaration(node); } else if (parseOptional(130)) { @@ -16035,7 +16124,7 @@ var ts; return nextToken() === 41; } function parseNamespaceExportDeclaration(node) { - node.kind = 241; + node.kind = 242; parseExpected(118); parseExpected(130); node.name = parseIdentifier(); @@ -16048,23 +16137,23 @@ var ts; var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 26 && token() !== 142) { + if (token() !== 26 && token() !== 143) { return parseImportEqualsDeclaration(node, identifier); } } - node.kind = 243; + node.kind = 244; if (identifier || token() === 39 || token() === 17) { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(142); + parseExpected(143); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 242; + node.kind = 243; node.name = identifier; parseExpected(58); node.moduleReference = parseModuleReference(); @@ -16072,13 +16161,13 @@ var ts; return finishNode(node); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(244, fullStart); + var importClause = createNode(245, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(26)) { - importClause.namedBindings = token() === 39 ? parseNamespaceImport() : parseNamedImportsOrExports(246); + importClause.namedBindings = token() === 39 ? parseNamespaceImport() : parseNamedImportsOrExports(247); } return finishNode(importClause); } @@ -16088,7 +16177,7 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(253); + var node = createNode(254); parseExpected(133); parseExpected(19); node.expression = parseModuleSpecifier(); @@ -16106,7 +16195,7 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(245); + var namespaceImport = createNode(246); parseExpected(39); parseExpected(118); namespaceImport.name = parseIdentifier(); @@ -16114,14 +16203,14 @@ var ts; } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 246 ? parseImportSpecifier : parseExportSpecifier, 17, 18); + node.elements = parseBracketedList(22, kind === 247 ? parseImportSpecifier : parseExportSpecifier, 17, 18); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(251); + return parseImportOrExportSpecifier(252); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(247); + return parseImportOrExportSpecifier(248); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -16140,21 +16229,21 @@ var ts; else { node.name = identifierName; } - if (kind === 247 && checkIdentifierIsKeyword) { + if (kind === 248 && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 249; + node.kind = 250; if (parseOptional(39)) { - parseExpected(142); + parseExpected(143); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(250); - if (token() === 142 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(142); + node.exportClause = parseNamedImportsOrExports(251); + if (token() === 143 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(143); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -16162,7 +16251,7 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 248; + node.kind = 249; if (parseOptional(58)) { node.isExportEquals = true; } @@ -16180,10 +16269,10 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1) - || node.kind === 242 && node.moduleReference.kind === 253 - || node.kind === 243 - || node.kind === 248 + || node.kind === 243 && node.moduleReference.kind === 254 + || node.kind === 244 || node.kind === 249 + || node.kind === 250 ? node : undefined; } @@ -16212,7 +16301,7 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(277, scanner.getTokenPos()); + var result = createNode(278, scanner.getTokenPos()); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(17); result.type = doInsideOfContext(2097152, parseJSDocType); if (!mayOmitBraces || hasBrace) { @@ -16253,8 +16342,8 @@ var ts; } JSDocParser.parseJSDocComment = parseJSDocComment; function parseJSDocCommentWorker(start, length) { + if (start === void 0) { start = 0; } var content = sourceText; - start = start || 0; var end = length === undefined ? content.length : start + length; length = end - start; ts.Debug.assert(start >= 0); @@ -16279,17 +16368,15 @@ var ts; comments.push(text); indent += text.length; } - var t = nextJSDocToken(); - while (t === 5) { - t = nextJSDocToken(); - } - if (t === 4) { + nextJSDocToken(); + while (parseOptionalJsdoc(5)) + ; + if (parseOptionalJsdoc(4)) { state = 0; indent = 0; - t = nextJSDocToken(); } loop: while (true) { - switch (t) { + switch (token()) { case 57: if (state === 0 || state === 1) { removeTrailingNewlines(comments); @@ -16339,7 +16426,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - t = nextJSDocToken(); + nextJSDocToken(); } removeLeadingNewlines(comments); removeTrailingNewlines(comments); @@ -16357,7 +16444,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(285, start); + var result = createNode(286, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -16495,7 +16582,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(atToken, tagName) { - var result = createNode(288, atToken.pos); + var result = createNode(289, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -16536,7 +16623,7 @@ var ts; switch (node.kind) { case 135: return true; - case 166: + case 167: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -16552,12 +16639,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 ? - createNode(297, atToken.pos) : - createNode(292, atToken.pos); + createNode(298, atToken.pos) : + createNode(293, atToken.pos); var comment; if (indent !== undefined) comment = parseTagComments(indent + scanner.getStartPos() - atToken.pos); - var nestedTypeLiteral = parseNestedTypeLiteral(typeExpression, name, target); + var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; @@ -16573,20 +16660,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(277, scanner.getTokenPos()); + var typeLiteralExpression = createNode(278, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_2 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, name); })) { - if (child.kind === 292 || child.kind === 297) { + if (child.kind === 293 || child.kind === 298) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(286, start_2); + jsdocTypeLiteral = createNode(287, start_2); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 166) { + if (typeExpression.type.kind === 167) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -16595,27 +16682,27 @@ var ts; } } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 293; })) { - parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); - } - var result = createNode(293, atToken.pos); - result.atToken = atToken; - result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); - return finishNode(result); - } - function parseTypeTag(atToken, tagName) { if (ts.forEach(tags, function (t) { return t.kind === 294; })) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } var result = createNode(294, atToken.pos); result.atToken = atToken; result.tagName = tagName; + result.typeExpression = tryParseTypeExpression(); + return finishNode(result); + } + function parseTypeTag(atToken, tagName) { + if (ts.forEach(tags, function (t) { return t.kind === 295; })) { + parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); + } + var result = createNode(295, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var result = createNode(289, atToken.pos); + var result = createNode(290, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); @@ -16623,7 +16710,7 @@ var ts; } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(17); - var node = createNode(206); + var node = createNode(207); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -16635,7 +16722,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(true); while (parseOptional(23)) { - var prop = createNode(184, node.pos); + var prop = createNode(185, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -16643,7 +16730,7 @@ var ts; return node; } function parseClassTag(atToken, tagName) { - var tag = createNode(290, atToken.pos); + var tag = createNode(291, atToken.pos); tag.atToken = atToken; tag.tagName = tagName; return finishNode(tag); @@ -16651,7 +16738,7 @@ var ts; function parseTypedefTag(atToken, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(296, atToken.pos); + var typedefTag = createNode(297, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -16667,9 +16754,9 @@ var ts; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildPropertyTag(); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(286, start_3); + jsdocTypeLiteral = createNode(287, start_3); } - if (child.kind === 294) { + if (child.kind === 295) { if (childTypeTag) { break; } @@ -16682,7 +16769,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 166) { + if (typeExpression && typeExpression.type.kind === 167) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -16697,7 +16784,7 @@ var ts; var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (typeNameOrNamespaceName && parseOptional(23)) { - var jsDocNamespaceNode = createNode(238, pos); + var jsDocNamespaceNode = createNode(239, pos); if (nested) { jsDocNamespaceNode.flags |= 4; } @@ -16711,7 +16798,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(atToken, tagName, indent) { - var callbackTag = createNode(291, atToken.pos); + var callbackTag = createNode(292, atToken.pos); callbackTag.atToken = atToken; callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); @@ -16720,16 +16807,15 @@ var ts; callbackTag.comment = parseTagComments(indent); var child; var start = scanner.getStartPos(); - var jsdocSignature = createNode(287, start); + var jsdocSignature = createNode(288, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (token() === 57) { - nextJSDocToken(); + if (parseOptionalJsdoc(57)) { var tag = parseTag(indent); - if (tag && tag.kind === 293) { + if (tag && tag.kind === 294) { return tag; } } @@ -16774,7 +16860,7 @@ var ts; case 57: if (canParseTag) { var child = tryParseChildTag(target); - if (child && child.kind === 292 && + if (child && child.kind === 293 && target !== 4 && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -16835,48 +16921,44 @@ var ts; return tag; } function parseTemplateTag(atToken, tagName) { - if (ts.some(tags, ts.isJSDocTemplateTag)) { - parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); + var constraint; + if (token() === 17) { + constraint = parseJSDocTypeExpression(); } var typeParameters = []; var typeParametersPos = getNodePos(); - while (true) { - var typeParameter = createNode(147); - var name = parseJSDocIdentifierNameWithOptionalBraces(); + do { skipWhitespace(); - if (!name) { - parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); + var typeParameter = createNode(148); + if (!ts.tokenIsIdentifierOrKeyword(token())) { + parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); return undefined; } - typeParameter.name = name; + typeParameter.name = parseJSDocIdentifierName(); + skipWhitespace(); finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 26) { - nextJSDocToken(); - skipWhitespace(); - } - else { - break; - } + } while (parseOptionalJsdoc(26)); + if (constraint) { + ts.first(typeParameters).constraint = constraint.type; } - var result = createNode(295, atToken.pos); + var result = createNode(296, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); finishNode(result); return result; } - function parseJSDocIdentifierNameWithOptionalBraces() { - var parsedBrace = parseOptional(17); - var res = parseJSDocIdentifierName(); - if (parsedBrace) { - parseExpected(18); - } - return res; - } function nextJSDocToken() { return currentToken = scanner.scanJSDocToken(); } + function parseOptionalJsdoc(t) { + if (token() === t) { + nextJSDocToken(); + return true; + } + return false; + } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(true); if (parseOptional(21)) { @@ -17266,10 +17348,7 @@ var ts; break; } case "amd-dependency": { - context.amdDependencies = ts.map(ts.toArray(entryOrList), function (_a) { - var _b = _a.arguments, name = _b.name, path = _b.path; - return ({ name: name, path: path }); - }); + context.amdDependencies = ts.map(ts.toArray(entryOrList), function (x) { return ({ name: x.arguments.name, path: x.arguments.path }); }); break; } case "amd-module": { @@ -17401,6 +17480,20 @@ var ts; } return argMap; } + function tagNamesAreEquivalent(lhs, rhs) { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === 71) { + return lhs.escapedText === rhs.escapedText; + } + if (lhs.kind === 99) { + return true; + } + return lhs.name.escapedText === rhs.name.escapedText && + tagNamesAreEquivalent(lhs.expression, rhs.expression); + } + ts.tagNamesAreEquivalent = tagNamesAreEquivalent; })(ts || (ts = {})); var ts; (function (ts) { @@ -17546,6 +17639,7 @@ var ts; "es2018.promise": "lib.es2018.promise.d.ts", "es2018.regexp": "lib.es2018.regexp.d.ts", "esnext.array": "lib.esnext.array.d.ts", + "esnext.symbol": "lib.esnext.symbol.d.ts", "esnext.asynciterable": "lib.esnext.asynciterable.d.ts", }), }, @@ -18169,7 +18263,7 @@ var ts; case "string": return ts.map(values, function (v) { return v || ""; }); default: - return ts.filter(ts.map(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }), function (v) { return !!v; }); + return ts.mapDefined(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); }); } } ts.parseListTypeOption = parseListTypeOption; @@ -18290,6 +18384,7 @@ var ts; } return optionNameMap.get(optionName); } + ts.getOptionFromName = getOptionFromName; function getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host) { var configFileText; try { @@ -18424,7 +18519,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 269) { + if (element.kind !== 270) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -18495,13 +18590,13 @@ var ts; case 8: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 197: + case 198: if (valueExpression.operator !== 38 || valueExpression.operand.kind !== 8) { break; } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 183: + case 184: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; if (option) { @@ -18511,7 +18606,7 @@ var ts; else { return convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined); } - case 182: + case 183: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -18548,6 +18643,7 @@ var ts; var expectedType = ts.isString(option.type) ? option.type : "string"; return typeof value === expectedType; } + return false; } function generateTSConfig(options, fileNames, newLine) { var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); @@ -18969,13 +19065,10 @@ var ts; } function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) { if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) { - return undefined; + return false; } var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption.compileOnSave, basePath, errors); - if (typeof result === "boolean" && result) { - return result; - } - return false; + return typeof result === "boolean" && result; } function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) { var errors = []; @@ -19004,7 +19097,7 @@ var ts; return options; } function getDefaultTypeAcquisition(configFileName) { - return { enable: configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; + return { enable: !!configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; } function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) { var options = getDefaultTypeAcquisition(configFileName); @@ -19278,7 +19371,7 @@ var ts; } ts.trace = trace; function isTraceEnabled(compilerOptions, host) { - return compilerOptions.traceResolution && host.trace !== undefined; + return !!compilerOptions.traceResolution && host.trace !== undefined; } ts.isTraceEnabled = isTraceEnabled; function withPackageId(packageId, r) { @@ -19439,14 +19532,13 @@ var ts; } } function secondaryLookup() { - var resolvedFile; var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile); if (initialLocationForSecondaryLookup !== undefined) { if (traceEnabled) { trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup); } var result = loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState, undefined); - resolvedFile = resolvedTypeScriptOnly(result && result.value); + var resolvedFile = resolvedTypeScriptOnly(result && result.value); if (!resolvedFile && traceEnabled) { trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); } @@ -19598,7 +19690,7 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); break; default: - ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); } if (perFolderCache) { perFolderCache.set(moduleName, result); @@ -19776,7 +19868,7 @@ var ts; var originalPath = void 0; if (!compilerOptions.preserveSymlinks && resolvedValue) { originalPath = resolvedValue.path; - var path = realPath(resolved_1.value.path, host, traceEnabled); + var path = realPath(resolvedValue.path, host, traceEnabled); if (path === originalPath) { originalPath = undefined; } @@ -19876,7 +19968,7 @@ var ts; function loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state) { if (extensions === Extensions.Json) { var extensionLess = ts.tryRemoveExtension(candidate, ".json"); - return extensionLess && tryAddingExtensions(extensionLess, extensions, failedLookupLocations, onlyRecordFailures, state); + return extensionLess === undefined ? undefined : tryAddingExtensions(extensionLess, extensions, failedLookupLocations, onlyRecordFailures, state); } var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocations, onlyRecordFailures, state); if (resolvedByAddingExtension) { @@ -19910,7 +20002,7 @@ var ts; } function tryExtension(ext) { var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); - return path && { path: path, ext: ext }; + return path === undefined ? undefined : { path: path, ext: ext }; } } function tryFile(fileName, failedLookupLocations, onlyRecordFailures, state) { @@ -20358,7 +20450,8 @@ var ts; addInferredTypings(module_1, "Inferred typings from unresolved imports"); } packageNameToTypingLocation.forEach(function (typing, name) { - if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && isTypingUpToDate(typing, typesRegistry.get(name))) { + var registryEntry = typesRegistry.get(name); + if (inferredTypings.has(name) && inferredTypings.get(name) === undefined && registryEntry !== undefined && isTypingUpToDate(typing, registryEntry)) { inferredTypings.set(name, typing.typingLocation); } }); @@ -20499,7 +20592,7 @@ var ts; case 0: return ts.Debug.fail(); default: - ts.Debug.assertNever(result); + throw ts.Debug.assertNever(result); } } JsTyping.renderPackageNameValidationFailure = renderPackageNameValidationFailure; @@ -20616,6 +20709,7 @@ var ts; this.pendingRunRequests = []; this.installRunCount = 1; this.inFlightRequestCount = 0; + this.latestDistTag = "latest"; this.toCanonicalFileName = ts.createGetCanonicalFileName(installTypingHost.useCaseSensitiveFileNames); this.globalCacheCanonicalPackageJsonPath = ts.combinePaths(this.toCanonicalFileName(globalCachePath), "package.json"); if (this.log.isEnabled()) { @@ -20833,7 +20927,7 @@ var ts; continue; } var distTags = _this.typesRegistry.get(packageName); - var newVersion = ts.Semver.parse(distTags["ts" + ts.versionMajorMinor] || distTags[latestDistTag]); + var newVersion = ts.Semver.parse(distTags["ts" + ts.versionMajorMinor] || distTags[_this.latestDistTag]); var newTyping = { typingLocation: typingFile, version: newVersion }; _this.packageNameToTypingLocation.set(packageName, newTyping); installedTypingFiles.push(typingFile); @@ -20992,7 +21086,6 @@ var ts; return "@types/" + packageName + "@ts" + ts.versionMajorMinor; } typingsInstaller.typingsName = typingsName; - var latestDistTag = "latest"; })(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {})); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); @@ -21025,12 +21118,11 @@ var ts; }()); function getDefaultNPMLocation(processName) { if (path.basename(processName).indexOf("node") === 0) { - var npmPath = "\"" + path.join(path.dirname(process.argv[0]), "npm") + "\""; - if (fs.existsSync(npmPath)) { - return npmPath; - } + return "\"" + path.join(path.dirname(process.argv[0]), "npm") + "\""; + } + else { + return "npm"; } - return "npm"; } function loadTypesRegistryFile(typesRegistryFilePath, host, log) { if (!host.fileExists(typesRegistryFilePath)) { @@ -21072,7 +21164,7 @@ var ts; if (_this.log.isEnabled()) { _this.log.writeLine("Updating " + typesRegistryPackageName + " npm package..."); } - _this.execSyncAndLog(_this.npmPath + " install --ignore-scripts " + typesRegistryPackageName, { cwd: globalTypingsCacheLocation }); + _this.execSyncAndLog(_this.npmPath + " install --ignore-scripts " + typesRegistryPackageName + "@" + _this.latestDistTag, { cwd: globalTypingsCacheLocation }); if (_this.log.isEnabled()) { _this.log.writeLine("Updated " + typesRegistryPackageName + " npm package"); } diff --git a/lib/zh-cn/diagnosticMessages.generated.json b/lib/zh-cn/diagnosticMessages.generated.json index b92e4727075..74e21e92be9 100644 --- a/lib/zh-cn/diagnosticMessages.generated.json +++ b/lib/zh-cn/diagnosticMessages.generated.json @@ -106,6 +106,7 @@ "Add_initializer_to_property_0_95019": "向属性“{0}”添加初始值设定项", "Add_initializers_to_all_uninitialized_properties_95027": "将初始化表达式添加到未初始化的所有属性", "Add_missing_super_call_90001": "添加缺失的 \"super()\" 调用", + "Add_missing_typeof_95052": "添加缺少的 \"typeof\"", "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "将限定符添加到匹配成员名称的所有未解析变量", "Add_to_all_uncalled_decorators_95044": "将 \"()\" 添加到所有未调用的修饰器", "Add_ts_ignore_to_all_error_messages_95042": "将 \"@ts-ignore\" 添加到所有错误消息", @@ -119,6 +120,7 @@ "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "抽象方法的所有声明必须是连续的。", "All_destructured_elements_are_unused_6198": "未取消使用任何解构元素。", "All_imports_in_import_declaration_are_unused_6192": "未使用导入声明中的所有导入。", + "All_variables_are_unused_6199": "所有变量均未使用。", "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011": "允许从不带默认输出的模块中默认输入。这不会影响代码发出,只是类型检查。", "Allow_javascript_files_to_be_compiled_6102": "允许编译 JavaScript 文件。", "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "提供 \"--isolatedModules\" 标志的情况下不允许使用环境常数枚举。", @@ -255,6 +257,7 @@ "Class_0_used_before_its_declaration_2449": "类“{0}”用于其声明前。", "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "类声明不能有多个 \"@augments\" 或 \"@extends\" 标记。", "Class_name_cannot_be_0_2414": "类名不能为“{0}”。", + "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725": "使用模块 {0} 将目标设置为 ES5 时,类名称不能为 \"Object\"。", "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417": "类静态侧“{0}”错误扩展基类静态侧“{1}”。", "Classes_can_only_extend_a_single_class_1174": "类只能扩展一个类。", "Classes_containing_abstract_methods_must_be_marked_abstract_2514": "包含抽象方法的类必须标记为抽象。", @@ -273,11 +276,14 @@ "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674": "类“{0}”的构造函数是受保护的,仅可在类声明中访问。", "Constructors_for_derived_classes_must_contain_a_super_call_2377": "派生类的构造函数必须包含 \"super\" 调用。", "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126": "未指定包含文件,并且无法确定根目录,正在跳过在 \"node_modules\" 文件夹中查找。", + "Convert_0_to_mapped_object_type_95055": "将“{0}”转换为映射对象类型", "Convert_all_constructor_functions_to_classes_95045": "将所有构造函数都转换为类", "Convert_all_require_to_import_95048": "将所有 \"require\" 转换为 \"import\"", "Convert_all_to_default_imports_95035": "全部转换为默认导入", "Convert_function_0_to_class_95002": "将函数“{0}”转换为类", "Convert_function_to_an_ES2015_class_95001": "将函数转换为 ES2015 类", + "Convert_named_imports_to_namespace_import_95057": "将命名导入转换为命名空间导入", + "Convert_namespace_import_to_named_imports_95056": "将命名空间导入转换为命名导入", "Convert_require_to_import_95047": "将 \"require\" 转换为 \"import\"", "Convert_to_ES6_module_95017": "转换为 ES6 模块", "Convert_to_default_import_95013": "转换为默认导入", @@ -580,6 +586,7 @@ "Not_all_code_paths_return_a_value_7030": "并非所有代码路径都返回值。", "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413": "数字索引类型“{0}”不能赋给字符串索引类型“{1}”。", "Numeric_separators_are_not_allowed_here_6188": "此处不允许使用数字分隔符。", + "Object_is_of_type_unknown_2571": "对象的类型为 \"unknown\"。", "Object_is_possibly_null_2531": "对象可能为 \"null\"。", "Object_is_possibly_null_or_undefined_2533": "对象可能为 \"null\" 或“未定义”。", "Object_is_possibly_undefined_2532": "对象可能为“未定义”。", @@ -708,10 +715,13 @@ "Redirect_output_structure_to_the_directory_6006": "将输出结构重定向到目录。", "Referenced_project_0_must_have_setting_composite_Colon_true_6306": "引用的项目“{0}”必须拥有设置 \"composite\": true。", "Remove_all_unreachable_code_95051": "删除所有无法访问的代码", + "Remove_all_unused_labels_95054": "删除所有未使用的标签", "Remove_declaration_for_Colon_0_90004": "删除“{0}”的声明", "Remove_destructuring_90009": "删除解构", "Remove_import_from_0_90005": "从“{0}”删除导入", "Remove_unreachable_code_95050": "删除无法访问的代码", + "Remove_unused_label_95053": "删除未使用的标签", + "Remove_variable_statement_90010": "删除变量语句", "Replace_import_with_0_95015": "用“{0}”替换导入。", "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "在函数中的所有代码路径并非都返回值时报告错误。", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "报告 switch 语句中遇到 fallthrough 情况的错误。", diff --git a/lib/zh-tw/diagnosticMessages.generated.json b/lib/zh-tw/diagnosticMessages.generated.json index f250984e6f2..fe237b08b4d 100644 --- a/lib/zh-tw/diagnosticMessages.generated.json +++ b/lib/zh-tw/diagnosticMessages.generated.json @@ -106,6 +106,7 @@ "Add_initializer_to_property_0_95019": "將初始設定式新增至屬性 '{0}'", "Add_initializers_to_all_uninitialized_properties_95027": "為所有未初始化的屬性新增初始設定式", "Add_missing_super_call_90001": "新增遺漏的 'super()' 呼叫", + "Add_missing_typeof_95052": "新增遺漏的 'typeof'", "Add_qualifier_to_all_unresolved_variables_matching_a_member_name_95037": "對所有比對成員名稱的未解析變數新增限定詞", "Add_to_all_uncalled_decorators_95044": "為所有未呼叫的裝飾項目新增 '()'", "Add_ts_ignore_to_all_error_messages_95042": "為所有錯誤訊息新增 '@ts-ignore'", @@ -119,6 +120,7 @@ "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "抽象方法的所有宣告必須連續。", "All_destructured_elements_are_unused_6198": "不會使用所有未經結構化的項目。", "All_imports_in_import_declaration_are_unused_6192": "匯入宣告中的所有匯入皆未使用。", + "All_variables_are_unused_6199": "所有變數都未使用。", "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011": "允許從沒有預設匯出的模組進行預設匯入。這不會影響程式碼發出,僅為類型檢查。", "Allow_javascript_files_to_be_compiled_6102": "允許編譯 JavaScript 檔案。", "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "提供 '--isolatedModules' 旗標時,不可使用環境常數列舉。", @@ -255,6 +257,7 @@ "Class_0_used_before_its_declaration_2449": "類別 '{0}' 的位置在其宣告之前。", "Class_declarations_cannot_have_more_than_one_augments_or_extends_tag_8025": "類別宣告只可有一個 '@augments' 或 '@extends' 標記。", "Class_name_cannot_be_0_2414": "類別名稱不得為 '{0}'。", + "Class_name_cannot_be_Object_when_targeting_ES5_with_module_0_2725": "當目標為具有模組 {0} 的 ES5 時,類別名稱不可為 'Object'。", "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417": "類別靜態端 '{0}' 不正確地擴充基底類別靜態端 '{1}'。", "Classes_can_only_extend_a_single_class_1174": "類別只能擴充一個類別。", "Classes_containing_abstract_methods_must_be_marked_abstract_2514": "包含抽象方法的類別必須標記為抽象。", @@ -273,11 +276,14 @@ "Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration_2674": "類別 '{0}' 的建構函式受到保護,並且只能在類別宣告內存取。", "Constructors_for_derived_classes_must_contain_a_super_call_2377": "衍生類別的建構函式必須包含 'super' 呼叫。", "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126": "未指定包含檔案,因此無法決定根目錄,而將略過 'node_modules' 中的查閱。", + "Convert_0_to_mapped_object_type_95055": "將 '{0}' 轉換為對應的物件類型", "Convert_all_constructor_functions_to_classes_95045": "將所有建構函式轉換為類別", "Convert_all_require_to_import_95048": "將所有 'require' 轉換至 'import'", "Convert_all_to_default_imports_95035": "全部轉換為預設匯入", "Convert_function_0_to_class_95002": "將函式 '{0}' 轉換為類別", "Convert_function_to_an_ES2015_class_95001": "將函式轉換為 ES2015 類別", + "Convert_named_imports_to_namespace_import_95057": "將具名匯入轉換為命名空間匯入", + "Convert_namespace_import_to_named_imports_95056": "將命名空間匯入轉換為具名匯入", "Convert_require_to_import_95047": "將 'require' 轉換至 'import'", "Convert_to_ES6_module_95017": "轉換為 ES6 模組", "Convert_to_default_import_95013": "轉換為預設匯入", @@ -580,6 +586,7 @@ "Not_all_code_paths_return_a_value_7030": "部分程式碼路徑並未傳回值。", "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413": "數值索引類型 '{0}' 不可指派給字串索引類型 '{1}'。", "Numeric_separators_are_not_allowed_here_6188": "這裡不允許數字分隔符號。", + "Object_is_of_type_unknown_2571": "物件的類型為 '未知'。", "Object_is_possibly_null_2531": "物件可能為「null」。", "Object_is_possibly_null_or_undefined_2533": "物件可能為「null」或「未定義」。", "Object_is_possibly_undefined_2532": "物件可能為「未定義」。", @@ -708,10 +715,13 @@ "Redirect_output_structure_to_the_directory_6006": "將輸出結構重新導向至目錄。", "Referenced_project_0_must_have_setting_composite_Colon_true_6306": "參考的專案 '{0}' 之設定 \"composite\" 必須為 true。", "Remove_all_unreachable_code_95051": "移除所有無法連線的程式碼", + "Remove_all_unused_labels_95054": "移除所有未使用的標籤", "Remove_declaration_for_Colon_0_90004": "移除 '{0}' 的宣告", "Remove_destructuring_90009": "移除解構", "Remove_import_from_0_90005": "從 '{0}' 移除匯入", "Remove_unreachable_code_95050": "移除無法連線的程式碼", + "Remove_unused_label_95053": "移除未使用的標籤", + "Remove_variable_statement_90010": "移除變數陳述式", "Replace_import_with_0_95015": "以 '{0}' 取代匯入。", "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "當函式中的部分程式碼路徑並未傳回值時回報錯誤。", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "回報 switch 陳述式內 fallthrough 案例的錯誤。",